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);
}
}
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);
}
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);
}
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;
}
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;
}
Aggregations