diff --git a/migrations.py b/migrations.py index 0df71bb..5c4be83 100644 --- a/migrations.py +++ b/migrations.py @@ -290,3 +290,12 @@ async def m022_add_onchain_settings_and_payments(db: Database): updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); """) + + +async def m023_add_allow_price_adjustment(db: Database): + """ + Add item price adjustment toggle to tpos table. + """ + await db.execute(""" + ALTER TABLE tpos.pos ADD allow_price_adjustment BOOLEAN DEFAULT true; + """) diff --git a/models.py b/models.py index 2996e4a..fdef6ab 100644 --- a/models.py +++ b/models.py @@ -69,6 +69,7 @@ class CreateTposData(BaseModel): business_address: str | None business_vat_id: str | None only_show_sats_on_bitcoin: bool = Query(True) + allow_price_adjustment: bool = Field(True) fiat_provider: str | None = Field(None) stripe_card_payments: bool = False stripe_reader_id: str | None = None @@ -108,6 +109,7 @@ class TposClean(BaseModel): business_address: str | None = None business_vat_id: str | None = None only_show_sats_on_bitcoin: bool = True + allow_price_adjustment: bool = True fiat_provider: str | None = None stripe_card_payments: bool = False stripe_reader_id: str | None = None diff --git a/static/js/index.js b/static/js/index.js index 09f7a80..3cfb790 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -46,6 +46,7 @@ const mapTpos = obj => { ? omitTagString.split(',').filter(Boolean) : [] obj.only_show_sats_on_bitcoin = obj.only_show_sats_on_bitcoin ?? true + obj.allow_price_adjustment = obj.allow_price_adjustment ?? true obj.allow_cash_settlement = Boolean(obj.allow_cash_settlement) obj.onchain_enabled = Boolean(obj.onchain_enabled) obj.onchain_wallet_id = obj.onchain_wallet_id || null @@ -148,6 +149,7 @@ window.app = Vue.createApp({ enable_receipt_print: false, enable_remote: false, only_show_sats_on_bitcoin: true, + allow_price_adjustment: true, fiat: false, stripe_card_payments: false, stripe_reader_id: '', @@ -303,6 +305,7 @@ window.app = Vue.createApp({ enable_receipt_print: false, enable_remote: false, only_show_sats_on_bitcoin: true, + allow_price_adjustment: true, fiat: false, stripe_card_payments: false, stripe_reader_id: '', diff --git a/static/js/tpos.js b/static/js/tpos.js index eeb3d3c..9aca1ff 100644 --- a/static/js/tpos.js +++ b/static/js/tpos.js @@ -43,6 +43,7 @@ window.app = Vue.createApp({ tposId: null, currency: null, fiatProvider: null, + allowPriceAdjustment: true, allowCashSettlement: false, onchainEnabled: false, payInFiat: false, @@ -539,6 +540,7 @@ window.app = Vue.createApp({ this.cartTaxTotal() }, promptItemPrice(item) { + if (!this.allowPriceAdjustment) return const cartItem = this.cart.get(item.id) if (!cartItem) return this.$q @@ -588,6 +590,7 @@ window.app = Vue.createApp({ }) }, updateCartItemPrice(cartItem, newPrice) { + if (!this.allowPriceAdjustment) return const roundedPrice = this.currency === 'sats' ? Math.ceil(newPrice) @@ -1657,6 +1660,7 @@ window.app = Vue.createApp({ this.wrapperMode = new URL(window.location.href).searchParams.get('wrapper') === 'true' this.fiatProvider = tpos.fiat_provider + this.allowPriceAdjustment = tpos.allow_price_adjustment ?? true this.allowCashSettlement = Boolean(tpos.allow_cash_settlement) this.onchainEnabled = Boolean(tpos.onchain_enabled) diff --git a/templates/tpos/_cart.html b/templates/tpos/_cart.html index 0ce86b2..32ab0b7 100644 --- a/templates/tpos/_cart.html +++ b/templates/tpos/_cart.html @@ -76,8 +76,8 @@
diff --git a/templates/tpos/index.html b/templates/tpos/index.html index faec8c1..df3d85b 100644 --- a/templates/tpos/index.html +++ b/templates/tpos/index.html @@ -569,6 +569,14 @@
{{SITE_TITLE}} TPoS extension
> +
+
+ +
+