Search in sources :

Example 1 with AdvancePayment

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;
}
Also used : AdvancePayment(com.axelor.apps.sale.db.AdvancePayment) BigDecimal(java.math.BigDecimal)

Example 2 with AdvancePayment

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);
}
Also used : AdvancePaymentService(com.axelor.apps.sale.service.AdvancePaymentService) AdvancePayment(com.axelor.apps.sale.db.AdvancePayment)

Example 3 with AdvancePayment

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());
    }
}
Also used : Company(com.axelor.apps.base.db.Company) Query(com.axelor.db.Query) InvoiceLineService(com.axelor.apps.account.service.invoice.InvoiceLineService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) EntityHelper(com.axelor.db.EntityHelper) PartnerService(com.axelor.apps.base.service.PartnerService) Inject(com.google.inject.Inject) CancelFactory(com.axelor.apps.account.service.invoice.factory.CancelFactory) VentilateFactory(com.axelor.apps.account.service.invoice.factory.VentilateFactory) Transactional(com.google.inject.persist.Transactional) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) MoveLine(com.axelor.apps.account.db.MoveLine) MoveToolService(com.axelor.apps.account.service.move.MoveToolService) ValidateFactory(com.axelor.apps.account.service.invoice.factory.ValidateFactory) SaleOrder(com.axelor.apps.sale.db.SaleOrder) InvoiceServiceImpl(com.axelor.apps.account.service.invoice.InvoiceServiceImpl) InvoiceLineRepository(com.axelor.apps.account.db.repo.InvoiceLineRepository) Timetable(com.axelor.apps.supplychain.db.Timetable) Set(java.util.Set) Invoice(com.axelor.apps.account.db.Invoice) Collectors(java.util.stream.Collectors) Currency(com.axelor.apps.base.db.Currency) Objects(java.util.Objects) List(java.util.List) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) AdvancePayment(com.axelor.apps.sale.db.AdvancePayment) Beans(com.axelor.inject.Beans) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) AlarmEngineService(com.axelor.apps.base.service.alarm.AlarmEngineService) ObjectUtils(com.axelor.common.ObjectUtils) TimetableRepository(com.axelor.apps.supplychain.db.repo.TimetableRepository) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService) Comparator(java.util.Comparator) ArrayList(java.util.ArrayList) Objects(java.util.Objects) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AdvancePayment(com.axelor.apps.sale.db.AdvancePayment)

Aggregations

AdvancePayment (com.axelor.apps.sale.db.AdvancePayment)3 BigDecimal (java.math.BigDecimal)2 Invoice (com.axelor.apps.account.db.Invoice)1 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)1 MoveLine (com.axelor.apps.account.db.MoveLine)1 InvoiceLineRepository (com.axelor.apps.account.db.repo.InvoiceLineRepository)1 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)1 AppAccountService (com.axelor.apps.account.service.app.AppAccountService)1 AccountConfigService (com.axelor.apps.account.service.config.AccountConfigService)1 InvoiceLineService (com.axelor.apps.account.service.invoice.InvoiceLineService)1 InvoiceServiceImpl (com.axelor.apps.account.service.invoice.InvoiceServiceImpl)1 CancelFactory (com.axelor.apps.account.service.invoice.factory.CancelFactory)1 ValidateFactory (com.axelor.apps.account.service.invoice.factory.ValidateFactory)1 VentilateFactory (com.axelor.apps.account.service.invoice.factory.VentilateFactory)1 MoveToolService (com.axelor.apps.account.service.move.MoveToolService)1 Company (com.axelor.apps.base.db.Company)1 Currency (com.axelor.apps.base.db.Currency)1 PartnerService (com.axelor.apps.base.service.PartnerService)1 AlarmEngineService (com.axelor.apps.base.service.alarm.AlarmEngineService)1 SaleOrder (com.axelor.apps.sale.db.SaleOrder)1