Feature: Added sale voucher to check sale import.
Chore: Frontend moved from Moment to date-fns and from dd-MMM-yyyy to ISO Date format.
This commit is contained in:
1 parent
7656c7e877
commit
fc3cd00662
102 files changed
+2121
-2103
No files matched your search
@@ -6,8 +6,8 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import moment from 'moment';
|
||||
|
||||
import { endOfMonth, formatIsoDate } from '../core/date-utils';
|
||||
import { EmployeeFunctionsService } from './employee-functions.service';
|
||||
|
||||
@Component({
|
||||
@@ -28,15 +28,15 @@ export class EmployeeFunctionsComponent {
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private ser = inject(EmployeeFunctionsService);
|
||||
|
||||
creditSalaryModel = signal({
|
||||
date: moment().date(moment().daysInMonth()),
|
||||
creditSalaryModel = signal<{ date: Date }>({
|
||||
date: endOfMonth(new Date()),
|
||||
});
|
||||
|
||||
creditSalaryForm = createForm(this.creditSalaryModel);
|
||||
|
||||
attendanceRecordModel = signal({
|
||||
startDate: moment(),
|
||||
finishDate: moment(),
|
||||
attendanceRecordModel = signal<{ startDate: Date; finishDate: Date }>({
|
||||
startDate: new Date(),
|
||||
finishDate: new Date(),
|
||||
});
|
||||
|
||||
attendanceRecordForm = createForm(this.attendanceRecordModel);
|
||||
@@ -44,28 +44,24 @@ export class EmployeeFunctionsComponent {
|
||||
fingerprintFile: File | null = null;
|
||||
|
||||
constructor() {
|
||||
const startDate = moment().date(1);
|
||||
const finishDate = moment().date(startDate.daysInMonth());
|
||||
this.creditSalaryModel.set({ date: finishDate });
|
||||
this.creditSalaryModel.set({ date: endOfMonth(new Date()) });
|
||||
}
|
||||
|
||||
chosenYearHandler(normalizedYear: moment.Moment) {
|
||||
const ctrlValue = moment(this.creditSalaryModel().date);
|
||||
ctrlValue.year(normalizedYear.year());
|
||||
ctrlValue.date(ctrlValue.daysInMonth());
|
||||
this.creditSalaryModel.update((m) => ({ ...m, date: ctrlValue }));
|
||||
chosenYearHandler(normalizedYear: Date) {
|
||||
const current = this.creditSalaryModel().date;
|
||||
const updated = new Date(normalizedYear.getFullYear(), current.getMonth(), 1);
|
||||
this.creditSalaryModel.update((m) => ({ ...m, date: endOfMonth(updated) }));
|
||||
}
|
||||
|
||||
chosenMonthHandler(normlizedMonth: moment.Moment, datepicker: MatDatepicker<moment.Moment>) {
|
||||
const ctrlValue = moment(this.creditSalaryModel().date);
|
||||
ctrlValue.month(normlizedMonth.month());
|
||||
ctrlValue.date(ctrlValue.daysInMonth());
|
||||
this.creditSalaryModel.update((m) => ({ ...m, date: ctrlValue }));
|
||||
chosenMonthHandler(normalizedMonth: Date, datepicker: MatDatepicker<Date>) {
|
||||
const current = this.creditSalaryModel().date;
|
||||
const updated = new Date(current.getFullYear(), normalizedMonth.getMonth(), 1);
|
||||
this.creditSalaryModel.update((m) => ({ ...m, date: endOfMonth(updated) }));
|
||||
datepicker.close();
|
||||
}
|
||||
|
||||
creditSalary() {
|
||||
const date = (this.creditSalaryModel().date ?? moment()).format('DD-MMM-YYYY');
|
||||
const date = formatIsoDate(this.creditSalaryModel().date);
|
||||
if (!date) {
|
||||
this.snackBar.open('Please choose a valid date.', 'Danger');
|
||||
return;
|
||||
@@ -81,20 +77,20 @@ export class EmployeeFunctionsComponent {
|
||||
}
|
||||
|
||||
attendanceRecordUrl() {
|
||||
const startDate = (this.attendanceRecordModel().startDate ?? moment()).format('DD-MMM-YYYY');
|
||||
const finishDate = (this.attendanceRecordModel().finishDate ?? moment()).format('DD-MMM-YYYY');
|
||||
const startDate = formatIsoDate(this.attendanceRecordModel().startDate ?? new Date());
|
||||
const finishDate = formatIsoDate(this.attendanceRecordModel().finishDate ?? new Date());
|
||||
if (!startDate || !finishDate) {
|
||||
// this.snackBar.open('Please choose a start and finish date.', 'Danger');
|
||||
this.snackBar.open('Please choose a start and finish date.', 'Danger');
|
||||
return '';
|
||||
}
|
||||
return `/attendance-report?s=${startDate}&f=${finishDate}`;
|
||||
}
|
||||
|
||||
fingerPrintUrl() {
|
||||
const startDate = (this.attendanceRecordModel().startDate ?? moment()).format('DD-MMM-YYYY');
|
||||
const finishDate = (this.attendanceRecordModel().finishDate ?? moment()).format('DD-MMM-YYYY');
|
||||
const startDate = formatIsoDate(this.attendanceRecordModel().startDate);
|
||||
const finishDate = formatIsoDate(this.attendanceRecordModel().finishDate);
|
||||
if (!startDate || !finishDate) {
|
||||
// this.snackBar.open('Please choose a start and finish date.', 'Danger');
|
||||
this.snackBar.open('Please choose a start and finish date.', 'Danger');
|
||||
return '';
|
||||
}
|
||||
return `/fingerprint-report?s=${startDate}&f=${finishDate}`;
|
||||
|
||||
Reference in new issue
Block a user