feat(bills): capture event name/date when importing historical invoices

The historical-invoice import form had no event field, so imported rows
landed with event_name = NULL even when the admin knew the occasion. Add
free-text Event name + Event date inputs to the import modal, thread them
through billsService.importHistorical and the POST /admin/invoices/import
validator, and store them in the event_name/event_date snapshot columns
(migration 107). event_id stays NULL — no FK, since the event may predate
picpeak. Autocomplete-to-event_id linking deferred as a future bonus.
This commit is contained in:
Luca
2026-06-02 09:50:51 +02:00
parent c2d3f663bc
commit db7d11dc7f
5 changed files with 28 additions and 0 deletions
+7
View File
@@ -427,6 +427,8 @@ router.post(
[
body('customerAccountId').isInt({ min: 1 }),
body('invoiceNumber').isString().isLength({ min: 1, max: 64 }),
body('eventName').optional({ values: 'falsy' }).isString().isLength({ max: 255 }),
body('eventDate').optional({ values: 'falsy' }).isISO8601(),
body('issueDate').isISO8601(),
body('dueDate').optional({ values: 'falsy' }).isISO8601(),
body('totalAmountMinor').isInt({ min: 0 }),
@@ -487,7 +489,12 @@ router.post(
invoice_number: req.body.invoiceNumber,
customer_account_id: customer.id,
source_quote_id: null,
// No FK link on import — the event may predate picpeak. Store the
// free-text snapshot only, mirroring createInvoice's event_name /
// event_date columns (migration 107).
event_id: null,
event_name: req.body.eventName || null,
event_date: req.body.eventDate || null,
language,
currency,
issue_date: issueDate,