use of com.axelor.apps.account.db.Budget in project axelor-open-suite by axelor.
the class BudgetController method draft.
public void draft(ActionRequest request, ActionResponse response) {
try {
Budget budget = request.getContext().asType(Budget.class);
budget = Beans.get(BudgetRepository.class).find(budget.getId());
Beans.get(BudgetService.class).draft(budget);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Budget in project axelor-open-suite by axelor.
the class BudgetController method updateLines.
public void updateLines(ActionRequest request, ActionResponse response) {
try {
Budget budget = request.getContext().asType(Budget.class);
budget = Beans.get(BudgetRepository.class).find(budget.getId());
List<BudgetLine> budgetLineList = Beans.get(BudgetService.class).updateLines(budget);
response.setValue("budgetLineList", budgetLineList);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Budget in project axelor-open-suite by axelor.
the class BudgetController method compute.
public void compute(ActionRequest request, ActionResponse response) {
try {
Budget budget = request.getContext().asType(Budget.class);
response.setValue("totalAmountExpected", Beans.get(BudgetService.class).compute(budget));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Budget in project axelor-open-suite by axelor.
the class PurchaseOrderServiceSupplychainImpl method requestPurchaseOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public void requestPurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException {
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
super.requestPurchaseOrder(purchaseOrder);
return;
}
// budget control
if (appAccountService.isApp("budget") && appAccountService.getAppBudget().getCheckAvailableBudget()) {
List<PurchaseOrderLine> purchaseOrderLines = purchaseOrder.getPurchaseOrderLineList();
Map<Budget, BigDecimal> amountPerBudget = new HashMap<>();
if (appAccountService.getAppBudget().getManageMultiBudget()) {
for (PurchaseOrderLine pol : purchaseOrderLines) {
if (pol.getBudgetDistributionList() != null) {
for (BudgetDistribution bd : pol.getBudgetDistributionList()) {
Budget budget = bd.getBudget();
if (!amountPerBudget.containsKey(budget)) {
amountPerBudget.put(budget, bd.getAmount());
} else {
BigDecimal oldAmount = amountPerBudget.get(budget);
amountPerBudget.put(budget, oldAmount.add(bd.getAmount()));
}
isBudgetExceeded(budget, amountPerBudget.get(budget));
}
}
}
} else {
for (PurchaseOrderLine pol : purchaseOrderLines) {
// getting Budget associated to POL
Budget budget = pol.getBudget();
if (!amountPerBudget.containsKey(budget)) {
amountPerBudget.put(budget, pol.getExTaxTotal());
} else {
BigDecimal oldAmount = amountPerBudget.get(budget);
amountPerBudget.put(budget, oldAmount.add(pol.getExTaxTotal()));
}
isBudgetExceeded(budget, amountPerBudget.get(budget));
}
}
}
super.requestPurchaseOrder(purchaseOrder);
int intercoPurchaseCreatingStatus = Beans.get(AppSupplychainService.class).getAppSupplychain().getIntercoPurchaseCreatingStatusSelect();
if (purchaseOrder.getInterco() && intercoPurchaseCreatingStatus == PurchaseOrderRepository.STATUS_REQUESTED) {
Beans.get(IntercoService.class).generateIntercoSaleFromPurchase(purchaseOrder);
}
if (purchaseOrder.getCreatedByInterco()) {
fillIntercompanySaleOrderCounterpart(purchaseOrder);
}
}
use of com.axelor.apps.account.db.Budget in project axelor-open-suite by axelor.
the class BudgetController method computeTotalAmountCommited.
public void computeTotalAmountCommited(ActionRequest request, ActionResponse response) {
try {
Budget budget = request.getContext().asType(Budget.class);
budget = Beans.get(BudgetRepository.class).find(budget.getId());
response.setValue("totalAmountCommitted", Beans.get(BudgetSupplychainService.class).computeTotalAmountCommitted(budget));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations