Fix amounts in transaction.

This commit is contained in:
James Cole
2025-09-09 17:14:53 +02:00
parent a9f21c9371
commit 134770644a
2 changed files with 34 additions and 17 deletions

View File

@@ -87,11 +87,16 @@ let show = function () {
if (this.entries.hasOwnProperty(i)) { if (this.entries.hasOwnProperty(i)) {
const currencyCode = this.entries[i].currency_code; const currencyCode = this.entries[i].currency_code;
const foreignCurrencyCode = this.entries[i].foreign_currency_code; const foreignCurrencyCode = this.entries[i].foreign_currency_code;
const primaryCurrencyCode = this.entries[i].primary_currency_code;
if (undefined === this.amounts[currencyCode]) { if (undefined === this.amounts[currencyCode]) {
this.amounts[currencyCode] = 0; this.amounts[currencyCode] = 0;
this.amounts[currencyCode] += parseFloat(this.entries[i].amount); this.amounts[currencyCode] += parseFloat(this.entries[i].amount);
} }
if (undefined === this.amounts[primaryCurrencyCode]) {
this.amounts[primaryCurrencyCode] = 0;
this.amounts[primaryCurrencyCode] += parseFloat(this.entries[i].pc_amount);
}
if (null !== foreignCurrencyCode && '' !== foreignCurrencyCode && undefined === this.amounts[foreignCurrencyCode]) { if (null !== foreignCurrencyCode && '' !== foreignCurrencyCode && undefined === this.amounts[foreignCurrencyCode]) {
this.amounts[foreignCurrencyCode] = 0; this.amounts[foreignCurrencyCode] = 0;
this.amounts[foreignCurrencyCode] += parseFloat(this.entries[i].foreign_amount); this.amounts[foreignCurrencyCode] += parseFloat(this.entries[i].foreign_amount);

View File

@@ -17,23 +17,23 @@
<tbody> <tbody>
<tr> <tr>
<th style="width:10%;"> <th style="width:10%;">
<template x-if="'Withdrawal' === groupProperties.transactionType"> <template x-if="'withdrawal' === groupProperties.transactionType">
<em class="fa fa-solid fa-arrow-left" <em class="fa fa-solid fa-arrow-left"
:title="groupProperties.transactionTypeTranslated"></em> :title="groupProperties.transactionTypeTranslated"></em>
</template> </template>
<template x-if="'Deposit' === groupProperties.transactionType"> <template x-if="'deposit' === groupProperties.transactionType">
<em class="fa-solid fa-arrow-right" <em class="fa-solid fa-arrow-right"
:title="groupProperties.transactionTypeTranslated"></em> :title="groupProperties.transactionTypeTranslated"></em>
</template> </template>
<template x-if="'Transfer' === groupProperties.transactionType"> <template x-if="'transfer' === groupProperties.transactionType">
<em class="fa-solid fa-rotate" <em class="fa-solid fa-rotate"
:title="groupProperties.transactionTypeTranslated"></em> :title="groupProperties.transactionTypeTranslated"></em>
</template> </template>
<template <template
x-if="'Transfer' !== groupProperties.transactionType && 'Deposit' !== groupProperties.transactionType && 'Withdrawal' !== groupProperties.transactionType"> x-if="'transfer' !== groupProperties.transactionType && 'deposit' !== groupProperties.transactionType && 'withdrawal' !== groupProperties.transactionType">
<span>TODO missing ICON</span> <span x-text="groupProperties.transactionType"></span>
</template> </template>
</th> </th>
<td><span class="group_title" :data-group="groupProperties.id" x-text="groupProperties.title"></span></td> <td><span class="group_title" :data-group="groupProperties.id" x-text="groupProperties.title"></span></td>
@@ -53,6 +53,18 @@
<a class="btn btn-danger" :href="'./transactions/delete/' + groupProperties.id"> <a class="btn btn-danger" :href="'./transactions/delete/' + groupProperties.id">
<em class="fa-solid fa-trash"></em> {{ __('firefly.delete') }} <em class="fa-solid fa-trash"></em> {{ __('firefly.delete') }}
</a> </a>
<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
{{ __('firefly.actions') }}
</button>
<ul class="dropdown-menu">
<li x-show="'withdrawal' !== groupProperties.transactionType"><a class="dropdown-item" href="{{ route('transactions.convert.index', ['withdrawal', $transactionGroup['id']]) }}">{{ __('firefly.convert_to_withdrawal') }}</a></li>
<li x-show="'deposit' !== groupProperties.transactionType"><a class="dropdown-item" href="{{ route('transactions.convert.index', ['deposit', $transactionGroup['id']]) }}">{{ __('firefly.convert_to_deposit') }}</a></li>
<li x-show="'transfer' !== groupProperties.transactionType"><a class="dropdown-item" href="{{ route('transactions.convert.index', ['transfer', $transactionGroup['id']]) }}">{{ __('firefly.convert_to_transfer') }}</a></li>
<li><a class="dropdown-item" href="#">{{ __('firefly.clone') }}</a></li>
<li><a class="dropdown-item" href="#">{{ __('firefly.clone_and_edit') }}</a></li>
</ul>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -70,25 +82,25 @@
<em class="fa-solid fa-money-bill-wave" title="{{ __('firefly.amount') }}"></em> <em class="fa-solid fa-money-bill-wave" title="{{ __('firefly.amount') }}"></em>
</th> </th>
<td> <td>
<template x-if="'Withdrawal' === groupProperties.transactionType"> <template x-if="'withdrawal' === groupProperties.transactionType">
<template x-for="(amount, code) in amounts"> <template x-for="(amount, code) in amounts">
<span class="text-danger" x-text="formatMoney(amount*-1, code)"></span> <span class="text-danger" x-text="formatMoney(amount*-1, code)"></span>
</template> </template>
</template> </template>
<template x-if="'Deposit' === groupProperties.transactionType"> <template x-if="'deposit' === groupProperties.transactionType">
<template x-for="(amount, code) in amounts"> <template x-for="(amount, code) in amounts">
<span class="text-success" x-text="formatMoney(amount, code)"></span> <span class="text-success" x-text="formatMoney(amount, code)"></span>
</template> </template>
</template> </template>
<template x-if="'Transfer' === groupProperties.transactionType"> <template x-if="'transfer' === groupProperties.transactionType">
<template x-for="(amount, code) in amounts"> <template x-for="(amount, code) in amounts">
<span class="text-info" x-text="formatMoney(amount, code)"></span> <span class="text-info" x-text="formatMoney(amount, code)"></span>
</template> </template>
</template> </template>
<template <template
x-if="'Transfer' !== groupProperties.transactionType && 'Deposit' !== groupProperties.transactionType && 'Withdrawal' !== groupProperties.transactionType"> x-if="'transfer' !== groupProperties.transactionType && 'deposit' !== groupProperties.transactionType && 'withdrawal' !== groupProperties.transactionType">
<span>TODO PARSE MISSING AMOUNT</span> <span>TODO PARSE MISSING AMOUNT</span>
</template> </template>
</td> </td>
@@ -164,33 +176,33 @@
:title="entry.source_account.name" :title="entry.source_account.name"
x-text="entry.source_account.name"></a> x-text="entry.source_account.name"></a>
&rarr; &rarr;
<template x-if="'Withdrawal' === groupProperties.transactionType"> <template x-if="'withdrawal' === groupProperties.transactionType">
<span class="text-danger" <span class="text-danger"
x-text="formatMoney(entry.amount*-1, entry.currency_code)"></span> x-text="formatMoney(entry.amount*-1, entry.currency_code)"></span>
</template> </template>
<template x-if="'Deposit' === groupProperties.transactionType"> <template x-if="'deposit' === groupProperties.transactionType">
<span class="text-success" <span class="text-success"
x-text="formatMoney(entry.amount, entry.currency_code)"></span> x-text="formatMoney(entry.amount, entry.currency_code)"></span>
</template> </template>
<template x-if="'Transfer' === groupProperties.transactionType"> <template x-if="'transfer' === groupProperties.transactionType">
<span class="text-info" <span class="text-info"
x-text="formatMoney(entry.amount, entry.currency_code)"></span> x-text="formatMoney(entry.amount, entry.currency_code)"></span>
</template> </template>
<template <template
x-if="null !== entry.foreign_currency_code && 'Withdrawal' === groupProperties.transactionType"> x-if="null !== entry.foreign_currency_code && '' !== entry.foreign_currency_code && 'withdrawal' === groupProperties.transactionType">
<span class="text-muted" <span class="text-muted"
x-text="formatMoney(entry.foreign_amount*-1, entry.foreign_currency_code)"></span> x-text="formatMoney(entry.foreign_amount*-1, entry.foreign_currency_code) + 'y'"></span>
</template> </template>
<template <template
x-if="null !== entry.foreign_currency_code && 'Withdrawal' !== groupProperties.transactionType"> x-if="null !== entry.foreign_currency_code && '' !== entry.foreign_currency_code && 'withdrawal' !== groupProperties.transactionType">
<span class="text-muted" <span class="text-muted"
x-text="formatMoney(entry.foreign_amount, entry.foreign_currency_code)"></span> x-text="formatMoney(entry.foreign_amount, entry.foreign_currency_code) + 'x'"></span>
</template> </template>
<template <template
x-if="'Transfer' !== groupProperties.transactionType && 'Deposit' !== groupProperties.transactionType && 'Withdrawal' !== groupProperties.transactionType"> x-if="'transfer' !== groupProperties.transactionType && 'deposit' !== groupProperties.transactionType && 'withdrawal' !== groupProperties.transactionType">
<span>TODO PARSE MISSING AMOUNT</span> <span>TODO PARSE MISSING AMOUNT</span>
</template> </template>
&rarr; &rarr;