From 14fe5aec2a3fb5c29bc4b3642bd599d0a2187097 Mon Sep 17 00:00:00 2001 From: arcbtc Date: Fri, 19 Dec 2025 02:12:30 +0000 Subject: [PATCH 1/3] Price update --- static/js/tpos.js | 59 +++++++++++++++++++++++++++++++++++++-- templates/tpos/_cart.html | 6 +++- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/static/js/tpos.js b/static/js/tpos.js index 9109f74..d33ade9 100644 --- a/static/js/tpos.js +++ b/static/js/tpos.js @@ -293,6 +293,8 @@ window.app = Vue.createApp({ } quantity = Math.min(quantity, item.quantity_in_stock - inCart) } + const existing = this.cart.get(item.id) + const priceSource = existing || item if (this.cart.has(item.id)) { this.cart.set(item.id, { ...this.cart.get(item.id), @@ -304,11 +306,12 @@ window.app = Vue.createApp({ quantity: quantity }) } - this.total = this.total + this.calculateItemPrice(item, quantity) + this.total = this.total + this.calculateItemPrice(priceSource, quantity) this.cartTaxTotal() }, removeFromCart(item, quantity = 1) { - let item_quantity = this.cart.get(item.id).quantity + const existing = this.cart.get(item.id) + let item_quantity = existing.quantity if (item_quantity == 1 || item_quantity == quantity) { this.cart.delete(item.id) } else { @@ -317,7 +320,57 @@ window.app = Vue.createApp({ quantity: this.cart.get(item.id).quantity - quantity }) } - this.total = this.total - this.calculateItemPrice(item, quantity) + const priceSource = existing || item + this.total = this.total - this.calculateItemPrice(priceSource, quantity) + this.cartTaxTotal() + }, + promptItemPrice(item) { + const cartItem = this.cart.get(item.id) + if (!cartItem) return + this.$q + .dialog({ + title: 'Set price', + message: 'Update item price for this cart line', + prompt: { + model: this.currency === 'sats' + ? String(cartItem.price) + : cartItem.price.toFixed(2), + type: 'number' + }, + cancel: true + }) + .onOk(val => { + const newPrice = parseFloat(val) + if (isNaN(newPrice) || newPrice < 0) { + Quasar.Notify.create({ + type: 'warning', + message: 'Please enter a valid price.' + }) + return + } + this.updateCartItemPrice(cartItem, newPrice) + }) + }, + updateCartItemPrice(cartItem, newPrice) { + const roundedPrice = + this.currency === 'sats' ? Math.ceil(newPrice) : +newPrice.toFixed(2) + const existing = this.cart.get(cartItem.id) + if (!existing) return + const oldItemTotal = this.calculateItemPrice( + existing, + existing.quantity + ) + const updatedItem = { + ...existing, + price: roundedPrice, + formattedPrice: this.formatAmount(roundedPrice, this.currency) + } + this.cart.set(cartItem.id, updatedItem) + const newItemTotal = this.calculateItemPrice( + updatedItem, + updatedItem.quantity + ) + this.total = +(this.total - oldItemTotal + newItemTotal).toFixed(2) this.cartTaxTotal() }, calculateItemPrice(item, qty) { diff --git a/templates/tpos/_cart.html b/templates/tpos/_cart.html index b0189eb..4e86f84 100644 --- a/templates/tpos/_cart.html +++ b/templates/tpos/_cart.html @@ -66,7 +66,11 @@
- +
From b34fcfcc3d775439ee655618e042befbc401b88b Mon Sep 17 00:00:00 2001 From: arcbtc Date: Fri, 19 Dec 2025 04:18:49 +0000 Subject: [PATCH 2/3] added stripe reader support --- migrations.py | 11 +++++++++++ models.py | 2 ++ static/js/index.js | 6 ++++-- templates/tpos/index.html | 17 +++++++++++++++++ views_api.py | 2 ++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/migrations.py b/migrations.py index d040b46..c4ea3fb 100644 --- a/migrations.py +++ b/migrations.py @@ -256,3 +256,14 @@ async def m017_add_inventory_omit_tags(db: Database): ALTER TABLE tpos.pos ADD inventory_omit_tags TEXT NULL; """ ) + + +async def m018_add_stripe_reader_id(db: Database): + """ + Add Stripe reader id column + """ + await db.execute( + """ + ALTER TABLE tpos.pos ADD stripe_reader_id TEXT NULL; + """ + ) diff --git a/models.py b/models.py index 3b3c155..7d4e956 100644 --- a/models.py +++ b/models.py @@ -65,6 +65,7 @@ class CreateTposData(BaseModel): business_vat_id: str | None fiat_provider: str | None = Field(None) stripe_card_payments: bool = False + stripe_reader_id: str | None = None @validator("tax_default", pre=True, always=True) def default_tax_when_none(cls, v): @@ -97,6 +98,7 @@ class TposClean(BaseModel): business_vat_id: str | None = None fiat_provider: str | None = None stripe_card_payments: bool = False + stripe_reader_id: str | None = None @property def withdraw_maximum(self) -> int: diff --git a/static/js/index.js b/static/js/index.js index 824e327..a88a874 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -107,7 +107,8 @@ window.app = Vue.createApp({ lnaddress_cut: 2, enable_receipt_print: false, fiat: false, - stripe_card_payments: false + stripe_card_payments: false, + stripe_reader_id: '' }, advanced: { tips: false, @@ -241,7 +242,8 @@ window.app = Vue.createApp({ lnaddress_cut: 2, enable_receipt_print: false, fiat: false, - stripe_card_payments: false + stripe_card_payments: false, + stripe_reader_id: '' } this.formDialog.advanced = {tips: false, otc: false} }, diff --git a/templates/tpos/index.html b/templates/tpos/index.html index c14a412..9216632 100644 --- a/templates/tpos/index.html +++ b/templates/tpos/index.html @@ -429,6 +429,23 @@
{{SITE_TITLE}} TPoS extension
+
+
+ +
+
Paym extra["inventory"] = inventory_payload.dict() if data.pay_in_fiat and tpos.fiat_provider: extra["fiat_method"] = data.fiat_method if data.fiat_method else "checkout" + if tpos.stripe_reader_id: + extra["terminal"] = {"reader_id": tpos.stripe_reader_id} invoice_data = CreateInvoice( unit=currency, out=False, From d437eaab5e1c65a21d014a9eb4aa81b0ef56478a Mon Sep 17 00:00:00 2001 From: arcbtc Date: Fri, 19 Dec 2025 04:42:12 +0000 Subject: [PATCH 3/3] make --- static/js/tpos.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/static/js/tpos.js b/static/js/tpos.js index a1de861..c1b34c8 100644 --- a/static/js/tpos.js +++ b/static/js/tpos.js @@ -333,9 +333,10 @@ window.app = Vue.createApp({ title: 'Set price', message: 'Update item price for this cart line', prompt: { - model: this.currency === 'sats' - ? String(cartItem.price) - : cartItem.price.toFixed(2), + model: + this.currency === 'sats' + ? String(cartItem.price) + : cartItem.price.toFixed(2), type: 'number' }, cancel: true @@ -357,10 +358,7 @@ window.app = Vue.createApp({ this.currency === 'sats' ? Math.ceil(newPrice) : +newPrice.toFixed(2) const existing = this.cart.get(cartItem.id) if (!existing) return - const oldItemTotal = this.calculateItemPrice( - existing, - existing.quantity - ) + const oldItemTotal = this.calculateItemPrice(existing, existing.quantity) const updatedItem = { ...existing, price: roundedPrice,