feat: account modify transaction

This commit is contained in:
iridiumR 2023-06-03 14:46:03 +08:00
parent 903aae2c63
commit 8893189866
No known key found for this signature in database
GPG key ID: 49735733EB1A32C8

View file

@ -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()