From 6ed53b92aafa53d7a0ecd2244112dc6da6823a4c Mon Sep 17 00:00:00 2001 From: Stevko Date: Sun, 11 May 2014 02:38:53 +0200 Subject: [PATCH] Added Barcode for cash payment. Barcode is '_cash_'. --- brmbar3/SQL | 3 +++ brmbar3/brmbar-gui-qt4.py | 6 ++++++ brmbar3/brmbar-gui-qt4/ItemInfo.qml | 12 +++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/brmbar3/SQL b/brmbar3/SQL index 82c22e4..8623ed5 100644 --- a/brmbar3/SQL +++ b/brmbar3/SQL @@ -52,6 +52,9 @@ CREATE TABLE barcodes ( account INTEGER NOT NULL, FOREIGN KEY (account) REFERENCES accounts (id) ); +-- Barcode for cash +-- XXX Silently assume there is only one. +INSERT INTO barcodes (barcode, account) VALUES ('_cash_', (SELECT id FROM accounts WHERE acctype = 'cash')); CREATE SEQUENCE transactions_id_seq START WITH 1 INCREMENT BY 1; diff --git a/brmbar3/brmbar-gui-qt4.py b/brmbar3/brmbar-gui-qt4.py index 67773be..23e6d37 100755 --- a/brmbar3/brmbar-gui-qt4.py +++ b/brmbar3/brmbar-gui-qt4.py @@ -29,6 +29,10 @@ class ShopAdapter(QtCore.QObject): map["price"] = str(sell) return map + def acct_cash_map(self, acct): + map = acct.__dict__.copy() + return map + def acct_map(self, acct): if acct is None: return None @@ -36,6 +40,8 @@ class ShopAdapter(QtCore.QObject): return self.acct_debt_map(acct) elif acct.acctype == "inventory": return self.acct_inventory_map(acct) + elif acct.acctype == "cash": + return self.acct_cash_map(acct) else: return None diff --git a/brmbar3/brmbar-gui-qt4/ItemInfo.qml b/brmbar3/brmbar-gui-qt4/ItemInfo.qml index b15596f..a39e322 100644 --- a/brmbar3/brmbar-gui-qt4/ItemInfo.qml +++ b/brmbar3/brmbar-gui-qt4/ItemInfo.qml @@ -50,12 +50,18 @@ Item { status_text.setStatus("Unknown barcode", "#ff4444") return } - if (acct.acctype !== "debt") { + if (acct.acctype !== "debt" && acct.acctype !== "cash") { loadPageByAcct(acct) return } - var balance = shop.sellItem(dbid, acct.id) - status_text.setStatus("Sold! "+acct.name+"'s credit is "+balance+".", "#ffff7c") + + if (acct.acctype == "cash") { //Copied from BarButton.onButtonClick + shop.sellItemCash(dbid) + status_text.setStatus("Sold! Put " + price + " Kč in the money box.", "#ffff7c") + } else { + var balance = shop.sellItem(dbid, acct.id) + status_text.setStatus("Sold! "+acct.name+"'s credit is "+balance+".", "#ffff7c") + } loadPage("MainPage") } }