Skip to content

Commit

Permalink
Refactor: Refactor PrintInvoiceView.razor file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenny-Tinoco committed Jul 3, 2024
1 parent 236280a commit d805eb7
Show file tree
Hide file tree
Showing 20 changed files with 372 additions and 410 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Directorys ignores
.vs/
.idea/
.vscode/
bin/

obj/
Properties/
bin/

**/*.user
3 changes: 2 additions & 1 deletion Academy/AcademyProfiles.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/academy/tariff-profiles"
@using wsmcbl.front.Controllers.AcademyController

@using wsmcbl.front.Controllers
@using wsmcbl.front.Models.Secretary.Input

@inject AcademyController controller;
Expand Down
8 changes: 4 additions & 4 deletions Accounting/AlertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ public AlertService(SweetAlertService service)

public async Task AlertSuccess(string title, string text)
{
await service.FireAsync(new SweetAlertOptions{ Title = title, Icon = SweetAlertIcon.Success});
await service.FireAsync(new SweetAlertOptions{ Title = title, Text = text, Icon = SweetAlertIcon.Success});
}

public async Task AlertError(string title, string text)
{
await service.FireAsync(new SweetAlertOptions{ Title = title, Icon = SweetAlertIcon.Error});
await service.FireAsync(new SweetAlertOptions{ Title = title, Text = text, Icon = SweetAlertIcon.Error});
}

public async Task<SweetAlertResult> AlertWarning(string title)
public async Task AlertWarning(string title)
{
return await service.FireAsync(new SweetAlertOptions{Title = title, Icon = SweetAlertIcon.Warning, ShowCancelButton = true });
await service.FireAsync(new SweetAlertOptions{Title = title, Icon = SweetAlertIcon.Warning, ShowCancelButton = true });
}
}
Original file line number Diff line number Diff line change
@@ -1,185 +1,134 @@
@page "/transactions/invoices/{transactionId}"
@layout EmptyLayout
@using wsmcbl.front.Models.Accounting
@using wsmcbl.front.Controllers
@inject NavigationManager navigationManager
@inject TariffCollectionController tariffcontroller
@inject SweetAlertService Swal;



<link rel="stylesheet" href="/css/Factura.css" />

@if (errorMessage != null)
{
<div class="alert alert-danger">@errorMessage</div>
<a href="/" class="btn btn-primary">Ir a la página principal</a>
}
else if (invoice == null)
{
<p>Cargando...</p>
}
else
{
<div class="factura">
<h5 class="izqC">Colegio Bautista Libertad</h5>
<p class="direccion">Entrada Norte C.C.Managua, 1c. E. 1c S. 1/2c-E.</p>
<p>Telefono: 22705587</p>

<p class="izqC">Recibo de Caja</p>
<hr>

<div class="row">
<div class="col">
<p class="izqN">N°</p>
</div>
<div class="col">
<p class="izq">@invoice.TransactionId</p>
</div>
</div>

<div class="row">
<div class="col">
<p class="izqN">Cod. Estu</p>
</div>
<div class="col">
<p class="izq">@invoice.StudentId</p>
</div>
</div>

<div class="row">
<div class="col">
<p class="izqN">Fecha</p>
</div>
<div class="col">
<p class="izq">@invoice.DateTime.ToString("dd-MM-yyyy")</p>
</div>
</div>

<div class="row">
<div class="col">
<p class="izqN">Cajero</p>
</div>
<div class="col">
<p class="izq">@invoice.CashierName</p>
</div>
</div>

<p class="der">A nombre de: </p>
<p class="izqC">@invoice.StudentName</p>

<blockquote class="izqC">DETALLE</blockquote>

<table>
<thead>
<tr>
<th>Concepto</th>
<th>Monto</th>
</tr>
</thead>
<tbody>
@foreach (var item in invoice.Tariffs)
{
<tr>
<td> @item.Concept </td>
<td> @item.Amount </td>
</tr>
}
</tbody>
</table>
<hr>


<div class="row">
<div class="col">
<p class="izqN">T. Bruto:</p>
</div>
<div class="col">
<p class="izq">C$ @invoice.Subtotal</p>
</div>
</div>
<hr>

<div class="row">
<div class="col">
<p class="izqN">T Neto:</p>
</div>
<div class="col">
<p class="izq">C$ @invoice.Total</p>
</div>
</div>
<hr>
<br>

<div class="row">
<div class="col">
<hr>
<p>Cliente</p>
</div>
<div class="col">
<hr>
<p>Administrador</p>
</div>
</div>
<br>

<hr>
<div class="row">
<div class="col">
<p class="izqN">Balance General</p>
</div>
<div class="col">
<p class="izq">C$ @balanceGeneral</p>
</div>
</div>
<p class="end">NO ES VALIDO SIN FIRMA NI SELLO DEL CAJERO</p>
</div>
<script src="/js/Facture.js" defer></script>
}


@code
{
InvoiceDto? invoice;
private bool showError;
private string? errorMessage;
private float balanceGeneral;

[Parameter]
public string? transactionId {get; set; }


protected override async Task OnInitializedAsync()
{
var segments = navigationManager.ToAbsoluteUri(navigationManager.Uri).Segments;
transactionId = segments.Last().Trim('/');

try
{
invoice = await tariffcontroller.GetInvoice(transactionId);

balanceGeneral = 0;
balanceGeneral = invoice!.GeneralBalance[1] - invoice.GeneralBalance[0];
}
catch (Exception ex)
{
errorMessage = ex.Message;
showError = true;
}
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (showError)
{
showError = false; // Resetear la bandera para no mostrar el error múltiples veces.
await Swal.FireAsync(new SweetAlertOptions
{
Title = "Obtuvimos unos problemas",
Text = errorMessage,
Icon = SweetAlertIcon.Error
});
}
}

}
@page "/transactions/invoices/{transactionId}"

@inherits PrintInvoice;
@layout EmptyLayout


<link rel="stylesheet" href="/css/Factura.css" />

@if (errorMessage != null)
{
<div class="alert alert-danger">@errorMessage</div>
<a href="/" class="btn btn-primary">Ir a la página principal</a>
}
else if (invoice == null)
{
<p>Cargando...</p>
}
else
{
<div class="factura">
<h5 class="izqC">Colegio Bautista Libertad</h5>
<p class="direccion">Entrada Norte C.C.Managua, 1c. E. 1c S. 1/2c-E.</p>
<p>Telefono: 22705587</p>

<p class="izqC">Recibo de Caja</p>
<hr>

<div class="row">
<div class="col">
<p class="izqN">N°</p>
</div>
<div class="col">
<p class="izq">@invoice.TransactionId</p>
</div>
</div>

<div class="row">
<div class="col">
<p class="izqN">Cod. Estu</p>
</div>
<div class="col">
<p class="izq">@invoice.StudentId</p>
</div>
</div>

<div class="row">
<div class="col">
<p class="izqN">Fecha</p>
</div>
<div class="col">
<p class="izq">@invoice.DateTime.ToString("dd-MM-yyyy")</p>
</div>
</div>

<div class="row">
<div class="col">
<p class="izqN">Cajero</p>
</div>
<div class="col">
<p class="izq">@invoice.CashierName</p>
</div>
</div>

<p class="der">A nombre de: </p>
<p class="izqC">@invoice.StudentName</p>

<blockquote class="izqC">DETALLE</blockquote>

<table>
<thead>
<tr>
<th>Concepto</th>
<th>Monto</th>
</tr>
</thead>
<tbody>
@foreach (var item in invoice.detail)
{
<tr>
<td> @item.Concept </td>
<td> @item.Amount </td>
</tr>
}
</tbody>
</table>
<hr>


<div class="row">
<div class="col">
<p class="izqN">T. Bruto:</p>
</div>
<div class="col">
<p class="izq">C$ @invoice.Subtotal</p>
</div>
</div>
<hr>

<div class="row">
<div class="col">
<p class="izqN">T Neto:</p>
</div>
<div class="col">
<p class="izq">C$ @invoice.Total</p>
</div>
</div>
<hr>
<br>

<div class="row">
<div class="col">
<hr>
<p>Cliente</p>
</div>
<div class="col">
<hr>
<p>Administrador</p>
</div>
</div>
<br>

<hr>
<div class="row">
<div class="col">
<p class="izqN">Balance General</p>
</div>
<div class="col">
<p class="izq">C$ @invoice.getGeneralBalance()</p>
</div>
</div>
<p class="end">NO ES VALIDO SIN FIRMA NI SELLO DEL CAJERO</p>
</div>
<script src="/js/Facture.js" defer></script>
}
Loading

0 comments on commit d805eb7

Please sign in to comment.