Search in sources :

Example 1 with AccountManagement

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;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountManagement(com.axelor.apps.account.db.AccountManagement) CallMethod(com.axelor.meta.CallMethod)

Example 2 with AccountManagement

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;
}
Also used : Company(com.axelor.apps.base.db.Company) ArrayList(java.util.ArrayList) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 3 with AccountManagement

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;
}
Also used : Tax(com.axelor.apps.account.db.Tax) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 4 with AccountManagement

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());
}
Also used : AxelorException(com.axelor.exception.AxelorException) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 5 with AccountManagement

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;
}
Also used : BankDetails(com.axelor.apps.base.db.BankDetails) ArrayList(java.util.ArrayList) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Aggregations

AccountManagement (com.axelor.apps.account.db.AccountManagement)12 ArrayList (java.util.ArrayList)5 BankDetails (com.axelor.apps.base.db.BankDetails)4 Account (com.axelor.apps.account.db.Account)3 AxelorException (com.axelor.exception.AxelorException)3 FixedAssetCategory (com.axelor.apps.account.db.FixedAssetCategory)2 AppAccountService (com.axelor.apps.account.service.app.AppAccountService)2 HashSet (java.util.HashSet)2 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)1 AnalyticDistributionTemplate (com.axelor.apps.account.db.AnalyticDistributionTemplate)1 Invoice (com.axelor.apps.account.db.Invoice)1 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)1 Journal (com.axelor.apps.account.db.Journal)1 PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)1 Tax (com.axelor.apps.account.db.Tax)1 TaxLine (com.axelor.apps.account.db.TaxLine)1 AccountTypeRepository (com.axelor.apps.account.db.repo.AccountTypeRepository)1 InvoiceLineRepository (com.axelor.apps.account.db.repo.InvoiceLineRepository)1 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)1 AccountManagementServiceAccountImpl (com.axelor.apps.account.service.AccountManagementServiceAccountImpl)1