payment voucher :: cheque printing PDF

This commit is contained in:
walid seghier
2022-11-06 15:07:50 +01:00
parent f60d2fe2af
commit 43913b038e

View File

@@ -72,6 +72,7 @@ import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.stream.Collectors;
import java.math.BigDecimal;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -959,34 +960,31 @@ public class InvoiceController {
public void printInvoicePayment(ActionRequest request, ActionResponse response)
throws AxelorException {
InvoicePayment invoicePayment = request.getContext().asType(InvoicePayment.class);
String name = I18n.get("Payment voucher");
String AmountToPay = invoicePayment.getAmount().toString();
String AmountToPay = request.getContext().get("amount").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 chequeModelBank = request.getContext().get("chequeModelBank").toString();
Map<String, String> Report = new HashMap<String, String>();
Report.put("CPA", "CPA.rptdesign");
Report.put("ASB", "ASB.rptdesign");
Report.put("BDL", "BDL.rptdesign");
Report.put("SGA", "SGA.rptdesign");
Report.put("BNA", "BNA.rptdesign");
BigDecimal amount = new BigDecimal(AmountToPay);
String fileLink =
ReportFactory.createReport(Report.get(chequeModelBank), name + "-${date}")
.addParam("PaymentVoucherId", invoicePayment.getId())
ReportFactory.createReport("chequeModelBank.rptdesign", name + "-${date}")
.addParam("NumberToWords", number)
.addParam("Wilaya", request.getContext().get("wilaya"))
.addParam("Wilaya", request.getContext().get("wilaya").toString())
.addParam("amount", amount)
.addParam("date", request.getContext().get("date").toString() )
.addParam("name", request.getContext().get("PartnerName"))
.addParam("chequeModelBank", chequeModelBank)
.generate()
.getFileLink();
logger.debug("Printing " + name);
response.setView(ActionView.define(name).add("html", fileLink).map());
}
}