use of com.axelor.apps.sale.db.AdvancePayment in project axelor-open-suite by axelor.
the class SaleOrderComputeServiceImpl method computeTotalAdvancePayment.
protected BigDecimal computeTotalAdvancePayment(SaleOrder saleOrder) {
List<AdvancePayment> advancePaymentList = saleOrder.getAdvancePaymentList();
BigDecimal total = BigDecimal.ZERO;
if (advancePaymentList == null || advancePaymentList.isEmpty()) {
return total;
}
for (AdvancePayment advancePayment : advancePaymentList) {
total = total.add(advancePayment.getAmount());
}
return total;
}
use of com.axelor.apps.sale.db.AdvancePayment in project axelor-open-suite by axelor.
the class AdvancePaymentController method cancelAdvancePayment.
public void cancelAdvancePayment(ActionRequest request, ActionResponse response) throws AxelorException {
AdvancePayment advancePayment = request.getContext().asType(AdvancePayment.class);
advancePayment = Beans.get(AdvancePaymentRepository.class).find(advancePayment.getId());
Beans.get(AdvancePaymentService.class).cancelAdvancePayment(advancePayment);
response.setReload(true);
}
use of com.axelor.apps.sale.db.AdvancePayment in project axelor-open-suite by axelor.
the class InvoiceServiceSupplychainImpl method getMoveLinesFromSOAdvancePayments.
@Override
public List<MoveLine> getMoveLinesFromSOAdvancePayments(Invoice invoice) {
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return super.getMoveLinesFromSOAdvancePayments(invoice);
}
// search sale order in the invoice
SaleOrder saleOrder = invoice.getSaleOrder();
// search sale order in invoice lines
List<SaleOrder> saleOrderList = invoice.getInvoiceLineList().stream().map(invoiceLine -> invoice.getSaleOrder()).collect(Collectors.toList());
saleOrderList.add(saleOrder);
// remove null value and duplicates
saleOrderList = saleOrderList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (saleOrderList.isEmpty()) {
return new ArrayList<>();
} else {
// get move lines from sale order
return saleOrderList.stream().flatMap(saleOrder1 -> saleOrder1.getAdvancePaymentList().stream()).filter(Objects::nonNull).distinct().map(AdvancePayment::getMove).filter(Objects::nonNull).distinct().flatMap(move -> moveToolService.getToReconcileCreditMoveLines(move).stream()).collect(Collectors.toList());
}
}
Aggregations