mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 17:57:09 +00:00
Update various pages, clean up some code.
This commit is contained in:
@@ -76,7 +76,6 @@ class IndexController extends Controller
|
||||
$collection = $this->repository->getBills();
|
||||
$total = $collection->count();
|
||||
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$parameters = new ParameterBag();
|
||||
// sub one day from temp start so the last paid date is one day before it should be.
|
||||
$tempStart = clone $start;
|
||||
@@ -84,7 +83,8 @@ class IndexController extends Controller
|
||||
// $tempStart->subDay();
|
||||
$parameters->set('start', $tempStart);
|
||||
$parameters->set('end', $end);
|
||||
|
||||
$parameters->set('convertToNative', $this->convertToNative);
|
||||
$parameters->set('defaultCurrency', $this->defaultCurrency);
|
||||
/** @var BillTransformer $transformer */
|
||||
$transformer = app(BillTransformer::class);
|
||||
$transformer->setParameters($parameters);
|
||||
@@ -112,7 +112,7 @@ class IndexController extends Controller
|
||||
'bills' => [],
|
||||
];
|
||||
|
||||
$currency = $bill->transactionCurrency ?? $defaultCurrency;
|
||||
$currency = $bill->transactionCurrency ?? $this->defaultCurrency;
|
||||
$array['currency_id'] = $currency->id;
|
||||
$array['currency_name'] = $currency->name;
|
||||
$array['currency_symbol'] = $currency->symbol;
|
||||
@@ -122,7 +122,6 @@ class IndexController extends Controller
|
||||
$array['rules'] = $rules[$bill['id']] ?? [];
|
||||
$bills[$groupOrder]['bills'][] = $array;
|
||||
}
|
||||
|
||||
// order by key
|
||||
ksort($bills);
|
||||
|
||||
|
@@ -123,10 +123,10 @@ class ReconcileController extends Controller
|
||||
Log::debug(sprintf('End balance: "%s"', $endBalance));
|
||||
Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));
|
||||
Log::debug(sprintf('Amount: "%s"', $amount));
|
||||
$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);
|
||||
$difference = bcadd(bcadd(bcsub($startBalance ?? '0', $endBalance ?? '0'), $clearedAmount?? '0'), $amount);
|
||||
$diffCompare = bccomp($difference, '0');
|
||||
$countCleared = count($clearedJournals);
|
||||
$reconSum = bcadd(bcadd($startBalance, $amount), $clearedAmount);
|
||||
$reconSum = bcadd(bcadd($startBalance ?? '0', $amount ?? '0'), $clearedAmount ?? '0');
|
||||
|
||||
try {
|
||||
$view = view('accounts.reconcile.overview', compact('account', 'start', 'diffCompare', 'difference', 'end', 'clearedAmount', 'startBalance', 'endBalance', 'amount', 'route', 'countCleared', 'reconSum', 'selectedIds'))->render();
|
||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Support\System\OAuthKeys;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
@@ -60,6 +60,8 @@ class Bill extends Model
|
||||
'match_encrypted' => 'boolean',
|
||||
'amount_min' => 'string',
|
||||
'amount_max' => 'string',
|
||||
'native_amount_min' => 'string',
|
||||
'native_amount_max' => 'string',
|
||||
];
|
||||
|
||||
protected $fillable
|
||||
@@ -81,6 +83,8 @@ class Bill extends Model
|
||||
'extension_date',
|
||||
'end_date_tz',
|
||||
'extension_date_tz',
|
||||
'native_amount_min',
|
||||
'native_amount_max',
|
||||
];
|
||||
|
||||
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
@@ -123,10 +124,10 @@ class Steam
|
||||
[ // @phpstan-ignore-line
|
||||
'transaction_journals.date',
|
||||
'transactions.transaction_currency_id',
|
||||
\DB::raw('SUM(transactions.amount) AS modified'),
|
||||
DB::raw('SUM(transactions.amount) AS modified'),
|
||||
'transactions.foreign_currency_id',
|
||||
\DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
|
||||
\DB::raw('SUM(transactions.native_amount) AS modified_native'),
|
||||
DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
|
||||
DB::raw('SUM(transactions.native_amount) AS modified_native'),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -178,24 +179,6 @@ class Steam
|
||||
// add to GBP, as expected.
|
||||
$currentBalance[$entryCurrency->code] = bcadd($currentBalance[$entryCurrency->code] ?? '0', $modified);
|
||||
}
|
||||
|
||||
// // add "modified" to amount if the currency id matches the account currency id.
|
||||
// if ($entry->transaction_currency_id === $currency->id) {
|
||||
// $currentBalance['balance'] = bcadd($currentBalance['balance'], $modified);
|
||||
// $currentBalance[$currency->code] = bcadd($currentBalance[$currency->code], $modified);
|
||||
// }
|
||||
//
|
||||
// // always add the native balance, even if it ends up at zero.
|
||||
// $currentBalance['native_balance'] = bcadd($currentBalance['native_balance'], $nativeModified);
|
||||
|
||||
// DO NOT add modified foreign to the array
|
||||
// if (null !== $entry->foreign_currency_id) {
|
||||
// $foreignId = $entry->foreign_currency_id;
|
||||
// $currencies[$foreignId] ??= TransactionCurrency::find($foreignId);
|
||||
// $foreignCurrency = $currencies[$foreignId];
|
||||
// $currentBalance[$foreignCurrency->code] ??= '0';
|
||||
// $currentBalance[$foreignCurrency->code] = bcadd($currentBalance[$foreignCurrency->code], $foreignModified);
|
||||
// }
|
||||
$balances[$carbon->format('Y-m-d')] = $currentBalance;
|
||||
Log::debug('Updated entry',$currentBalance);
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Models\BillDateCalculator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -58,6 +59,8 @@ class BillTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function transform(Bill $bill): array
|
||||
{
|
||||
$defaultCurrency = $this->parameters->get('defaultCurrency') ?? Amount::getDefaultCurrency();
|
||||
|
||||
$paidData = $this->paidData($bill);
|
||||
$lastPaidDate = $this->getLastPaidDate($paidData);
|
||||
$start = $this->parameters->get('start') ?? today()->subYears(10);
|
||||
@@ -149,6 +152,8 @@ class BillTransformer extends AbstractTransformer
|
||||
'name' => $bill->name,
|
||||
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
|
||||
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
|
||||
'native_amount_min' => app('steam')->bcround($bill->native_amount_min, $defaultCurrency->decimal_places),
|
||||
'native_amount_max' => app('steam')->bcround($bill->native_amount_max, $defaultCurrency->decimal_places),
|
||||
'date' => $bill->date->toAtomString(),
|
||||
'end_date' => $bill->end_date?->toAtomString(),
|
||||
'extension_date' => $bill->extension_date?->toAtomString(),
|
||||
@@ -169,7 +174,7 @@ class BillTransformer extends AbstractTransformer
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/bills/'.$bill->id,
|
||||
'uri' => '/bills/' . $bill->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@@ -27,7 +27,15 @@
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{{ trans('firefly.match_between_amounts', {low: formatAmountByCurrency(object.data.currency,object.data.amount_min), high: formatAmountByCurrency(object.data.currency,object.data.amount_max) })|raw }}
|
||||
{% set lowAmount = formatAmountByCurrency(object.data.currency,object.data.amount_min) %}
|
||||
{% set highAmount = formatAmountByCurrency(object.data.currency,object.data.amount_max) %}
|
||||
{% if(0 != object.data.native_amount_min) %}
|
||||
{% set lowAmount = lowAmount ~ ' (' ~ formatAmountByCode(object.data.native_amount_min, defaultCurrency.code) ~ ')' %}
|
||||
{% endif %}
|
||||
{% if(0 != object.data.native_amount_max) %}
|
||||
{% set highAmount = highAmount ~ ' (' ~ formatAmountByCode(object.data.native_amount_max, defaultCurrency.code) ~ ')' %}
|
||||
{% endif %}
|
||||
{{ trans('firefly.match_between_amounts', {low: lowAmount, high: highAmount })|raw }}
|
||||
{{ 'repeats'|_ }}
|
||||
{{ trans('firefly.repeat_freq_' ~object.data.repeat_freq) }}.
|
||||
</td>
|
||||
|
@@ -67,6 +67,10 @@
|
||||
title="{{ formatAmountBySymbol(entry.amount_min, entry.currency_symbol, entry.currency_decimal_places, false)|escape }} -- {{ formatAmountBySymbol(entry.amount_max, entry.currency_symbol, entry.currency_decimal_places, false)|escape }}"
|
||||
>
|
||||
~ {{ formatAmountBySymbol((entry.amount_max + entry.amount_min)/2, entry.currency_symbol, entry.currency_decimal_places) }}
|
||||
|
||||
{% if '0' != entry.native_amount_max %}
|
||||
({{ formatAmountBySymbol((entry.native_amount_max + entry.native_amount_min)/2, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
|
Reference in New Issue
Block a user