Search in sources :

Example 11 with BudgetDistribution

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

the class BudgetService method updateBudgetLinesFromInvoice.

public void updateBudgetLinesFromInvoice(Invoice invoice) {
    List<InvoiceLine> invoiceLineList = invoice.getInvoiceLineList();
    if (invoiceLineList == null) {
        return;
    }
    invoiceLineList.stream().filter(invoiceLine -> invoiceLine.getBudgetDistributionList() != null).flatMap(x -> x.getBudgetDistributionList().stream()).forEach(budgetDistribution -> {
        Budget budget = budgetDistribution.getBudget();
        updateLines(budget);
        computeTotalAmountRealized(budget);
    });
}
Also used : BudgetLineRepository(com.axelor.apps.account.db.repo.BudgetLineRepository) Budget(com.axelor.apps.account.db.Budget) TraceBackRepository(com.axelor.exception.db.repo.TraceBackRepository) BudgetDistributionRepository(com.axelor.apps.account.db.repo.BudgetDistributionRepository) Inject(com.google.inject.Inject) Invoice(com.axelor.apps.account.db.Invoice) Transactional(com.google.inject.persist.Transactional) ArrayList(java.util.ArrayList) IExceptionMessage(com.axelor.apps.account.exception.IExceptionMessage) BigDecimal(java.math.BigDecimal) List(java.util.List) BudgetLine(com.axelor.apps.account.db.BudgetLine) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) AxelorException(com.axelor.exception.AxelorException) Beans(com.axelor.inject.Beans) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) BudgetRepository(com.axelor.apps.account.db.repo.BudgetRepository) LocalDate(java.time.LocalDate) I18n(com.axelor.i18n.I18n) Optional(java.util.Optional) BudgetDistribution(com.axelor.apps.account.db.BudgetDistribution) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) Budget(com.axelor.apps.account.db.Budget)

Aggregations

BudgetDistribution (com.axelor.apps.account.db.BudgetDistribution)11 Transactional (com.google.inject.persist.Transactional)7 LocalDate (java.time.LocalDate)6 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)5 BigDecimal (java.math.BigDecimal)5 BudgetLine (com.axelor.apps.account.db.BudgetLine)4 BudgetDistributionRepository (com.axelor.apps.account.db.repo.BudgetDistributionRepository)4 Budget (com.axelor.apps.account.db.Budget)3 Invoice (com.axelor.apps.account.db.Invoice)3 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)3 BudgetLineRepository (com.axelor.apps.account.db.repo.BudgetLineRepository)2 BudgetRepository (com.axelor.apps.account.db.repo.BudgetRepository)2 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)2 Beans (com.axelor.inject.Beans)2 Inject (com.google.inject.Inject)2 List (java.util.List)2 Optional (java.util.Optional)2 IExceptionMessage (com.axelor.apps.account.exception.IExceptionMessage)1 BudgetService (com.axelor.apps.account.service.BudgetService)1 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)1