diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java index 2441f157..a4c20c94 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java +++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java @@ -22,6 +22,7 @@ import com.axelor.apps.account.db.Invoice; import com.axelor.apps.account.db.InvoicePayment; import com.axelor.apps.account.db.PaymentCondition; import com.axelor.apps.account.db.PaymentMode; +import com.axelor.apps.account.db.PaymentVoucher; import com.axelor.apps.account.db.repo.InvoiceRepository; import com.axelor.apps.account.exception.IExceptionMessage; import com.axelor.apps.account.service.AccountingSituationService; @@ -987,4 +988,30 @@ public class InvoiceController { response.setView(ActionView.define(name).add("html", fileLink).map()); } + + public void printPaymentFile(ActionRequest request, ActionResponse response) + throws AxelorException { + + PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class); + + String name = I18n.get("Payment voucher"); + String AmountToPay = paymentVoucher.getPaidAmount().toString(); + String[] arrOfStr = AmountToPay.split("\\."); + + String left = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(arrOfStr[0])); + String right = Beans.get(ConvertNumberToFrenchWordsService.class).convert(Long.parseLong(arrOfStr[1])); + String number = left+" dinars algériens et "+right+" centimes"; + + String fileLink = + ReportFactory.createReport("PaymentRequest.rptdesign", name + "-${date}") + .addParam("PaymentVoucherId", paymentVoucher.getId()) + .addParam("NumberToWords", number) + .generate() + .getFileLink(); + + logger.debug("Printing " + name); + + response.setView(ActionView.define(name).add("html", fileLink).map()); + } + } diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml index 8c37fc96..b69e5500 100644 --- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml +++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/PaymentVoucher.xml @@ -59,6 +59,21 @@ + + + + + + + + + + + + + + +