Compare commits
1 Commits
42751393ad
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 79bbb720b0 |
@@ -1,5 +1,5 @@
|
||||
from typing import NamedTuple, Optional
|
||||
from dataclasses import dataclass, replace
|
||||
from dataclasses import dataclass, field, replace
|
||||
import datetime as dt
|
||||
|
||||
from .transaction import ABCPosting, Transaction, TXNPosting, TXNFlag
|
||||
@@ -62,6 +62,8 @@ class PartialTXN:
|
||||
narration: str = ""
|
||||
comment: Optional[str] = None
|
||||
document: Optional[str] = None
|
||||
original: Optional[str] = None
|
||||
metadata: dict[str, str] = field(default_factory=dict)
|
||||
tags: str = ""
|
||||
links: str = ""
|
||||
source_posting: PartialPosting
|
||||
@@ -143,6 +145,10 @@ class PartialTXN:
|
||||
elif self.partial:
|
||||
raise ValueError("Cannot upgrade partial transaction.")
|
||||
else:
|
||||
if self.original is not None:
|
||||
metadata = self.metadata | {"original": self.original}
|
||||
else:
|
||||
metadata = self.metadata.copy()
|
||||
upgraded = Transaction(
|
||||
date=self.date,
|
||||
flag=TXNFlag(self.flag),
|
||||
@@ -150,6 +156,7 @@ class PartialTXN:
|
||||
narration=self.narration,
|
||||
comments=[self.comment] if self.comment else [],
|
||||
document=[self.document] if self.document else [],
|
||||
metadata=metadata,
|
||||
tags=self.tags.split(),
|
||||
links=self.links.split(),
|
||||
postings=[p.upgrade() for p in self.postings.values()],
|
||||
|
||||
@@ -141,6 +141,7 @@ class Transaction:
|
||||
self.documents: list[str] = kwargs.get("documents", [])
|
||||
self.tags: list[str] = kwargs.get("tags", [])
|
||||
self.links: list[str] = kwargs.get("links", [])
|
||||
self.metadata: dict[str, str] = kwargs.get("metadata", {})
|
||||
|
||||
self.postings: list[TXNPosting] = kwargs.get("postings", [])
|
||||
|
||||
@@ -164,6 +165,9 @@ class Transaction:
|
||||
).strip()
|
||||
|
||||
lines = []
|
||||
for key, value in self.metadata.items():
|
||||
lines.append(f'{key}: "{value}"')
|
||||
|
||||
for comment in self.comments:
|
||||
lines.append("; " + comment)
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class CBAConverter(Converter[CBARecord, PartialTXN, CBAConfig]):
|
||||
account=fields.get("target_account", None),
|
||||
amount=record.to_target,
|
||||
)
|
||||
args.setdefault("comment", record.description)
|
||||
args.setdefault("original", record.description)
|
||||
|
||||
txn = PartialTXN(**args)
|
||||
logger.debug(f"Converted CBA CSV Record {record!r} to PartialTXN {txn!r}")
|
||||
|
||||
@@ -141,7 +141,7 @@ class CBASTConverter(Converter[CBASTRecord, PartialTXN, CBASTConfig]):
|
||||
account=fields.get("target_account", None),
|
||||
amount=record.to_target,
|
||||
)
|
||||
args.setdefault("comment", record.description)
|
||||
args.setdefault("original", record.description)
|
||||
|
||||
txn = PartialTXN(**args)
|
||||
logger.debug(f"Converted CBA Statement Record {record!r} to PartialTXN {txn!r}")
|
||||
|
||||
@@ -238,7 +238,7 @@ class PaypalConverter(Converter[PaypalRecord, PaypalPartialTXN, PaypalConfig]):
|
||||
|
||||
# comment
|
||||
args.setdefault(
|
||||
"comment",
|
||||
"original",
|
||||
f"{record.txntype} | {record.name} | {record.txnid} | Transferred {record.transferred_in}",
|
||||
)
|
||||
|
||||
|
||||
@@ -401,6 +401,8 @@ class WiseConverter(Converter[WiseRecord, WisePartialTXN, WiseConfig]):
|
||||
amount=record.target_fee,
|
||||
)
|
||||
|
||||
# TODO: Add original field
|
||||
|
||||
txn = WisePartialTXN(**args)
|
||||
|
||||
logger.debug(f"Converted Wise Record {record!r} to Partial Transaction {txn!r}")
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
2025-06-29 ! "Amazon" "Something from Amazon AU"
|
||||
; AMAZON AU MARKETPLACE SYDNEY
|
||||
original: "AMAZON AU MARKETPLACE SYDNEY"
|
||||
Liabilities:CBA:CreditCard -70.4 AUD
|
||||
Expenses:Shopping:Amazon 70.4 AUD
|
||||
|
||||
2025-06-24 * "APIA" "House Insurance"
|
||||
; APIA BRISBANE QLD
|
||||
original: "APIA BRISBANE QLD"
|
||||
Liabilities:CBA:CreditCard -322.39 AUD
|
||||
Expenses:House:Insurance 322.39 AUD
|
||||
|
||||
2025-06-24 * "CBA" "Bank Fees"
|
||||
; MONTHLY FEE
|
||||
original: "MONTHLY FEE"
|
||||
Liabilities:CBA:CreditCard -8.0 AUD
|
||||
Expenses:Fees 8.0 AUD
|
||||
|
||||
2025-06-24 * "CBA" "Bank Fees"
|
||||
; MONTHLY FEE
|
||||
original: "MONTHLY FEE"
|
||||
Liabilities:CBA:CreditCard -8.0 AUD
|
||||
Expenses:Fees 8.0 AUD
|
||||
|
||||
2025-06-17 * "Ergon Energy" "Electricity Bill"
|
||||
; BPAYN ERGON ENERGY RETAILBPAY
|
||||
original: "BPAYN ERGON ENERGY RETAILBPAY"
|
||||
Liabilities:CBA:CreditCard -515.43 AUD
|
||||
Expenses:House:Electricity 515.43 AUD
|
||||
|
||||
2025-06-15 ! "CBA" "International Transaction Fee"
|
||||
; INTNL TRANSACTION FEE
|
||||
original: "INTNL TRANSACTION FEE"
|
||||
Liabilities:CBA:CreditCard -1.19 AUD
|
||||
Expenses:CBA:Fees 1.19 AUD
|
||||
|
||||
2025-06-14 ! "CBA" "International Transaction Fee"
|
||||
; INTNL TRANSACTION FEE
|
||||
original: "INTNL TRANSACTION FEE"
|
||||
Liabilities:CBA:CreditCard -8.64 AUD
|
||||
Expenses:CBA:Fees 8.64 AUD
|
||||
|
||||
2025-06-11 ! "CBA" "International Transaction Fee"
|
||||
; INTNL TRANSACTION FEE
|
||||
original: "INTNL TRANSACTION FEE"
|
||||
Liabilities:CBA:CreditCard -0.86 AUD
|
||||
Expenses:CBA:Fees 0.86 AUD
|
||||
|
||||
2025-06-04 ! "" "Credit Card Payment"
|
||||
; PAYMENT RECEIVED, THANK YOU
|
||||
original: "PAYMENT RECEIVED, THANK YOU"
|
||||
Assets:OtherBankAccount -2897.86 AUD
|
||||
Liabilities:CBA:CreditCard 2897.86 AUD
|
||||
|
||||
|
||||
@@ -1,80 +1,80 @@
|
||||
2018-04-01 * "Account Fees" ""
|
||||
; Account Fee
|
||||
original: "Account Fee"
|
||||
Liabilities:CBA:Streamline -6.0 AUD
|
||||
Expenses:Fees 6.0 AUD
|
||||
|
||||
2018-04-04 * "Tenants" ""
|
||||
; Direct Credit 015895
|
||||
original: "Direct Credit 015895"
|
||||
Income:Tenants -399.01 AUD
|
||||
Liabilities:CBA:Streamline 399.01 AUD
|
||||
|
||||
2018-04-13 * "Ergon Energy" ""
|
||||
; Direct Debit 066228 ERGON
|
||||
original: "Direct Debit 066228 ERGON"
|
||||
Liabilities:CBA:Streamline -882.81 AUD
|
||||
Expenses:Electricity 882.81 AUD
|
||||
|
||||
2018-04-17 * "CommInsure" ""
|
||||
; Direct Debit 062246 CommInsure
|
||||
original: "Direct Debit 062246 CommInsure"
|
||||
Liabilities:CBA:Streamline -53.82 AUD
|
||||
Expenses:Insurance 53.82 AUD
|
||||
|
||||
2018-04-18 * "Tenants" ""
|
||||
; Direct Credit 015895 FAO FAMILIES
|
||||
original: "Direct Credit 015895 FAO FAMILIES"
|
||||
Income:Tenants -399.01 AUD
|
||||
Liabilities:CBA:Streamline 399.01 AUD
|
||||
|
||||
2018-04-26 * "Transfer" ""
|
||||
; Transfer to xx3555 NetBank
|
||||
original: "Transfer to xx3555 NetBank"
|
||||
Liabilities:CBA:Streamline -800.0 AUD
|
||||
Assets:3555 800.0 AUD
|
||||
|
||||
2018-05-01 * "Account Fees" ""
|
||||
; Account Fee
|
||||
original: "Account Fee"
|
||||
Liabilities:CBA:Streamline -6.0 AUD
|
||||
Expenses:Fees 6.0 AUD
|
||||
|
||||
2018-05-01 * "Colonial First State" ""
|
||||
; Direct Credit 011802 Col First State
|
||||
original: "Direct Credit 011802 Col First State"
|
||||
Income:Trading -53.62 AUD
|
||||
Liabilities:CBA:Streamline 53.62 AUD
|
||||
|
||||
2018-05-02 * "Tenants" ""
|
||||
; Direct Credit 015895 FAO FAMILIES
|
||||
original: "Direct Credit 015895 FAO FAMILIES"
|
||||
Income:Tenants -399.01 AUD
|
||||
Liabilities:CBA:Streamline 399.01 AUD
|
||||
|
||||
2018-05-03 * "Transfer" ""
|
||||
; Transfer to xx3555 NetBank
|
||||
original: "Transfer to xx3555 NetBank"
|
||||
Liabilities:CBA:Streamline -400.0 AUD
|
||||
Assets:3555 400.0 AUD
|
||||
|
||||
2018-05-16 * "Tenants" ""
|
||||
; Direct Credit 015895 FAO FAMILIES
|
||||
original: "Direct Credit 015895 FAO FAMILIES"
|
||||
Income:Tenants -399.01 AUD
|
||||
Liabilities:CBA:Streamline 399.01 AUD
|
||||
|
||||
2018-05-17 * "CommInsure" ""
|
||||
; Direct Debit 062246 CommInsure
|
||||
original: "Direct Debit 062246 CommInsure"
|
||||
Liabilities:CBA:Streamline -53.82 AUD
|
||||
Expenses:Insurance 53.82 AUD
|
||||
|
||||
2018-05-21 * "Transfer" ""
|
||||
; Transfer to xx3555 NetBank
|
||||
original: "Transfer to xx3555 NetBank"
|
||||
Liabilities:CBA:Streamline -300.0 AUD
|
||||
Assets:3555 300.0 AUD
|
||||
|
||||
2018-05-30 * "Tenants" ""
|
||||
; Direct Credit 015895 FAO FAMILIES
|
||||
original: "Direct Credit 015895 FAO FAMILIES"
|
||||
Income:Tenants -399.01 AUD
|
||||
Liabilities:CBA:Streamline 399.01 AUD
|
||||
|
||||
2018-06-01 * "Account Fees" ""
|
||||
; Account Fee
|
||||
original: "Account Fee"
|
||||
Liabilities:CBA:Streamline -6.0 AUD
|
||||
Expenses:Fees 6.0 AUD
|
||||
|
||||
2018-06-13 * "Tenants" ""
|
||||
; Direct Credit 015895 FAO FAMILIES
|
||||
original: "Direct Credit 015895 FAO FAMILIES"
|
||||
Income:Tenants -399.01 AUD
|
||||
Liabilities:CBA:Streamline 399.01 AUD
|
||||
|
||||
|
||||
Reference in New Issue
Block a user