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

SAP CCO Plugin - Cross out Article from sales screen

former_member12197
Participant
0 Likes
596

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

R_Zieschang
Active Contributor
0 Likes

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

former_member12197
Participant
0 Likes

Hi Robert,
I appreciate the answer here. We are using Retail Mode. Do you have any suggestion for me on achieving this in retail mode. I just really need to work this out.

Thank you!

Former Member
0 Likes
rzieschang,

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>
R_Zieschang
Active Contributor
0 Likes

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