Skip to content

Commit

Permalink
Fix code
Browse files Browse the repository at this point in the history
TariffCollectionBase.cs
TariffCollectionView.razor
No Finish
  • Loading branch information
EzequielUrbina committed Jun 27, 2024
1 parent d228e21 commit bfa9f64
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.idea/
obj/
bin/Debug/
wsmcbl.front.csproj.user
*.user
44 changes: 22 additions & 22 deletions Accounting/TariffCollection/TariffCollectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected override async Task OnParametersSetAsync()
debtTariffs = new List<Tariff>();
foreach (var item in fullTariffs)
{
if (item.Type != 1)
if (item.Type != 1)//Fix
{
continue;
}
Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -192,8 +194,6 @@ protected async Task ConfirmTransaction()
await JSRuntime.InvokeVoidAsync("showModal", "finistariff");
}
}


protected void ReloadPage()
{
navigationManager.NavigateTo(navigationManager.Uri, forceLoad: true);
Expand Down
25 changes: 14 additions & 11 deletions Accounting/TariffCollection/TariffCollectionView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@ else
<td>@item.TariffId</td>
<td>@item.SchoolYear</td>
<td>@item.Concept</td>
<td>@item.Amount</td>
<td>
@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
}
</td>
<td>@item.IsLate</td>
<td>@item.DueDate</td>
<td>
@if (student.paymentHistory.Any(t => t.DebtBalance == 0))
@if (student.paymentHistory.Any(t => t.TariffId == item.TariffId && t.DebtBalance == 0))
{
<button type="button" class="btn btn-danger btn-sm " disabled>
Pagado
Expand Down Expand Up @@ -311,19 +321,12 @@ else
<tr>
<td>@item.Concept</td>
<td>@item.Amount</td>
<td>
@{
var discountAmount = item.Amount * student.discount;
var total = item.Amount - discountAmount;
@total
}
</td>

<td>@(student.discount*100)%</td>
@if (item.IsLate)
{
<td>
@{
var mora = (discountAmount * taxArrears);
var mora = (item.Amount * taxArrears);
@mora
}
</td>
Expand Down

0 comments on commit bfa9f64

Please sign in to comment.