Search in sources :

Example 11 with Budget

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

Budget (com.axelor.apps.account.db.Budget)11 BudgetService (com.axelor.apps.account.service.BudgetService)5 BudgetDistribution (com.axelor.apps.account.db.BudgetDistribution)3 BudgetLine (com.axelor.apps.account.db.BudgetLine)3 Transactional (com.google.inject.persist.Transactional)3 BigDecimal (java.math.BigDecimal)3 Invoice (com.axelor.apps.account.db.Invoice)2 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)2 BudgetDistributionRepository (com.axelor.apps.account.db.repo.BudgetDistributionRepository)2 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 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)2 Beans (com.axelor.inject.Beans)2 Inject (com.google.inject.Inject)2 LocalDate (java.time.LocalDate)2 List (java.util.List)2 Optional (java.util.Optional)2 IExceptionMessage (com.axelor.apps.account.exception.IExceptionMessage)1 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)1