ledger: Put account classification on each row in a hidden column.
This makes it easier to build formulas based on classification. Hiding it keeps the presentation neat for human readers.
This commit is contained in:
parent
27acf1f0c1
commit
5081c8934c
1 changed files with 6 additions and 0 deletions
|
@ -109,6 +109,7 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
|
|||
('Assets', ['rt-id', 'receipt', 'approval', 'bank-statement']),
|
||||
('Liabilities', ['rt-id', 'receipt', 'approval', 'bank-statement']),
|
||||
])
|
||||
CLASSIFICATION_COLUMN = "Account Classification"
|
||||
# Excel 2003 was limited to 65,536 rows per worksheet.
|
||||
# While we can probably count on all our users supporting more modern
|
||||
# formats (Excel 2007 supports over 1 million rows per worksheet),
|
||||
|
@ -189,6 +190,7 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
|
|||
'Booked Amount': self.amount_column,
|
||||
data.Metadata.human_name('project'): self.amount_column,
|
||||
data.Metadata.human_name('rt-id'): self.amount_column,
|
||||
self.CLASSIFICATION_COLUMN: self.column_style(3),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
@ -295,11 +297,13 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
|
|||
self.sheet_columns: Sequence[str] = [
|
||||
*self.CORE_COLUMNS,
|
||||
*(data.Metadata.human_name(meta_key) for meta_key in self.metadata_columns),
|
||||
self.CLASSIFICATION_COLUMN,
|
||||
]
|
||||
for col_name in self.sheet_columns:
|
||||
self.sheet.addElement(odf.table.TableColumn(
|
||||
stylename=self.column_styles.get(col_name, self.default_column),
|
||||
))
|
||||
self.sheet.lastChild.setAttribute('visibility', 'collapse')
|
||||
self.add_row(*(
|
||||
self.string_cell(col_name, stylename=self.style_bold)
|
||||
for col_name in self.sheet_columns
|
||||
|
@ -408,6 +412,7 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
|
|||
return len(self.account_groups[account])
|
||||
|
||||
def write_entries(self, account: data.Account, rows: Iterable[data.Posting]) -> None:
|
||||
classification = account.meta.get('classification', '')
|
||||
for row in rows:
|
||||
if row.cost is None:
|
||||
amount_cell = odf.table.TableCell()
|
||||
|
@ -423,6 +428,7 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
|
|||
if key in data.LINK_METADATA
|
||||
else self.string_cell(row.meta.get(key, ''))
|
||||
for key in self.metadata_columns),
|
||||
self.string_cell(classification),
|
||||
)
|
||||
|
||||
def write(self, rows: Iterable[data.Posting]) -> None:
|
||||
|
|
Loading…
Reference in a new issue