Search in sources :

Example 1 with MoveLineService

use of com.axelor.apps.account.service.move.MoveLineService in project axelor-open-suite by axelor.

the class PaymentScheduleLineBankPaymentServiceImpl method createRejectionMove.

@Transactional(rollbackOn = { Exception.class })
protected Move createRejectionMove(PaymentScheduleLine paymentScheduleLine) throws AxelorException {
    MoveValidateService moveValidateService = moveService.getMoveValidateService();
    MoveLineService moveLineService = moveService.getMoveLineService();
    Move advanceOrPaymentMove = paymentScheduleLine.getAdvanceOrPaymentMove();
    Move rejectionMove = moveService.generateReverse(advanceOrPaymentMove, true, true, false, advanceOrPaymentMove.getDate());
    rejectionMove.setRejectOk(true);
    moveValidateService.validate(rejectionMove);
    List<MoveLine> moveLineList = new ArrayList<>();
    moveLineList.addAll(advanceOrPaymentMove.getMoveLineList());
    moveLineList.addAll(rejectionMove.getMoveLineList());
    moveLineService.reconcileMoveLines(moveLineList);
    return rejectionMove;
}
Also used : MoveLineService(com.axelor.apps.account.service.move.MoveLineService) MoveValidateService(com.axelor.apps.account.service.move.MoveValidateService) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) Transactional(com.google.inject.persist.Transactional)

Example 2 with MoveLineService

use of com.axelor.apps.account.service.move.MoveLineService in project axelor-open-suite by axelor.

the class PaymentScheduleLineBankPaymentServiceImpl method cancelInvoicePayments.

@Transactional(rollbackOn = { Exception.class })
protected void cancelInvoicePayments(PaymentScheduleLine paymentScheduleLine) throws AxelorException {
    MoveLineService moveLineService = moveService.getMoveLineService();
    PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
    MoveLine creditMoveLine = paymentScheduleLine.getAdvanceMoveLine();
    Set<Invoice> invoiceSet = MoreObjects.firstNonNull(paymentSchedule.getInvoiceSet(), Collections.emptySet());
    for (Invoice invoice : invoiceSet) {
        MoveLine debitMoveLine = moveLineService.getDebitCustomerMoveLine(invoice);
        Reconcile reconcile = reconcileRepo.findByMoveLines(debitMoveLine, creditMoveLine);
        if (reconcile == null) {
            continue;
        }
        for (InvoicePayment invoicePayment : invoicePaymentRepo.findByReconcile(reconcile).fetch()) {
            invoicePaymentCancelService.cancel(invoicePayment);
        }
    }
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) MoveLineService(com.axelor.apps.account.service.move.MoveLineService) Invoice(com.axelor.apps.account.db.Invoice) PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) MoveLine(com.axelor.apps.account.db.MoveLine) Reconcile(com.axelor.apps.account.db.Reconcile) Transactional(com.google.inject.persist.Transactional)

Aggregations

MoveLine (com.axelor.apps.account.db.MoveLine)2 MoveLineService (com.axelor.apps.account.service.move.MoveLineService)2 Transactional (com.google.inject.persist.Transactional)2 Invoice (com.axelor.apps.account.db.Invoice)1 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)1 Move (com.axelor.apps.account.db.Move)1 PaymentSchedule (com.axelor.apps.account.db.PaymentSchedule)1 Reconcile (com.axelor.apps.account.db.Reconcile)1 MoveValidateService (com.axelor.apps.account.service.move.MoveValidateService)1 ArrayList (java.util.ArrayList)1