Skip to content

Commit

Permalink
Fix summarization in currency UDIS to pesos
Browse files Browse the repository at this point in the history
  • Loading branch information
efrain-jerv committed Feb 24, 2022
1 parent 00a910d commit 63f7364
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions BalanceEngine.Tests/Balances/TrialBalanceUseCasesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void Should_Build_Analitico_De_Cuentas() {
command.WithSubledgerAccount = false;
command.WithAverageBalance = false;
command.ShowCascadeBalances = false;
command.FromAccount = "1.01.02.02";
command.ToAccount = "1.01.02.02";
command.FromAccount = "2.13.01.07";
command.ToAccount = "2.13.01.07";

TrialBalanceDto trialBalance = _usecases.BuildTrialBalance(command);

Expand Down
5 changes: 5 additions & 0 deletions BalanceEngine/Domain/TrialBalanceEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public int Level {
}


public bool IsSummaryForAnalytics {
get; set;
} = false;


internal void MultiplyBy(decimal value) {
this.InitialBalance *= value;
this.Debit *= value;
Expand Down
2 changes: 2 additions & 0 deletions BalanceEngine/Domain/TrialBalanceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,8 @@ private void GetSummaryToSectorZeroForPesosAndUdis(
entryWithSummarySector.Credit += entry.Credit;
entryWithSummarySector.CurrentBalance += entry.CurrentBalance;
entryWithSummarySector.AverageBalance += entry.AverageBalance;
} else {
entry.IsSummaryForAnalytics = true;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions BalanceEngine/Domain/TwoCurrenciesBalanceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,14 @@ private void SumTwoCurrenciesBalanceEntry(TwoCurrenciesBalanceEntry twoCurrencie
} else {
if (entry.Level == 1 && (currentCurrency.Code == "01" || currentCurrency.Code == "44")) {
twoCurrenciesEntry.DomesticBalance += entry.CurrentBalance;
} else if (currentCurrency.Code == "01" && entry.Sector.Code == "00") {
} else if (entry.Sector.Code == "00" && currentCurrency.Code == "01") {
twoCurrenciesEntry.DomesticBalance = entry.CurrentBalance;
} else if (entry.Sector.Code != "00" &&
(currentCurrency.Code == "01" || currentCurrency.Code == "44")) {
twoCurrenciesEntry.DomesticBalance += entry.CurrentBalance;
} else if (currentCurrency.Code == "44" && entry.IsSummaryForAnalytics) {
twoCurrenciesEntry.DomesticBalance += entry.CurrentBalance;
}

}
twoCurrenciesEntry.InitialBalance += entry.InitialBalance;
twoCurrenciesEntry.Debit += entry.Debit;
Expand Down

0 comments on commit 63f7364

Please sign in to comment.