From bfa9f64acda71209496fe93364ae6983812664d5 Mon Sep 17 00:00:00 2001 From: Ezequiel Urbina Date: Wed, 26 Jun 2024 19:33:39 -0600 Subject: [PATCH] Fix code TariffCollectionBase.cs TariffCollectionView.razor No Finish --- .gitignore | 1 + .../TariffCollection/TariffCollectionBase.cs | 44 +++++++++---------- .../TariffCollectionView.razor | 25 ++++++----- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index a66ef51..1e77546 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .idea/ obj/ bin/Debug/ +wsmcbl.front.csproj.user *.user \ No newline at end of file diff --git a/Accounting/TariffCollection/TariffCollectionBase.cs b/Accounting/TariffCollection/TariffCollectionBase.cs index 7b7e2b1..a46bfb6 100644 --- a/Accounting/TariffCollection/TariffCollectionBase.cs +++ b/Accounting/TariffCollection/TariffCollectionBase.cs @@ -74,7 +74,7 @@ protected override async Task OnParametersSetAsync() debtTariffs = new List(); foreach (var item in fullTariffs) { - if (item.Type != 1) + if (item.Type != 1)//Fix { continue; } @@ -105,16 +105,8 @@ protected void OnSelectItemChanged(ChangeEventArgs e, Tariff tariff) { if (!selectedTariffs.Contains(tariff)) { + subtotal = getTotal(tariff); selectedTariffs.Add(tariff); - subtotal = subtotal + tariff.Amount; - - var discountAmount = tariff.Amount * student.discount; - discount += tariff.Amount - discountAmount; - - if (tariff.IsLate) - { - arrears += tariff.Amount * taxArrears; - } } } else @@ -123,7 +115,7 @@ protected void OnSelectItemChanged(ChangeEventArgs e, Tariff tariff) { selectedTariffs.Remove(tariff); subtotal = subtotal - tariff.Amount; - discount -= student.discount; + discount = 0; if (tariff.IsLate) { @@ -132,6 +124,25 @@ protected void OnSelectItemChanged(ChangeEventArgs e, Tariff tariff) } } } + private double getTotal(Tariff item) + { + var total = 0.0; + var arrear = 0.0; + + if(student.paymentHistory.Any(t => t.TariffId == item.TariffId && t.DebtBalance > 0)) //Existe un abono? + { + item.Amount = student.paymentHistory.First(t => t.TariffId == item.TariffId && t.DebtBalance > 0).DebtBalance; + total = item.Amount; + arrear = 1; + } + else + { + total = item.Amount * (1 - student.discount); + arrear = (item.IsLate) ? (1 + taxArrears) : 1; + } + + return Math.Round(total * arrear); + } protected void DistributePay() { if (amountToDivide <= 0) @@ -154,14 +165,6 @@ protected void DistributePay() } } } - - private double getTotal(Tariff item) - { - var total = item.Amount * (1 - student.discount); - var arrear = (item.IsLate) ? (1 + taxArrears) : 1; - return Math.Round(total * arrear); - } - protected async Task Pay() { controller.addDetail(selectedTariffs, applyArear); @@ -178,7 +181,6 @@ protected async Task Pay() await alertService.AlertError("¡Error en el Pago!", "La transacción no se completó correctamente."); } } - protected async Task ConfirmTransaction() { if (selectedTariffs.Count == 0) @@ -192,8 +194,6 @@ protected async Task ConfirmTransaction() await JSRuntime.InvokeVoidAsync("showModal", "finistariff"); } } - - protected void ReloadPage() { navigationManager.NavigateTo(navigationManager.Uri, forceLoad: true); diff --git a/Accounting/TariffCollection/TariffCollectionView.razor b/Accounting/TariffCollection/TariffCollectionView.razor index 952d8c0..443c62a 100644 --- a/Accounting/TariffCollection/TariffCollectionView.razor +++ b/Accounting/TariffCollection/TariffCollectionView.razor @@ -46,11 +46,21 @@ else @item.TariffId @item.SchoolYear @item.Concept - @item.Amount + + @if(student.paymentHistory.Any(t => t.TariffId == item.TariffId && t.DebtBalance > 0)) + { + var amount = student.paymentHistory.First(t => t.TariffId == item.TariffId && t.DebtBalance > 0).DebtBalance; + @amount + } + else + { + @item.Amount + } + @item.IsLate @item.DueDate - @if (student.paymentHistory.Any(t => t.DebtBalance == 0)) + @if (student.paymentHistory.Any(t => t.TariffId == item.TariffId && t.DebtBalance == 0)) {