From 75a045de14aa992dcc410c18230ea83da697afb7 Mon Sep 17 00:00:00 2001 From: Arc Date: Sat, 10 Jan 2026 22:46:44 +0000 Subject: [PATCH 1/8] if fiat payment remove sats stuff from reciept --- migrations.py | 11 +++++++++++ models.py | 2 ++ services.py | 1 - static/components/receipt.js | 17 +++++++++++++++-- static/js/index.js | 3 +++ tasks.py | 3 +-- templates/tpos/index.html | 4 ++++ views_api.py | 9 +++++---- 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/migrations.py b/migrations.py index c4ea3fb..1ff6a7b 100644 --- a/migrations.py +++ b/migrations.py @@ -267,3 +267,14 @@ async def m018_add_stripe_reader_id(db: Database): ALTER TABLE tpos.pos ADD stripe_reader_id TEXT NULL; """ ) + + +async def m019_add_receipt_sats_only(db: Database): + """ + Add receipt option to only show sats on bitcoin transactions + """ + await db.execute( + """ + ALTER TABLE tpos.pos ADD only_show_sats_on_bitcoin BOOLEAN DEFAULT true; + """ + ) diff --git a/models.py b/models.py index 7d4e956..8486621 100644 --- a/models.py +++ b/models.py @@ -63,6 +63,7 @@ class CreateTposData(BaseModel): business_name: str | None business_address: str | None business_vat_id: str | None + only_show_sats_on_bitcoin: bool = Query(True) fiat_provider: str | None = Field(None) stripe_card_payments: bool = False stripe_reader_id: str | None = None @@ -96,6 +97,7 @@ class TposClean(BaseModel): business_name: str | None = None business_address: str | None = None business_vat_id: str | None = None + only_show_sats_on_bitcoin: bool = True fiat_provider: str | None = None stripe_card_payments: bool = False stripe_reader_id: str | None = None diff --git a/services.py b/services.py index eda5610..ae26b2a 100644 --- a/services.py +++ b/services.py @@ -1,7 +1,6 @@ from typing import Any import httpx - from lnbits.core.crud import get_wallet from lnbits.core.models import User from lnbits.helpers import create_access_token diff --git a/static/components/receipt.js b/static/components/receipt.js index 80dbd68..7670606 100644 --- a/static/components/receipt.js +++ b/static/components/receipt.js @@ -46,6 +46,17 @@ window.app.component('receipt', { }, currencyText() { return `(${this.currency})` + }, + isBitcoinTransaction() { + return !( + this.data.extra?.paid_in_fiat || + this.data.extra?.fiat_method || + this.data.extra?.fiat_payment_request + ) + }, + showBitcoinDetails() { + const onlyShowOnBitcoin = this.data.only_show_sats_on_bitcoin !== false + return !onlyShowOnBitcoin || this.isBitcoinTransaction } }, methods: { @@ -66,7 +77,9 @@ window.app.component('receipt', {

Receipt

-

+

+ +

@@ -119,7 +132,7 @@ window.app.component('receipt', {
-
+
Total (sats)
diff --git a/static/js/index.js b/static/js/index.js index a88a874..c97c5b0 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -21,6 +21,7 @@ const mapTpos = obj => { obj.inventory_omit_tags = omitTagString ? omitTagString.split(',').filter(Boolean) : [] + obj.only_show_sats_on_bitcoin = obj.only_show_sats_on_bitcoin ?? true obj.itemsMap = new Map() obj.items.forEach((item, idx) => { let id = `${obj.id}:${idx + 1}` @@ -106,6 +107,7 @@ window.app = Vue.createApp({ lnaddress: false, lnaddress_cut: 2, enable_receipt_print: false, + only_show_sats_on_bitcoin: true, fiat: false, stripe_card_payments: false, stripe_reader_id: '' @@ -241,6 +243,7 @@ window.app = Vue.createApp({ lnaddress: false, lnaddress_cut: 2, enable_receipt_print: false, + only_show_sats_on_bitcoin: true, fiat: false, stripe_card_payments: false, stripe_reader_id: '' diff --git a/tasks.py b/tasks.py index be80e72..be3de17 100644 --- a/tasks.py +++ b/tasks.py @@ -1,7 +1,5 @@ import asyncio -from loguru import logger - from lnbits.core.models import Payment from lnbits.core.services import ( create_invoice, @@ -10,6 +8,7 @@ websocket_updater, ) from lnbits.tasks import register_invoice_listener +from loguru import logger from .crud import get_tpos from .services import deduct_inventory_stock diff --git a/templates/tpos/index.html b/templates/tpos/index.html index 9216632..faa99c8 100644 --- a/templates/tpos/index.html +++ b/templates/tpos/index.html @@ -521,6 +521,10 @@
{{SITE_TITLE}} TPoS extension
label="VAT ID" placeholder="123456789" > +