From 79c3bcdbc1b8d6682f357599e5788ee57ae8ec92 Mon Sep 17 00:00:00 2001 From: Abdul-AMA Date: Sun, 19 Oct 2025 14:34:24 +0300 Subject: [PATCH 1/4] refactor: pass all options to super --- wallete/public/js/custom_point_of_sale.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wallete/public/js/custom_point_of_sale.js b/wallete/public/js/custom_point_of_sale.js index 4e01316..251020f 100644 --- a/wallete/public/js/custom_point_of_sale.js +++ b/wallete/public/js/custom_point_of_sale.js @@ -1,10 +1,11 @@ frappe.provide('erpnext.PointOfSale'); frappe.require('point-of-sale.bundle.js', function () { - erpnext.PointOfSale.Payment = class CustomPayment extends erpnext.PointOfSale.Payment { - constructor({ events, wrapper }) { - super({ events, wrapper }); - this.bind_event_show_customer_wallet() + const BasePayment = erpnext.PointOfSale.Payment; + erpnext.PointOfSale.Payment = class CustomPayment extends BasePayment { + constructor(options) { + super(options); + } set_customer_wallet() { From b6463fd02b611ba8ef038f4d602ac356ae3d577d Mon Sep 17 00:00:00 2001 From: Abdul-AMA Date: Sun, 19 Oct 2025 14:35:04 +0300 Subject: [PATCH 2/4] fix: improve customer wallet handling and payment mode checks --- wallete/public/js/custom_point_of_sale.js | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/wallete/public/js/custom_point_of_sale.js b/wallete/public/js/custom_point_of_sale.js index 251020f..9fbd472 100644 --- a/wallete/public/js/custom_point_of_sale.js +++ b/wallete/public/js/custom_point_of_sale.js @@ -12,6 +12,10 @@ frappe.require('point-of-sale.bundle.js', function () { // THIS IS OUR FUNCTION const pos_invoice = this.events.get_frm().doc; const customer = pos_invoice.customer; + if (!customer) { + this.customer_wallet = 0; + return Promise.resolve(); + } return new Promise((resolve) => { frappe.call({ method: "wallete.wallete.doctype.wallet.wallet.get_customer_wallet_balance", @@ -29,28 +33,34 @@ frappe.require('point-of-sale.bundle.js', function () { set_payment_modes_is_wallet() { // THIS IS OUR FUNCTION const pos_invoice = this.events.get_frm().doc; - const payments = pos_invoice.payments; + const payments = (pos_invoice.payments || []); payments.forEach(payment => { + if (!payment || !payment.mode_of_payment) return; frappe.db.get_value('Mode of Payment', payment.mode_of_payment, ["is_wallet_payment"], function (value) { - payment.is_wallet_payment = value.is_wallet_payment; + payment.is_wallet_payment = value && (value.is_wallet_payment || 0); }); - }) + }); } render_payment_mode_dom() { super.render_payment_mode_dom(); // THIS IS OUR CODE - this.set_customer_wallet(); + this.bind_event_show_customer_wallet(); this.set_payment_modes_is_wallet(); const pos_invoice = this.events.get_frm().doc; const customer = pos_invoice.customer; const currency = pos_invoice.currency; - const payments = pos_invoice.payments; - const customer_wallet = this.customer_wallet > 0 ? format_currency(this.customer_wallet, currency) : ''; + const payments = (pos_invoice.payments || []); + this.set_customer_wallet() + .then(() => { + const customer_wallet = this.customer_wallet > 0 ? format_currency(this.customer_wallet, currency) : ''; - payments.forEach(payment => { - this.attach_customer_wallet(payment, customer, customer_wallet); - }); + payments.forEach(payment => { + this.attach_customer_wallet(payment, customer, customer_wallet); + }); + }) + .catch(() => { + }); } bind_event_show_customer_wallet() { @@ -67,7 +77,7 @@ frappe.require('point-of-sale.bundle.js', function () { attach_customer_wallet(payment, customer, customer_wallet) { // THIS IS OUR FUNCTION if ( - this.customer_wallet !== undefined && this.customer_wallet > 0.0 && payment.is_wallet_payment === 1 + this.customer_wallet !== undefined && this.customer_wallet > 0.0 && !!payment.is_wallet_payment ) { this.$payment_modes.find('.customer-wallet').remove(); this.$payment_modes.find(`[data-payment-type="${payment.type}"]`).find('.mode-of-payment-control') @@ -77,6 +87,6 @@ frappe.require('point-of-sale.bundle.js', function () { } }; - wrapper.pos = new erpnext.PointOfSale.Controller(wrapper); - window.cur_pos = wrapper.pos; + + }); \ No newline at end of file From 3152735b73db7848bd04dcebef495a3ac307649a Mon Sep 17 00:00:00 2001 From: Abdul-AMA Date: Sun, 19 Oct 2025 16:32:48 +0300 Subject: [PATCH 3/4] chore: update version to 0.1.1 --- wallete/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallete/__init__.py b/wallete/__init__.py index 3dc1f76..485f44a 100644 --- a/wallete/__init__.py +++ b/wallete/__init__.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" From 6b07148649dbe3036a3f0ef64bb1a7d2b2efa7dd Mon Sep 17 00:00:00 2001 From: Abdulrahman Ammouna Date: Tue, 21 Oct 2025 16:14:36 +0300 Subject: [PATCH 4/4] Upgrade pre-commit action to version 3.0.0 --- .github/workflows/linters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ebb88c9..9994e7b 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -17,7 +17,7 @@ jobs: python-version: 3.8 - name: Install and Run Pre-commit - uses: pre-commit/action@v2.0.3 + uses: pre-commit/action@v3.0.0 - name: Download Semgrep rules run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules