Make invoice due date optional with 14-day default #8

Merged
odweta merged 2 commits from odweta-stunning-engine into main 2026-09-10 17:31:02 +02:00
odweta commented 2026-09-10 17:30:25 +02:00 (Migrated from github.com)

Why

The invoice editor required picking a fixed due-date preset (14 or 30 days). We want issue and due dates to be optional fields that fall back to sensible defaults: today for the issue date, and 14 days after the issue date for the due date, only overridden when the user explicitly enters a custom value.

What changed

  • Replaced the dueDateOption select with two optional <input type="date"> fields: Datum vystaveni and Datum splatnosti.
  • script.js: added getIssueDate/getDueDate helpers that default to today / issue date + 14 days when the corresponding field is empty, and only use the entered value otherwise. These are wired into reading, saving, clearing, and loading invoice data.
  • app.js: added matching resolveIssueDate/resolveDueDate helpers on the server side so generated PDFs apply the same default logic, and print both dates in the invoice header next to the invoice number.
  • Merged latest main (invoice numbering settings, PDF payment footer/line-height tweaks, signature upload) into the branch; resolved one conflict in script.js from renamed DOM references, with no functional overlap.

Notes for review

  • No new dependencies or schema changes; dates are stored in the existing invoice_data JSON column.
  • Verified with npm test (3/3 passing) and node --check on both modified JS files.
## Why The invoice editor required picking a fixed due-date preset (14 or 30 days). We want issue and due dates to be optional fields that fall back to sensible defaults: today for the issue date, and 14 days after the issue date for the due date, only overridden when the user explicitly enters a custom value. ## What changed - Replaced the `dueDateOption` select with two optional `<input type="date">` fields: **Datum vystaveni** and **Datum splatnosti**. - `script.js`: added `getIssueDate`/`getDueDate` helpers that default to today / issue date + 14 days when the corresponding field is empty, and only use the entered value otherwise. These are wired into reading, saving, clearing, and loading invoice data. - `app.js`: added matching `resolveIssueDate`/`resolveDueDate` helpers on the server side so generated PDFs apply the same default logic, and print both dates in the invoice header next to the invoice number. - Merged latest `main` (invoice numbering settings, PDF payment footer/line-height tweaks, signature upload) into the branch; resolved one conflict in `script.js` from renamed DOM references, with no functional overlap. ## Notes for review - No new dependencies or schema changes; dates are stored in the existing `invoice_data` JSON column. - Verified with `npm test` (3/3 passing) and `node --check` on both modified JS files.
Sign in to join this conversation.