Search in sources :

Example 1 with FixedAssetCategory

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

the class FixedAssetTestTool method createFixedAssetCategoryFromIsProrataTemporis.

public static FixedAssetCategory createFixedAssetCategoryFromIsProrataTemporis(boolean isProrataTemporis, boolean usProrataTemporis) {
    FixedAssetType fixedAssetType = new FixedAssetType();
    FixedAssetCategory fixedAssetCategory = new FixedAssetCategory();
    fixedAssetCategory.setFixedAssetType(fixedAssetType);
    fixedAssetCategory.setIsProrataTemporis(isProrataTemporis);
    fixedAssetCategory.setIsUSProrataTemporis(usProrataTemporis);
    return fixedAssetCategory;
}
Also used : FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) FixedAssetType(com.axelor.apps.account.db.FixedAssetType)

Example 2 with FixedAssetCategory

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

the class InvoiceLineController method getFixedAssetCategory.

public void getFixedAssetCategory(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
    Invoice invoice = this.getInvoice(context);
    Product product = invoiceLine.getProduct();
    if (invoice == null || product == null) {
        return;
    }
    FixedAssetCategory fixedAssetCategory = null;
    if (!product.getAccountManagementList().isEmpty() && (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE || invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND)) {
        Optional<AccountManagement> optionalFixedAssetCategory = product.getAccountManagementList().stream().filter(am -> invoice.getCompany().equals(am.getCompany())).findFirst();
        fixedAssetCategory = optionalFixedAssetCategory.isPresent() ? optionalFixedAssetCategory.get().getFixedAssetCategory() : null;
    }
    response.setValue("fixedAssetCategory", fixedAssetCategory);
}
Also used : Context(com.axelor.rpc.Context) FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) InvoiceLineService(com.axelor.apps.account.service.invoice.InvoiceLineService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) HashMap(java.util.HashMap) AccountManagementServiceAccountImpl(com.axelor.apps.account.service.AccountManagementServiceAccountImpl) Mapper(com.axelor.db.mapper.Mapper) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) BigDecimal(java.math.BigDecimal) AccountTypeRepository(com.axelor.apps.account.db.repo.AccountTypeRepository) AxelorException(com.axelor.exception.AxelorException) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) TaxLine(com.axelor.apps.account.db.TaxLine) ActionResponse(com.axelor.rpc.ActionResponse) Map(java.util.Map) I18n(com.axelor.i18n.I18n) FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) ActionRequest(com.axelor.rpc.ActionRequest) AccountManagement(com.axelor.apps.account.db.AccountManagement) InvoiceLineManagement(com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement) ITranslation(com.axelor.apps.account.translation.ITranslation) InvoiceLineRepository(com.axelor.apps.account.db.repo.InvoiceLineRepository) TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) Collectors(java.util.stream.Collectors) Account(com.axelor.apps.account.db.Account) InvoiceToolService(com.axelor.apps.account.service.invoice.InvoiceToolService) List(java.util.List) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) Beans(com.axelor.inject.Beans) Product(com.axelor.apps.base.db.Product) Entry(java.util.Map.Entry) Optional(java.util.Optional) Context(com.axelor.rpc.Context) Singleton(com.google.inject.Singleton) Invoice(com.axelor.apps.account.db.Invoice) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) Product(com.axelor.apps.base.db.Product) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 3 with FixedAssetCategory

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

the class InvoiceLineGeneratorSupplyChain method createInvoiceLine.

/**
 * @return
 * @throws AxelorException
 */
