Fix: import script to fit the new structure of voucher table (is_printed field removed, voucher_type != KOT is now assumed to be printed)

Fix: Take-away bill type is now removed
Fix: Table overview now shows the right amounts
Voucher Save and Update should now work
Discounts now working (permissions are not checked)
This commit is contained in:
Amritanshu
2019-08-08 13:31:30 +05:30
parent 7d06a2f961
commit c81b92c336
24 changed files with 534 additions and 249 deletions

View File

@ -3,6 +3,9 @@
queryParamsHandling="preserve">
<h3 class="item-name">Add Product</h3>
</mat-card>
<mat-card fxLayout="column" class="square-button" matRipple (click)="discount()">
<h3 class="item-name">Discount</h3>
</mat-card>
<mat-card fxLayout="column" class="square-button" matRipple (click)="printKot()">
<h3 class="item-name">Print KOT</h3>
</mat-card>

View File

@ -1,8 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { AuthService } from '../../auth/auth.service';
import { ActivatedRoute, Router } from "@angular/router";
import { MatDialog } from "@angular/material";
import { mergeMap, tap } from "rxjs/operators";
import { Observable, of as observableOf } from "rxjs";
import { BillService } from '../bill.service';
import { ActivatedRoute } from "@angular/router";
import { ToasterService } from "../../core/toaster.service";
import { DiscountComponent } from "../discount/discount.component";
import { SaleCategoryService } from "../../sale-category/sale-category.service";
@Component({
selector: 'app-sales-home',
@ -10,19 +14,17 @@ import { ActivatedRoute } from "@angular/router";
styleUrls: ['./sales-home.component.css']
})
export class SalesHomeComponent implements OnInit {
public nameObject = new Subject<string>();
constructor(private route: ActivatedRoute, private auth: AuthService, private bs: BillService) {
constructor(
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private toaster: ToasterService,
private mcSer: SaleCategoryService,
private bs: BillService) {
}
ngOnInit() {
this.auth.userObservable.subscribe((user) => {
if (user.isAuthenticated) {
this.nameObject.next(user.name);
} else {
this.nameObject.next(null);
}
});
}
printKot() {
@ -30,10 +32,48 @@ export class SalesHomeComponent implements OnInit {
if (this.route.snapshot.queryParamMap.has("guest")) {
guestBookId = this.route.snapshot.queryParamMap.get("guest");
}
this.bs.printKot(guestBookId);
this.bs.printKot(guestBookId).subscribe(x => {
this.toaster.show('Success', '');
this.router.navigate(['/sales']);
});
}
discount(): void {
this.showDiscount().subscribe();
}
showDiscount(): Observable<boolean | { id: string, name: string, discount: number }[]> {
const dialogRef = this.dialog.open(DiscountComponent, {
// width: '750px',
data: this.mcSer.listForDiscount()
});
return dialogRef.afterClosed().pipe(
tap((result: boolean | { id: string, name: string, discount: number }[]) => {
if (!!result) {
this.bs.discount(result as { id: string, name: string, discount: number }[]);
}
})
)
}
printBill() {
this.bs.printBill();
const canGiveDiscount = true;
let guestBookId = null;
if (this.route.snapshot.queryParamMap.has("guest")) {
guestBookId = this.route.snapshot.queryParamMap.get("guest");
}
let discObs = null
if (!canGiveDiscount) {
discObs = this.showDiscount();
} else {
discObs = observableOf("");
}
discObs.pipe(
mergeMap(x => this.bs.printBill(guestBookId))
).subscribe(x => {
this.toaster.show('Success', '');
this.router.navigate(['/sales']);
});
}
}