on ‎2020 Jun 12 2:12 AM
Good night,
how can I modify the price value from my java code in the plugin.
Thank you.Request clarification before answering.
Hello xsalgadog ,
when using the quickservice ui, it should work with something like this:
try (CDBSession cdbSession = CDBSessionFactory.instance.createSession()) {
ReceiptPosService receiptPosService = ServiceFactory.INSTANCE.getOrCreateServiceInstance(ReceiptPosService.class, cdbSession);
ReceiptEntity receipt = receiptPosService.findOrCreate(UserRegistry.INSTANCE.getCurrentUser(), null, true);
CalculationPosService calculationPosService = ServiceFactory.INSTANCE.getOrCreateServiceInstance(CalculationPosService.class, cdbSession);
receipt.getSalesItems()
.stream()
.filter(salesItem -> StringUtils.equals(salesItem.getKey(), item.getReference()))
.forEach(salesItem -> {
salesItem.setUnitGrossAmount(BigDecimal.ONE);
salesItem.setUnitPriceChanged(true);
salesItem.setMarkChanged(true);
});
calculationPosService.recalculateReceipt(receipt);
receiptPosService.updateReceipt(receipt, true);
BroadcasterHolder.INSTANCE.getBroadcaster().broadcastPluginEventForPath("RECEIPT_REFRESH", null);
} catch (InconsistentReceiptStateException e) {
log.severe(e.getLocalizedMessage());
log.fine(ExceptionUtils.getFullStackTrace(e));
}hth
Robert
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.