Fix: Accidentally used menu category instead of sale category

This commit is contained in:
2026-02-14 06:00:09 +00:00
parent 061dd1310d
commit c9fa83e8ac
8 changed files with 33 additions and 34 deletions
@@ -12,7 +12,7 @@ import { MatTableModule } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';
import moment from 'moment';
import { MenuCategory } from '../core/menu-category';
import { SaleCategory } from '../core/sale-category';
import { ToCsvService } from '../shared/to-csv.service';
import { BeerSaleExportHeaderInterface } from './beer-sale-export-header-interface';
import { BeerSaleReport } from './beer-sale-report';
@@ -40,13 +40,13 @@ export class BeerSaleReportComponent implements OnInit {
private router = inject(Router);
private toCsv = inject(ToCsvService);
menuCategories: MenuCategory[] = [];
saleCategories: SaleCategory[] = [];
info: BeerSaleReport = new BeerSaleReport();
dataSource: BeerSaleReportDataSource = new BeerSaleReportDataSource(this.info.data);
form: FormGroup<{
startDate: FormControl<Date>;
finishDate: FormControl<Date>;
menuCategory: FormControl<string>;
saleCategory: FormControl<string>;
regular: FormControl<boolean>;
happy: FormControl<boolean>;
staff: FormControl<boolean>;
@@ -61,7 +61,7 @@ export class BeerSaleReportComponent implements OnInit {
this.form = new FormGroup({
startDate: new FormControl(new Date(), { nonNullable: true }),
finishDate: new FormControl(new Date(), { nonNullable: true }),
menuCategory: new FormControl('', { nonNullable: true }),
saleCategory: new FormControl('', { nonNullable: true }),
regular: new FormControl<boolean>(true, { nonNullable: true }),
happy: new FormControl<boolean>(true, { nonNullable: true }),
staff: new FormControl<boolean>(true, { nonNullable: true }),
@@ -71,14 +71,14 @@ export class BeerSaleReportComponent implements OnInit {
ngOnInit() {
this.route.data.subscribe((value) => {
const data = value as { info: BeerSaleReport; menuCategories: MenuCategory[] };
const data = value as { info: BeerSaleReport; saleCategories: SaleCategory[] };
this.info = data.info;
this.menuCategories = data.menuCategories;
this.saleCategories = data.saleCategories;
this.displayedColumns = ['date'].concat(this.info.headers);
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
menuCategory: this.info.menuCategory?.id ?? '',
saleCategory: this.info.saleCategory?.id ?? '',
regular: this.info.regular,
happy: this.info.happy,
staff: this.info.staff,
@@ -94,7 +94,7 @@ export class BeerSaleReportComponent implements OnInit {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate,
menuCategory: info.menuCategory?.id ?? '',
saleCategory: info.saleCategory?.id ?? '',
regular: info.regular,
happy: info.happy,
staff: info.staff,
@@ -104,8 +104,8 @@ export class BeerSaleReportComponent implements OnInit {
}
filterOn(id: string) {
const mc = this.menuCategories.find((x) => x.id === id);
this.info.menuCategory = mc ? mc : new MenuCategory({ id });
const sc = this.saleCategories.find((x) => x.id === id);
this.info.saleCategory = sc ? sc : new SaleCategory({ id });
}
getInfo(): BeerSaleReport {
@@ -114,7 +114,7 @@ export class BeerSaleReportComponent implements OnInit {
return new BeerSaleReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
menuCategory: this.info.menuCategory,
saleCategory: this.info.saleCategory,
regular: formModel.regular,
happy: formModel.happy,
staff: formModel.staff,