Search in sources :

Example 1 with AnalyticDistributionTemplate

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

the class InvoiceLineServiceImpl method getAndComputeAnalyticDistribution.

public List<AnalyticMoveLine> getAndComputeAnalyticDistribution(InvoiceLine invoiceLine, Invoice invoice) {
    if (appAccountService.getAppAccount().getAnalyticDistributionTypeSelect() == AppAccountRepository.DISTRIBUTION_TYPE_FREE) {
        return MoreObjects.firstNonNull(invoiceLine.getAnalyticMoveLineList(), new ArrayList<>());
    }
    AnalyticDistributionTemplate analyticDistributionTemplate = analyticMoveLineService.getAnalyticDistributionTemplate(invoice.getPartner(), invoiceLine.getProduct(), invoice.getCompany());
    invoiceLine.setAnalyticDistributionTemplate(analyticDistributionTemplate);
    if (invoiceLine.getAnalyticMoveLineList() != null) {
        invoiceLine.getAnalyticMoveLineList().clear();
    }
    return this.computeAnalyticDistribution(invoiceLine);
}
Also used : AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate)

Example 2 with AnalyticDistributionTemplate

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

the class PurchaseOrderLineServiceSupplychainImpl method getAndComputeAnalyticDistribution.

public PurchaseOrderLine getAndComputeAnalyticDistribution(PurchaseOrderLine purchaseOrderLine, PurchaseOrder purchaseOrder) {
    if (appAccountService.getAppAccount().getAnalyticDistributionTypeSelect() == AppAccountRepository.DISTRIBUTION_TYPE_FREE) {
        return purchaseOrderLine;
    }
    AnalyticDistributionTemplate analyticDistributionTemplate = analyticMoveLineService.getAnalyticDistributionTemplate(purchaseOrder.getSupplierPartner(), purchaseOrderLine.getProduct(), purchaseOrder.getCompany());
    purchaseOrderLine.setAnalyticDistributionTemplate(analyticDistributionTemplate);
    if (purchaseOrderLine.getAnalyticMoveLineList() != null) {
        purchaseOrderLine.getAnalyticMoveLineList().clear();
    }
    this.computeAnalyticDistribution(purchaseOrderLine);
    return purchaseOrderLine;
}
Also used : AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate)

Example 3 with AnalyticDistributionTemplate

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

the class ExpenseServiceImpl method getAndComputeAnalyticDistribution.

@Override
public ExpenseLine getAndComputeAnalyticDistribution(ExpenseLine expenseLine, Expense expense) {
    if (appAccountService.getAppAccount().getAnalyticDistributionTypeSelect() == AppAccountRepository.DISTRIBUTION_TYPE_FREE) {
        return expenseLine;
    }
    AnalyticDistributionTemplate analyticDistributionTemplate = analyticMoveLineService.getAnalyticDistributionTemplate(expenseLine.getUser().getPartner(), expenseLine.getExpenseProduct(), expense.getCompany());
    expenseLine.setAnalyticDistributionTemplate(analyticDistributionTemplate);
    if (expenseLine.getAnalyticMoveLineList() != null) {
        expenseLine.getAnalyticMoveLineList().clear();
    }
    this.computeAnalyticDistribution(expenseLine);
    return expenseLine;
}
Also used : AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate)

Example 4 with AnalyticDistributionTemplate

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

the class AccountingCutOffServiceImpl method getAndComputeAnalyticDistribution.

protected void getAndComputeAnalyticDistribution(Product product, Move move, MoveLine moveLine) {
    if (appAccountService.getAppAccount().getAnalyticDistributionTypeSelect() == AppAccountRepository.DISTRIBUTION_TYPE_FREE) {
        return;
    }
    AnalyticDistributionTemplate analyticDistributionTemplate = analyticMoveLineService.getAnalyticDistributionTemplate(move.getPartner(), product, move.getCompany());
    moveLine.setAnalyticDistributionTemplate(analyticDistributionTemplate);
    List<AnalyticMoveLine> analyticMoveLineList = moveLineService.createAnalyticDistributionWithTemplate(moveLine).getAnalyticMoveLineList();
    for (AnalyticMoveLine analyticMoveLine : analyticMoveLineList) {
        analyticMoveLine.setMoveLine(moveLine);
    }
    analyticMoveLineList.stream().forEach(analyticMoveLineRepository::save);
}
Also used : AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 5 with AnalyticDistributionTemplate

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

the class SaleOrderLineServiceSupplyChainImpl method getAndComputeAnalyticDistribution.

public SaleOrderLine getAndComputeAnalyticDistribution(SaleOrderLine saleOrderLine, SaleOrder saleOrder) {
    if (appAccountService.getAppAccount().getAnalyticDistributionTypeSelect() == AppAccountRepository.DISTRIBUTION_TYPE_FREE) {
        return saleOrderLine;
    }
    AnalyticDistributionTemplate analyticDistributionTemplate = analyticMoveLineService.getAnalyticDistributionTemplate(saleOrder.getClientPartner(), saleOrderLine.getProduct(), saleOrder.getCompany());
    saleOrderLine.setAnalyticDistributionTemplate(analyticDistributionTemplate);
    if (saleOrderLine.getAnalyticMoveLineList() != null) {
        saleOrderLine.getAnalyticMoveLineList().clear();
    }
    this.computeAnalyticDistribution(saleOrderLine);
    return saleOrderLine;
}
Also used : AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate)

Aggregations

AnalyticDistributionTemplate (com.axelor.apps.account.db.AnalyticDistributionTemplate)6 AccountManagement (com.axelor.apps.account.db.AccountManagement)1 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)1