mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed all problems related to strict types.
This commit is contained in:
@@ -132,7 +132,7 @@ class BudgetController extends Controller
|
||||
/*
|
||||
* Sum of expenses on this day:
|
||||
*/
|
||||
$amount = round(bcadd($amount, $sum), 2);
|
||||
$amount = round(bcadd(strval($amount), $sum), 2);
|
||||
$entries->push([clone $start, $amount]);
|
||||
$start->addDay();
|
||||
}
|
||||
|
@@ -126,24 +126,19 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
|
||||
protected function multiYearInOut(array $earned, array $spent, Carbon $start, Carbon $end)
|
||||
{
|
||||
bcscale(2);
|
||||
$income = '0';
|
||||
$expense = '0';
|
||||
$count = 0;
|
||||
$entries = new Collection;
|
||||
while ($start < $end) {
|
||||
$date = $start->format('Y-m');
|
||||
$currentIncome = $earned[$date] ?? 0;
|
||||
$currentExpense = isset($spent[$date]) ? ($spent[$date] * -1) : 0;
|
||||
$income = bcadd($income, $currentIncome);
|
||||
$expense = bcadd($expense, $currentExpense);
|
||||
|
||||
$count++;
|
||||
$start->addMonth();
|
||||
$incomeSum = $this->pluckFromArray($start->year, $earned);
|
||||
$expenseSum = $this->pluckFromArray($start->year, $spent) * -1;
|
||||
|
||||
$entries->push([clone $start, $incomeSum, $expenseSum]);
|
||||
$start->addYear();
|
||||
}
|
||||
|
||||
$data = $this->generator->yearInOutSummarized($income, $expense, $count);
|
||||
$data = $this->generator->multiYearInOut($entries);
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -179,28 +174,23 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $earned
|
||||
* @param array $spent
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param int $year
|
||||
* @param array $set
|
||||
*
|
||||
* @return array
|
||||
* @return string
|
||||
*/
|
||||
protected function multiYearInOut(array $earned, array $spent, Carbon $start, Carbon $end)
|
||||
protected function pluckFromArray($year, array $set)
|
||||
{
|
||||
$entries = new Collection;
|
||||
while ($start < $end) {
|
||||
|
||||
$incomeSum = $this->pluckFromArray($start->year, $earned);
|
||||
$expenseSum = $this->pluckFromArray($start->year, $spent) * -1;
|
||||
|
||||
$entries->push([clone $start, $incomeSum, $expenseSum]);
|
||||
$start->addYear();
|
||||
bcscale(2);
|
||||
$sum = '0';
|
||||
foreach ($set as $date => $amount) {
|
||||
if (substr($date, 0, 4) == $year) {
|
||||
$sum = bcadd($sum, $amount);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->generator->multiYearInOut($entries);
|
||||
return $sum;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,22 +222,32 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $year
|
||||
* @param array $set
|
||||
* @param array $earned
|
||||
* @param array $spent
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
protected function pluckFromArray($year, array $set)
|
||||
protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
|
||||
{
|
||||
bcscale(2);
|
||||
$sum = '0';
|
||||
foreach ($set as $date => $amount) {
|
||||
if (substr($date, 0, 4) == $year) {
|
||||
$sum = bcadd($sum, $amount);
|
||||
}
|
||||
$income = '0';
|
||||
$expense = '0';
|
||||
$count = 0;
|
||||
while ($start < $end) {
|
||||
$date = $start->format('Y-m');
|
||||
$currentIncome = $earned[$date] ?? '0';
|
||||
$currentExpense = isset($spent[$date]) ? bcmul($spent[$date], '-1') : '0';
|
||||
$income = bcadd($income, $currentIncome);
|
||||
$expense = bcadd($expense, $currentExpense);
|
||||
|
||||
$count++;
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
return $sum;
|
||||
$data = $this->generator->yearInOutSummarized($income, $expense, $count);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@@ -242,10 +242,11 @@ class TagController extends Controller
|
||||
$longitude = null;
|
||||
$zoomLevel = null;
|
||||
}
|
||||
$date = $request->get('date') ?? '';
|
||||
|
||||
$data = [
|
||||
'tag' => $request->get('tag'),
|
||||
'date' => strlen($request->get('date')) > 0 ? new Carbon($request->get('date')) : null,
|
||||
'date' => strlen($date) > 0 ? new Carbon($date) : null,
|
||||
'description' => strlen($request->get('description')) > 0 ? $request->get('description') : '',
|
||||
'latitude' => $latitude,
|
||||
'longitude' => $longitude,
|
||||
@@ -287,10 +288,12 @@ class TagController extends Controller
|
||||
$longitude = null;
|
||||
$zoomLevel = null;
|
||||
}
|
||||
$date = $request->get('date') ?? '';
|
||||
|
||||
|
||||
$data = [
|
||||
'tag' => $request->get('tag'),
|
||||
'date' => strlen($request->get('date')) > 0 ? new Carbon($request->get('date')) : null,
|
||||
'date' => strlen($date) > 0 ? new Carbon($date) : null,
|
||||
'description' => strlen($request->get('description')) > 0 ? $request->get('description') : '',
|
||||
'latitude' => $latitude,
|
||||
'longitude' => $longitude,
|
||||
|
@@ -31,6 +31,7 @@ class JournalFormRequest extends Request
|
||||
*/
|
||||
public function getJournalData()
|
||||
{
|
||||
$tags = $this->get('tags') ?? '';
|
||||
return [
|
||||
'what' => $this->get('what'),
|
||||
'description' => $this->get('description'),
|
||||
@@ -45,7 +46,7 @@ class JournalFormRequest extends Request
|
||||
'date' => new Carbon($this->get('date')),
|
||||
'budget_id' => intval($this->get('budget_id')),
|
||||
'category' => $this->get('category'),
|
||||
'tags' => explode(',', $this->get('tags')),
|
||||
'tags' => explode(',', $tags),
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user