mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 10:53:37 +00:00
Fix piggy views.
This commit is contained in:
@@ -87,21 +87,18 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get currently saved amount:
|
// get currently saved amount:
|
||||||
$currentAmountStr = $this->piggyRepos->getCurrentAmount($piggyBank);
|
$currentAmount = app('steam')->bcround($this->piggyRepos->getCurrentAmount($piggyBank), $currency->decimal_places);
|
||||||
$currentAmount = app('steam')->bcround($currentAmountStr, $currency->decimal_places);
|
|
||||||
|
|
||||||
// Amounts, depending on 0.0 state of target amount
|
// Amounts, depending on 0.0 state of target amount
|
||||||
$percentage = null;
|
$percentage = null;
|
||||||
$targetAmountString = null;
|
$targetAmount = $piggyBank->targetamount;
|
||||||
$leftToSaveString = null;
|
$leftToSave = null;
|
||||||
$savePerMonth = null;
|
$savePerMonth = null;
|
||||||
if (0 !== bccomp(app('steam')->bcround($currentAmountStr, $currency->decimal_places), '0')) {
|
if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $currentAmountStr);
|
$leftToSave = bcsub($piggyBank->targetamount, $currentAmount);
|
||||||
$targetAmount = (string)$piggyBank->targetamount;
|
$percentage = (int)bcmul(bcdiv($currentAmount, $targetAmount), '100');
|
||||||
$targetAmount = 1 === bccomp('0.01', $targetAmount) ? '0.01' : $targetAmount;
|
$targetAmount = app('steam')->bcround($targetAmount, $currency->decimal_places);
|
||||||
$percentage = (int)(0 !== bccomp('0', $currentAmountStr) ? $currentAmountStr / $targetAmount * 100 : 0);
|
$leftToSave = app('steam')->bcround($leftToSave, $currency->decimal_places);
|
||||||
$targetAmountString = app('steam')->bcround($targetAmount, $currency->decimal_places);
|
|
||||||
$leftToSaveString = app('steam')->bcround($leftToSave, $currency->decimal_places);
|
|
||||||
$savePerMonth = app('steam')->bcround($this->piggyRepos->getSuggestedMonthlyAmount($piggyBank), $currency->decimal_places);
|
$savePerMonth = app('steam')->bcround($this->piggyRepos->getSuggestedMonthlyAmount($piggyBank), $currency->decimal_places);
|
||||||
}
|
}
|
||||||
$startDate = $piggyBank->startdate?->toAtomString();
|
$startDate = $piggyBank->startdate?->toAtomString();
|
||||||
@@ -119,10 +116,10 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
'currency_code' => $currency->code,
|
'currency_code' => $currency->code,
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||||
'target_amount' => $targetAmountString,
|
'target_amount' => $targetAmount,
|
||||||
'percentage' => $percentage,
|
'percentage' => $percentage,
|
||||||
'current_amount' => $currentAmount,
|
'current_amount' => $currentAmount,
|
||||||
'left_to_save' => $leftToSaveString,
|
'left_to_save' => $leftToSave,
|
||||||
'save_per_month' => $savePerMonth,
|
'save_per_month' => $savePerMonth,
|
||||||
'start_date' => $startDate,
|
'start_date' => $startDate,
|
||||||
'target_date' => $targetDate,
|
'target_date' => $targetDate,
|
||||||
|
@@ -77,6 +77,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<td class="hidden-sm hidden-xs" style="width:40px;">
|
<td class="hidden-sm hidden-xs" style="width:40px;">
|
||||||
|
|
||||||
{% if piggy.left_to_save > 0 or null == piggy.left_to_save %}
|
{% if piggy.left_to_save > 0 or null == piggy.left_to_save %}
|
||||||
<a href="{{ route('piggy-banks.add-money', piggy.id) }}" class="btn btn-default btn-xs addMoney" data-id="{{ piggy.id }}">
|
<a href="{{ route('piggy-banks.add-money', piggy.id) }}" class="btn btn-default btn-xs addMoney" data-id="{{ piggy.id }}">
|
||||||
<span data-id="{{ piggy.id }}" class="fa fa-plus"></span></a>
|
<span data-id="{{ piggy.id }}" class="fa fa-plus"></span></a>
|
||||||
|
Reference in New Issue
Block a user