mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Updated various files for #506
This commit is contained in:
parent
9ec3febbfa
commit
ac86e75233
@ -58,7 +58,7 @@ class ChartJsGenerator implements GeneratorInterface
|
|||||||
{
|
{
|
||||||
reset($data);
|
reset($data);
|
||||||
$first = current($data);
|
$first = current($data);
|
||||||
$labels = array_keys($first['entries']);
|
$labels = is_array($first['entries']) ? array_keys($first['entries']) : [];
|
||||||
|
|
||||||
$chartData = [
|
$chartData = [
|
||||||
'count' => count($data),
|
'count' => count($data),
|
||||||
|
@ -35,27 +35,10 @@ class BalanceLine
|
|||||||
|
|
||||||
/** @var BudgetModel */
|
/** @var BudgetModel */
|
||||||
protected $budget;
|
protected $budget;
|
||||||
/** @var int */
|
|
||||||
protected $role = self::ROLE_DEFAULTROLE;
|
|
||||||
|
|
||||||
/** @var BudgetLimit */
|
/** @var BudgetLimit */
|
||||||
protected $budgetLimit;
|
protected $budgetLimit;
|
||||||
|
/** @var int */
|
||||||
/**
|
protected $role = self::ROLE_DEFAULTROLE;
|
||||||
* @return BudgetLimit
|
|
||||||
*/
|
|
||||||
public function getBudgetLimit(): BudgetLimit
|
|
||||||
{
|
|
||||||
return $this->budgetLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*/
|
|
||||||
public function setBudgetLimit(BudgetLimit $budgetLimit)
|
|
||||||
{
|
|
||||||
$this->budgetLimit = $budgetLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -106,6 +89,22 @@ class BalanceLine
|
|||||||
$this->budget = $budget;
|
$this->budget = $budget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BudgetLimit
|
||||||
|
*/
|
||||||
|
public function getBudgetLimit(): BudgetLimit
|
||||||
|
{
|
||||||
|
return $this->budgetLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param BudgetLimit $budgetLimit
|
||||||
|
*/
|
||||||
|
public function setBudgetLimit(BudgetLimit $budgetLimit)
|
||||||
|
{
|
||||||
|
$this->budgetLimit = $budgetLimit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +60,6 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function addBudgeted(string $add): Budget
|
public function addBudgeted(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
|
||||||
$this->budgeted = bcadd($this->budgeted, $add);
|
$this->budgeted = bcadd($this->budgeted, $add);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -73,7 +72,6 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function addLeft(string $add): Budget
|
public function addLeft(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
|
||||||
$this->left = bcadd($this->left, $add);
|
$this->left = bcadd($this->left, $add);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -86,7 +84,6 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function addOverspent(string $add): Budget
|
public function addOverspent(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
|
||||||
$this->overspent = bcadd($this->overspent, $add);
|
$this->overspent = bcadd($this->overspent, $add);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -99,7 +96,6 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function addSpent(string $add): Budget
|
public function addSpent(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
|
||||||
$this->spent = bcadd($this->spent, $add);
|
$this->spent = bcadd($this->spent, $add);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -168,7 +164,7 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function setOverspent(string $overspent): Budget
|
public function setOverspent(string $overspent): Budget
|
||||||
{
|
{
|
||||||
$this->overspent = strval(round($overspent, 2));
|
$this->overspent = $overspent;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -188,7 +184,7 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function setSpent(string $spent): Budget
|
public function setSpent(string $spent): Budget
|
||||||
{
|
{
|
||||||
$this->spent = strval(round($spent, 2));
|
$this->spent = $spent;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@ class Category
|
|||||||
*/
|
*/
|
||||||
public function addTotal(string $add)
|
public function addTotal(string $add)
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
|
||||||
$this->total = bcadd($this->total, $add);
|
$this->total = bcadd($this->total, $add);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ class Category
|
|||||||
*/
|
*/
|
||||||
public function getTotal(): string
|
public function getTotal(): string
|
||||||
{
|
{
|
||||||
return strval(round($this->total, 2));
|
return $this->total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class AccountController extends Controller
|
|||||||
$endBalance = $endBalances[$id] ?? '0';
|
$endBalance = $endBalances[$id] ?? '0';
|
||||||
$diff = bcsub($endBalance, $startBalance);
|
$diff = bcsub($endBalance, $startBalance);
|
||||||
if (bccomp($diff, '0') !== 0) {
|
if (bccomp($diff, '0') !== 0) {
|
||||||
$chartData[$account->name] = round($diff, 2);
|
$chartData[$account->name] = $diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arsort($chartData);
|
arsort($chartData);
|
||||||
@ -391,7 +391,7 @@ class AccountController extends Controller
|
|||||||
$diff = bcsub($endBalance, $startBalance);
|
$diff = bcsub($endBalance, $startBalance);
|
||||||
$diff = bcmul($diff, '-1');
|
$diff = bcmul($diff, '-1');
|
||||||
if (bccomp($diff, '0') !== 0) {
|
if (bccomp($diff, '0') !== 0) {
|
||||||
$chartData[$account->name] = round($diff, 2);
|
$chartData[$account->name] = $diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,11 +475,11 @@ class AccountController extends Controller
|
|||||||
];
|
];
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$range = Steam::balanceInRange($account, $start, clone $end);
|
$range = Steam::balanceInRange($account, $start, clone $end);
|
||||||
$previous = round(array_values($range)[0], 2);
|
$previous = array_values($range)[0];
|
||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
$format = $currentStart->format('Y-m-d');
|
$format = $currentStart->format('Y-m-d');
|
||||||
$label = $currentStart->formatLocalized(strval(trans('config.month_and_day')));
|
$label = $currentStart->formatLocalized(strval(trans('config.month_and_day')));
|
||||||
$balance = isset($range[$format]) ? round($range[$format], 2) : $previous;
|
$balance = isset($range[$format]) ? round($range[$format], 12) : $previous;
|
||||||
$previous = $balance;
|
$previous = $balance;
|
||||||
$currentStart->addDay();
|
$currentStart->addDay();
|
||||||
$currentSet['entries'][$label] = $balance;
|
$currentSet['entries'][$label] = $balance;
|
||||||
|
@ -258,7 +258,7 @@ class BudgetController extends Controller
|
|||||||
$label = $periods[$period];
|
$label = $periods[$period];
|
||||||
$spent = isset($entries[$budget->id]['entries'][$period]) ? $entries[$budget->id]['entries'][$period] : '0';
|
$spent = isset($entries[$budget->id]['entries'][$period]) ? $entries[$budget->id]['entries'][$period] : '0';
|
||||||
$limit = isset($budgeted[$period]) ? $budgeted[$period] : 0;
|
$limit = isset($budgeted[$period]) ? $budgeted[$period] : 0;
|
||||||
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 2);
|
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
|
||||||
$chartData[1]['entries'][$label] = $limit;
|
$chartData[1]['entries'][$label] = $limit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -245,8 +245,8 @@ class BudgetReportController extends Controller
|
|||||||
$currentExpenses = $expenses[$budget->id] ?? '0';
|
$currentExpenses = $expenses[$budget->id] ?? '0';
|
||||||
$sumOfExpenses[$budget->id] = $sumOfExpenses[$budget->id] ?? '0';
|
$sumOfExpenses[$budget->id] = $sumOfExpenses[$budget->id] ?? '0';
|
||||||
$sumOfExpenses[$budget->id] = bcadd($currentExpenses, $sumOfExpenses[$budget->id]);
|
$sumOfExpenses[$budget->id] = bcadd($currentExpenses, $sumOfExpenses[$budget->id]);
|
||||||
$chartData[$budget->id]['entries'][$label] = round(bcmul($currentExpenses, '-1'), 2);
|
$chartData[$budget->id]['entries'][$label] = bcmul($currentExpenses, '-1');
|
||||||
$chartData[$budget->id . '-sum']['entries'][$label] = round(bcmul($sumOfExpenses[$budget->id], '-1'), 2);
|
$chartData[$budget->id . '-sum']['entries'][$label] = bcmul($sumOfExpenses[$budget->id], '-1');
|
||||||
|
|
||||||
if (count($budgetLimits) > 0) {
|
if (count($budgetLimits) > 0) {
|
||||||
$budgetLimitId = $budgetLimits->first()->id;
|
$budgetLimitId = $budgetLimits->first()->id;
|
||||||
|
@ -117,7 +117,7 @@ class NewUserController extends Controller
|
|||||||
'virtualBalance' => 0,
|
'virtualBalance' => 0,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'accountRole' => 'defaultAsset',
|
'accountRole' => 'defaultAsset',
|
||||||
'openingBalance' => round($request->input('bank_balance'), 2),
|
'openingBalance' => round($request->input('bank_balance'), 12),
|
||||||
'openingBalanceDate' => new Carbon,
|
'openingBalanceDate' => new Carbon,
|
||||||
'openingBalanceCurrency' => intval($request->input('amount_currency_id_bank_balance')),
|
'openingBalanceCurrency' => intval($request->input('amount_currency_id_bank_balance')),
|
||||||
];
|
];
|
||||||
@ -142,7 +142,7 @@ class NewUserController extends Controller
|
|||||||
'virtualBalance' => 0,
|
'virtualBalance' => 0,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'accountRole' => 'savingAsset',
|
'accountRole' => 'savingAsset',
|
||||||
'openingBalance' => round($request->input('savings_balance'), 2),
|
'openingBalance' => round($request->input('savings_balance'), 12),
|
||||||
'openingBalanceDate' => new Carbon,
|
'openingBalanceDate' => new Carbon,
|
||||||
'openingBalanceCurrency' => intval($request->input('amount_currency_id_savings_balance')),
|
'openingBalanceCurrency' => intval($request->input('amount_currency_id_savings_balance')),
|
||||||
];
|
];
|
||||||
@ -163,7 +163,7 @@ class NewUserController extends Controller
|
|||||||
'name' => 'Credit card',
|
'name' => 'Credit card',
|
||||||
'iban' => null,
|
'iban' => null,
|
||||||
'accountType' => 'asset',
|
'accountType' => 'asset',
|
||||||
'virtualBalance' => round($request->get('credit_card_limit'), 2),
|
'virtualBalance' => round($request->get('credit_card_limit'), 12),
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'accountRole' => 'ccAsset',
|
'accountRole' => 'ccAsset',
|
||||||
'openingBalance' => null,
|
'openingBalance' => null,
|
||||||
|
@ -219,7 +219,7 @@ class PiggyBankController extends Controller
|
|||||||
$accounts = [];
|
$accounts = [];
|
||||||
/** @var PiggyBank $piggyBank */
|
/** @var PiggyBank $piggyBank */
|
||||||
foreach ($piggyBanks as $piggyBank) {
|
foreach ($piggyBanks as $piggyBank) {
|
||||||
$piggyBank->savedSoFar = round($piggyBank->currentRelevantRep()->currentamount, 2);
|
$piggyBank->savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
||||||
$piggyBank->percentage = $piggyBank->savedSoFar != 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
$piggyBank->percentage = $piggyBank->savedSoFar != 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
||||||
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, strval($piggyBank->savedSoFar));
|
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, strval($piggyBank->savedSoFar));
|
||||||
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
|
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
|
||||||
@ -234,7 +234,7 @@ class PiggyBankController extends Controller
|
|||||||
'balance' => Steam::balanceIgnoreVirtual($account, $end),
|
'balance' => Steam::balanceIgnoreVirtual($account, $end),
|
||||||
'leftForPiggyBanks' => $piggyBank->leftOnAccount($end),
|
'leftForPiggyBanks' => $piggyBank->leftOnAccount($end),
|
||||||
'sumOfSaved' => strval($piggyBank->savedSoFar),
|
'sumOfSaved' => strval($piggyBank->savedSoFar),
|
||||||
'sumOfTargets' => strval(round($piggyBank->targetamount, 2)),
|
'sumOfTargets' => $piggyBank->targetamount,
|
||||||
'leftToSave' => $piggyBank->leftToSave,
|
'leftToSave' => $piggyBank->leftToSave,
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
@ -279,15 +279,15 @@ class PiggyBankController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$amount = strval(round($request->get('amount'), 2));
|
$amount = $request->get('amount');
|
||||||
/** @var Carbon $date */
|
/** @var Carbon $date */
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
$leftOnAccount = $piggyBank->leftOnAccount($date);
|
$leftOnAccount = $piggyBank->leftOnAccount($date);
|
||||||
$savedSoFar = strval($piggyBank->currentRelevantRep()->currentamount);
|
$savedSoFar = strval($piggyBank->currentRelevantRep()->currentamount);
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||||
$maxAmount = round(min($leftOnAccount, $leftToSave), 2);
|
$maxAmount = strval(min(round($leftOnAccount, 12), round($leftToSave, 12)));
|
||||||
|
|
||||||
if ($amount <= $maxAmount) {
|
if (bccomp($amount, $maxAmount) === -1) {
|
||||||
$repetition = $piggyBank->currentRelevantRep();
|
$repetition = $piggyBank->currentRelevantRep();
|
||||||
$currentAmount = $repetition->currentamount ?? '0';
|
$currentAmount = $repetition->currentamount ?? '0';
|
||||||
$repetition->currentamount = bcadd($currentAmount, $amount);
|
$repetition->currentamount = bcadd($currentAmount, $amount);
|
||||||
@ -319,11 +319,11 @@ class PiggyBankController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$amount = strval(round($request->get('amount'), 2));
|
$amount = strval(round($request->get('amount'), 12));
|
||||||
|
|
||||||
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
||||||
|
|
||||||
if ($amount <= $savedSoFar) {
|
if (bccomp($amount, $savedSoFar) === -1) {
|
||||||
$repetition = $piggyBank->currentRelevantRep();
|
$repetition = $piggyBank->currentRelevantRep();
|
||||||
$repetition->currentamount = bcsub($repetition->currentamount, $amount);
|
$repetition->currentamount = bcsub($repetition->currentamount, $amount);
|
||||||
$repetition->save();
|
$repetition->save();
|
||||||
|
@ -214,7 +214,7 @@ class MassController extends Controller
|
|||||||
'source_account_name' => $sourceAccountName,
|
'source_account_name' => $sourceAccountName,
|
||||||
'destination_account_id' => intval($destAccountId),
|
'destination_account_id' => intval($destAccountId),
|
||||||
'destination_account_name' => $destAccountName,
|
'destination_account_name' => $destAccountName,
|
||||||
'amount' => round($request->get('amount')[$journal->id], 4),
|
'amount' => round($request->get('amount')[$journal->id], 12),
|
||||||
'currency_id' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
|
'currency_id' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
|
||||||
'date' => new Carbon($request->get('date')[$journal->id]),
|
'date' => new Carbon($request->get('date')[$journal->id]),
|
||||||
'interest_date' => $journal->interest_date,
|
'interest_date' => $journal->interest_date,
|
||||||
|
@ -257,7 +257,7 @@ class SplitController extends Controller
|
|||||||
'source_account_name' => $transaction['source_account_name'],
|
'source_account_name' => $transaction['source_account_name'],
|
||||||
'destination_account_id' => $transaction['destination_account_id'],
|
'destination_account_id' => $transaction['destination_account_id'],
|
||||||
'destination_account_name' => $transaction['destination_account_name'],
|
'destination_account_name' => $transaction['destination_account_name'],
|
||||||
'amount' => round($transaction['destination_amount'], 2),
|
'amount' => round($transaction['destination_amount'], 12),
|
||||||
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : 0,
|
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : 0,
|
||||||
'category' => $transaction['category'],
|
'category' => $transaction['category'],
|
||||||
];
|
];
|
||||||
@ -292,7 +292,7 @@ class SplitController extends Controller
|
|||||||
'source_account_name' => $transaction['source_account_name'] ?? '',
|
'source_account_name' => $transaction['source_account_name'] ?? '',
|
||||||
'destination_account_id' => $transaction['destination_account_id'] ?? 0,
|
'destination_account_id' => $transaction['destination_account_id'] ?? 0,
|
||||||
'destination_account_name' => $transaction['destination_account_name'] ?? '',
|
'destination_account_name' => $transaction['destination_account_name'] ?? '',
|
||||||
'amount' => round($transaction['amount'] ?? 0, 2),
|
'amount' => round($transaction['amount'] ?? 0, 12),
|
||||||
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : 0,
|
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : 0,
|
||||||
'category' => $transaction['category'] ?? '',
|
'category' => $transaction['category'] ?? '',
|
||||||
];
|
];
|
||||||
|
@ -43,13 +43,13 @@ class AccountFormRequest extends Request
|
|||||||
'active' => intval($this->input('active')) === 1,
|
'active' => intval($this->input('active')) === 1,
|
||||||
'accountType' => $this->input('what'),
|
'accountType' => $this->input('what'),
|
||||||
'currency_id' => intval($this->input('currency_id')),
|
'currency_id' => intval($this->input('currency_id')),
|
||||||
'virtualBalance' => round($this->input('virtualBalance'), 2),
|
'virtualBalance' => round($this->input('virtualBalance'), 12),
|
||||||
'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')),
|
'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')),
|
||||||
'iban' => trim(strval($this->input('iban'))),
|
'iban' => trim(strval($this->input('iban'))),
|
||||||
'BIC' => trim(strval($this->input('BIC'))),
|
'BIC' => trim(strval($this->input('BIC'))),
|
||||||
'accountNumber' => trim(strval($this->input('accountNumber'))),
|
'accountNumber' => trim(strval($this->input('accountNumber'))),
|
||||||
'accountRole' => $this->input('accountRole'),
|
'accountRole' => $this->input('accountRole'),
|
||||||
'openingBalance' => round($this->input('openingBalance'), 2),
|
'openingBalance' => round($this->input('openingBalance'), 12),
|
||||||
'openingBalanceDate' => new Carbon((string)$this->input('openingBalanceDate')),
|
'openingBalanceDate' => new Carbon((string)$this->input('openingBalanceDate')),
|
||||||
'openingBalanceCurrency' => intval($this->input('amount_currency_id_openingBalance')),
|
'openingBalanceCurrency' => intval($this->input('amount_currency_id_openingBalance')),
|
||||||
'ccType' => $this->input('ccType'),
|
'ccType' => $this->input('ccType'),
|
||||||
|
@ -40,10 +40,10 @@ class BillFormRequest extends Request
|
|||||||
return [
|
return [
|
||||||
'name' => $this->get('name'),
|
'name' => $this->get('name'),
|
||||||
'match' => $this->get('match'),
|
'match' => $this->get('match'),
|
||||||
'amount_min' => round($this->get('amount_min'), 2),
|
'amount_min' => round($this->get('amount_min'), 12),
|
||||||
'amount_currency_id_amount_min' => intval($this->get('amount_currency_id_amount_min')),
|
'amount_currency_id_amount_min' => intval($this->get('amount_currency_id_amount_min')),
|
||||||
'amount_currency_id_amount_max' => intval($this->get('amount_currency_id_amount_max')),
|
'amount_currency_id_amount_max' => intval($this->get('amount_currency_id_amount_max')),
|
||||||
'amount_max' => round($this->get('amount_max'), 2),
|
'amount_max' => round($this->get('amount_max'), 12),
|
||||||
'date' => new Carbon($this->get('date')),
|
'date' => new Carbon($this->get('date')),
|
||||||
'repeat_freq' => $this->get('repeat_freq'),
|
'repeat_freq' => $this->get('repeat_freq'),
|
||||||
'skip' => intval($this->get('skip')),
|
'skip' => intval($this->get('skip')),
|
||||||
|
@ -59,7 +59,7 @@ class JournalFormRequest extends Request
|
|||||||
|
|
||||||
// transaction / journal data:
|
// transaction / journal data:
|
||||||
'description' => $this->getFieldOrEmptyString('description'),
|
'description' => $this->getFieldOrEmptyString('description'),
|
||||||
'amount' => round($this->get('amount'), 2),
|
'amount' => round($this->get('amount'), 12),
|
||||||
'budget_id' => intval($this->get('budget_id')),
|
'budget_id' => intval($this->get('budget_id')),
|
||||||
'category' => $this->getFieldOrEmptyString('category'),
|
'category' => $this->getFieldOrEmptyString('category'),
|
||||||
'source_account_id' => intval($this->get('source_account_id')),
|
'source_account_id' => intval($this->get('source_account_id')),
|
||||||
|
@ -41,7 +41,7 @@ class PiggyBankFormRequest extends Request
|
|||||||
'name' => trim($this->get('name')),
|
'name' => trim($this->get('name')),
|
||||||
'startdate' => new Carbon,
|
'startdate' => new Carbon,
|
||||||
'account_id' => intval($this->get('account_id')),
|
'account_id' => intval($this->get('account_id')),
|
||||||
'targetamount' => round($this->get('targetamount'), 2),
|
'targetamount' => round($this->get('targetamount'), 12),
|
||||||
'targetdate' => strlen(strval($this->get('targetdate'))) > 0 ? new Carbon($this->get('targetdate')) : null,
|
'targetdate' => strlen(strval($this->get('targetdate'))) > 0 ? new Carbon($this->get('targetdate')) : null,
|
||||||
'note' => trim(strval($this->get('note'))),
|
'note' => trim(strval($this->get('note'))),
|
||||||
];
|
];
|
||||||
|
@ -93,7 +93,7 @@ class SplitJournalFormRequest extends Request
|
|||||||
$category = $this->get('category')[$index] ?? '';
|
$category = $this->get('category')[$index] ?? '';
|
||||||
$transaction = [
|
$transaction = [
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'amount' => round($this->get('amount')[$index], 2),
|
'amount' => round($this->get('amount')[$index], 12),
|
||||||
'budget_id' => $this->get('budget_id')[$index] ? intval($this->get('budget_id')[$index]) : 0,
|
'budget_id' => $this->get('budget_id')[$index] ? intval($this->get('budget_id')[$index]) : 0,
|
||||||
'category' => trim($category),
|
'category' => trim($category),
|
||||||
'source_account_id' => isset($this->get('source_account_id')[$index])
|
'source_account_id' => isset($this->get('source_account_id')[$index])
|
||||||
|
@ -62,7 +62,7 @@ class Amount extends BasicConverter implements ConverterInterface
|
|||||||
$this->setCertainty(90);
|
$this->setCertainty(90);
|
||||||
|
|
||||||
|
|
||||||
return round(floatval($value), 4);
|
return round(floatval($value), 12);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ class Account extends Model
|
|||||||
*/
|
*/
|
||||||
public function setVirtualBalanceAttribute($value)
|
public function setVirtualBalanceAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['virtual_balance'] = strval(round($value, 2));
|
$this->attributes['virtual_balance'] = strval(round($value, 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,9 +29,6 @@ class Bill extends Model
|
|||||||
{
|
{
|
||||||
|
|
||||||
use ValidatingTrait;
|
use ValidatingTrait;
|
||||||
/** @var array */
|
|
||||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be casted to native types.
|
* The attributes that should be casted to native types.
|
||||||
*
|
*
|
||||||
@ -49,6 +46,8 @@ class Bill extends Model
|
|||||||
'name_encrypted' => 'boolean',
|
'name_encrypted' => 'boolean',
|
||||||
'match_encrypted' => 'boolean',
|
'match_encrypted' => 'boolean',
|
||||||
];
|
];
|
||||||
|
/** @var array */
|
||||||
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||||
protected $fillable
|
protected $fillable
|
||||||
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
|
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
|
||||||
'automatch', 'active',];
|
'automatch', 'active',];
|
||||||
@ -105,7 +104,7 @@ class Bill extends Model
|
|||||||
*/
|
*/
|
||||||
public function setAmountMaxAttribute($value)
|
public function setAmountMaxAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['amount_max'] = strval(round($value, 2));
|
$this->attributes['amount_max'] = strval(round($value, 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +112,7 @@ class Bill extends Model
|
|||||||
*/
|
*/
|
||||||
public function setAmountMinAttribute($value)
|
public function setAmountMinAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['amount_min'] = strval(round($value, 2));
|
$this->attributes['amount_min'] = strval(round($value, 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +81,7 @@ class BudgetLimit extends Model
|
|||||||
*/
|
*/
|
||||||
public function setAmountAttribute($value)
|
public function setAmountAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['amount'] = strval(round($value, 2));
|
$this->attributes['amount'] = strval(round($value, 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,6 @@ class PiggyBank extends Model
|
|||||||
*/
|
*/
|
||||||
public function setTargetamountAttribute($value)
|
public function setTargetamountAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['targetamount'] = strval(round($value, 2));
|
$this->attributes['targetamount'] = strval(round($value, 12));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ class ExpandedForm
|
|||||||
|
|
||||||
// make sure value is formatted nicely:
|
// make sure value is formatted nicely:
|
||||||
if (!is_null($value) && $value !== '') {
|
if (!is_null($value) && $value !== '') {
|
||||||
$value = round($value, 2);
|
$value = round($value, $defaultCurrency->decimal_places);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user