# MAYA OS ENTERPRISE — DUAL CALENDAR (BS + AD) ARCHITECTURE

## 1. Single Central Calendar Engine (`apps.localization`)

All BS <-> AD conversions across Accounting, HR/Payroll, Procurement, Treasury, Projects, Fleet, Reporting, and Print Templates run through `apps.localization.bs_calendar` (`bs_to_ad`, `ad_to_bs`, `format_dual_date`) backed by verified Nepal BS month-length tables stored and versioned in `CalendarDataVersion`.

- **Storage Rule**: Every database date column stores standard timezone-aware `AD` (`DATE` / `DATETIME` UTC with `Asia/Kathmandu` localization). Companion formatted BS strings (`YYYY-MM-DD BS`) and Fiscal Periods derive deterministically without storing drifting manual dates.
- **Global & Scoped Settings**: Managed in `CalendarSetting` via `SYSTEM CONFIGURATION -> DATE, TIME & CALENDAR STUDIO` (`/api/v1/admin/calendar/`) supporting `BS_AD_BOTH`, `BS_ONLY`, `AD_ONLY`, `ENGLISH` vs `NEPALI_DEVANAGARI` numerals, and `Company -> Branch -> Module -> User` inheritance.

## 2. Public Calendar API Endpoints

| Endpoint | Purpose |
| :--- | :--- |
| `GET /api/v1/calendar/settings/effective/` | Resolved display setting (`mode`, `primary`, `digits`, `timezone`) for current workspace/user |
| `GET /api/v1/calendar/convert/` | Bidirectional conversion (`?bs=2083-04-01` or `?ad=2026-07-17`) |
| `GET /api/v1/calendar/month-grid/` | BS or AD month calendar matrix for `DualDatePicker` & `DualDateRangePicker` |
| `GET /api/v1/calendar/nepal-fiscal-year/` | Nepal Fiscal Year boundary dates (`1 Shrawan` to `Ashadh End`) |

