Fix: Recipe now checks for recursion (hopefully)

Feature: Recipe prices are now calculated based on periods and saved
Feature: The recipe export excel now has prices
This commit is contained in:
2023-08-12 08:29:21 +05:30
parent 72843feaac
commit 1705d58dbc
10 changed files with 321 additions and 73 deletions

View File

@ -2,7 +2,7 @@
<mat-card-header>
<mat-card-title-group>
<mat-card-title>Recipes</mat-card-title>
<a mat-icon-button href="{{ excelLink() }}">
<a mat-icon-button [href]="'/api/recipes/xlsx?t=' + period.id">
<mat-icon>save_alt</mat-icon>
</a>
<a mat-button [routerLink]="['/recipes', 'new']">

View File

@ -31,6 +31,7 @@ export class RecipeListComponent implements OnInit {
list: Recipe[] = [];
data: BehaviorSubject<Recipe[]> = new BehaviorSubject<Recipe[]>([]);
dataSource: RecipeListDatasource = new RecipeListDatasource(this.productGroupFilter, this.data);
period: Period = new Period();
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'yield', 'date', 'source'];
@ -44,13 +45,14 @@ export class RecipeListComponent implements OnInit {
productGroup: new FormControl<ProductGroup | string | null>(null),
});
// Listen to Payment Account Change
this.form.controls.period.valueChanges.subscribe((x) =>
this.form.controls.period.valueChanges.subscribe((x) => {
this.router.navigate([], {
relativeTo: this.route,
queryParams: { p: x.id },
replaceUrl: true,
}),
);
});
this.period = x;
});
}
ngOnInit() {
@ -73,8 +75,4 @@ export class RecipeListComponent implements OnInit {
filterProductGroup(val: string) {
this.productGroupFilter.next(val || '');
}
excelLink() {
return `/api/recipes/xlsx`;
}
}