mirror of
https://github.com/goldenfishs/MRobot.git
synced 2026-02-04 18:00:19 +08:00
准备加分类
This commit is contained in:
parent
b6a5d9e818
commit
dd801f5d6a
@ -38,6 +38,9 @@ class CreateTransactionDialog(QDialog):
|
|||||||
|
|
||||||
if transaction:
|
if transaction:
|
||||||
self.load_transaction_data(transaction)
|
self.load_transaction_data(transaction)
|
||||||
|
else:
|
||||||
|
# 新建时默认为"入账"
|
||||||
|
self.transaction_type_combo.setCurrentIndex(0)
|
||||||
|
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
"""初始化UI"""
|
"""初始化UI"""
|
||||||
@ -45,6 +48,17 @@ class CreateTransactionDialog(QDialog):
|
|||||||
layout.setContentsMargins(20, 20, 20, 20)
|
layout.setContentsMargins(20, 20, 20, 20)
|
||||||
layout.setSpacing(15)
|
layout.setSpacing(15)
|
||||||
|
|
||||||
|
# 交易类型
|
||||||
|
type_layout = QHBoxLayout()
|
||||||
|
type_layout.addWidget(BodyLabel("交易类型:"))
|
||||||
|
self.transaction_type_combo = ComboBox()
|
||||||
|
self.transaction_type_combo.addItem("入账 (正数)")
|
||||||
|
self.transaction_type_combo.addItem("支出 (负数)")
|
||||||
|
self.transaction_type_combo.setMaximumWidth(200)
|
||||||
|
type_layout.addWidget(self.transaction_type_combo)
|
||||||
|
type_layout.addStretch()
|
||||||
|
layout.addLayout(type_layout)
|
||||||
|
|
||||||
# 日期
|
# 日期
|
||||||
date_layout = QHBoxLayout()
|
date_layout = QHBoxLayout()
|
||||||
date_layout.addWidget(BodyLabel("日期:"))
|
date_layout.addWidget(BodyLabel("日期:"))
|
||||||
@ -156,8 +170,15 @@ class CreateTransactionDialog(QDialog):
|
|||||||
|
|
||||||
def load_transaction_data(self, transaction: Transaction):
|
def load_transaction_data(self, transaction: Transaction):
|
||||||
"""加载交易记录数据到表单"""
|
"""加载交易记录数据到表单"""
|
||||||
|
# 根据金额的正负设置交易类型
|
||||||
|
if transaction.amount >= 0:
|
||||||
|
self.transaction_type_combo.setCurrentIndex(0) # 入账
|
||||||
|
else:
|
||||||
|
self.transaction_type_combo.setCurrentIndex(1) # 支出
|
||||||
|
|
||||||
self.date_edit.setDate(QDate.fromString(transaction.date, "yyyy-MM-dd"))
|
self.date_edit.setDate(QDate.fromString(transaction.date, "yyyy-MM-dd"))
|
||||||
self.amount_spin.setValue(transaction.amount)
|
# 显示绝对值
|
||||||
|
self.amount_spin.setValue(abs(transaction.amount))
|
||||||
self.trader_edit.setText(transaction.trader)
|
self.trader_edit.setText(transaction.trader)
|
||||||
self.notes_edit.setText(transaction.notes)
|
self.notes_edit.setText(transaction.notes)
|
||||||
|
|
||||||
@ -208,18 +229,22 @@ class CreateTransactionDialog(QDialog):
|
|||||||
dialog.exec()
|
dialog.exec()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 根据交易类型设置金额符号:入账为正数,支出为负数
|
||||||
|
is_income = self.transaction_type_combo.currentIndex() == 0
|
||||||
|
final_amount = amount if is_income else -amount
|
||||||
|
|
||||||
if self.transaction:
|
if self.transaction:
|
||||||
# 编辑现有交易记录
|
# 编辑现有交易记录
|
||||||
trans_id = self.transaction.id
|
trans_id = self.transaction.id
|
||||||
self.finance_manager.update_transaction(
|
self.finance_manager.update_transaction(
|
||||||
self.account_id, trans_id,
|
self.account_id, trans_id,
|
||||||
date=date_str, amount=amount,
|
date=date_str, amount=final_amount,
|
||||||
trader=trader, notes=notes
|
trader=trader, notes=notes
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# 创建新交易记录
|
# 创建新交易记录
|
||||||
transaction = Transaction(
|
transaction = Transaction(
|
||||||
date=date_str, amount=amount,
|
date=date_str, amount=final_amount,
|
||||||
trader=trader, notes=notes
|
trader=trader, notes=notes
|
||||||
)
|
)
|
||||||
self.finance_manager.add_transaction(self.account_id, transaction)
|
self.finance_manager.add_transaction(self.account_id, transaction)
|
||||||
@ -527,44 +552,45 @@ class FinanceInterface(QWidget):
|
|||||||
date_layout.addWidget(BodyLabel("日期范围:"))
|
date_layout.addWidget(BodyLabel("日期范围:"))
|
||||||
self.query_date_start = DateEdit()
|
self.query_date_start = DateEdit()
|
||||||
self.query_date_start.setDate(QDate.currentDate().addMonths(-1))
|
self.query_date_start.setDate(QDate.currentDate().addMonths(-1))
|
||||||
self.query_date_start.setMaximumWidth(150)
|
date_layout.addWidget(self.query_date_start, 1)
|
||||||
date_layout.addWidget(self.query_date_start)
|
|
||||||
date_layout.addWidget(BodyLabel("至"))
|
date_layout.addWidget(BodyLabel("至"))
|
||||||
self.query_date_end = DateEdit()
|
self.query_date_end = DateEdit()
|
||||||
self.query_date_end.setDate(QDate.currentDate())
|
self.query_date_end.setDate(QDate.currentDate())
|
||||||
self.query_date_end.setMaximumWidth(150)
|
date_layout.addWidget(self.query_date_end, 1)
|
||||||
date_layout.addWidget(self.query_date_end)
|
filter_layout.addLayout(date_layout)
|
||||||
date_layout.addSpacing(20)
|
|
||||||
|
|
||||||
# 金额范围
|
# 第二行:交易类型和金额范围
|
||||||
date_layout.addWidget(BodyLabel("金额范围:"))
|
type_amount_layout = QHBoxLayout()
|
||||||
|
type_amount_layout.addWidget(BodyLabel("交易类型:"))
|
||||||
|
self.query_transaction_type = ComboBox()
|
||||||
|
self.query_transaction_type.addItem("全部")
|
||||||
|
self.query_transaction_type.addItem("收入 (正数)")
|
||||||
|
self.query_transaction_type.addItem("支出 (负数)")
|
||||||
|
type_amount_layout.addWidget(self.query_transaction_type, 1)
|
||||||
|
|
||||||
|
type_amount_layout.addWidget(BodyLabel("金额范围:"))
|
||||||
self.query_amount_min = DoubleSpinBox()
|
self.query_amount_min = DoubleSpinBox()
|
||||||
self.query_amount_min.setRange(0, 999999999)
|
self.query_amount_min.setRange(0, 999999999)
|
||||||
self.query_amount_min.setPrefix("¥ ")
|
self.query_amount_min.setPrefix("¥ ")
|
||||||
self.query_amount_min.setMaximumWidth(120)
|
type_amount_layout.addWidget(self.query_amount_min, 1)
|
||||||
date_layout.addWidget(self.query_amount_min)
|
type_amount_layout.addWidget(BodyLabel("至"))
|
||||||
date_layout.addWidget(BodyLabel("至"))
|
|
||||||
self.query_amount_max = DoubleSpinBox()
|
self.query_amount_max = DoubleSpinBox()
|
||||||
self.query_amount_max.setRange(0, 999999999)
|
self.query_amount_max.setRange(0, 999999999)
|
||||||
self.query_amount_max.setValue(999999999)
|
self.query_amount_max.setValue(999999999)
|
||||||
self.query_amount_max.setPrefix("¥ ")
|
self.query_amount_max.setPrefix("¥ ")
|
||||||
self.query_amount_max.setMaximumWidth(120)
|
type_amount_layout.addWidget(self.query_amount_max, 1)
|
||||||
date_layout.addWidget(self.query_amount_max)
|
filter_layout.addLayout(type_amount_layout)
|
||||||
date_layout.addStretch()
|
|
||||||
filter_layout.addLayout(date_layout)
|
|
||||||
|
|
||||||
# 第二行:交易人搜索和查询按钮
|
# 第三行:交易人搜索和查询按钮
|
||||||
trader_layout = QHBoxLayout()
|
trader_layout = QHBoxLayout()
|
||||||
trader_layout.addWidget(BodyLabel("交易人:"))
|
trader_layout.addWidget(BodyLabel("交易人:"))
|
||||||
self.query_trader_edit = SearchLineEdit()
|
self.query_trader_edit = SearchLineEdit()
|
||||||
self.query_trader_edit.setPlaceholderText("输入交易人名称...")
|
self.query_trader_edit.setPlaceholderText("输入交易人名称...")
|
||||||
self.query_trader_edit.setMaximumWidth(250)
|
trader_layout.addWidget(self.query_trader_edit, 1)
|
||||||
trader_layout.addWidget(self.query_trader_edit)
|
|
||||||
|
|
||||||
query_btn = PrimaryPushButton("查询")
|
query_btn = PrimaryPushButton("查询")
|
||||||
query_btn.clicked.connect(self.perform_query)
|
query_btn.clicked.connect(self.perform_query)
|
||||||
trader_layout.addWidget(query_btn)
|
trader_layout.addWidget(query_btn)
|
||||||
trader_layout.addStretch()
|
|
||||||
filter_layout.addLayout(trader_layout)
|
filter_layout.addLayout(trader_layout)
|
||||||
|
|
||||||
layout.addWidget(filter_card)
|
layout.addWidget(filter_card)
|
||||||
@ -877,6 +903,14 @@ class FinanceInterface(QWidget):
|
|||||||
trader=trader
|
trader=trader
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 根据交易类型过滤
|
||||||
|
transaction_type_index = self.query_transaction_type.currentIndex()
|
||||||
|
if transaction_type_index == 1: # 收入(正数)
|
||||||
|
results = [t for t in results if t.amount >= 0]
|
||||||
|
elif transaction_type_index == 2: # 支出(负数)
|
||||||
|
results = [t for t in results if t.amount < 0]
|
||||||
|
# 如果是 0(全部),不进行过滤
|
||||||
|
|
||||||
self.query_result_table.clear()
|
self.query_result_table.clear()
|
||||||
|
|
||||||
for transaction in results:
|
for transaction in results:
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"id": "073897b0-dd62-477b-9522-aa74bd79f3e7",
|
||||||
|
"date": "2025-11-25",
|
||||||
|
"amount": 20.0,
|
||||||
|
"trader": "吕祖成、",
|
||||||
|
"notes": "asd",
|
||||||
|
"invoice_path": "accounts/578ac4f1-9e00-4ee4-97c5-749ef846efc9/073897b0-dd62-477b-9522-aa74bd79f3e7/invoice/截屏2025-11-25 02.51.22.png",
|
||||||
|
"payment_path": "accounts/578ac4f1-9e00-4ee4-97c5-749ef846efc9/073897b0-dd62-477b-9522-aa74bd79f3e7/payment/截屏2025-11-18 19.18.52.png",
|
||||||
|
"purchase_path": "accounts/578ac4f1-9e00-4ee4-97c5-749ef846efc9/073897b0-dd62-477b-9522-aa74bd79f3e7/purchase/截屏2025-11-21 16.36.54.png",
|
||||||
|
"created_at": "2025-11-25T19:27:03.518689",
|
||||||
|
"updated_at": "2025-11-25T19:27:03.522646"
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 MiB |
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"id": "0ff26867-63d0-4dc5-84cc-a8e21a750736",
|
||||||
|
"date": "2025-11-25",
|
||||||
|
"amount": 2.0,
|
||||||
|
"trader": "21",
|
||||||
|
"notes": "11",
|
||||||
|
"category": "lll",
|
||||||
|
"invoice_path": null,
|
||||||
|
"payment_path": null,
|
||||||
|
"purchase_path": null,
|
||||||
|
"created_at": "2025-11-25T19:32:25.775406",
|
||||||
|
"updated_at": "2025-11-25T19:32:25.775421"
|
||||||
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "15e8df81-a66c-448b-9d55-76095b90a67a",
|
|
||||||
"date": "2025-11-25",
|
|
||||||
"amount": 3.0,
|
|
||||||
"trader": "1212",
|
|
||||||
"notes": "",
|
|
||||||
"invoice_path": null,
|
|
||||||
"payment_path": null,
|
|
||||||
"purchase_path": null,
|
|
||||||
"created_at": "2025-11-25T19:06:52.171539",
|
|
||||||
"updated_at": "2025-11-25T19:06:52.171544"
|
|
||||||
}
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"id": "168805da-aba0-4293-9808-ad4d5cd01258",
|
||||||
|
"date": "2025-11-25",
|
||||||
|
"amount": -4.0,
|
||||||
|
"trader": "lzc",
|
||||||
|
"notes": "",
|
||||||
|
"invoice_path": null,
|
||||||
|
"payment_path": null,
|
||||||
|
"purchase_path": null,
|
||||||
|
"created_at": "2025-11-25T19:14:56.268684",
|
||||||
|
"updated_at": "2025-11-25T19:14:56.268692"
|
||||||
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "467981d6-f32d-410d-a98a-3d407b506d0e",
|
|
||||||
"date": "2025-11-25",
|
|
||||||
"amount": 5.0,
|
|
||||||
"trader": "kk",
|
|
||||||
"notes": "",
|
|
||||||
"invoice_path": null,
|
|
||||||
"payment_path": null,
|
|
||||||
"purchase_path": null,
|
|
||||||
"created_at": "2025-11-25T19:05:35.519984",
|
|
||||||
"updated_at": "2025-11-25T19:05:35.519990"
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "5964be23-0875-4d11-9487-d374f686eb35",
|
|
||||||
"date": "2025-11-25",
|
|
||||||
"amount": 1.0,
|
|
||||||
"trader": "121",
|
|
||||||
"notes": "",
|
|
||||||
"invoice_path": null,
|
|
||||||
"payment_path": null,
|
|
||||||
"purchase_path": null,
|
|
||||||
"created_at": "2025-11-25T19:06:45.550932",
|
|
||||||
"updated_at": "2025-11-25T19:06:45.550937"
|
|
||||||
}
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"id": "5e38a21d-0565-488f-9613-2f4f935ed55e",
|
||||||
|
"date": "2025-11-25",
|
||||||
|
"amount": 1222.0,
|
||||||
|
"trader": "asd",
|
||||||
|
"notes": "asd",
|
||||||
|
"category": "oo",
|
||||||
|
"invoice_path": null,
|
||||||
|
"payment_path": null,
|
||||||
|
"purchase_path": null,
|
||||||
|
"created_at": "2025-11-25T19:36:13.333758",
|
||||||
|
"updated_at": "2025-11-25T19:36:13.333774"
|
||||||
|
}
|
||||||
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"id": "a9d005c4-447d-4989-b056-735b1560a212",
|
"id": "a9d005c4-447d-4989-b056-735b1560a212",
|
||||||
"date": "2025-11-25",
|
"date": "2025-11-25",
|
||||||
"amount": 1.0,
|
"amount": 20000.0,
|
||||||
"trader": "lzc",
|
"trader": "lzc",
|
||||||
"notes": "",
|
"notes": "比赛奖金",
|
||||||
"invoice_path": null,
|
"invoice_path": null,
|
||||||
"payment_path": null,
|
"payment_path": null,
|
||||||
"purchase_path": null,
|
"purchase_path": null,
|
||||||
"created_at": "2025-11-25T18:59:56.514706",
|
"created_at": "2025-11-25T18:59:56.514706",
|
||||||
"updated_at": "2025-11-25T18:59:56.514714"
|
"updated_at": "2025-11-25T19:15:40.563492"
|
||||||
}
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "c4a78a37-1f6f-4cec-bf32-a6fd8017e182",
|
|
||||||
"date": "2025-11-25",
|
|
||||||
"amount": 2.0,
|
|
||||||
"trader": "1221",
|
|
||||||
"notes": "",
|
|
||||||
"invoice_path": null,
|
|
||||||
"payment_path": null,
|
|
||||||
"purchase_path": null,
|
|
||||||
"created_at": "2025-11-25T19:06:58.617525",
|
|
||||||
"updated_at": "2025-11-25T19:06:58.617531"
|
|
||||||
}
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"id": "e900acf7-6e15-49e6-8c47-4fc85fba42ff",
|
||||||
|
"date": "2025-11-25",
|
||||||
|
"amount": 20.0,
|
||||||
|
"trader": "11",
|
||||||
|
"notes": "lzc",
|
||||||
|
"category": "新建",
|
||||||
|
"invoice_path": null,
|
||||||
|
"payment_path": null,
|
||||||
|
"purchase_path": null,
|
||||||
|
"created_at": "2025-11-25T19:40:46.913479",
|
||||||
|
"updated_at": "2025-11-25T19:40:46.913486"
|
||||||
|
}
|
||||||
@ -2,6 +2,9 @@
|
|||||||
"id": "578ac4f1-9e00-4ee4-97c5-749ef846efc9",
|
"id": "578ac4f1-9e00-4ee4-97c5-749ef846efc9",
|
||||||
"name": "测试账户",
|
"name": "测试账户",
|
||||||
"description": "用于调试的测试账户",
|
"description": "用于调试的测试账户",
|
||||||
|
"categories": [
|
||||||
|
"新建"
|
||||||
|
],
|
||||||
"created_at": "2025-11-25T18:55:25.821559",
|
"created_at": "2025-11-25T18:55:25.821559",
|
||||||
"updated_at": "2025-11-25T18:55:25.821560"
|
"updated_at": "2025-11-25T19:40:40.234965"
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user