Skip to content

Commit

Permalink
fix(frozen period): exclude empty cash flow categories
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed May 19, 2024
1 parent 5b8041d commit 44dd0a0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/Controllers/FrozenPeriodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,12 @@ function ($previous_total, $summary) {

$opened_liquid_amount = BigRational::zero();
$closed_liquid_amount = BigRational::zero();
$liquid_cash_flow_category_subtotals = [];
$illiquid_cash_flow_category_subtotals = [];

// Compute for cash flow statement
if (isset($categorized_summaries[$currency->id])) {
$summaries = $categorized_summaries[$currency->id];
$liquid_cash_flow_category_subtotals = [];
$illiquid_cash_flow_category_subtotals = [];

foreach ($summaries as $cash_flow_category_id => $account_summaries) {
$cash_flow_category = $keyed_categories[$cash_flow_category_id];
Expand Down Expand Up @@ -955,6 +955,19 @@ function ($previous_total, $calculation) {
}
}

$liquid_cash_flow_category_subtotals = array_filter(
$liquid_cash_flow_category_subtotals,
function($cash_flow_category_subtotal) {
return $cash_flow_category_subtotal["subtotal"]->getSign() !== 0;
}
);
$illiquid_cash_flow_category_subtotals = array_filter(
$illiquid_cash_flow_category_subtotals,
function($cash_flow_category_subtotal) {
return $cash_flow_category_subtotal["subtotal"]->getSign() !== 0;
}
);

$opened_liquid_amount = array_reduce(
$liquid_cash_flow_category_subtotals,
function ($previous_total, $calculation) {
Expand Down

0 comments on commit 44dd0a0

Please sign in to comment.