Used to get the settings of the business calendar, such as:

  • Working hours and lunch time
  • Non-working days
  • Short days and public holidays

Hierarchy

  • ProductionSchedule

Properties

Readonly specialCalendars

specialCalendars: SpecialCalendars

Object for working with calendars of exceptions.

Readonly workCalendars

workCalendars: WorkCalendars

Object for working with business calendars.

Methods

calcDate

  • The method calculates a date inside the working time interval.

    The date is calculated from the specified date and with the specified duration. If a user is provided, the calculation will use the business calendar associated with that user. Otherwise, the default calendar specified for the company as a whole will be used. For example, you can calculate date within working hours will be 14 hours after the process start date:

    const workingTime = await System.productionSchedule. calcDate(Context.data.__createdAt, new Duration(14, 'hours'));
    

    Important: the time parameter must be a multiple of minutes. The result is an object of the TDatetime type, with the same time zone as the input parameter from.

    Parameters

    Returns Promise<TDatetime>

deleteSpecialDays

  • deleteSpecialDays(dates: TDate[]): Promise<void>
  • Delete exceptions in the default 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

    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

    Returns Promise<ProductionScheduleSpecialDay[]>

getWorkingTime

  • The method is used to get the duration of working time within a specified period.

    The working hours duration is returned for the period passed in the method’ s arguments. If a user is provided, the calculation will use the business calendar associated with that user. Otherwise, the default calendar specified for the company as a whole will be used.

    Parameters

    Returns Promise<TDuration>

saveGeneralSettings

  • The method allows you to modify the general settings of the default business calendar, that is, the calendar specified in the company settings.

    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

    Returns Promise<void>

saveSpecialDays

  • Create or edit exceptions in the default 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

    Returns Promise<void>