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