Skip to content

Commit

Permalink
[FIX] spp_pos_id_redemption: refund functionality on POS
Browse files Browse the repository at this point in the history
  • Loading branch information
emjay0921 committed Jan 16, 2025
1 parent de23e49 commit 55014fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion spp_pos_id_redemption/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def redeem_voucher(self, longitude=None, latitude=None):
rec.entitlement_id.longitude = longitude
rec.entitlement_id.latitude = latitude

def unredeem_voucher(self):
def undo_redeem_voucher(self, longitude=None, latitude=None):
for rec in self:
if rec.entitlement_id:
rec.entitlement_id.voucher_redeemed = False
rec.entitlement_id.longitude = longitude
rec.entitlement_id.latitude = latitude
17 changes: 15 additions & 2 deletions spp_pos_id_redemption/static/src/js/payment_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,21 @@ patch(PaymentScreen.prototype, {
for (const orderline of this.pos.get_order().orderlines) {
if (orderline.product.created_from_entitlement) {
const productId = orderline.product.id;
await this.orm.call("product.template", "redeem_voucher", [productId, latitude, longitude]);
orderline.product.voucher_redeemed = true;
if (orderline.quantity >= 1) {
await this.orm.call("product.template", "redeem_voucher", [
productId,
latitude,
longitude,
]);
orderline.product.voucher_redeemed = true;
} else {
await this.orm.call("product.template", "undo_redeem_voucher", [
productId,
latitude,
longitude,
]);
orderline.product.voucher_redeemed = false;
}
}
}
},
Expand Down

0 comments on commit 55014fd

Please sign in to comment.