Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
refactor(front-end): Remove repeating code to show the detail of a bill
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Jan 31, 2021
1 parent 58b6651 commit a873bdd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,7 @@ <h4 class="text-center mt-4 empty-list-text">
</mat-card-header>
<mat-card-content>
<div class="pt-3">
<div class="icon-text-container">
<mat-icon [matTooltip]="'Fecha de generación de factura'">
date_range
</mat-icon>
<span>
{{
productInvoice.generationDate | date: "MMMM d, y, h:mm a"
}}
</span>
</div>
<div class="icon-text-container">
<mat-icon [matTooltip]="'Estado de factura'"> more </mat-icon>
<span>
{{ productInvoice.state | invoiceState }}
</span>
</div>
<div *ngIf="productInvoice.state == 2">
<div class="icon-text-container">
<mat-icon [matTooltip]="'Método de pago'">
payments
</mat-icon>
<span>
{{ productInvoice.paymentMethod | paymentMethod }}
</span>
</div>
<div class="icon-text-container">
<mat-icon [matTooltip]="'Fecha de pago'">
receipt_long
</mat-icon>
<span>
{{ productInvoice.paymentDate | date: "MMMM d, y, h:mm a" }}
</span>
</div>
</div>
</div>
<div class="pt-3">
<div class="icon-text-container">
<mat-icon [matTooltip]="'Cliente'">person</mat-icon>
<span>
{{ productInvoice.client.id }},
{{ productInvoice.client.firstName }}
{{ productInvoice.client?.secondName }}
{{ productInvoice.client.lastName }}
{{ productInvoice.client?.secondLastName }},
{{ productInvoice.client.tradeName }}
</span>
</div>
<app-invoice-detail [invoice]="productInvoice"></app-invoice-detail>
</div>
<div class="pt-2 pb-3">
<mat-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class ProductInvoiceDetailComponent implements OnInit {
private productInvoiceService: ProductInvoiceService,
private activatedRoute: ActivatedRoute,
private authService: AuthenticationService
) {}
) {
}

ngOnInit(): void {
this.loadData();
Expand All @@ -33,7 +34,7 @@ export class ProductInvoiceDetailComponent implements OnInit {
private loadData(): void {
const id = +this.activatedRoute.snapshot.paramMap.get('id');
this.productInvoice$ = this.productInvoiceService.getProductInvoice(id);

const role = this.authService.getUserRole();
if (role === CLIENT_ROLE) {
this.isClient = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>Facturas de producto</h1>
<td mat-cell *matCellDef="let productInvoice">
<a
mat-icon-button
routerLink="/payments/products/{{ productInvoice.id }}"
routerLink="/payments/invoices/products/{{ productInvoice.id }}"
[matTooltip]="'Ver más información'"
>
<mat-icon>visibility</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,66 +23,18 @@ <h4 class="text-center mt-4 empty-list-text">
</mat-card-header>
<mat-card-content>
<div class="pt-3">
<div class="icon-text-container">
<mat-icon [matTooltip]="'Fecha de generación de factura'">
date_range
</mat-icon>
<span>
{{
serviceInvoice.generationDate | date: "MMMM d, y, h:mm a"
}}
</span>
</div>
<div class="icon-text-container">
<mat-icon [matTooltip]="'Estado de factura'"> more </mat-icon>
<span>
{{ serviceInvoice.state | invoiceState }}
</span>
</div>
<div *ngIf="serviceInvoice.state == 2">
<div class="icon-text-container">
<mat-icon [matTooltip]="'Método de pago'">
payments
</mat-icon>
<span>
{{ serviceInvoice.paymentMethod | paymentMethod }}
</span>
</div>
<div class="icon-text-container">
<mat-icon [matTooltip]="'Fecha de pago'">
receipt_long
</mat-icon>
<span>
{{ serviceInvoice.paymentDate | date: "MMMM d, y, h:mm a" }}
</span>
</div>
</div>
</div>
<div class="pt-3">
<div class="icon-text-container">
<mat-icon [matTooltip]="'Cliente'">person</mat-icon>
<span>
{{ serviceInvoice.client.id }},
{{ serviceInvoice.client.firstName }}
{{ serviceInvoice.client?.secondName }}
{{ serviceInvoice.client.lastName }}
{{ serviceInvoice.client?.secondLastName }},
{{ serviceInvoice.client.tradeName }}
</span>
</div>
<app-invoice-detail [invoice]="serviceInvoice"></app-invoice-detail>
</div>
<div class="pt-2 pb-3">
<mat-list>
<div mat-subheader>Se facturan los siguientes servicios</div>
<mat-list-item
*ngFor="let detail of serviceInvoice.serviceInvoiceDetails"
>
<mat-icon style="margin-right: 7px" color="primary"
>offline_bolt</mat-icon
>
<span>
{{ detail.serviceName }}
</span>
<div class="icon-text-container">
<mat-icon color="primary">offline_bolt</mat-icon>
<span>{{detail.serviceName}}</span>
</div>
<mat-divider></mat-divider>
</mat-list-item>
</mat-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>Facturas de servicio</h1>
<td mat-cell *matCellDef="let serviceInvoice">
<a
mat-icon-button
routerLink="/payments/service_invoices/{{
routerLink="/payments/invoices/services/{{
serviceInvoice.id
}}"
[matTooltip]="'Ver más información'"
Expand Down
4 changes: 3 additions & 1 deletion Kaizen/ClientApp/src/app/modules/payments/payments.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ProductInvoicesComponent } from './components/product-invoices/product-
import { ServiceInvoiceDetailComponent } from './components/service-invoice-detail/service-invoice-detail.component';
import { ServiceInvoicesComponent } from './components/service-invoices/service-invoices.component';
import { PaymentsRoutingModule } from './payments-routing.module';
import { InvoiceDetailComponent } from './components/invoice-detail/invoice-detail.component';

@NgModule({
declarations: [
Expand All @@ -21,7 +22,8 @@ import { PaymentsRoutingModule } from './payments-routing.module';
ServiceInvoiceDetailComponent,
PayProductInvoiceComponent,
ProductInvoiceRegisterComponent,
ProductInvoiceDetailComponent
ProductInvoiceDetailComponent,
InvoiceDetailComponent
],
imports: [ CommonModule, PaymentsRoutingModule, SharedModule, ReactiveFormsModule, FormsModule ]
})
Expand Down

0 comments on commit a873bdd

Please sign in to comment.