use of com.axelor.apps.account.db.AccountManagement in project axelor-open-suite by axelor.
the class AccountManagementServiceAccountImpl method getProductAccount.
/**
* Get the product tax
*
* @param product
* @param company
* @param isPurchase
* @param fixedAsset Specify if we should get the purchase account for fixed asset or not. Used
* only if isPurchase param is true.
* @param configObject Specify if we want get the tax from the product or its product family
* <li>1 : product
* <li>2 : product family
* @return
* @throws AxelorException
*/
@CallMethod
protected Account getProductAccount(Product product, Company company, boolean isPurchase, boolean fixedAsset, int configObject) {
AccountManagement accountManagement = this.getAccountManagement(product, company, configObject);
Account account = null;
if (accountManagement != null) {
if (isPurchase) {
if (fixedAsset) {
account = accountManagement.getPurchFixedAssetsAccount();
} else {
account = accountManagement.getPurchaseAccount();
}
} else {
account = accountManagement.getSaleAccount();
}
}
if (account == null && configObject == CONFIG_OBJECT_PRODUCT) {
return getProductAccount(product, company, isPurchase, fixedAsset, CONFIG_OBJECT_PRODUCT_FAMILY);
}
return account;
}
use of com.axelor.apps.account.db.AccountManagement in project axelor-open-suite by axelor.
the class PaymentModeServiceImpl method getAccountManagementDefaults.
@Override
public List<AccountManagement> getAccountManagementDefaults() {
List<AccountManagement> accountManagementList = new ArrayList<>();
List<Company> companyList = Beans.get(CompanyRepository.class).all().fetch();
for (Company company : companyList) {
AccountManagement accountManagement = new AccountManagement();
accountManagement.setCompany(company);
accountManagement.setTypeSelect(AccountManagementRepository.TYPE_PAYMENT);
accountManagementList.add(accountManagement);
}
return accountManagementList;
}
use of com.axelor.apps.account.db.AccountManagement in project axelor-open-suite by axelor.
the class AccountManagementServiceImpl method getProductTax.
/**
* Get the product tax
*
* @param product
* @param company
* @param isPurchase
* @param configObject Specify if we want get the tax from the product or its product family
* <li>1 : product
* <li>2 : product family
* @return
* @throws AxelorException
*/
protected Tax getProductTax(Product product, Company company, boolean isPurchase, int configObject) {
AccountManagement accountManagement = this.getAccountManagement(product, company, configObject);
Tax tax = null;
if (accountManagement != null) {
if (isPurchase) {
tax = accountManagement.getPurchaseTax();
} else {
tax = accountManagement.getSaleTax();
}
}
if (tax == null && configObject == CONFIG_OBJECT_PRODUCT) {
return getProductTax(product, company, isPurchase, CONFIG_OBJECT_PRODUCT_FAMILY);
}
return tax;
}
use of com.axelor.apps.account.db.AccountManagement in project axelor-open-suite by axelor.
the class PaymentModeServiceImpl method getPaymentModeAccount.
@Override
public Account getPaymentModeAccount(PaymentMode paymentMode, Company company, BankDetails bankDetails) throws AxelorException {
log.debug("Récupération du compte comptable du mode de paiement associé à la société :" + " Société : {}, Mode de paiement : {}", new Object[] { company.getName(), paymentMode.getName() });
AccountManagement accountManagement = this.getAccountManagement(paymentMode, company, bankDetails);
if (accountManagement != null && accountManagement.getCashAccount() != null) {
return accountManagement.getCashAccount();
}
throw new AxelorException(paymentMode, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get("Company") + " : %s, " + I18n.get("Payment mode") + " : %s: " + I18n.get(IExceptionMessage.PAYMENT_MODE_1), company.getName(), paymentMode.getName());
}
use of com.axelor.apps.account.db.AccountManagement in project axelor-open-suite by axelor.
the class PaymentModeServiceImpl method getCompatibleBankDetailsList.
@Override
public List<BankDetails> getCompatibleBankDetailsList(PaymentMode paymentMode, Company company) {
List<BankDetails> bankDetailsList = new ArrayList<>();
if (paymentMode == null) {
return bankDetailsList;
}
List<AccountManagement> accountManagementList = paymentMode.getAccountManagementList();
if (accountManagementList == null) {
return bankDetailsList;
}
for (AccountManagement accountManagement : accountManagementList) {
if (accountManagement.getCompany().equals(company) && accountManagement.getBankDetails() != null && accountManagement.getBankDetails().getActive()) {
bankDetailsList.add(accountManagement.getBankDetails());
}
}
return bankDetailsList;
}
Aggregations