Save Bill Works
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import {Bill, Inventory, Kot} from './bill';
|
||||
import {BillsDataSource} from './bills-datasource';
|
||||
import {BillService} from "../bill.service";
|
||||
import { Bill } from './bill';
|
||||
import { BillsDataSource } from './bills-datasource';
|
||||
import { BillService } from '../bill.service';
|
||||
import { QuantityComponent } from '../quantity/quantity.component';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bills',
|
||||
@ -17,40 +19,18 @@ export class BillsComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private dialog: MatDialog,
|
||||
private bs: BillService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log("ds set")
|
||||
this.dataSource = new BillsDataSource(this.bs.dataObs);
|
||||
this.route.data
|
||||
.subscribe((data: { item: Bill }) => {
|
||||
this.updateView(data.item);
|
||||
this.item = data.item;
|
||||
this.bs.loadData(data.item);
|
||||
});
|
||||
}
|
||||
|
||||
updateView(item) {
|
||||
this.item = item;
|
||||
let view = item.kots.map(k => {
|
||||
return [{
|
||||
isKot: true,
|
||||
}, ...k.inventories.map(i => {
|
||||
return {
|
||||
id: i.id,
|
||||
isKot: false,
|
||||
product: i.product,
|
||||
productId: i.product.id,
|
||||
isHappyHour: i.isHappyHour,
|
||||
isPrinted: true,
|
||||
info: `${i.product.name} (${i.product.units}) @ ${i.price}`,
|
||||
quantity: 1,
|
||||
modifiers: i.modifiers
|
||||
}
|
||||
})]
|
||||
});
|
||||
view = view.reduce((a, c) => {return a.concat(c)} , []);
|
||||
this.bs.loadData(view);
|
||||
this.dataSource = new BillsDataSource(this.bs.dataObs);
|
||||
}
|
||||
|
||||
addOne(item: any): void {
|
||||
@ -58,7 +38,17 @@ export class BillsComponent implements OnInit {
|
||||
}
|
||||
|
||||
quantity(item: any): void {
|
||||
this.bs.quantity(item);
|
||||
const dialogRef = this.dialog.open(QuantityComponent, {
|
||||
// width: '750px',
|
||||
data: item.quantity
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean | number) => {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
this.bs.quantity(item, result as number);
|
||||
});
|
||||
}
|
||||
|
||||
subtractOne(item: any): void {
|
||||
|
||||
Reference in New Issue
Block a user