Search in sources :

Example 36 with AccountConfig

use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.

the class AppAccountServiceImpl method generateAccountConfigurations.

@Transactional
@Override
public void generateAccountConfigurations() {
    List<Company> companies = companyRepo.all().filter("self.accountConfig is null").fetch();
    for (Company company : companies) {
        AccountConfig config = new AccountConfig();
        config.setCompany(company);
        accountConfigRepo.save(config);
    }
}
Also used : Company(com.axelor.apps.base.db.Company) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 37 with AccountConfig

use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.

the class AccountingSituationInitServiceImpl method createAccountingSituation.

@Override
@Transactional(rollbackOn = { Exception.class })
public AccountingSituation createAccountingSituation(Partner partner, Company company) throws AxelorException {
    AccountingSituation accountingSituation = new AccountingSituation();
    accountingSituation.setCompany(company);
    partner.addCompanySetItem(company);
    PaymentMode inPaymentMode = partner.getInPaymentMode();
    PaymentMode outPaymentMode = partner.getOutPaymentMode();
    BankDetails defaultBankDetails = company.getDefaultBankDetails();
    if (inPaymentMode != null) {
        List<BankDetails> authorizedInBankDetails = paymentModeService.getCompatibleBankDetailsList(inPaymentMode, company);
        if (authorizedInBankDetails.contains(defaultBankDetails)) {
            accountingSituation.setCompanyInBankDetails(defaultBankDetails);
        }
    }
    if (outPaymentMode != null) {
        List<BankDetails> authorizedOutBankDetails = paymentModeService.getCompatibleBankDetailsList(outPaymentMode, company);
        if (authorizedOutBankDetails.contains(defaultBankDetails)) {
            accountingSituation.setCompanyOutBankDetails(defaultBankDetails);
        }
    }
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    accountingSituation.setInvoiceAutomaticMail(accountConfig.getInvoiceAutomaticMail());
    accountingSituation.setInvoiceMessageTemplate(accountConfig.getInvoiceMessageTemplate());
    partner.addAccountingSituationListItem(accountingSituation);
    return accountingSituationRepository.save(accountingSituation);
}
Also used : BankDetails(com.axelor.apps.base.db.BankDetails) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) PaymentMode(com.axelor.apps.account.db.PaymentMode) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 38 with AccountConfig

use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.

the class AccountingSituationInitServiceImpl method createPartnerAccounts.

@Override
@Transactional(rollbackOn = { Exception.class })
public void createPartnerAccounts(AccountingSituation situation) throws AxelorException {
    AccountConfig accountConfig = situation.getCompany().getAccountConfig();
    int creationMode;
    if (accountConfig == null || (creationMode = accountConfig.getPartnerAccountGenerationModeSelect()) == AccountConfigRepository.AUTOMATIC_ACCOUNT_CREATION_NONE) {
        // Ignore even if account config is null since this means no automatic creation
        return;
    }
    createCustomerAccount(accountConfig, situation, creationMode);
    createSupplierAccount(accountConfig, situation, creationMode);
    createEmployeeAccount(accountConfig, situation, creationMode);
}
Also used : AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 39 with AccountConfig

use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.

the class AccountingSituationServiceImpl method getCustomerAccount.

@Override
public Account getCustomerAccount(Partner partner, Company company) throws AxelorException {
    Account account = null;
    AccountingSituation accountingSituation = getAccountingSituation(partner, company);
    if (accountingSituation != null) {
        account = accountingSituation.getCustomerAccount();
    }
    if (account == null) {
        AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
        account = accountConfigService.getCustomerAccount(accountConfig);
    }
    return account;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 40 with AccountConfig

use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.

the class AccountingSituationServiceImpl method getSupplierAccount.

@Override
public Account getSupplierAccount(Partner partner, Company company) throws AxelorException {
    Account account = null;
    AccountingSituation accountingSituation = getAccountingSituation(partner, company);
    if (accountingSituation != null) {
        account = accountingSituation.getSupplierAccount();
    }
    if (account == null) {
        AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
        account = accountConfigService.getSupplierAccount(accountConfig);
    }
    return account;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Aggregations

AccountConfig (com.axelor.apps.account.db.AccountConfig)46 Company (com.axelor.apps.base.db.Company)27 Move (com.axelor.apps.account.db.Move)18 MoveLine (com.axelor.apps.account.db.MoveLine)17 BigDecimal (java.math.BigDecimal)17 Account (com.axelor.apps.account.db.Account)14 Partner (com.axelor.apps.base.db.Partner)14 Transactional (com.google.inject.persist.Transactional)14 Journal (com.axelor.apps.account.db.Journal)9 AccountConfigService (com.axelor.apps.account.service.config.AccountConfigService)9 AxelorException (com.axelor.exception.AxelorException)9 AccountingSituation (com.axelor.apps.account.db.AccountingSituation)7 Reconcile (com.axelor.apps.account.db.Reconcile)7 BankDetails (com.axelor.apps.base.db.BankDetails)6 LocalDate (java.time.LocalDate)6 ArrayList (java.util.ArrayList)6 Invoice (com.axelor.apps.account.db.Invoice)5 PaymentMode (com.axelor.apps.account.db.PaymentMode)5 List (java.util.List)4 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)3