Chore: Reformatted everthing
Fix: Product ledger was not totalling. This is because for some reason, pydantic was sending the data as string when the field was nullable
This commit is contained in:
@@ -40,9 +40,7 @@
|
||||
[displayWith]="displayProduct"
|
||||
(optionSelected)="productSelected($event)"
|
||||
>
|
||||
<mat-option *ngFor="let product of products | async" [value]="product">{{
|
||||
product.name
|
||||
}}</mat-option>
|
||||
<mat-option *ngFor="let product of products | async" [value]="product">{{ product.name }}</mat-option>
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="flex-auto basis-1/10 mr-5">
|
||||
@@ -50,10 +48,7 @@
|
||||
<input type="text" matInput formControlName="recipeYield" autocomplete="off" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div
|
||||
formGroupName="addRow"
|
||||
class="flex flex-row justify-around content-start items-start sm:max-lg:flex-col"
|
||||
>
|
||||
<div formGroupName="addRow" class="flex flex-row justify-around content-start items-start sm:max-lg:flex-col">
|
||||
<mat-form-field class="flex-auto basis-2/5 mr-5">
|
||||
<mat-label>Ingredient</mat-label>
|
||||
<input
|
||||
@@ -89,9 +84,7 @@
|
||||
<span matTextPrefix>₹ </span>
|
||||
</mat-form-field>
|
||||
|
||||
<button mat-raised-button color="primary" (click)="addRow()" class="flex-auto basis-1/10">
|
||||
Add
|
||||
</button>
|
||||
<button mat-raised-button color="primary" (click)="addRow()" class="flex-auto basis-1/10">Add</button>
|
||||
</div>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
<!-- Ingredient Column -->
|
||||
|
||||
@@ -94,9 +94,7 @@ export class RecipeDetailComponent implements OnInit, AfterViewInit {
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) =>
|
||||
x === null ? observableOf([]) : this.productSer.autocompleteProduct(x, null),
|
||||
),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.productSer.autocompleteProduct(x, null))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -166,9 +164,7 @@ export class RecipeDetailComponent implements OnInit, AfterViewInit {
|
||||
if (this.ingredient === null || quantity <= 0 || rate <= 0) {
|
||||
return;
|
||||
}
|
||||
const oldFiltered = this.item.items.filter(
|
||||
(x) => x.product.id === (this.ingredient as ProductSku).id,
|
||||
);
|
||||
const oldFiltered = this.item.items.filter((x) => x.product.id === (this.ingredient as ProductSku).id);
|
||||
if (oldFiltered.length) {
|
||||
this.toaster.show('Danger', 'Product already added');
|
||||
return;
|
||||
|
||||
@@ -16,17 +16,12 @@
|
||||
<div class="flex flex-row justify-around content-start items-start sm:max-lg:flex-col">
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-select formControlName="period">
|
||||
<mat-option *ngFor="let p of periods" [value]="p">
|
||||
{{ p.validFrom }} to {{ p.validTill }}
|
||||
</mat-option>
|
||||
<mat-option *ngFor="let p of periods" [value]="p"> {{ p.validFrom }} to {{ p.validTill }} </mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-label>Product Type</mat-label>
|
||||
<mat-select
|
||||
formControlName="productGroup"
|
||||
(selectionChange)="filterProductGroup($event.value)"
|
||||
>
|
||||
<mat-select formControlName="productGroup" (selectionChange)="filterProductGroup($event.value)">
|
||||
<mat-option>-- All Products --</mat-option>
|
||||
<mat-option *ngFor="let mc of productGroups" [value]="mc.id">
|
||||
{{ mc.name }}
|
||||
@@ -65,13 +60,7 @@
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="0"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250]"
|
||||
>
|
||||
<mat-paginator #paginator [length]="0" [pageIndex]="0" [pageSize]="50" [pageSizeOptions]="[25, 50, 100, 250]">
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@@ -54,20 +54,13 @@ export class RecipeListComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource = new RecipeListDatasource(
|
||||
this.productGroupFilter,
|
||||
this.data,
|
||||
this.paginator,
|
||||
this.sort,
|
||||
);
|
||||
this.dataSource = new RecipeListDatasource(this.productGroupFilter, this.data, this.paginator, this.sort);
|
||||
// this.dataSource = new RecipeListDatasource(this.validFromFilter, this.validTillFilter, this.productGroupFilter, this.data);
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Recipe[]; productGroups: ProductGroup[]; periods: Period[] };
|
||||
this.productGroups = data.productGroups;
|
||||
this.periods = data.periods;
|
||||
const period =
|
||||
this.periods.find((x) => x.id === this.route.snapshot.queryParamMap.get('p')) ||
|
||||
this.periods[0];
|
||||
const period = this.periods.find((x) => x.id === this.route.snapshot.queryParamMap.get('p')) || this.periods[0];
|
||||
|
||||
this.form.setValue({
|
||||
period: period,
|
||||
|
||||
@@ -16,8 +16,7 @@ const recipeRoutes: Routes = [
|
||||
path: '',
|
||||
component: RecipeListComponent,
|
||||
canActivate: [
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
|
||||
inject(AuthGuard).canActivate(route, state),
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
|
||||
],
|
||||
data: {
|
||||
permission: 'Recipes',
|
||||
@@ -33,8 +32,7 @@ const recipeRoutes: Routes = [
|
||||
path: 'new',
|
||||
component: RecipeDetailComponent,
|
||||
canActivate: [
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
|
||||
inject(AuthGuard).canActivate(route, state),
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
|
||||
],
|
||||
data: {
|
||||
permission: 'Recipes',
|
||||
@@ -48,8 +46,7 @@ const recipeRoutes: Routes = [
|
||||
path: ':id',
|
||||
component: RecipeDetailComponent,
|
||||
canActivate: [
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
|
||||
inject(AuthGuard).canActivate(route, state),
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
|
||||
],
|
||||
data: {
|
||||
permission: 'Recipes',
|
||||
|
||||
Reference in New Issue
Block a user