mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix negative amount thing.
This commit is contained in:
parent
4838670649
commit
4004c53e1b
@ -55,8 +55,18 @@ class Expense
|
|||||||
*/
|
*/
|
||||||
public function addToTotal($add)
|
public function addToTotal($add)
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
|
|
||||||
|
|
||||||
|
$add = strval(round($add, 2));
|
||||||
|
if (bccomp('0', $add) === 1) {
|
||||||
|
$add = bcmul($add, '-1');
|
||||||
|
}
|
||||||
|
|
||||||
|
// if amount is positive, the original transaction
|
||||||
|
// was a transfer. But since this is an expense report,
|
||||||
|
// that amount must be negative.
|
||||||
|
|
||||||
$this->total = bcadd($this->total, $add);
|
$this->total = bcadd($this->total, $add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
$object = new Expense;
|
$object = new Expense;
|
||||||
$set = $this->query->expenseInPeriodCorrectedForList($start, $end, $accounts);
|
$set = $this->query->expenseInPeriodCorrectedForList($start, $end, $accounts);
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$object->addToTotal($entry->amount);
|
$object->addToTotal($entry->amount); // can be positive, if it's a transfer
|
||||||
$object->addOrCreateExpense($entry);
|
$object->addOrCreateExpense($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user