mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
Added Barcode for cash payment. Barcode is '_cash_'.
This commit is contained in:
parent
65741c31f0
commit
6ed53b92aa
3 changed files with 18 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue