Search in sources :

Example 11 with AccountManagement

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

the class AccountManagementServiceAccountImpl method getProductFixedAssetCategory.

/**
 * Get the product fixed asset category
 *
 * @param product
 * @param company
 * @param configObject Specify if we want get the fixed asset category from the product or its
 *     product family
 *     <li>1 : product
 *     <li>2 : product family
 * @return
 * @throws AxelorException
 */
protected FixedAssetCategory getProductFixedAssetCategory(Product product, Company company, int configObject) {
    AccountManagement accountManagement = this.getAccountManagement(product, company, configObject);
    FixedAssetCategory fixedAssetCategory = null;
    if (accountManagement != null) {
        fixedAssetCategory = accountManagement.getFixedAssetCategory();
    }
    if (fixedAssetCategory == null && configObject == CONFIG_OBJECT_PRODUCT) {
        return getProductFixedAssetCategory(product, company, CONFIG_OBJECT_PRODUCT_FAMILY);
    }
    return fixedAssetCategory;
}
Also used : FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 12 with AccountManagement

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

the class BankDetailsServiceAccountImpl method createCompanyBankDetailsDomain.

/**
 * In this implementation, we use the O2M in payment mode.
 *
 * @param company
 * @param paymentMode
 * @return
 * @throws AxelorException
 */
@Override
public String createCompanyBankDetailsDomain(Partner partner, Company company, PaymentMode paymentMode, Integer operationTypeSelect) throws AxelorException {
    AppAccountService appAccountService = Beans.get(AppAccountService.class);
    if (!appAccountService.isApp("account") || !appAccountService.getAppBase().getManageMultiBanks()) {
        return super.createCompanyBankDetailsDomain(partner, company, paymentMode, operationTypeSelect);
    } else {
        if (partner != null) {
            partner = Beans.get(PartnerRepository.class).find(partner.getId());
        }
        List<BankDetails> authorizedBankDetails = new ArrayList<>();
        if (partner != null && partner.getFactorizedCustomer() && operationTypeSelect != null && (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_SALE || operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND)) {
            authorizedBankDetails = createCompanyBankDetailsDomainFromFactorPartner(company);
        } else {
            if (paymentMode == null) {
                return "self.id IN (0)";
            }
            List<AccountManagement> accountManagementList = paymentMode.getAccountManagementList();
            authorizedBankDetails = new ArrayList<>();
            for (AccountManagement accountManagement : accountManagementList) {
                if (accountManagement.getCompany() != null && accountManagement.getCompany().equals(company)) {
                    authorizedBankDetails.add(accountManagement.getBankDetails());
                }
            }
        }
        if (authorizedBankDetails.isEmpty()) {
            return "self.id IN (0)";
        } else {
            return "self.id IN (" + StringTool.getIdListString(authorizedBankDetails) + ") AND self.active = true";
        }
    }
}
Also used : BankDetails(com.axelor.apps.base.db.BankDetails) ArrayList(java.util.ArrayList) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) 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