Skip to Content

Add a free voucher using JAVA

Hello all:

I would like to know how I can add a free voucher manually using code.

Trying to find the solution I found this object that has similar properties to when I add the free voucher through UI.

But it does not work.

anyone knows how to do this?

Thanks in advance.


freevoucher.png (8.5 kB)
freevoucher2.png (7.0 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Mar 12 at 07:22 AM

    Hi José Reyes , Hi Isaac Valdez

    sorry for the late reply.

    You need to add a new PaymentItemEntity to your ReceiptEntity. The type of the paymentitem needs to be 20 and the paymenitem also needs to have a voucherentity attached. I did not tested it myself so it could be possible that I am missing some fields in one of these entities which needs to be set, but this would be a good start.

    try (CDBSession cdbSession = CDBSessionFactory.instance.createSession()) {
                ReceiptPosService receiptManager = ServiceFactory.INSTANCE.getOrCreateServiceInstance(ReceiptPosService.class, cdbSession);
    PaymentItemEntity paymentItemEntity = new PaymentItemEntity();
    paymentItemEntity.setBusinessTransactionAmount(new BigDecimal(50));
    paymentItemEntity.setOriginalBusinessTransactionAmount(new BigDecimal(50));
    VoucherEntity voucher = new VoucherEntity();
    voucher.setCashDeskId("MY cashdesk id");
    voucher.setOriginalAmount(new BigDecimal(50));
    voucher.setValidTo(new Date(2020, 10, 20));
    receiptManager .addPaymentItems(receipt, paymentItemEntity);

    The receipt Pos service also validates your paymentItem and voucher. So if there is anything missing, it should throw an exception which hints you into the right direction.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.