on 01-13-2020 1:10 PM
Hi josehrmatos , Hi isaacceo
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));
paymentItemEntity.setBusinessTransactioncurrency("EUR");
paymentItemEntity.setCreditCardTypeCode(PaymentItemEntity.PaymentType.FREE_VOUCHER);
paymentItemEntity.setPaymentFormCode(PaymentItemEntity.PaymentFormCode.VOUCHER);
paymentItemEntity.setStatus(PaymentItemEntity.Status.CONFIRMED);
VoucherEntity voucher = new VoucherEntity();
voucher.setCashDeskId("MY cashdesk id");
voucher.setCurrency("EUR");
voucher.setFreeVoucher(true);
voucher.setOriginalAmount(new BigDecimal(50));
voucher.setValidTo(new Date(2020, 10, 20));
paymentItemEntity.setVoucher(voucher);
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.
hth
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert,
I need your help. I have added 'Loyalty Point' in Credit Card Type. Now, I want to include this type from the backend. Please find the attached code. It's not showing that payment type in the payment area. Can you please help me out?
CDBSession cdbSession = CDBSessionFactory.instance.createSession();
StockLocationPosService stockLocationPosService = ServiceFactory.INSTANCE
.getOrCreateServiceInstance(StockLocationPosService.class, cdbSession);
ReceiptPosService receiptPosService = ServiceFactory.INSTANCE
.getOrCreateServiceInstance(ReceiptPosService.class, cdbSession);
ReceiptEntity receipt = receiptPosService.findOrCreate(UserRegistry.INSTANCE.getCurrentUser(), null,true);
if (receipt == null) {
throw new RuntimeException("Failed to retrieve or create a receipt.");
}
ReceiptManager rm = new ReceiptManager(cdbSession);
PaymentItemEntity paymentItemEntity = new PaymentItemEntity();
paymentItemEntity.setBusinessTransactionAmount(paymentTender.getLoyaltyAmount());
paymentItemEntity.setOriginalBusinessTransactionAmount(paymentTender.getLoyaltyAmount());
paymentItemEntity.setOriginalBusinessTransactioncurrency("LYD");
paymentItemEntity.setBusinessTransactioncurrency("LYD");
paymentItemEntity.setCreditCardTypeCode("16");
paymentItemEntity.setCreditCardErpTypeCode("101");
paymentItemEntity.setPaymentFormCode(PaymentItemEntity.PaymentFormCode.CARD_PAYMENT);
paymentItemEntity.setStatus(PaymentItemEntity.Status.CONFIRMED);
paymentItemEntity.setCreditCardTypeName("Loyalty Point");
paymentItemEntity.setExchangeRateUsed(new BigDecimal(1));
paymentItemEntity.setMarkChanged(false);
rm.addPaymentItems(receipt, paymentItemEntity);
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.