# Workday (Calendar)

For some business scenarios, it's important to calculate working days for business validation or batch processing, for example to derive a policy effective date N working days after application submission, to control claim processing deadlines and grace periods, or to schedule batch jobs only on working days.

Our platform provides a calendar menu under the path **Global Configuration** > **Calendar**, which helps to set the workdays and holidays. After that, we have our APIs and DSL to fetch the definition and calculate the date difference.

## User Scenario

For anyone who needs to maintain the working calendar, or build business logic (validation, due date calculation, batch scheduling) that depends on working days.

## Calendar View

The calendar page displays a full year with 12 monthly calendars. Users can switch the year to view or maintain other years.

* **Red day** is a holiday.
* **Black day** is a workday.

## Default Working Rule

Dates do not need to be maintained one by one from scratch. The platform applies a default rule: **Monday to Friday are workdays, Saturday and Sunday are holidays**.

Any explicitly maintained date overrides this default, which covers two typical adjustments:

* Marking a Saturday/Sunday as a workday, e.g. a make-up working day.
* Marking a weekday as a holiday, e.g. public holidays.

When a tenant is initialized, around 21 years of working calendar are pre-generated following the default rule; holidays still need to be maintained or imported.

## Update a Date

Users can click the target date, and in the dialog update:

* **Workday**: Y or N.
* **Description**: free text to label the date, e.g. the holiday name such as "Chinese Spring Festival".

Click **Confirm** to save, and the calendar refreshes immediately. Maintaining the calendar requires the **Calendar-Write** permission; users without it can still browse the calendar.

 ![Calendar Update](./image/public_setting/calendar_update.png)

## Import and Export

For cross-environment deployment, users can **Export** the calendar and **Import** it in the target environment. Then it will be updated.

 ![Calendar Export/Import](./image/public_setting/calendar_exportimport.png)

Notes for import/export:

* The export contains **all years** of calendar data, not just the currently displayed year.
* Import is keyed by date: the imported flag and description overwrite the existing setting of the same date, and dates not present before are added.
* A confirmation dialog is displayed before the import starts.

## Bulk Preparation via API

Currently, there is no support for uploading workday data via Excel, and users need to manually choose a tick for the workday or holiday if not matching.

For cases where the initial dataset is extensive, alternatively, users can call the following API to prepare the data:

* POST /platform-busi-config/public/workday/v1/importWorkdays
* POST /platform-busi-config/public/workday/v1/updateWorkdays

Both accept a list of date entries with the workday flag and description, and behave as upsert by date. The changes take effect immediately after import or update.

## Working Day Calculation

The platform provides SDK methods and DSL functions to consume the calendar, which can be used in APIs, rules, and validation logic:

* Check whether a date is a workday.
* Get the Nth working day after (or before) a date, skipping holidays — e.g. the due date 5 working days after submission.
* Count working days between two dates, with flexible boundary options: including both ends, excluding both ends, or including only one end — e.g. to compute the actual processing days of a claim.

## Batch Job Integration

When defining a batch job, users can enable the **Only Executed in WorkDay** option, so the job is only triggered on working days, following the same calendar.

## Notes

* Each calendar date has a single setting; re-importing or re-updating a date overwrites its previous flag and description.
* For dates beyond the maintained range, the default Monday-to-Friday rule applies.
