DB Normalization: Moved fractionUnits back to Product from SKU as it is better suited there.
Feature: Created the ProductSku schema for the product/sku autocomplete
This commit is contained in:
@@ -9,6 +9,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
|
||||
import { Batch } from '../core/batch';
|
||||
import { Inventory } from '../core/inventory';
|
||||
import { Product } from '../core/product';
|
||||
import { ProductSku } from '../core/product-sku';
|
||||
import { ProductService } from '../product/product.service';
|
||||
import { MathService } from '../shared/math.service';
|
||||
|
||||
@@ -18,9 +19,9 @@ import { MathService } from '../shared/math.service';
|
||||
styleUrls: ['./purchase-dialog.component.css'],
|
||||
})
|
||||
export class PurchaseDialogComponent implements OnInit {
|
||||
products: Observable<Product[]>;
|
||||
products: Observable<ProductSku[]>;
|
||||
form: FormGroup;
|
||||
product: Product = new Product();
|
||||
product: ProductSku = new ProductSku();
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<PurchaseDialogComponent>,
|
||||
@@ -42,7 +43,7 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.productSer.autocomplete(x, true))),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.productSer.autocompleteSku(x, true))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
|
||||
productSelected(event: MatAutocompleteSelectedEvent): void {
|
||||
this.product = event.option.value;
|
||||
(this.form.get('price') as FormControl).setValue(this.product.price);
|
||||
(this.form.get('price') as FormControl).setValue(this.product.costPrice);
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
|
||||
Reference in New Issue
Block a user