diff --git a/ledger_pyreport/jinja2/transactions.html b/ledger_pyreport/jinja2/transactions.html index dd6052b..1eb332d 100644 --- a/ledger_pyreport/jinja2/transactions.html +++ b/ledger_pyreport/jinja2/transactions.html @@ -67,12 +67,38 @@ {% endif %} {% for transaction in transactions %} + {% set trn_url = '/transaction?' + {'tid': transaction.id, 'cash': 'on' if cash else ''}|urlencode %} + + {% if transaction.has_comment_detail %} + + {% if transaction.id %}{% endif %}{{ transaction.date.strftime('%Y-%m-%d') }}{% if transaction.id %}{% endif %} + {% if transaction.id %}{% endif %}{{ transaction.description }}{% if transaction.id %}{% endif %} + + {% if account %} + + + + {% else %} + + + {% endif %} + + {% endif %} + {% for posting in transaction.postings if posting.account != account %} {% set amount = posting.exchange(report_commodity, transaction.date) %} - {% set trn_url = '/transaction?' + {'tid': transaction.id, 'cash': 'on' if cash else ''}|urlencode %} - - {% if loop.first %}{% if transaction.id %}{% endif %}{{ transaction.date.strftime('%Y-%m-%d') }}{% if transaction.id %}{% endif %}{% endif %} - {% if loop.first %}{% if transaction.id %}{% endif %}{{ transaction.description }}{% if transaction.id %}{% endif %}{% endif %} + {% set trn_first = not transaction.has_comment_detail and loop.first %} + {% set trn_last = loop.last %} + + + {% if trn_first %}{% if transaction.id %}{% endif %}{{ transaction.date.strftime('%Y-%m-%d') }}{% if transaction.id %}{% endif %}{% endif %} + {% if trn_first %} + {% if transaction.id %}{% endif %}{{ transaction.description }}{% if transaction.id %}{% endif %} + {% elif transaction.has_comment_detail and posting.comment %} + {{ posting.comment }} + {% else %} + + {% endif %} {{ (posting.account.name|e).__str__().replace(':', ':')|safe }} {% if account %} {# Reverse Dr/Cr so it's from the "perspective" of this account #} diff --git a/ledger_pyreport/model.py b/ledger_pyreport/model.py index 1edd2d5..06183c4 100644 --- a/ledger_pyreport/model.py +++ b/ledger_pyreport/model.py @@ -82,6 +82,10 @@ class Transaction: for posting in self.postings: result.append(' {} {}'.format(posting.account.name, posting.amount.tostr(False))) return '\n'.join(result) + + @property + def has_comment_detail(self): + return any(p.comment for p in self.postings) class Posting: class State(Enum):