feat(customers): a shelf folder number the office can hand back out
The office files every customer in a numbered paper folder and reuses the number once an account closes. That number was the legacy NUMid, which is also an import key and the portal login, so reusing it meant re-pointing an identity. It is now customers.folderNumber: a plain label nothing joins on. - Unique only among non-archived customers, checked in CustomersService (create, update, restore). Archived customers keep theirs as history. - GET /customers/folder/next suggests the lowest free number; the new customer form pre-fills it. - Backfilled from the utilities NUMid (dev: 1,171 folders, 0 shared); the importer copies it on load. Insurance-only customers start without one. - Reports, the printed statement and the customer file show "Carpeta" instead of NUMid. The list searches by it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
031b13f8c8
commit
b016e53893
15 files changed
+261
-58
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
-- The office files every customer in a numbered paper folder and hands the
|
||||
-- number back out once an account is closed. That number has been the legacy
|
||||
-- utilities NUMid; it becomes a plain label here so reusing it never touches
|
||||
-- an identity. Unique among non-archived customers only, enforced by the API.
|
||||
ALTER TABLE `customers` ADD COLUMN `folderNumber` INTEGER NULL;
|
||||
|
||||
CREATE INDEX `customers_folderNumber_idx` ON `customers`(`folderNumber`);
|
||||
|
||||
-- Existing customers start with their utilities NUMid. Insurance-only
|
||||
-- customers have none and get one from the office.
|
||||
UPDATE `customers` c
|
||||
JOIN (
|
||||
SELECT `customerId`, MIN(CAST(`legacyId` AS UNSIGNED)) AS n
|
||||
FROM `customer_legacy_refs`
|
||||
WHERE `sourceSystem` = 'utilities'
|
||||
AND `sourceTable` = 'DATGRAL'
|
||||
AND `legacyId` REGEXP '^[0-9]+$'
|
||||
GROUP BY `customerId`
|
||||
) r ON r.`customerId` = c.`id`
|
||||
SET c.`folderNumber` = r.n;
|
||||
Reference in new issue
Block a user