Add start_date to financing plans and protect paid paychecks from refresh

- Migration 004: adds start_date column to financing_plans (DEFAULT CURRENT_DATE)
- generatePaychecks: skips financing plans whose start_date is after the target month
- buildVirtualPaychecks: same start_date guard for virtual previews (already applied)
- generatePaychecks upsert: preserves gross/net when paycheck has any paid bills
- financing.js POST/PUT: accept and store start_date
- Financing.jsx: add Start Date field to create/edit form (defaults to today)
- CLAUDE.md: document start_date guard and paid-paycheck refresh protection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-19 20:37:37 -04:00
parent 72c2e0a0c7
commit 119d53c33a
4 changed files with 46 additions and 12 deletions

View File

@@ -20,10 +20,13 @@ function ProgressBar({ paid, total }) {
);
}
const TODAY = new Date().toISOString().slice(0, 10);
const EMPTY_FORM = {
name: '',
total_amount: '',
due_date: '',
start_date: TODAY,
assigned_paycheck: 'both',
};
@@ -111,6 +114,7 @@ export default function Financing() {
name: plan.name,
total_amount: plan.total_amount,
due_date: plan.due_date,
start_date: plan.start_date || TODAY,
assigned_paycheck: plan.assigned_paycheck == null ? 'both' : String(plan.assigned_paycheck),
});
setFormError(null);
@@ -138,6 +142,7 @@ export default function Financing() {
name: form.name,
total_amount: parseFloat(form.total_amount),
due_date: form.due_date,
start_date: form.start_date || TODAY,
assigned_paycheck: form.assigned_paycheck === 'both' ? null : parseInt(form.assigned_paycheck, 10),
};
const url = editingId ? `/api/financing/${editingId}` : '/api/financing';
@@ -204,6 +209,11 @@ export default function Financing() {
<input name="due_date" type="date" value={form.due_date}
onChange={handleChange} required className="form-input" />
</div>
<div className="form-group">
<label className="form-label">Start Date</label>
<input name="start_date" type="date" value={form.start_date}
onChange={handleChange} required className="form-input" />
</div>
<div className="form-group" style={{ gridColumn: '1 / -1' }}>
<label className="form-label">Assign to paycheck</label>
<select name="assigned_paycheck" value={form.assigned_paycheck}