@Override
protected InvoiceLine createInvoiceLine() throws AxelorException {
    InvoiceLine invoiceLine = super.createInvoiceLine();
    if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
        return invoiceLine;
    }
    InvoiceLineService invoiceLineService = Beans.get(InvoiceLineService.class);
    this.assignOriginElements(invoiceLine);
    List<AnalyticMoveLine> analyticMoveLineList = null;
    if (saleOrderLine != null) {
        switch(saleOrderLine.getTypeSelect()) {
            case SaleOrderLineRepository.TYPE_END_OF_PACK:
                invoiceLine.setIsHideUnitAmounts(saleOrderLine.getIsHideUnitAmounts());
                invoiceLine.setIsShowTotal(saleOrderLine.getIsShowTotal());
                break;
            case SaleOrderLineRepository.TYPE_NORMAL:
                if (saleOrderLine.getAnalyticDistributionTemplate() != null || !ObjectUtils.isEmpty(saleOrderLine.getAnalyticMoveLineList())) {
                    invoiceLine.setAnalyticDistributionTemplate(saleOrderLine.getAnalyticDistributionTemplate());
                    this.copyAnalyticMoveLines(saleOrderLine.getAnalyticMoveLineList(), invoiceLine);
                    analyticMoveLineList = invoiceLineService.computeAnalyticDistribution(invoiceLine);
                } else {
                    analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
                    analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
                }
                break;
            default:
                return invoiceLine;
        }
    } else if (purchaseOrderLine != null) {
        if (purchaseOrderLine.getAnalyticDistributionTemplate() != null || !ObjectUtils.isEmpty(purchaseOrderLine.getAnalyticMoveLineList())) {
            invoiceLine.setAnalyticDistributionTemplate(purchaseOrderLine.getAnalyticDistributionTemplate());
            this.copyAnalyticMoveLines(purchaseOrderLine.getAnalyticMoveLineList(), invoiceLine);
            analyticMoveLineList = invoiceLineService.computeAnalyticDistribution(invoiceLine);
        } else {
            analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
            analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
        }
        this.copyBudgetDistributionList(purchaseOrderLine.getBudgetDistributionList(), invoiceLine);
        invoiceLine.setBudget(purchaseOrderLine.getBudget());
        invoiceLine.setBudgetDistributionSumAmount(purchaseOrderLine.getBudgetDistributionSumAmount());
        invoiceLine.setFixedAssets(purchaseOrderLine.getFixedAssets());
        if (product != null) {
            invoiceLine.setProductCode((String) productCompanyService.get(product, "code", invoice.getCompany()));
            Account account = accountManagementService.getProductAccount(product, invoice.getCompany(), invoice.getPartner().getFiscalPosition(), InvoiceToolService.isPurchase(invoice), invoiceLine.getFixedAssets());
            invoiceLine.setAccount(account);
        }
        if (product != null && purchaseOrderLine.getFixedAssets()) {
            FixedAssetCategory fixedAssetCategory = accountManagementService.getProductFixedAssetCategory(product, invoice.getCompany());
            invoiceLine.setFixedAssetCategory(fixedAssetCategory);
        }
    } else if (stockMoveLine != null) {
        this.price = stockMoveLine.getUnitPriceUntaxed();
        this.inTaxPrice = stockMoveLine.getUnitPriceTaxed();
        this.price = unitConversionService.convert(stockMoveLine.getUnit(), this.unit, this.price, appBaseService.getNbDecimalDigitForUnitPrice(), product);
        this.inTaxPrice = unitConversionService.convert(stockMoveLine.getUnit(), this.unit, this.inTaxPrice, appBaseService.getNbDecimalDigitForUnitPrice(), product);
        invoiceLine.setPrice(price);
        invoiceLine.setInTaxPrice(inTaxPrice);
        analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
        analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
    }
    return invoiceLine;
}
Also used : FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) Account(com.axelor.apps.account.db.Account) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) InvoiceLineService(com.axelor.apps.account.service.invoice.InvoiceLineService) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 4 with FixedAssetCategory

use of com.axelor.apps.account.db.FixedAssetCategory 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)

Aggregations

FixedAssetCategory (com.axelor.apps.account.db.FixedAssetCategory)4 Account (com.axelor.apps.account.db.Account)2 AccountManagement (com.axelor.apps.account.db.AccountManagement)2 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)2 InvoiceLineService (com.axelor.apps.account.service.invoice.InvoiceLineService)2 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)1 FixedAssetType (com.axelor.apps.account.db.FixedAssetType)1 Invoice (com.axelor.apps.account.db.Invoice)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 AppAccountService (com.axelor.apps.account.service.app.AppAccountService)1 InvoiceToolService (com.axelor.apps.account.service.invoice.InvoiceToolService)1 InvoiceLineManagement (com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement)1 ITranslation (com.axelor.apps.account.translation.ITranslation)1 Product (com.axelor.apps.base.db.Product)1 Mapper (com.axelor.db.mapper.Mapper)1 AxelorException (com.axelor.exception.AxelorException)1