forked from brmlab/brmbar-github
fixes from runtime
This commit is contained in:
parent
f922edf042
commit
96bf23662e
2 changed files with 3 additions and 3 deletions
|
@ -45,7 +45,7 @@ class Account:
|
||||||
return cls(db, name = name, id = id, currency = currency, acctype = acctype)
|
return cls(db, name = name, id = id, currency = currency, acctype = acctype)
|
||||||
|
|
||||||
def balance(self):
|
def balance(self):
|
||||||
crbalance = self.db.execute_and_fetch("SELECT crbalance FROM accounts WHERE account = %s", [self.id])
|
crbalance = self.db.execute_and_fetch("SELECT crbalance FROM accounts WHERE id = %s", [self.id])
|
||||||
crbalance = crbalance[0] or 0
|
crbalance = crbalance[0] or 0
|
||||||
return crbalance
|
return crbalance
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class Account:
|
||||||
""" Common part of credit() and debit(). """
|
""" Common part of credit() and debit(). """
|
||||||
self.db.execute("INSERT INTO transaction_splits (transaction, side, account, amount, memo) VALUES (%s, %s, %s, %s, %s)", [transaction, side, self.id, amount, memo])
|
self.db.execute("INSERT INTO transaction_splits (transaction, side, account, amount, memo) VALUES (%s, %s, %s, %s, %s)", [transaction, side, self.id, amount, memo])
|
||||||
|
|
||||||
self.db.execute("UPDATE accounts set crbalance = crbalance - (CASE WHEN %s = 'credit' THEN -amount ELSE amount END)", [side])
|
self.db.execute("UPDATE accounts set crbalance = crbalance + (CASE WHEN %s = 'credit' THEN -amount ELSE amount END)", [side])
|
||||||
|
|
||||||
def add_barcode(self, barcode):
|
def add_barcode(self, barcode):
|
||||||
self.db.execute("INSERT INTO barcodes (account, barcode) VALUES (%s, %s)", [self.id, barcode])
|
self.db.execute("INSERT INTO barcodes (account, barcode) VALUES (%s, %s)", [self.id, barcode])
|
||||||
|
|
|
@ -106,7 +106,7 @@ class Shop:
|
||||||
# We assume all debt accounts share a currency
|
# We assume all debt accounts share a currency
|
||||||
sumselect = """
|
sumselect = """
|
||||||
SELECT SUM(crbalance)
|
SELECT SUM(crbalance)
|
||||||
FROM accounts WHERE acctype = %s AND
|
FROM accounts WHERE acctype = %s
|
||||||
"""
|
"""
|
||||||
cur = self.db.execute_and_fetch(sumselect, ["debt"])
|
cur = self.db.execute_and_fetch(sumselect, ["debt"])
|
||||||
cur = cur[0] or 0
|
cur = cur[0] or 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue