feat: account modify transaction
This commit is contained in:
parent
903aae2c63
commit
8893189866
1 changed files with 10 additions and 0 deletions
|
@ -94,6 +94,8 @@ class AccountTab(TabPage):
|
||||||
data = self.pg.fetchall()
|
data = self.pg.fetchall()
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
oldBalance = float(data[0][1])
|
||||||
|
|
||||||
# 绘制界面并填充数据
|
# 绘制界面并填充数据
|
||||||
accountNameLabel = QLabel("Account Name:")
|
accountNameLabel = QLabel("Account Name:")
|
||||||
accountNameLine = QLineEdit()
|
accountNameLine = QLineEdit()
|
||||||
|
@ -150,6 +152,14 @@ class AccountTab(TabPage):
|
||||||
|
|
||||||
self.pg.execute("UPDATE account SET meta=%s WHERE a_id=%s", (data, a_id))
|
self.pg.execute("UPDATE account SET meta=%s WHERE a_id=%s", (data, a_id))
|
||||||
|
|
||||||
|
if oldBalance != balance:
|
||||||
|
# 修改账户时,在transaction表中添加一条记录
|
||||||
|
data = {"type":"modify", "description": "Account Modify"}
|
||||||
|
data = json.dumps(data)
|
||||||
|
self.pg.execute(
|
||||||
|
"INSERT INTO transaction (a_id, time, amount, meta) VALUES (%s, now(), %s,%s)", (a_id, balance - oldBalance, data,))
|
||||||
|
|
||||||
|
|
||||||
# 刷新表格
|
# 刷新表格
|
||||||
self.selected()
|
self.selected()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue