mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
brmbar-cli userlog
This commit is contained in:
parent
0e306912d7
commit
a9e72d736c
2 changed files with 11 additions and 3 deletions
|
@ -107,8 +107,7 @@ CREATE VIEW transaction_nicesplits AS
|
||||||
FROM transaction_splits AS ts LEFT JOIN accounts AS a ON a.id = ts.account
|
FROM transaction_splits AS ts LEFT JOIN accounts AS a ON a.id = ts.account
|
||||||
ORDER BY ts.id;
|
ORDER BY ts.id;
|
||||||
|
|
||||||
-- List transactions with summary information regarding their cash element
|
-- List transactions with summary information regarding their cash element.
|
||||||
-- (except in case of transfers between cash and debt accounts, which will cancel out).
|
|
||||||
CREATE VIEW transaction_cashsums AS
|
CREATE VIEW transaction_cashsums AS
|
||||||
SELECT t.id AS id, t.time AS time, SUM(credit_cash) AS cash_credit, SUM(debit_cash) AS cash_debit, t.description AS description
|
SELECT t.id AS id, t.time AS time, SUM(credit_cash) AS cash_credit, SUM(debit_cash) AS cash_debit, t.description AS description
|
||||||
FROM transactions AS t
|
FROM transactions AS t
|
||||||
|
@ -124,4 +123,4 @@ CREATE VIEW transaction_cashsums AS
|
||||||
WHERE a.currency = (SELECT currency FROM accounts WHERE name = 'BrmBar Cash')
|
WHERE a.currency = (SELECT currency FROM accounts WHERE name = 'BrmBar Cash')
|
||||||
AND a.acctype IN ('cash', 'debt')
|
AND a.acctype IN ('cash', 'debt')
|
||||||
AND dts.amount > 0) debit ON dts_t = t.id
|
AND dts.amount > 0) debit ON dts_t = t.id
|
||||||
GROUP BY t.id ORDER BY t.id;
|
GROUP BY t.id ORDER BY t.id DESC;
|
||||||
|
|
|
@ -19,6 +19,7 @@ Usage: brmbar-cli.py COMMAND ARGS...
|
||||||
You can use negative AMT to undo a sale.
|
You can use negative AMT to undo a sale.
|
||||||
restock ITEM AMT
|
restock ITEM AMT
|
||||||
userinfo USER
|
userinfo USER
|
||||||
|
userlog USER TIMESTAMP
|
||||||
iteminfo ITEM
|
iteminfo ITEM
|
||||||
|
|
||||||
2. Management commands
|
2. Management commands
|
||||||
|
@ -142,6 +143,14 @@ elif sys.argv[1] == "userinfo":
|
||||||
res = db.execute_and_fetchall("SELECT barcode FROM barcodes WHERE account = %s", [acct.id])
|
res = db.execute_and_fetchall("SELECT barcode FROM barcodes WHERE account = %s", [acct.id])
|
||||||
print("Barcodes: " + ", ".join(map((lambda r: r[0]), res)))
|
print("Barcodes: " + ", ".join(map((lambda r: r[0]), res)))
|
||||||
|
|
||||||
|
elif sys.argv[1] == "userlog":
|
||||||
|
acct = load_user(sys.argv[2])
|
||||||
|
timestamp = sys.argv[3]
|
||||||
|
|
||||||
|
res = db.execute_and_fetchall("SELECT transactions.time,transactions.description FROM transactions INNER JOIN accounts ON accounts.id=transactions.responsible WHERE accounts.name=%s and time > TIMESTAMP %s ORDER BY time", [acct.name,timestamp])
|
||||||
|
for transaction in res:
|
||||||
|
print("{}\t{}\t".format(transaction[0],transaction[1]))
|
||||||
|
|
||||||
elif sys.argv[1] == "iteminfo":
|
elif sys.argv[1] == "iteminfo":
|
||||||
acct = load_item(sys.argv[2])
|
acct = load_item(sys.argv[2])
|
||||||
print("{} (id {}): {} pcs".format(acct.name, acct.id, acct.balance()))
|
print("{} (id {}): {} pcs".format(acct.name, acct.id, acct.balance()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue