# Task D.6.2 - Opportunity to Quotation Prefill & Project Timeline Fields ## Objective Improve the Opportunity -> Quotation workflow so users do not need to select the same Opportunity twice, while adding timeline fields and hot-project forecasting support. ## Requirements ### 1. Create Quotation from Opportunity Detail - Clicking `Create Quotation` from Opportunity detail must open the quotation form with the current Opportunity already selected. - Related customer/project/contact/product context should be prefilled where available. ### 2. Add Project Timeline Fields Add these fields to both Opportunity and Quotation: - `Project Close Date` - `Delivery Date` Rules: - Use calendar date pickers. - Display format must be `YYYY-MM-DD`. ### 3. Auto Hot Project Rule - When `Project Close Date <= current date + 3 months`, the system should auto-suggest `hotProject = true`. - User may manually uncheck it. ### 4. Manual Override Rule Hot Project must support: - `auto suggested` - `manual override` Recommended persisted fields: - `isHotProject` - `hotProjectAutoSuggested` - `hotProjectManuallyOverridden` The UI must not keep forcing the checkbox back on during the same edit session after the user manually changes it. ### 5. Backend Enforcement Backend must: - accept `projectCloseDate` - accept `deliveryDate` - validate `YYYY-MM-DD` - calculate hot-project suggestion - preserve manual override - persist all values correctly ### 6. Quotation Prefill Rules When creating a quotation from an Opportunity, prefill where available: - `opportunityId` - customer / billing customer / project parties - project name - product type - branch - contact - `projectCloseDate` - `deliveryDate` - `hotProject` Do not overwrite user edits after the form has already been opened. ### 7. UI Requirements Opportunity Detail: - `Create Quotation` must pass the current Opportunity context. - Quotation form shows selected Opportunity already filled. Opportunity Form: - `Project Close Date` - `Delivery Date` - `Hot Project` Quotation Form: - `Project Close Date` - `Delivery Date` - `Hot Project` ### 8. Testing Run: ```bash npm run typecheck npm run build npm run audit:pdf ``` Test cases: - Create quotation from Opportunity detail preselects Opportunity. - User does not need to reselect Opportunity. - Project Close Date within 3 months auto-checks Hot Project. - User can uncheck Hot Project. - Project Close Date beyond 3 months does not auto-check. - Delivery Date saves correctly. - Quotation receives timeline fields from Opportunity. - Existing quotation create flow still works without Opportunity. ## Acceptance Criteria - Create Quotation from Opportunity detail preselects current Opportunity. - Opportunity does not need to be selected twice. - Opportunity has Project Close Date and Delivery Date. - Quotation has Project Close Date and Delivery Date. - Date fields use calendar pickers. - Hot Project is auto-checked when Project Close Date is within 3 months. - User can manually uncheck Hot Project. - Manual override is preserved. - Existing create/edit flows remain compatible. - Typecheck, build, and PDF audit pass. --- ## Implementation Result - 2026-07-01 Status: Completed Summary: - Added `Project Close Date` and `Delivery Date` to opportunity and quotation persistence, DTOs, validation, and form UI. - Added shared hot-project auto-suggestion logic plus persisted `hotProjectAutoSuggested` and `hotProjectManuallyOverridden`. - Updated opportunity detail `Create Quotation` flow to pass current opportunity context into the quotation sheet, including project parties when already available. - Updated quotation prefill logic so automatic population no longer overwrites fields the user already edited in the same open session. Verification: - `npm run typecheck` passed. - `npm run build` passed with existing Turbopack workspace-root and broad local storage path warnings. - `npm run audit:pdf` passed and refreshed PDF audit artifacts. Implementation note: - [task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/implementation/task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md)