Added note to the CSV output of ledgers.

This commit is contained in:
依瑪貓 2023-03-05 17:41:34 +08:00
parent 1d0a79e33c
commit b806b1ed1f
2 changed files with 8 additions and 3 deletions

View File

@ -95,6 +95,8 @@ class LedgerRow(ReportRow):
"""The credit amount.""" """The credit amount."""
self.balance: Decimal | None = None self.balance: Decimal | None = None
"""The balance.""" """The balance."""
self.note: str | None = None
"""The note."""
if entry is not None: if entry is not None:
self.entry = entry self.entry = entry
self.summary = entry.summary self.summary = entry.summary
@ -107,9 +109,11 @@ class LedgerRow(ReportRow):
"Summary": None, "Summary": None,
"Debit": self.debit, "Debit": self.debit,
"Credit": self.credit, "Credit": self.credit,
"Balance": self.balance} "Balance": self.balance,
"Note": None}
return {"Date": self.date, return {"Date": self.date,
"Summary": self.summary, "Summary": self.summary,
"Debit": self.debit, "Debit": self.debit,
"Credit": self.credit, "Credit": self.credit,
"Balance": self.balance} "Balance": self.balance,
"Note": self.note}

View File

@ -342,10 +342,11 @@ class Ledger(JournalEntryReport[LedgerRow]):
if row.entry is not None: if row.entry is not None:
row.transaction = transactions[row.entry.transaction_id] row.transaction = transactions[row.entry.transaction_id]
row.date = row.transaction.date row.date = row.transaction.date
row.note = row.transaction.note
@property @property
def csv_field_names(self) -> list[str]: def csv_field_names(self) -> list[str]:
return ["Date", "Summary", "Debit", "Credit", "Balance"] return ["Date", "Summary", "Debit", "Credit", "Balance", "Note"]
@property @property
def csv_filename(self) -> str: def csv_filename(self) -> str: