Feature: Added a column called print in bill to the table customer.

This will prevent printing all customer's names and phone numbers in the bill in case of simple walkins.
This is a breaking change as there is schema changes in the database.
It also bolds the customers who are to be printed in the bill in the running tables list.
This commit is contained in:
2021-06-28 08:41:32 +05:30
parent 143ddfb860
commit db5f2731be
17 changed files with 80 additions and 11 deletions

View File

@ -5,6 +5,7 @@ export class Customer {
name: string;
phone: string;
address: string;
printInBill: boolean;
discounts: CustomerDiscount[];
public constructor(init?: Partial<Customer>) {
@ -12,6 +13,7 @@ export class Customer {
this.name = '';
this.phone = '';
this.address = '';
this.printInBill = false;
this.discounts = [];
Object.assign(this, init);
}

View File

@ -10,6 +10,7 @@ export class Table {
status?: string;
pax?: number;
guest?: string;
bold?: boolean;
date?: string;
amount?: number;

View File

@ -41,6 +41,16 @@
<textarea matInput placeholder="Address" formControlName="address"> </textarea>
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-checkbox formControlName="printInBill">Print in Bill?</mat-checkbox>
</div>
<mat-divider></mat-divider>
<div formArrayName="discounts">
<div

View File

@ -34,6 +34,7 @@ export class CustomerDetailComponent implements OnInit, AfterViewInit {
name: '',
phone: '',
address: '',
printInBill: false,
discounts: this.fb.array([]),
});
}
@ -50,6 +51,7 @@ export class CustomerDetailComponent implements OnInit, AfterViewInit {
(this.form.get('name') as AbstractControl).setValue(item.name);
(this.form.get('phone') as AbstractControl).setValue(item.phone);
(this.form.get('address') as AbstractControl).setValue(item.address);
(this.form.get('printInBill') as AbstractControl).setValue(item.printInBill);
this.form.setControl(
'discounts',
this.fb.array(
@ -112,6 +114,7 @@ export class CustomerDetailComponent implements OnInit, AfterViewInit {
this.item.name = formModel.name;
this.item.phone = formModel.phone;
this.item.address = formModel.address;
this.item.printInBill = formModel.printInBill;
const array = this.form.get('discounts') as FormArray;
this.item.discounts.forEach((item, index) => {
item.discount = Math.max(

View File

@ -28,6 +28,12 @@
<mat-cell *matCellDef="let row">{{ row.address }}</mat-cell>
</ng-container>
<!-- Print In Bill Column -->
<ng-container matColumnDef="printInBill">
<mat-header-cell *matHeaderCellDef>Print in Bill</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.printInBill }}</mat-cell>
</ng-container>
<!-- Discounts Column -->
<ng-container matColumnDef="discounts">
<mat-header-cell *matHeaderCellDef>Discounts</mat-header-cell>

View File

@ -14,7 +14,7 @@ export class CustomerListComponent implements OnInit {
dataSource: CustomerListDatasource = new CustomerListDatasource([]);
list: Customer[] = [];
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'phone', 'address', 'discounts'];
displayedColumns = ['name', 'phone', 'address', 'printInBill', 'discounts'];
constructor(private route: ActivatedRoute) {}

View File

@ -53,7 +53,6 @@ export class DiscountComponent {
for (let i = this.list.length - 1; i >= 0; i--) {
const item = this.list[i];
const control = (array.controls[i] as FormGroup).controls.discount as FormControl;
console.log(item.name, control.value, typeof control.value);
if (
control.value === null ||
control.value === '' ||

View File

@ -13,6 +13,10 @@
color: #000000;
}
.bold {
font-weight: bold;
}
.square-button {
min-width: 150px;
max-width: 150px;

View File

@ -14,8 +14,12 @@
[class.printed]="table.status === 'printed'"
>
<h3 class="item-name">{{ table.name }}</h3>
<mat-card-subtitle class="center">{{ table.guest }}</mat-card-subtitle>
<span class="center">{{ table.pax || 0 }} / {{ table.seats }} Seats</span>
<mat-card-subtitle class="center" [class.bold]="table.bold">{{
table.guest
}}</mat-card-subtitle>
<span class="center"
>{{ table.pax || '-' }} / {{ table.seats }} / {{ table.section?.name }}</span
>
<span class="center" *ngIf="table.date">{{ table.date }}</span>
<span class="center" *ngIf="table.amount">{{ table.amount | currency: 'INR' }}</span>
</mat-card>