Feature: Open bill using bill number

This commit is contained in:
2020-12-24 12:58:46 +05:30
parent 98c75f66c9
commit 161896154d
17 changed files with 234 additions and 29 deletions

View File

@ -8,6 +8,11 @@
color: #000000;
}
.open-bill {
background-color: #8e44ad;
color: #000000;
}
.square-button {
min-width: 150px;
max-width: 150px;

View File

@ -19,5 +19,8 @@
<span class="center" *ngIf="table.date">{{ table.date }}</span>
<span class="center" *ngIf="table.amount">{{ table.amount | currency: 'INR' }}</span>
</mat-card>
<mat-card fxLayout="column" class="square-button open-bill" matRipple (click)="openBill()">
<h3 class="item-name">Open Bill</h3>
</mat-card>
</mat-card-content>
</mat-card>

View File

@ -1,7 +1,11 @@
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { map } from 'rxjs/operators';
import { Table } from '../../core/table';
import { ToasterService } from '../../core/toaster.service';
import { BillNumberComponent } from '../bill-number/bill-number.component';
@Component({
selector: 'app-running-tables',
@ -11,7 +15,12 @@ import { Table } from '../../core/table';
export class RunningTablesComponent implements OnInit {
list: Table[] = [];
constructor(private router: Router, private route: ActivatedRoute) {}
constructor(
private dialog: MatDialog,
private router: Router,
private route: ActivatedRoute,
private toaster: ToasterService,
) {}
ngOnInit() {
this.route.data.subscribe((value) => {
@ -33,4 +42,22 @@ export class RunningTablesComponent implements OnInit {
};
this.router.navigate(['/sales', 'bill'], navigationExtras);
}
openBill() {
return this.dialog
.open(BillNumberComponent)
.afterClosed()
.pipe(
map((x) => {
if (x === undefined || x === false) {
throw new Error('Invalid Bill Number');
}
return x;
}),
)
.subscribe(
(x) => this.router.navigate(['/sales', 'bill'], { queryParams: { bill: x } }),
(x) => this.toaster.show('Error', x),
);
}
}