cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How refresh SalesItem screen in when modifying item description

Former Member
0 Likes
591

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()); }); 

Accepted Solutions (1)

Accepted Solutions (1)

R_Zieschang
Active Contributor

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

Former Member
0 Likes

Thanks for the helps, that's works for me. but I use as method.

@PluginAt(pluginClass = ReceiptPosService.class, method = "addSalesItem", where = PluginAt.POSITION.AFTER)

Answers (1)

Answers (1)

JoergAldinger
Active Contributor
0 Likes

Which event are you using to modify the description, isaacceo ?

Former Member
0 Likes

addSalesItem