on 2020 Nov 12 7:53 AM
Hi guys,
How can I cancel sales item in a plugin source code(Java)?
I tried salesItem.setStatus(“3”);. But it doesn’t work.
I found below method and don’t know how to call it.

Thank you.
Request clarification before answering.
Dear baigalmaa,
which UI Mode are you using? Setting the status manually does not suffice.
You also need to tell CCO to recalculate the receipt (because sums etc. change when you cancel an item) and also to refresh the new state of the receipt in the ui.
// get the calculation service (only available in quickservice ui)
CalculationPosService calculationPosService = ServiceFactory.INSTANCE.getOrCreateServiceInstance(CalculationPosService.class, cdbSession);
// get the ReceiptPosService
ReceiptPosService receiptPosService = ServiceFactory.INSTANCE.getOrCreateServiceInstance(ReceiptPosService.class, cdbSession);
// do stuff with your salesitem
// set is as changed!
salesItem.setMarkChanged(true);
// after all your manipulation on the receipt, recalculate and refresh it
log.info("Recalculation receipt.");
calculationPosService.recalculateReceipt(receipt);
log.info("Updating receipt.");
receiptPosService.updateReceipt(receipt, true);
BroadcasterHolder.INSTANCE.getBroadcaster().broadcastPluginEventForPath("RECEIPT_REFRESH", null);
hth
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your response.
We are using Retail-Mode. According to your advice I tried below method and I think it works.
Is that right?
sales.setStatus("3");
sales.setUnitPriceChanged(true);
sales.setMarkChanged(true);
BroadcasterHolder.INSTANCE.getBroadcaster().broadcastActionForPath("RECEIPT_REFRESH", "sales", null);<br>
Please check if the receipt posted is exactly what you want, because you did not update the receipt. Maybe the change is only visible in the ui and the receipt in the backend and the receipt shown in the ui are out of sync.
When using retail ui the equivalent to the ReceiptPosService is the ReceiptManager. Both should have a updateReceipt method iirc.
setUnitPriceChanged only needs to be set, if you changed the unit price. But this should do no harm.
Regards
Robert
| User | Count |
|---|---|
| 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.