use of com.axelor.apps.account.db.PayVoucherElementToPay in project axelor-open-suite by axelor.
the class PaymentVoucherCreateService method createPaymentVoucherIPO.
@Transactional(rollbackOn = { Exception.class })
public PaymentVoucher createPaymentVoucherIPO(Invoice invoice, LocalDate date, BigDecimal amount, PaymentMode paymentMode) throws AxelorException {
MoveLine customerMoveLine = moveToolService.getCustomerMoveLineByQuery(invoice);
log.debug("Création d'une saisie paiement par TIP ou TIP chèque - facture : {}", invoice.getInvoiceId());
log.debug("Création d'une saisie paiement par TIP ou TIP chèque - mode de paiement : {}", paymentMode.getCode());
log.debug("Création d'une saisie paiement par TIP ou TIP chèque - société : {}", invoice.getCompany().getName());
log.debug("Création d'une saisie paiement par TIP ou TIP chèque - tiers payeur : {}", invoice.getPartner().getName());
PaymentVoucher paymentVoucher = this.createPaymentVoucher(invoice.getCompany(), null, paymentMode, date, invoice.getPartner(), amount, null, invoice, null, null, null);
paymentVoucher.setHasAutoInput(true);
List<PayVoucherElementToPay> lines = new ArrayList<PayVoucherElementToPay>();
lines.add(payVoucherElementToPayService.createPayVoucherElementToPay(paymentVoucher, 1, invoice, customerMoveLine, customerMoveLine.getDebit(), customerMoveLine.getAmountRemaining(), amount));
paymentVoucher.setPayVoucherElementToPayList(lines);
paymentVoucherRepository.save(paymentVoucher);
paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher);
return paymentVoucher;
}
use of com.axelor.apps.account.db.PayVoucherElementToPay in project axelor-open-suite by axelor.
the class PaymentVoucherLoadService method completeElementToPay.
/**
* Allows to load selected lines (from 1st 02M) to the 2nd O2M and dispatching amounts according
* to amountRemainnig for the loaded move and the paid amount remaining of the paymentVoucher
*
* @param paymentVoucher
* @param paymentVoucherContext
* @return
* @return
* @return values Map of data
* @throws AxelorException
*/
public void completeElementToPay(PaymentVoucher paymentVoucher) throws AxelorException {
int sequence = paymentVoucher.getPayVoucherElementToPayList().size() + 1;
List<PayVoucherDueElement> toRemove = new ArrayList<>();
for (PayVoucherDueElement payVoucherDueElement : paymentVoucher.getPayVoucherDueElementList()) {
if (payVoucherDueElement.isSelected()) {
PayVoucherElementToPay payVoucherElementToPay = this.createPayVoucherElementToPay(paymentVoucher, payVoucherDueElement, sequence++);
paymentVoucher.addPayVoucherElementToPayListItem(payVoucherElementToPay);
if (payVoucherElementToPay != null) {
paymentVoucher.setRemainingAmount(paymentVoucher.getRemainingAmount().subtract(payVoucherElementToPay.getAmountToPay()));
}
// Remove the line from the due elements lists
toRemove.add(payVoucherDueElement);
}
}
for (PayVoucherDueElement payVoucherDueElement : toRemove) {
paymentVoucher.removePayVoucherDueElementListItem(payVoucherDueElement);
}
}
use of com.axelor.apps.account.db.PayVoucherElementToPay in project axelor-open-suite by axelor.
the class PaymentVoucherConfirmService method deleteUnPaidLines.
public void deleteUnPaidLines(PaymentVoucher paymentVoucher) {
if (paymentVoucher.getPayVoucherElementToPayList() == null) {
return;
}
paymentVoucher.getPayVoucherDueElementList().clear();
List<PayVoucherElementToPay> payVoucherElementToPayToRemove = new ArrayList<>();
for (PayVoucherElementToPay payVoucherElementToPay : paymentVoucher.getPayVoucherElementToPayList()) {
if (payVoucherElementToPay.getAmountToPay().compareTo(BigDecimal.ZERO) == 0 && payVoucherElementToPay.getMoveLineGenerated() == null) {
payVoucherElementToPayToRemove.add(payVoucherElementToPay);
}
}
paymentVoucher.getPayVoucherElementToPayList().removeAll(payVoucherElementToPayToRemove);
}
use of com.axelor.apps.account.db.PayVoucherElementToPay in project axelor-open-suite by axelor.
the class PaymentVoucherConfirmService method waitForDepositSlip.
private void waitForDepositSlip(PaymentVoucher paymentVoucher) {
for (PayVoucherElementToPay payVoucherElementToPay : paymentVoucher.getPayVoucherElementToPayList()) {
Invoice invoice = payVoucherElementToPay.getMoveLine().getMove().getInvoice();
boolean hasPendingPayments = payVoucherElementToPay.getRemainingAmountAfterPayment().signum() <= 0;
invoice.setHasPendingPayments(hasPendingPayments);
}
paymentVoucher.setStatusSelect(PaymentVoucherRepository.STATUS_WAITING_FOR_DEPOSIT_SLIP);
}
use of com.axelor.apps.account.db.PayVoucherElementToPay in project axelor-open-suite by axelor.
the class PayVoucherElementToPayService method createPayVoucherElementToPay.
/**
* Generic method for creating invoice to pay lines (2nd O2M in the view)
*
* @param pv
* @param seq
* @return
*/
public PayVoucherElementToPay createPayVoucherElementToPay(PaymentVoucher paymentVoucher, int seq, Invoice invoice, MoveLine moveLine, BigDecimal totalAmount, BigDecimal remainingAmount, BigDecimal amountToPay) {
log.debug("In createPayVoucherElementToPay....");
if (paymentVoucher != null && moveLine != null) {
PayVoucherElementToPay piToPay = new PayVoucherElementToPay();
piToPay.setSequence(seq);
piToPay.setMoveLine(moveLine);
piToPay.setTotalAmount(totalAmount);
piToPay.setRemainingAmount(remainingAmount);
piToPay.setAmountToPay(amountToPay);
piToPay.setPaymentVoucher(paymentVoucher);
log.debug("End createPayVoucherElementToPay IF.");
return piToPay;
} else {
log.debug("End createPayVoucherElementToPay ELSE.");
return null;
}
}
Aggregations