Skip to content

Commit

Permalink
revert(frozen period): resolve of unadjusted value
Browse files Browse the repository at this point in the history
This reverts commit a632e7b.
Another columns will be added for flowed amounts.
  • Loading branch information
KennethTrecy committed May 19, 2024
1 parent d874609 commit ea4744b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/Controllers/FrozenPeriodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,29 @@ function ($raw_calculations, $modifier) use ($grouped_financial_entries) {
);
$raw_summary_calculations = array_map(
function ($raw_calculation) {
$unadjusted_debit_amount = $raw_calculation["unadjusted_debit_amount"];
$unadjusted_credit_amount = $raw_calculation["unadjusted_credit_amount"];
$closed_debit_amount = $raw_calculation["closed_debit_amount"];
$closed_credit_amount = $raw_calculation["closed_credit_amount"];

$unadjusted_balance = $unadjusted_debit_amount
->minus($unadjusted_credit_amount)
->simplified();
$adjusted_balance = $closed_debit_amount
->minus($closed_credit_amount)
->simplified();

$is_unadjusted_balance_positive = $unadjusted_balance->getSign() > 0;
$is_adjusted_balance_positive = $adjusted_balance->getSign() > 0;
$is_unadjusted_balance_negative = $unadjusted_balance->getSign() < 0;
$is_adjusted_balance_negative = $adjusted_balance->getSign() < 0;

$raw_calculation["unadjusted_debit_amount"] = $is_unadjusted_balance_positive
? $unadjusted_balance
: BigRational::zero();
$raw_calculation["unadjusted_credit_amount"] = $is_unadjusted_balance_negative
? $unadjusted_balance->negated()
: BigRational::zero();
$raw_calculation["closed_debit_amount"] = $is_adjusted_balance_positive
? $adjusted_balance
: BigRational::zero();
Expand All @@ -514,7 +527,9 @@ function ($raw_calculation) {
$raw_summary_calculations = array_filter(
$raw_summary_calculations,
function ($raw_summary_calculation) {
return $raw_summary_calculation->closed_debit_amount->getSign() !== 0
return $raw_summary_calculation->unadjusted_debit_amount->getSign() !== 0
|| $raw_summary_calculation->unadjusted_credit_amount->getSign() !== 0
|| $raw_summary_calculation->closed_debit_amount->getSign() !== 0
|| $raw_summary_calculation->closed_credit_amount->getSign() !== 0;
}
);
Expand Down

0 comments on commit ea4744b

Please sign in to comment.