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;
}
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);
}
}
}
Aggregations