feat(scheduling): tenant-wide standard due date for tasks and no-SLA tickets #257

Merged
vas2000-work merged 1 commit from feat/PMS-345-standard-due-date into main 2026-06-16 02:23:10 +02:00
Owner

Background

Project tasks have a due_date (NaiveDate) with no defaulting: created without one, they stay open-ended. Tickets get SLA-derived dates (sla_due_date/first_response_due/resolution_due) via calculate_sla_dates, but a ticket matching no SLA returns early with those columns NULL, so it also has no due date.

Goal

Let a tenant set a standard due date that applies whenever an explicit one is missing.

Proposed approach

New tenant setting scheduling/default_due_business_days (integer 0..=365; 0 disables). Applied in two places:

  • projects::service::create_task: when request.due_date is None, fall back to today + N business days.
  • tickets::service::create_ticket: after calculate_sla_dates, fill sla_due_date with the same fallback only when it is still NULL, so any SLA-derived date wins.

Business-day math is a new utils::datetime::add_business_days (skips Sat/Sun) with unit tests. The setting is read through a settings::read_default_due_business_days free function so both services apply it without depending on SettingsService. validate_setting_value gains an arm rejecting out-of-range values (HTTP 422).

Acceptance criteria

  • scheduling/default_due_business_days setting validated (0..=365, 0 disables)
  • New task without a due date gets today + N business days
  • No-SLA ticket gets the fallback; SLA-derived date always wins
  • add_business_days skips weekends, with unit tests
  • fmt, clippy (-D warnings), unit tests green

Frontend Settings field to edit the value is a separate mokosh-apps PR.

## Background Project tasks have a `due_date` (`NaiveDate`) with no defaulting: created without one, they stay open-ended. Tickets get SLA-derived dates (`sla_due_date`/`first_response_due`/`resolution_due`) via `calculate_sla_dates`, but a ticket matching no SLA returns early with those columns NULL, so it also has no due date. ## Goal Let a tenant set a standard due date that applies whenever an explicit one is missing. ## Proposed approach New tenant setting `scheduling/default_due_business_days` (integer 0..=365; 0 disables). Applied in two places: - `projects::service::create_task`: when `request.due_date` is None, fall back to today + N business days. - `tickets::service::create_ticket`: after `calculate_sla_dates`, fill `sla_due_date` with the same fallback only when it is still NULL, so any SLA-derived date wins. Business-day math is a new `utils::datetime::add_business_days` (skips Sat/Sun) with unit tests. The setting is read through a `settings::read_default_due_business_days` free function so both services apply it without depending on `SettingsService`. `validate_setting_value` gains an arm rejecting out-of-range values (HTTP 422). ## Acceptance criteria - [x] `scheduling/default_due_business_days` setting validated (0..=365, 0 disables) - [x] New task without a due date gets today + N business days - [x] No-SLA ticket gets the fallback; SLA-derived date always wins - [x] `add_business_days` skips weekends, with unit tests - [x] fmt, clippy (-D warnings), unit tests green Frontend Settings field to edit the value is a separate mokosh-apps PR.
feat(scheduling): tenant-wide standard due date for tasks and no-SLA tickets
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 42s
Check / fmt + clippy + compile + unit/doc tests (pull_request) Successful in 1m16s
Integration / integration tests (pull_request) Successful in 4m31s
Create release / Create release from merged PR (pull_request) Has been skipped
12f9bb7ab1
Add a tenant setting `scheduling/default_due_business_days` (integer 0..=365, 0 disables) that supplies a default due date when none is set explicitly. New project tasks created without a due date get today + N business days; tickets that match no SLA (so `calculate_sla_dates` leaves `sla_due_date` NULL) get the same fallback, while any SLA-derived date always wins. Business-day math lives in a new `utils::datetime::add_business_days` helper (skips Sat/Sun) with unit tests, and the value is read via a `settings::read_default_due_business_days` free function so the projects and tickets services apply it without depending on `SettingsService`. Validation arm rejects out-of-range values with HTTP 422.

#PMS-345

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vas2000-work deleted branch feat/PMS-345-standard-due-date 2026-06-16 02:23:10 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!257
No description provided.