Search in sources :

Example 11 with PaymentVoucher

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);
    }
}
Also used : PaymentVoucherLoadService(com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherLoadService) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Example 12 with PaymentVoucher

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;
}
Also used : LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher)

Example 13 with PaymentVoucher

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;
}
Also used : PayVoucherElementToPay(com.axelor.apps.account.db.PayVoucherElementToPay) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) Transactional(com.google.inject.persist.Transactional)

Example 14 with 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;
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) BankDetails(com.axelor.apps.base.db.BankDetails) Currency(com.axelor.apps.base.db.Currency) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 15 with PaymentVoucher

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);
    }
}
Also used : PaymentVoucherConfirmService(com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherConfirmService) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Aggregations

PaymentVoucher (com.axelor.apps.account.db.PaymentVoucher)16 AxelorException (com.axelor.exception.AxelorException)8 PaymentVoucherLoadService (com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherLoadService)5 MoveLine (com.axelor.apps.account.db.MoveLine)3 PaymentMode (com.axelor.apps.account.db.PaymentMode)3 BankDetails (com.axelor.apps.base.db.BankDetails)3 BigDecimal (java.math.BigDecimal)3 LocalDate (java.time.LocalDate)3 Invoice (com.axelor.apps.account.db.Invoice)2 Journal (com.axelor.apps.account.db.Journal)2 PayVoucherDueElement (com.axelor.apps.account.db.PayVoucherDueElement)2 Company (com.axelor.apps.base.db.Company)2 Partner (com.axelor.apps.base.db.Partner)2 InterbankCodeLine (com.axelor.apps.account.db.InterbankCodeLine)1 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)1 Move (com.axelor.apps.account.db.Move)1 PayVoucherElementToPay (com.axelor.apps.account.db.PayVoucherElementToPay)1 PaymentVoucherRepository (com.axelor.apps.account.db.repo.PaymentVoucherRepository)1 PaymentModeService (com.axelor.apps.account.service.payment.PaymentModeService)1 PaymentVoucherConfirmService (com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherConfirmService)1