Moved from moment to luxon.

Report Printing is not a post not a get.
This commit is contained in:
2026-08-31 04:19:05 +00:00
parent e90c80999e
commit d90c1cb563
44 changed files with 677 additions and 650 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import {
provideZonelessChangeDetection,
} from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { LuxonDateAdapter } from '@angular/material-luxon-adapter';
import { MatButtonModule } from '@angular/material/button';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
import { MatDialogModule } from '@angular/material/dialog';
@@ -71,7 +71,7 @@ export const appConfig: ApplicationConfig = {
}),
withComponentInputBinding(),
),
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: DateAdapter, useClass: LuxonDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: dateFormat },
{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 3000 } },
provideZonelessChangeDetection(),
+8 -8
View File
@@ -6,15 +6,15 @@ export const environment = {
export const dateFormat = {
parse: {
dateInput: 'DD-MMM-YYYY',
timeInput: 'hh:mm A',
dateInput: 'dd-MMM-yyyy',
timeInput: 'hh:mm a',
},
display: {
dateInput: 'DD-MMM-YYYY',
timeInput: 'hh:mm A',
timeOptionLabel: 'hh:mm A',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'DD-MMM-YYYY',
monthYearA11yLabel: 'MMM YYYY',
dateInput: 'dd-MMM-yyyy',
timeInput: 'hh:mm a',
timeOptionLabel: 'hh:mm a',
monthYearLabel: 'MMM yyyy',
dateA11yLabel: 'dd-MMM-yyyy',
monthYearA11yLabel: 'MMM yyyy',
},
};
@@ -10,7 +10,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { SaleCategoryService } from '../sale-category/sale-category.service';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
@@ -21,8 +21,8 @@ import { BeerSaleReport } from './beer-sale-report';
import { BeerSaleReportService } from './beer-sale-report.service';
export interface BeerSaleReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
saleCategory: string;
regular: boolean;
happy: boolean;
@@ -81,8 +81,8 @@ export class BeerSaleReportComponent {
computation: (info): BeerSaleReportFormData => {
if (info) {
return {
startDate: moment(info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(info.finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(info.startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(info.finishDate, 'dd-MMM-yyyy'),
saleCategory: info.saleCategory?.id ?? '',
regular: info.regular,
happy: info.happy,
@@ -91,8 +91,8 @@ export class BeerSaleReportComponent {
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
saleCategory: '',
regular: true,
happy: true,
@@ -131,8 +131,8 @@ export class BeerSaleReportComponent {
const formModel = this.formModel();
return new BeerSaleReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
saleCategory: this.saleCategories().find((sc) => sc.id === formModel.saleCategory),
regular: formModel.regular,
happy: formModel.happy,
@@ -8,7 +8,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
import { LocalTimePipe } from '../shared/local-time.pipe';
@@ -18,8 +18,8 @@ import { BillSettlementReport } from './bill-settlement-report';
import { BillSettlementReportService } from './bill-settlement-report.service';
export interface BillSettlementReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
}
@Component({
@@ -56,13 +56,13 @@ export class BillSettlementReportComponent {
computation: (infoVal): BillSettlementReportFormData => {
if (infoVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
};
},
});
@@ -86,8 +86,8 @@ export class BillSettlementReportComponent {
const formModel = this.formModel();
return new BillSettlementReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
}
@@ -11,7 +11,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { User } from '../core/user';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
@@ -21,8 +21,8 @@ import { CashierReport } from './cashier-report';
import { CashierReportService } from './cashier-report.service';
export interface CashierReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
cashier: string | null;
}
@@ -67,13 +67,13 @@ export class CashierReportComponent {
if (infoVal) {
return {
cashier: this.info().cashier.id ?? '',
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
cashier: null,
};
},
@@ -115,8 +115,8 @@ export class CashierReportComponent {
return new CashierReport({
cashier: new User({ id: formModel.cashier ?? undefined }),
cashiers: this.info().cashiers,
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
}
@@ -66,7 +66,7 @@ export class CashierReportService {
options.params = options.params.set('f', finishDate);
}
return this.http
.get<boolean>(printUrl, options)
.post<boolean>(printUrl, null, options)
.pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable<boolean>;
}
}
@@ -9,7 +9,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
import { SkeletonLoaderComponent } from '../shared/skeleton-loader/skeleton-loader.component';
@@ -18,8 +18,8 @@ import { DiscountReport } from './discount-report';
import { DiscountReportService } from './discount-report.service';
export interface DiscountReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
}
@Component({
@@ -56,13 +56,13 @@ export class DiscountReportComponent {
computation: (infoVal): DiscountReportFormData => {
if (infoVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
};
},
});
@@ -86,8 +86,8 @@ export class DiscountReportComponent {
const formModel = this.formModel();
return new DiscountReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
}
@@ -44,7 +44,7 @@ export class DiscountReportService {
options.params = options.params.set('f', finishDate);
}
return this.http
.get<boolean>(printUrl, options)
.post<boolean>(printUrl, null, options)
.pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable<boolean>;
}
}
@@ -10,7 +10,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTimepickerModule } from '@angular/material/timepicker';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { Customer } from '../../core/customer';
import { CustomerService } from '../../customers/customer.service';
@@ -26,8 +26,8 @@ export interface GuestBookDetailFormData {
pax: number;
address: string;
notes: string;
date: Date;
time: Date;
date: DateTime;
time: DateTime;
}
@Component({
@@ -73,8 +73,8 @@ export class GuestBookDetailComponent {
pax: itemVal.pax,
address: itemVal.address ?? '',
notes: itemVal.notes ?? '',
date: dt ? new Date(dt) : new Date(),
time: dt ? new Date(dt) : new Date(),
date: dt ? DateTime.fromJSDate(new Date(dt)) : DateTime.now(),
time: dt ? DateTime.fromJSDate(new Date(dt)) : DateTime.now(),
};
}
return {
@@ -83,8 +83,8 @@ export class GuestBookDetailComponent {
pax: 0,
address: '',
notes: '',
date: new Date(),
time: new Date(),
date: DateTime.now(),
time: DateTime.now(),
};
},
});
@@ -172,15 +172,15 @@ export class GuestBookDetailComponent {
item.pax = formModel.pax ?? 0;
item.address = formModel.address;
item.notes = formModel.notes;
const timeStr = formModel.time ? moment(formModel.time).format('HH:mm') : '00:00';
const timeStr = formModel.time ? formModel.time.toFormat('HH:mm') : '00:00';
item.type = item.type || this.t() || 'walk_in';
if (item.type === 'booking') {
item.bookingDate = moment(formModel.date).format('DD-MMM-YYYY') + ' ' + timeStr;
item.bookingDate = formModel.date.toFormat('dd-MMM-yyyy') + ' ' + timeStr;
} else {
const existingDate = item.arrivalDate
? (item.arrivalDate as string).substring(0, 12)
: moment(formModel.date).format('DD-MMM-YYYY ');
: formModel.date.toFormat('dd-MMM-yyyy ');
item.arrivalDate = existingDate + timeStr;
}
@@ -7,7 +7,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTableModule } from '@angular/material/table';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { ErrorStateComponent } from '../../shared/error-state/error-state.component';
import { LocalTimePipe } from '../../shared/local-time.pipe';
@@ -15,7 +15,7 @@ import { SkeletonLoaderComponent } from '../../shared/skeleton-loader/skeleton-l
import { GuestBookService } from '../guest-book.service';
export interface GuestBookListFormData {
date: Date;
date: DateTime;
}
@Component({
@@ -42,13 +42,13 @@ export class GuestBookListComponent {
private router = inject(Router);
private ser = inject(GuestBookService);
date = input(new Date(), {
transform: (v: string | null | undefined): Date => {
date = input(DateTime.now(), {
transform: (v: string | null | undefined): DateTime => {
if (v) {
const parsed = moment(v, 'DD-MMM-YYYY', true);
if (parsed.isValid()) return parsed.toDate();
const parsed = DateTime.fromFormat(v, 'dd-MMM-yyyy');
if (parsed.isValid) return parsed;
}
return new Date();
return DateTime.now();
},
});
@@ -63,7 +63,7 @@ export class GuestBookListComponent {
displayedColumns = ['sno', 'name', 'phone', 'pax', 'date', 'action'];
dateSignal = computed(() => moment(this.formModel().date).format('DD-MMM-YYYY'));
dateSignal = computed(() => this.formModel().date.toFormat('dd-MMM-yyyy'));
listResource = this.ser.list(this.dateSignal);
dataSource = computed(() => this.listResource.value()?.list ?? []);
@@ -11,8 +11,8 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import { DateTime } from 'luxon';
import { equal, larger, largerEq, smaller, smallerEq } from 'mathjs';
import moment from 'moment';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
import { SkeletonLoaderComponent } from '../shared/skeleton-loader/skeleton-loader.component';
@@ -22,8 +22,8 @@ import { MenuEngineeringReportItem } from './menu-engineering-report-item';
import { MenuEngineeringReportService } from './menu-engineering-report.service';
export interface MenuEngineeringReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
filter: string;
}
@@ -64,14 +64,14 @@ export class MenuEngineeringReportComponent {
computation: (infoVal): MenuEngineeringReportFormData => {
if (infoVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
filter: '',
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
filter: '',
};
},
@@ -143,8 +143,8 @@ export class MenuEngineeringReportComponent {
const formModel = this.formModel();
return new MenuEngineeringReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
}
@@ -44,7 +44,7 @@ export class MenuEngineeringReportService {
options.params = options.params.set('f', finishDate);
}
return this.http
.get<boolean>(printUrl, options)
.post<boolean>(printUrl, null, options)
.pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable<boolean>;
}
}
@@ -10,7 +10,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { SectionService } from '../sections/section.service';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
@@ -20,8 +20,8 @@ import { ProductSaleReport } from './product-sale-report';
import { ProductSaleReportService } from './product-sale-report.service';
export interface ProductSaleReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
section: string | null;
}
@@ -66,14 +66,14 @@ export class ProductSaleReportComponent {
computation: (sectionsVal): ProductSaleReportFormData => {
if (sectionsVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
section: this.info().sectionId || null,
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
section: null,
};
},
@@ -102,8 +102,8 @@ export class ProductSaleReportComponent {
const formModel = this.formModel();
const data = new ProductSaleReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
if (formModel.section) {
data.sectionId = formModel.section;
@@ -52,7 +52,7 @@ export class ProductSaleReportService {
options.params = options.params.set('section', section);
}
return this.http
.get<boolean>(printUrl, options)
.post<boolean>(printUrl, null, options)
.pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable<boolean>;
}
}
@@ -7,7 +7,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
import { SkeletonLoaderComponent } from '../shared/skeleton-loader/skeleton-loader.component';
@@ -16,8 +16,8 @@ import { ProductUpdatesReport } from './product-updates-report';
import { ProductUpdatesReportService } from './product-updates-report.service';
export interface ProductUpdatesReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
}
@Component({
@@ -52,13 +52,13 @@ export class ProductUpdatesReportComponent {
computation: (infoVal): ProductUpdatesReportFormData => {
if (infoVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
};
},
});
@@ -82,8 +82,8 @@ export class ProductUpdatesReportComponent {
const formModel = this.formModel();
return new ProductUpdatesReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
}
@@ -11,7 +11,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { SectionService } from '../sections/section.service';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
@@ -21,8 +21,8 @@ import { SaleReport } from './sale-report';
import { SaleReportService } from './sale-report.service';
export interface SaleReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
section: string | null;
}
@@ -67,14 +67,14 @@ export class SaleReportComponent {
computation: (sectionsVal): SaleReportFormData => {
if (sectionsVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
section: this.info().sectionId || null,
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
section: null,
};
},
@@ -102,8 +102,8 @@ export class SaleReportComponent {
getInfo(): SaleReport {
const formModel = this.formModel();
const data = new SaleReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
if (formModel.section) {
data.sectionId = formModel.section;
@@ -52,7 +52,7 @@ export class SaleReportService {
options.params = options.params.set('section', section);
}
return this.http
.get<boolean>(printUrl, options)
.post<boolean>(printUrl, null, options)
.pipe(catchError(this.log.handleError(serviceName, 'print'))) as Observable<boolean>;
}
}
@@ -8,7 +8,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTabsModule } from '@angular/material/tabs';
import moment from 'moment';
import { DateTime } from 'luxon';
import { environment } from '../app.environment';
import { AuthService } from '../auth/auth.service';
@@ -68,8 +68,8 @@ export class SettingsComponent {
runMaintenance() {
const formModel = this.formModel();
const startDate = moment(formModel.startDate).format('DD-MMM-YYYY');
const finishDate = moment(formModel.finishDate).format('DD-MMM-YYYY');
const startDate = DateTime.fromJSDate(formModel.startDate).toFormat('dd-MMM-yyyy');
const finishDate = DateTime.fromJSDate(formModel.finishDate).toFormat('dd-MMM-yyyy');
if (!this.beerFile || !this.saleFile) {
this.snackBar.open('Please choose both files first!', 'Danger');
+5 -5
View File
@@ -1,5 +1,5 @@
import { Pipe, PipeTransform } from '@angular/core';
import moment from 'moment';
import { DateTime } from 'luxon';
@Pipe({
name: 'localTime',
@@ -11,10 +11,10 @@ export class LocalTimePipe implements PipeTransform {
return '';
}
if (value.length === 5) {
return moment(value, 'HH:mm').subtract(new Date().getTimezoneOffset(), 'minutes').format('HH:mm');
return DateTime.fromFormat(value, 'HH:mm').minus({ minutes: new Date().getTimezoneOffset() }).toFormat('HH:mm');
}
return moment(value, 'DD-MMM-YYYY HH:mm')
.subtract(new Date().getTimezoneOffset(), 'minutes')
.format('DD-MMM-YYYY HH:mm');
return DateTime.fromFormat(value, 'dd-MMM-yyyy HH:mm')
.minus({ minutes: new Date().getTimezoneOffset() })
.toFormat('dd-MMM-yyyy HH:mm');
}
}
@@ -8,7 +8,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
import { SkeletonLoaderComponent } from '../shared/skeleton-loader/skeleton-loader.component';
@@ -17,8 +17,8 @@ import { TaxReport } from './tax-report';
import { TaxReportService } from './tax-report.service';
export interface TaxReportFormData {
startDate: Date;
finishDate: Date;
startDate: DateTime;
finishDate: DateTime;
}
@Component({
@@ -55,13 +55,13 @@ export class TaxReportComponent {
computation: (infoVal): TaxReportFormData => {
if (infoVal) {
return {
startDate: moment(this.info().startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info().finishDate, 'DD-MMM-YYYY').toDate(),
startDate: DateTime.fromFormat(this.info().startDate, 'dd-MMM-yyyy'),
finishDate: DateTime.fromFormat(this.info().finishDate, 'dd-MMM-yyyy'),
};
}
return {
startDate: new Date(),
finishDate: new Date(),
startDate: DateTime.now(),
finishDate: DateTime.now(),
};
},
});
@@ -85,8 +85,8 @@ export class TaxReportComponent {
const formModel = this.formModel();
return new TaxReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
startDate: formModel.startDate.toFormat('dd-MMM-yyyy'),
finishDate: formModel.finishDate.toFormat('dd-MMM-yyyy'),
});
}
@@ -14,7 +14,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { MenuCategory } from '../../core/menu-category';
import { SaleCategory } from '../../core/sale-category';
@@ -30,8 +30,8 @@ export interface TemporalProductFormData {
name: string;
fractionUnits: string;
saleCategory: string;
validFrom: Date | null;
validTill: Date | null;
validFrom: DateTime | null;
validTill: DateTime | null;
}
export interface TemporalSkuFormData {
@@ -43,8 +43,8 @@ export interface TemporalSkuFormData {
menuCategory: string;
hasHappyHour: boolean;
isNotAvailable: boolean;
validFrom: Date | null;
validTill: Date | null;
validFrom: DateTime | null;
validTill: DateTime | null;
}
@Component({
@@ -101,8 +101,8 @@ export class TemporalProductDetailComponent {
name: '',
fractionUnits: '',
saleCategory: '',
validFrom: null as Date | null,
validTill: null as Date | null,
validFrom: null as DateTime | null,
validTill: null as DateTime | null,
};
}
return {
@@ -130,8 +130,8 @@ export class TemporalProductDetailComponent {
menuCategory: '',
hasHappyHour: false,
isNotAvailable: false,
validFrom: null as Date | null,
validTill: null as Date | null,
validFrom: null as DateTime | null,
validTill: null as DateTime | null,
};
}
return {
@@ -151,12 +151,12 @@ export class TemporalProductDetailComponent {
skuForm = form(this.skuFormModel);
private parseDateOrNull(d: string | null | undefined): Date | null {
return !d ? null : moment(d, 'DD-MMM-YYYY').toDate();
private parseDateOrNull(d: string | null | undefined): DateTime | null {
return !d ? null : DateTime.fromFormat(d, 'dd-MMM-yyyy');
}
private formatDateOrNull(d: Date | null | undefined): string | null {
return !d ? null : moment(d).format('DD-MMM-YYYY');
private formatDateOrNull(d: DateTime | null | undefined): string | null {
return !d ? null : d.toFormat('dd-MMM-yyyy');
}
constructor() {
@@ -11,7 +11,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import moment from 'moment';
import { DateTime } from 'luxon';
import { MenuCategoryService } from '../menu-category/menu-category.service';
import { ErrorStateComponent } from '../shared/error-state/error-state.component';
@@ -21,7 +21,7 @@ import { UpdateProductPrices } from './update-product-prices';
import { UpdateProductPricesService } from './update-product-prices.service';
export interface UpdateProductPricesFormData {
date: Date;
date: DateTime;
menuCategory: string;
prices: { newPrice: number | null }[];
}
@@ -64,7 +64,7 @@ export class UpdateProductPricesComponent {
source: () => this.info(),
computation: (info): UpdateProductPricesFormData => {
return {
date: info.date ? moment(info.date, 'DD-MMM-YYYY').toDate() : new Date(),
date: info.date ? DateTime.fromFormat(info.date, 'dd-MMM-yyyy') : DateTime.now(),
menuCategory: info.menuCategoryId !== undefined ? info.menuCategoryId : '',
prices: info.items.map((x) => ({ newPrice: x.newPrice })),
};
@@ -99,7 +99,7 @@ export class UpdateProductPricesComponent {
});
return {
date: moment(formModel.date).format('DD-MMM-YYYY'),
date: formModel.date.toFormat('dd-MMM-yyyy'),
menuCategoryId: formModel.menuCategory,
items: [...info.items],
};