Tidy display

Show all amounts in reporting currency so can hide commodity symbol
Use narrow non-breaking spaces rather than commas
Right align all amounts
Consistently separate "Dr/Cr" into own column
This commit is contained in:
RunasSudo 2022-12-25 17:05:39 +11:00
parent 2d3b5093c9
commit 7b8f060308
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
5 changed files with 35 additions and 29 deletions

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from markupsafe import Markup
from . import AMOUNT_DPS
class Transaction:
@ -75,10 +77,12 @@ class Amount:
return Amount(-self.quantity, self.commodity)
def format(self):
if len(self.commodity) == 1:
return '{0}{1:,.{dps}f}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS)
if self.commodity == '$':
return Markup('{:,.{dps}f}'.format(self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', '&#x202F;'))
elif len(self.commodity) == 1:
return Markup('{0}{1:,.{dps}f}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', '&#x202F;'))
else:
return '{1:,.{dps}f} {0}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS)
return Markup('{1:,.{dps}f} {0}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', '&#x202F;'))
def quantity_string(self):
if self.commodity == '$':

View File

@ -29,16 +29,16 @@
<thead>
<tr>
<th>Date</th>
<th colspan="2">Description</th>
<th>Dr</th>
<th>Cr</th>
<th colspan="3">Description</th>
<th class="text-end">Dr</th>
<th class="text-end">Cr</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr>
<td>{{ transaction.dt.strftime('%Y-%m-%d') }}</td>
<td colspan="2">{{ transaction.description }} <a href="/general-journal/edit?id={{ transaction.id }}"><i class="bi bi-pencil text-muted"></i></a></td>
<td colspan="3">{{ transaction.description }} <a href="/general-journal/edit?id={{ transaction.id }}"><i class="bi bi-pencil text-muted"></i></a></td>
<td></td>
<td></td>
</tr>
@ -46,9 +46,10 @@
<tr>
<td></td>
<td>{{ posting.description or '' }}</td>
<td><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i> {{ posting.account }}</td>
<td>{{ posting.amount().format() if posting.quantity >= 0 else '' }}</td>
<td>{{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }}</td>
<td class="text-end"><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i></td>
<td>{{ posting.account }}</td>
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
</tr>
{% endfor %}
{% endfor %}

View File

@ -25,16 +25,16 @@
<thead>
<tr>
<th>Date</th>
<th colspan="2">Description</th>
<th>Dr</th>
<th>Cr</th>
<th colspan="3">Description</th>
<th class="text-end">Dr</th>
<th class="text-end">Cr</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr>
<td>{{ transaction.dt.strftime('%Y-%m-%d') }}</td>
<td colspan="2">{{ transaction.description }}</td>
<td colspan="3">{{ transaction.description }}</td>
<td></td>
<td></td>
</tr>
@ -42,9 +42,10 @@
<tr>
<td></td>
<td>{{ posting.description or '' }}</td>
<td><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i> {{ posting.account }}</td>
<td>{{ posting.amount().format() if posting.quantity >= 0 else '' }}</td>
<td>{{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }}</td>
<td class="text-end"><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i></td>
<td>{{ posting.account }}</td>
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
</tr>
{% endfor %}
{% endfor %}

View File

@ -34,9 +34,9 @@
<th>Date</th>
<th>Description</th>
<th>Charged to</th>
<th>Dr</th>
<th>Cr</th>
<th>Balance</th>
<th class="text-end">Dr</th>
<th class="text-end">Cr</th>
<th class="text-end">Balance</th>
</tr>
</thead>
<tbody>
@ -56,9 +56,9 @@
{% endif %}
<a href="/statement-lines/edit-transaction?line-id={{ line.id }}" class="text-muted"><i class="bi bi-pencil"></i></a>
</td>
<td>{{ line.amount().format() if line.quantity >= 0 else '' }}</td>
<td>{{ (line.amount()|abs).format() if line.quantity < 0 else '' }}</td>
<td>{{ line.balance or '' }}</td>
<td class="text-end">{{ line.amount().format() if line.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (line.amount()|abs).format() if line.quantity < 0 else '' }}</td>
<td class="text-end">{{ line.balance or '' }}</td>
</tr>
{% endfor %}
</tbody>

View File

@ -42,8 +42,8 @@
<td>{{ transaction.dt.strftime('%Y-%m-%d') }}</td>
<td>{{ transaction.description }}</td>
<td>{% for p in transaction.postings if p.account != account %}{{ p.account }}{% endfor %}</td>
<td class="text-end">{{ posting.amount().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }}</td>
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
<td class="text-end">{{ (running_total|abs).format() }}</td>
<td>{{ 'Dr' if running_total.quantity >= 0 else 'Cr' }}</td>
</tr>
@ -63,8 +63,8 @@
<td></td>
<td class="text-end"><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i></td>
<td>{{ account }}</td>
<td class="text-end">{{ posting.amount().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }}</td>
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
<td class="text-end">{{ (running_total|abs).format() }}</td>
<td>{{ 'Dr' if running_total.quantity >= 0 else 'Cr' }}</td>
</tr>
@ -74,8 +74,8 @@
<td></td>
<td class="text-end"><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i></td>
<td>{{ posting.account }}</td>
<td class="text-end">{{ posting.amount().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }}</td>
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
<td></td>
<td></td>
</tr>