Hierarchy
- ProductionSchedule
Methods
calcDate
-
The method calculates a date inside the working time interval.
The date is calculated based on the specified date and duration. For example, you can calculate the date within the work schedule 14 hours after a process starts:
const workingTime = await System. productionSchedule.calcDate(Context.data.__createdAt, new Duration(14, 'hours'));
Important: the
time
parameter has to be divisible by minutes.Parameters
-
from: TDatetime
Start date and time used for calculation.
-
time: number | TDuration
Time period in hours or as a TDuration value.
Returns Promise<TDatetime>
-
deleteSpecialDays
-
Delete exceptions in the business calendar.
Example of deleting short days and public holidays:
await System.productionSchedule.deleteSpecialDays([ new TDate(2023, 12, 31), new TDate(2023, 12, 30), ]);
Parameters
-
dates: TDate[]
Dates of the deleted short days and public holidays.
Returns Promise<void>
-
getGeneralSettings
-
The method returns the general settings of the business calendar.
General settings of the Business Calendar include work schedule and non- working days of the week.
const generalSettings = await System.productionSchedule.getGeneralSettings();
Returns Promise<ProductionScheduleGeneralSettings>
getSpecialDays
-
The method gets short days and public holidays from the business calendar.
Sort days and public holidays are returned for a certain period specified
in the method's arguemnts:Parameters
-
from: TDatetime
Start of the period.
-
to: TDatetime
End of the period.
const fromDate = Context.data.__createdAt; const toDate = Context.data.request_deadline const specialDays = await System.productionSchedule.getSpecialDays(fromDate, toDate);
Returns Promise<ProductionScheduleSpecialDay[]>
-
getWorkingTime
-
The method is used to get the duration of working time within a specified period.
The duration of working time is returned for the period specified in the method’s arguemnts:
Parameters
-
from: TDatetime
Start of the period.
-
to: TDatetime
End of the period.
const fromDatetime = Context.data. report_start; const toDatetime = Context.data.report_end; const reportedWorkingTime = await System.productionSchedule.getWorkingTime( fromDatetime, toDatetime); const weeklyHours = new Duration(40, 'hours'); if (workingTime.hours > eightHours.hours) { Context.data.notification = 'The specified time exceeds the working hours'; };
Returns Promise<TDuration>
-
saveGeneralSettings
-
The method allows changing the general settings of the business calendar.
Example of editing the settings:
const settings = await System.productionSchedule.getGeneralSettings(); settings.weekends = { monday: false, tuesday: false, wednesday: false, thursday: false, friday: false, saturday: true, // Saturday is a non- working day sunday: true, // Sunday is a non-working day } await System.productionSchedule.saveGeneralSettings(settings);
Parameters
-
settings: ProductionScheduleGeneralSettings
An object containing the edited settings.
Returns Promise<void>
-
saveSpecialDays
-
Create or edit exceptions in the business calendar.
Example of creating short days and public holidays:
await System.productionSchedule.saveSpecialDays([ { date: new TDate(2023, 12, 30), holiday: false, from: 16 * 60 * 60, // From 4 pm to: 18 * 60 * 60, // To 6 pm }, { date: new TDate(2023, 12, 31), holiday: true, // Holiday from: 0, to: 0, }, ]);
Parameters
-
specialDays: ProductionScheduleSpecialDay[]
Saved short days and public holidays.
Returns Promise<void>
-
Business calendar object
Used to get the settings of the business calendar, such as: