diff --git a/barker/barker/routers/reports/beer_sale_report.py b/barker/barker/routers/reports/beer_sale_report.py index b6349f7c..c1f83efb 100644 --- a/barker/barker/routers/reports/beer_sale_report.py +++ b/barker/barker/routers/reports/beer_sale_report.py @@ -18,7 +18,7 @@ from ...models.stock_keeping_unit import StockKeepingUnit from ...models.voucher import Voucher from ...models.voucher_type import VoucherType from ...schemas.beer_consumption_report import BeerConsumptionReport, BeerConsumptionReportItem -from ...schemas.menu_category import MenuCategoryLink +from ...schemas.sale_category import SaleCategoryLink from ...schemas.user_token import UserToken from .. import _pv_onclause, _sv_onclause from . import check_audit_permission, report_finish_date, report_start_date @@ -31,7 +31,7 @@ router = APIRouter() def beer_consumption( start_date: date = Depends(report_start_date), finish_date: date = Depends(report_finish_date), - m: uuid.UUID | None = None, # Menu Category + sc: uuid.UUID | None = None, # Sale Category r: bool | None = True, h: bool | None = True, st: bool | None = True, @@ -51,7 +51,6 @@ def beer_consumption( .join(Kot.inventories) .join(Inventory.sku) .join(SkuVersion, onclause=sku_version_onclause) - .join(SkuVersion.menu_category) .join(StockKeepingUnit.product) .join(ProductVersion, onclause=product_version_onclause) .where( @@ -60,8 +59,8 @@ def beer_consumption( day <= finish_date, ) ) - if m: - query = query.where(SkuVersion.menu_category_id == m) + if sc: + query = query.where(ProductVersion.sale_category_id == sc) if h is False and r is not False: query = query.where(Inventory.is_happy_hour == h) if r is False and h is not False: @@ -96,7 +95,7 @@ def beer_consumption( return BeerConsumptionReport( start_date=start_date, finish_date=finish_date, - menu_category=MenuCategoryLink(id_=m, name="", skus=[]) if m else None, + sale_category=SaleCategoryLink(id_=sc, name="") if sc else None, regular=r, happy=h, staff=st, diff --git a/barker/barker/schemas/beer_consumption_report.py b/barker/barker/schemas/beer_consumption_report.py index b4083ef4..8dcbb4b1 100644 --- a/barker/barker/schemas/beer_consumption_report.py +++ b/barker/barker/schemas/beer_consumption_report.py @@ -13,7 +13,7 @@ from pydantic import ( ) from . import Daf, to_camel -from .menu_category import MenuCategoryLink +from .sale_category import SaleCategoryLink class BeerConsumptionReportItem(BaseModel): @@ -57,7 +57,7 @@ class BeerConsumptionReportItem(BaseModel): class BeerConsumptionReport(BaseModel): start_date: date finish_date: date - menu_category: MenuCategoryLink | None + sale_category: SaleCategoryLink | None regular: bool | None happy: bool | None staff: bool | None diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.component.html b/bookie/src/app/beer-sale-report/beer-sale-report.component.html index aa8e90eb..7254bee2 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.component.html +++ b/bookie/src/app/beer-sale-report/beer-sale-report.component.html @@ -32,11 +32,11 @@ - Menu Category - - @for (mc of menuCategories; track mc) { - - {{ mc.name }} + Sale Category + + @for (sc of saleCategories; track sc) { + + {{ sc.name }} } diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.component.ts b/bookie/src/app/beer-sale-report/beer-sale-report.component.ts index d20da2c4..2681be9b 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.component.ts +++ b/bookie/src/app/beer-sale-report/beer-sale-report.component.ts @@ -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; finishDate: FormControl; - menuCategory: FormControl; + saleCategory: FormControl; regular: FormControl; happy: FormControl; staff: FormControl; @@ -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(true, { nonNullable: true }), happy: new FormControl(true, { nonNullable: true }), staff: new FormControl(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, diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.resolver.ts b/bookie/src/app/beer-sale-report/beer-sale-report.resolver.ts index 57c5388f..9efaf541 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.resolver.ts +++ b/bookie/src/app/beer-sale-report/beer-sale-report.resolver.ts @@ -7,10 +7,10 @@ import { BeerSaleReportService } from './beer-sale-report.service'; export const beerSaleReportResolver: ResolveFn = (route) => { const startDate = route.queryParamMap.get('startDate') ?? null; const finishDate = route.queryParamMap.get('finishDate') ?? null; - const menuCategory = route.queryParamMap.get('menuCategory') ?? null; + const saleCategory = route.queryParamMap.get('saleCategory') ?? null; const regular = route.queryParamMap.get('regular') !== 'false'; const happy = route.queryParamMap.get('happy') !== 'false'; const staff = route.queryParamMap.get('staff') !== 'false'; const nc = route.queryParamMap.get('nc') !== 'false'; - return inject(BeerSaleReportService).get(startDate, finishDate, menuCategory, regular, happy, staff, nc); + return inject(BeerSaleReportService).get(startDate, finishDate, saleCategory, regular, happy, staff, nc); }; diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.routes.ts b/bookie/src/app/beer-sale-report/beer-sale-report.routes.ts index 82656a5c..885b001b 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.routes.ts +++ b/bookie/src/app/beer-sale-report/beer-sale-report.routes.ts @@ -1,7 +1,7 @@ import { Routes } from '@angular/router'; import { authGuard } from '../auth/auth-guard.service'; -import { menuCategoryListResolver } from '../menu-category/menu-category-list.resolver'; +import { saleCategoryListResolver } from '../sale-category/sale-category-list.resolver'; import { BeerSaleReportComponent } from './beer-sale-report.component'; import { beerSaleReportResolver } from './beer-sale-report.resolver'; @@ -15,7 +15,7 @@ export const routes: Routes = [ }, resolve: { info: beerSaleReportResolver, - menuCategories: menuCategoryListResolver, + saleCategories: saleCategoryListResolver, }, runGuardsAndResolvers: 'always', }, diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.service.ts b/bookie/src/app/beer-sale-report/beer-sale-report.service.ts index 3628ed4a..f1e1df33 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.service.ts +++ b/bookie/src/app/beer-sale-report/beer-sale-report.service.ts @@ -19,7 +19,7 @@ export class BeerSaleReportService { get( startDate: string | null, finishDate: string | null, - menuCategory: string | null, + saleCategory: string | null, regular: boolean, happy: boolean, staff: boolean, @@ -32,8 +32,8 @@ export class BeerSaleReportService { if (finishDate !== null) { options.params = options.params.set('f', finishDate); } - if (menuCategory != null) { - options.params = options.params.set('m', menuCategory); + if (saleCategory != null) { + options.params = options.params.set('sc', saleCategory); } options.params = options.params.set('r', regular); options.params = options.params.set('h', happy); diff --git a/bookie/src/app/beer-sale-report/beer-sale-report.ts b/bookie/src/app/beer-sale-report/beer-sale-report.ts index 5be04daa..767da769 100644 --- a/bookie/src/app/beer-sale-report/beer-sale-report.ts +++ b/bookie/src/app/beer-sale-report/beer-sale-report.ts @@ -1,10 +1,10 @@ -import { MenuCategory } from '../core/menu-category'; +import { SaleCategory } from '../core/sale-category'; import { BeerSaleReportItem } from './beer-sale-report-item'; export class BeerSaleReport { startDate: string; finishDate: string; - menuCategory: MenuCategory; + saleCategory: SaleCategory; regular: boolean; happy: boolean; staff: boolean; @@ -15,7 +15,7 @@ export class BeerSaleReport { public constructor(init?: Partial) { this.startDate = ''; this.finishDate = ''; - this.menuCategory = new MenuCategory(); + this.saleCategory = new SaleCategory(); this.regular = true; this.happy = true; this.staff = true;