mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 13:24:01 +02:00
SQL schema v002 script part 1
This commit is contained in:
parent
2f601a0b1a
commit
3000731ac7
3 changed files with 91 additions and 10 deletions
|
@ -219,14 +219,15 @@ class Shop:
|
|||
self.db.commit()
|
||||
|
||||
def undo(self, oldtid):
|
||||
description = self.db.execute_and_fetch("SELECT description FROM transactions WHERE id = %s", [oldtid])[0]
|
||||
description = 'undo %d (%s)' % (oldtid, description)
|
||||
#description = self.db.execute_and_fetch("SELECT description FROM transactions WHERE id = %s", [oldtid])[0]
|
||||
#description = 'undo %d (%s)' % (oldtid, description)
|
||||
|
||||
transaction = self._transaction(description=description)
|
||||
for split in self.db.execute_and_fetchall("SELECT id, side, account, amount, memo FROM transaction_splits WHERE transaction = %s", [oldtid]):
|
||||
splitid, side, account, amount, memo = split
|
||||
memo = 'undo %d (%s)' % (splitid, memo)
|
||||
amount = -amount
|
||||
self.db.execute("INSERT INTO transaction_splits (transaction, side, account, amount, memo) VALUES (%s, %s, %s, %s, %s)", [transaction, side, account, amount, memo])
|
||||
#transaction = self._transaction(description=description)
|
||||
#for split in self.db.execute_and_fetchall("SELECT id, side, account, amount, memo FROM transaction_splits WHERE transaction = %s", [oldtid]):
|
||||
# splitid, side, account, amount, memo = split
|
||||
# memo = 'undo %d (%s)' % (splitid, memo)
|
||||
# amount = -amount
|
||||
# self.db.execute("INSERT INTO transaction_splits (transaction, side, account, amount, memo) VALUES (%s, %s, %s, %s, %s)", [transaction, side, account, amount, memo])
|
||||
transaction = self.db.execute_and_fetch("CALL undo_transaction(%s)",[oldtid])[0]
|
||||
self.db.commit()
|
||||
return transaction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue