use of com.axelor.apps.account.db.BudgetDistribution in project axelor-open-suite by axelor.
the class BudgetService method updateLines.
@Transactional
public List<BudgetLine> updateLines(Budget budget) {
if (budget.getBudgetLineList() != null && !budget.getBudgetLineList().isEmpty()) {
for (BudgetLine budgetLine : budget.getBudgetLineList()) {
budgetLine.setAmountRealized(BigDecimal.ZERO);
}
List<BudgetDistribution> budgetDistributionList = Beans.get(BudgetDistributionRepository.class).all().filter("self.budget.id = ?1 AND (self.invoiceLine.invoice.statusSelect = ?2 OR self.invoiceLine.invoice.statusSelect = ?3)", budget.getId(), InvoiceRepository.STATUS_VALIDATED, InvoiceRepository.STATUS_VENTILATED).fetch();
for (BudgetDistribution budgetDistribution : budgetDistributionList) {
Optional<LocalDate> optionaldate = getDate(budgetDistribution);
optionaldate.ifPresent(date -> {
for (BudgetLine budgetLine : budget.getBudgetLineList()) {
LocalDate fromDate = budgetLine.getFromDate();
LocalDate toDate = budgetLine.getToDate();
if (fromDate != null && toDate != null && (fromDate.isBefore(date) || fromDate.isEqual(date)) && (toDate.isAfter(date) || toDate.isEqual(date))) {
budgetLine.setAmountRealized(budgetLine.getAmountRealized().add(budgetDistribution.getAmount()));
break;
}
}
});
}
}
return budget.getBudgetLineList();
}
use of com.axelor.apps.account.db.BudgetDistribution in project axelor-open-suite by axelor.
the class PurchaseOrderServiceSupplychainImpl method applyToallBudgetDistribution.
@Transactional
@Override
public void applyToallBudgetDistribution(PurchaseOrder purchaseOrder) {
for (PurchaseOrderLine purchaseOrderLine : purchaseOrder.getPurchaseOrderLineList()) {
BudgetDistribution newBudgetDistribution = new BudgetDistribution();
newBudgetDistribution.setAmount(purchaseOrderLine.getCompanyExTaxTotal());
newBudgetDistribution.setBudget(purchaseOrder.getBudget());
newBudgetDistribution.setPurchaseOrderLine(purchaseOrderLine);
Beans.get(BudgetDistributionRepository.class).save(newBudgetDistribution);
Beans.get(PurchaseOrderLineServiceSupplychainImpl.class).computeBudgetDistributionSumAmount(purchaseOrderLine, purchaseOrder);
}
}
use of com.axelor.apps.account.db.BudgetDistribution in project axelor-open-suite by axelor.
the class BudgetSupplychainService method updateBudgetLinesFromPurchaseOrder.
public void updateBudgetLinesFromPurchaseOrder(PurchaseOrder purchaseOrder) {
List<PurchaseOrderLine> purchaseOrderLineList = purchaseOrder.getPurchaseOrderLineList();
if (purchaseOrderLineList == null) {
return;
}
purchaseOrderLineList.stream().flatMap(x -> x.getBudgetDistributionList().stream()).forEach(budgetDistribution -> {
Budget budget = budgetDistribution.getBudget();
updateLines(budget);
computeTotalAmountCommitted(budget);
});
}
use of com.axelor.apps.account.db.BudgetDistribution in project axelor-open-suite by axelor.
the class ValidateState method generateBudgetDistribution.
private void generateBudgetDistribution(Invoice invoice) {
if (invoice.getInvoiceLineList() != null) {
for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
if (invoiceLine.getBudget() != null && (invoiceLine.getBudgetDistributionList() == null || invoiceLine.getBudgetDistributionList().isEmpty())) {
BudgetDistribution budgetDistribution = new BudgetDistribution();
budgetDistribution.setBudget(invoiceLine.getBudget());
budgetDistribution.setAmount(invoiceLine.getCompanyExTaxTotal());
invoiceLine.addBudgetDistributionListItem(budgetDistribution);
}
}
}
}
use of com.axelor.apps.account.db.BudgetDistribution in project axelor-open-suite by axelor.
the class InvoiceLineGeneratorSupplyChain method copyBudgetDistributionList.
public void copyBudgetDistributionList(List<BudgetDistribution> originalBudgetDistributionList, InvoiceLine invoiceLine) {
if (originalBudgetDistributionList == null) {
return;
}
for (BudgetDistribution budgetDistributionIt : originalBudgetDistributionList) {
BudgetDistribution budgetDistribution = new BudgetDistribution();
budgetDistribution.setBudget(budgetDistributionIt.getBudget());
budgetDistribution.setAmount(budgetDistributionIt.getAmount());
budgetDistribution.setBudgetAmountAvailable(budgetDistributionIt.getBudgetAmountAvailable());
invoiceLine.addBudgetDistributionListItem(budgetDistribution);
}
}
Aggregations