use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.
the class PaymentVoucherController method loadSelectedLines.
// Filling lines to pay (2nd O2M)
public void loadSelectedLines(ActionRequest request, ActionResponse response) {
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
try {
Beans.get(PaymentVoucherLoadService.class).loadSelectedLines(paymentVoucher);
response.setValue("payVoucherDueElementList", paymentVoucher.getPayVoucherDueElementList());
response.setValue("payVoucherElementToPayList", paymentVoucher.getPayVoucherElementToPayList());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.
the class PaymentVoucherCreateService method createPaymentVoucher.
/**
* Generic method to create a payment voucher
*
* @param company
* @param user
* @param paymentMode
* @param date
* @param partner
* @param amount
* @param moveLine
* @param invoiceToPay
* @param rejectToPay
* @param scheduleToPay
* @param paymentScheduleToPay
* @return
* @throws AxelorException
*/
public PaymentVoucher createPaymentVoucher(Company company, User user, PaymentMode paymentMode, LocalDate date, Partner partner, BigDecimal amount, MoveLine moveLine, Invoice invoiceToPay, MoveLine rejectToPay, PaymentScheduleLine scheduleToPay, PaymentSchedule paymentScheduleToPay) throws AxelorException {
log.debug("\n\n createPaymentVoucher ....");
LocalDate date2 = date;
if (date2 == null) {
date2 = appAccountService.getTodayDate(company);
}
BigDecimal amount2 = amount;
if (amount2 == null) {
amount2 = BigDecimal.ZERO;
}
// create the move
PaymentVoucher paymentVoucher = new PaymentVoucher();
if (company != null && paymentMode != null && partner != null) {
paymentVoucher.setCompany(company);
paymentVoucher.setUser(user);
paymentVoucher.setPaymentDate(date2);
paymentVoucher.setPaymentMode(paymentMode);
paymentVoucher.setPartner(partner);
paymentVoucher.setPaidAmount(amount2);
paymentVoucher.setMoveLine(moveLine);
paymentVoucherSequenceService.setReference(paymentVoucher);
return paymentVoucher;
}
return null;
}
use of com.axelor.apps.account.db.PaymentVoucher 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.PaymentVoucher in project axelor-open-suite by axelor.
the class InvoicePaymentCreateServiceImpl method createInvoicePayment.
/**
* @param invoice
* @param amount
* @param paymentDate
* @param paymentMove
* @return
*/
public InvoicePayment createInvoicePayment(Invoice invoice, BigDecimal amount, Move paymentMove) throws AxelorException {
LocalDate paymentDate = paymentMove.getDate();
BigDecimal amountConverted = currencyService.getAmountCurrencyConvertedAtDate(paymentMove.getCompanyCurrency(), paymentMove.getCurrency(), amount, paymentDate);
int typePaymentMove = this.determineType(paymentMove);
Currency currency = paymentMove.getCurrency();
if (currency == null) {
currency = paymentMove.getCompanyCurrency();
}
PaymentMode paymentMode;
InvoicePayment invoicePayment;
if (typePaymentMove == InvoicePaymentRepository.TYPE_REFUND_INVOICE || typePaymentMove == InvoicePaymentRepository.TYPE_INVOICE) {
paymentMode = null;
} else {
paymentMode = paymentMove.getPaymentMode();
}
invoicePayment = this.createInvoicePayment(invoice, amountConverted, paymentDate, currency, paymentMode, typePaymentMove);
invoicePayment.setMove(paymentMove);
invoicePayment.setStatusSelect(InvoicePaymentRepository.STATUS_VALIDATED);
PaymentVoucher paymentVoucher = paymentMove.getPaymentVoucher();
if (paymentVoucher != null) {
invoicePayment.setCompanyBankDetails(paymentVoucher.getCompanyBankDetails());
} else if (invoice.getSchedulePaymentOk() && invoice.getPaymentSchedule() != null) {
BankDetails companyBankDetails = invoice.getPaymentSchedule().getCompanyBankDetails();
invoicePayment.setCompanyBankDetails(companyBankDetails);
}
computeAdvancePaymentImputation(invoicePayment, paymentMove);
invoice.addInvoicePaymentListItem(invoicePayment);
invoicePaymentToolService.updateAmountPaid(invoice);
invoicePaymentRepository.save(invoicePayment);
return invoicePayment;
}
use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.
the class PaymentVoucherController method confirmPaymentVoucher.
// Confirm the payment voucher
public void confirmPaymentVoucher(ActionRequest request, ActionResponse response) {
PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
paymentVoucher = Beans.get(PaymentVoucherRepository.class).find(paymentVoucher.getId());
try {
Beans.get(PaymentVoucherConfirmService.class).confirmPaymentVoucher(paymentVoucher);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations