mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-22 06:23:12 -06:00
Fixed some bugs that caused inconsistencies in the monthly reports.
This commit is contained in:
parent
e5b88be5fa
commit
c3958ed3c4
@ -33,11 +33,10 @@ class Expense
|
|||||||
*/
|
*/
|
||||||
public function addOrCreateExpense(TransactionJournal $entry)
|
public function addOrCreateExpense(TransactionJournal $entry)
|
||||||
{
|
{
|
||||||
|
|
||||||
$accountId = $entry->account_id;
|
$accountId = $entry->account_id;
|
||||||
if (!$this->expenses->has($accountId)) {
|
if (!$this->expenses->has($accountId)) {
|
||||||
$newObject = new stdClass;
|
$newObject = new stdClass;
|
||||||
$newObject->amount = strval(round($entry->amount, 2));
|
$newObject->amount = strval(round($entry->actual_amount, 2));
|
||||||
$newObject->name = $entry->name;
|
$newObject->name = $entry->name;
|
||||||
$newObject->count = 1;
|
$newObject->count = 1;
|
||||||
$newObject->id = $accountId;
|
$newObject->id = $accountId;
|
||||||
@ -45,7 +44,7 @@ class Expense
|
|||||||
} else {
|
} else {
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
$existing = $this->expenses->get($accountId);
|
$existing = $this->expenses->get($accountId);
|
||||||
$existing->amount = bcadd($existing->amount, $entry->amount);
|
$existing->amount = bcadd($existing->amount, $entry->actual_amount);
|
||||||
$existing->count++;
|
$existing->count++;
|
||||||
$this->expenses->put($accountId, $existing);
|
$this->expenses->put($accountId, $existing);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class Income
|
|||||||
$accountId = $entry->account_id;
|
$accountId = $entry->account_id;
|
||||||
if (!$this->incomes->has($accountId)) {
|
if (!$this->incomes->has($accountId)) {
|
||||||
$newObject = new stdClass;
|
$newObject = new stdClass;
|
||||||
$newObject->amount = strval(round($entry->amount, 2));
|
$newObject->amount = strval(round($entry->actual_amount, 2));
|
||||||
$newObject->name = $entry->name;
|
$newObject->name = $entry->name;
|
||||||
$newObject->count = 1;
|
$newObject->count = 1;
|
||||||
$newObject->id = $accountId;
|
$newObject->id = $accountId;
|
||||||
@ -46,7 +46,7 @@ class Income
|
|||||||
} else {
|
} else {
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
$existing = $this->incomes->get($accountId);
|
$existing = $this->incomes->get($accountId);
|
||||||
$existing->amount = bcadd($existing->amount, $entry->amount);
|
$existing->amount = bcadd($existing->amount, $entry->actual_amount);
|
||||||
$existing->count++;
|
$existing->count++;
|
||||||
$this->incomes->put($accountId, $existing);
|
$this->incomes->put($accountId, $existing);
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
$object = new Expense;
|
$object = new Expense;
|
||||||
$set = $this->query->expenseInPeriodCorrected($start, $end, $shared);
|
$set = $this->query->expenseInPeriodCorrected($start, $end, $shared);
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$object->addToTotal($entry->amount);
|
$object->addToTotal($entry->actual_amount);
|
||||||
$object->addOrCreateExpense($entry);
|
$object->addOrCreateExpense($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
$object = new Income;
|
$object = new Income;
|
||||||
$set = $this->query->incomeInPeriodCorrected($start, $end, $shared);
|
$set = $this->query->incomeInPeriodCorrected($start, $end, $shared);
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$object->addToTotal($entry->amount);
|
$object->addToTotal($entry->actual_amount);
|
||||||
$object->addOrCreateIncome($entry);
|
$object->addOrCreateIncome($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,15 +70,6 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$data = $data->filter(
|
|
||||||
function (TransactionJournal $journal) {
|
|
||||||
if ($journal->amount != 0) {
|
|
||||||
return $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user