on ‎2020 Sep 07 6:17 PM
when I update a receipt field, the description of an item does not refresh the screen until I return, add another article someone knows how i can solve?
receipt.getSalesItems().stream().forEach(item -> {
if(!item.getDescription().contains(item.getQuantityTypeCodeName()) && !item.getQuantityTypeCode().equals("-1"))
item.setDescription(item.getDescription() + " - " + item.getQuantityTypeCodeName()); });
Request clarification before answering.
Dear isaacceo,
assuming you are using the quick service ui, you also need to "inform" the UI that there was a change in the salesitem.
So use the receipt Post service to update the receipt and push the updates to the UI. The receipt pos service can be get via the proxy object when you hook into methods from it.
e.g.
@PluginAt(pluginClass = ReceiptPosService.class, method = "updateSalesItem", where = PluginAt.POSITION.AFTER)
public Object onSalesItemUpdated(Object proxy, Object[] args, Object ret, StackTraceElement caller) {
ReceiptPosService posService = (ReceiptPosService) proxy;Sometimes you also need to recalculate the receipt...
CalculationPosService calculationPosService = ServiceFactory.INSTANCE.getOrCreateServiceInstance(CalculationPosService.class, posService.getDbSession());
calculationPosService.recalculateReceipt(receipt);
salesItem.setMarkChanged(true);
receiptPosService.updateReceipt(receipt, true);BroadcasterHolder.INSTANCE.getBroadcaster().broadcastPluginEventForPath("RECEIPT_REFRESH", null);<br>}
Please mark this answer as correct if this was the correct solution to help others.
hth
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which event are you using to modify the description, isaacceo ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 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.