Search in sources :

Example 6 with PaymentVoucher

use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.

the class PaymentVoucherController method resetImputation.

// Reset imputation
public void resetImputation(ActionRequest request, ActionResponse response) {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    try {
        Beans.get(PaymentVoucherLoadService.class).resetImputation(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 7 with PaymentVoucher

use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.

the class PaymentVoucherController method fillCompanyBankDetails.

/**
 * Called on load and in partner, company or payment mode change. Fill the bank details with a
 * default value.
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    PaymentMode paymentMode = paymentVoucher.getPaymentMode();
    Company company = paymentVoucher.getCompany();
    Partner partner = paymentVoucher.getPartner();
    if (company == null) {
        return;
    }
    if (partner != null) {
        partner = Beans.get(PartnerRepository.class).find(partner.getId());
    }
    BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
    response.setValue("companyBankDetails", defaultBankDetails);
}
Also used : BankDetailsService(com.axelor.apps.base.service.BankDetailsService) Company(com.axelor.apps.base.db.Company) BankDetails(com.axelor.apps.base.db.BankDetails) Partner(com.axelor.apps.base.db.Partner) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 8 with PaymentVoucher

use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.

the class PaymentVoucherController method initFromInvoice.

public void initFromInvoice(ActionRequest request, ActionResponse response) {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    @SuppressWarnings("unchecked") Invoice invoice = Mapper.toBean(Invoice.class, (Map<String, Object>) request.getContext().get("_invoice"));
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        Beans.get(PaymentVoucherLoadService.class).initFromInvoice(paymentVoucher, invoice);
        response.setValues(paymentVoucher);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentVoucherLoadService(com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherLoadService) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Example 9 with PaymentVoucher

use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.

the class PaymentVoucherController method printPaymentVoucher.

public void printPaymentVoucher(ActionRequest request, ActionResponse response) throws AxelorException {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    String name = I18n.get("Payment voucher");
    if (!Strings.isNullOrEmpty(paymentVoucher.getReceiptNo())) {
        name += " " + paymentVoucher.getReceiptNo();
    }
    String fileLink = ReportFactory.createReport(IReport.PAYMENT_VOUCHER, name + "-${date}").addParam("PaymentVoucherId", paymentVoucher.getId()).addParam("Timezone", paymentVoucher.getCompany() != null ? paymentVoucher.getCompany().getTimezone() : null).generate().getFileLink();
    logger.debug("Printing " + name);
    response.setView(ActionView.define(name).add("html", fileLink).map());
}
Also used : PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher)

Example 10 with PaymentVoucher

use of com.axelor.apps.account.db.PaymentVoucher in project axelor-open-suite by axelor.

the class PaymentVoucherController method askPaymentVoucher.

public void askPaymentVoucher(ActionRequest request, ActionResponse response) {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    if (paymentVoucher.getHasAutoInput()) {
        PaymentMode paymentMode = paymentVoucher.getPaymentMode();
        Company company = paymentVoucher.getCompany();
        BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails();
        try {
            Journal journal = Beans.get(PaymentModeService.class).getPaymentModeJournal(paymentMode, company, companyBankDetails);
            if (journal.getExcessPaymentOk()) {
                response.setAlert(I18n.get("No items have been selected. Do you want to continue?"));
            }
        } catch (Exception e) {
            TraceBackService.trace(response, e);
        }
    }
}
Also used : Company(com.axelor.apps.base.db.Company) PaymentModeService(com.axelor.apps.account.service.payment.PaymentModeService) BankDetails(com.axelor.apps.base.db.BankDetails) Journal(com.axelor.apps.account.db.Journal) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException) PaymentMode(com.axelor.apps.account.db.PaymentMode)

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