Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
""")
2 changes: 2 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: '',
Expand Down Expand Up @@ -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: '',
Expand Down
4 changes: 4 additions & 0 deletions static/js/tpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ window.app = Vue.createApp({
tposId: null,
currency: null,
fiatProvider: null,
allowPriceAdjustment: true,
allowCashSettlement: false,
onchainEnabled: false,
payInFiat: false,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -588,6 +590,7 @@ window.app = Vue.createApp({
})
},
updateCartItemPrice(cartItem, newPrice) {
if (!this.allowPriceAdjustment) return
const roundedPrice =
this.currency === 'sats'
? Math.ceil(newPrice)
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions templates/tpos/_cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ <h5 v-show="!denomIsSats" class="q-mt-none q-mb-sm">
<td>
<div class="text-center">
<span
class="cursor-pointer text-secondary"
@click="promptItemPrice(item)"
:class="allowPriceAdjustment ? 'cursor-pointer text-secondary' : ''"
@click="allowPriceAdjustment && promptItemPrice(item)"
v-text="item.formattedPrice"
></span>
</div>
Expand Down
8 changes: 8 additions & 0 deletions templates/tpos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} TPoS extension</h6>
></q-checkbox>
</div>
</div>
<div class="row">
<div class="col">
<q-checkbox
v-model="formDialog.data.allow_price_adjustment"
label="Allow cart item price adjustment"
></q-checkbox>
</div>
</div>
<template v-if="formDialog.data.enable_receipt_print">
<p class="text-caption">
Receipt printing is an experimental feature. Not all devices work
Expand Down
1 change: 1 addition & 0 deletions templates/tpos/tpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ <h5 class="text-italic">
? tpos.inventory_omit_tags.split(',').filter(Boolean)
: []
tpos.use_inventory = Boolean(tpos.use_inventory)
tpos.allow_price_adjustment = tpos.allow_price_adjustment ?? true
if (tpos.withdraw_maximum) {
tpos.withdraw_premium = Number(tpos.withdraw_maximum / 100)
}
Expand Down
Loading