Feature: Added product bundles. Have to wire it up to inventory and reports.
This commit is contained in:
@@ -9,13 +9,13 @@ import { BillViewItem } from '../core/bill-view-item';
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
import { ReceivePaymentItem } from '../core/receive-payment-item';
|
||||
import { SaleCategory } from '../core/sale-category';
|
||||
import { StockKeepingUnit } from '../core/stock-keeping-unit';
|
||||
import { Table } from '../core/table';
|
||||
import { ModifierCategoryService } from '../modifier-categories/modifier-category.service';
|
||||
import { MathService } from '../shared/math.service';
|
||||
import { Bill } from './bills/bill';
|
||||
import { Inventory } from './bills/inventory';
|
||||
import { Kot } from './bills/kot';
|
||||
import { ProductLink } from './bills/product-link';
|
||||
import { VoucherType } from './bills/voucher-type';
|
||||
import { VoucherService } from './bills/voucher.service';
|
||||
import { ModifiersComponent } from './modifiers/modifiers.component';
|
||||
@@ -109,7 +109,7 @@ export class BillService {
|
||||
);
|
||||
}
|
||||
|
||||
addSku(sku: StockKeepingUnit, quantity: number, discount: number): void {
|
||||
addSku(sku: ProductLink, quantity: number, discount: number): void {
|
||||
const newKot = this.bill.kots.find((k) => k.id === undefined) as Kot;
|
||||
const old = newKot.inventories.find((x) => x.sku.id === sku.id && x.isHappyHour === sku.hasHappyHour);
|
||||
if (quantity < 0) {
|
||||
@@ -127,7 +127,7 @@ export class BillService {
|
||||
quantity,
|
||||
price: sku.price,
|
||||
isHappyHour: sku.hasHappyHour,
|
||||
taxRate: sku.tax.rate,
|
||||
taxRate: sku.tax?.rate,
|
||||
tax: sku.tax,
|
||||
discount,
|
||||
modifiers: [],
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Modifier } from '../../core/modifier';
|
||||
import { StockKeepingUnit as Product } from '../../core/stock-keeping-unit';
|
||||
import { Tax } from '../../core/tax';
|
||||
import { ProductLink } from './product-link';
|
||||
|
||||
export class Inventory {
|
||||
id: string | undefined;
|
||||
sku: Product;
|
||||
sku: ProductLink;
|
||||
quantity: number;
|
||||
price: number;
|
||||
isHappyHour: boolean;
|
||||
@@ -16,7 +16,7 @@ export class Inventory {
|
||||
|
||||
public constructor(init?: Partial<Inventory>) {
|
||||
this.id = undefined;
|
||||
this.sku = new Product();
|
||||
this.sku = new ProductLink();
|
||||
this.quantity = 0;
|
||||
this.price = 0;
|
||||
this.isHappyHour = false;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { SaleCategory } from '../../core/sale-category';
|
||||
import { Tax } from '../../core/tax';
|
||||
|
||||
export class ProductLink {
|
||||
id: string | undefined;
|
||||
name: string;
|
||||
price: number;
|
||||
tax: Tax | undefined;
|
||||
saleCategory: SaleCategory | undefined;
|
||||
hasHappyHour: boolean;
|
||||
enabled: boolean;
|
||||
|
||||
public constructor(init?: Partial<ProductLink>) {
|
||||
this.id = undefined;
|
||||
this.name = '';
|
||||
this.price = 0;
|
||||
this.hasHappyHour = false;
|
||||
this.enabled = false;
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,9 @@ import { MatCardModule } from '@angular/material/card';
|
||||
import { MatRippleModule } from '@angular/material/core';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { ProductQuery } from '../../core/product-query';
|
||||
import { BillService } from '../bill.service';
|
||||
import { Product } from '../product';
|
||||
import { ProductLink } from '../bills/product-link';
|
||||
|
||||
@Component({
|
||||
selector: 'app-products',
|
||||
@@ -17,19 +18,19 @@ export class ProductsComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private bs = inject(BillService);
|
||||
|
||||
list: Product[] = [];
|
||||
list: ProductQuery[] = [];
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Product[] };
|
||||
const data = value as { list: ProductQuery[] };
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
|
||||
addSku(product: Product): void {
|
||||
addSku(product: ProductQuery): void {
|
||||
if (product.isNotAvailable) {
|
||||
return;
|
||||
}
|
||||
this.bs.addSku(product, 1, 0);
|
||||
this.bs.addSku(new ProductLink(product), 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Product } from '../../core/product';
|
||||
import { ProductQuery } from '../../core/product-query';
|
||||
import { ProductService } from '../../product/product.service';
|
||||
|
||||
export const productsResolver: ResolveFn<Product[]> = (route) => {
|
||||
export const productsResolver: ResolveFn<ProductQuery[]> = (route) => {
|
||||
const id = route.paramMap.get('id') as string;
|
||||
return inject(ProductService).listIsActiveOfCategory(id);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user