You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(api): bulk-create endpoints for 7 indirect-scoped entities (P3-H2) (#88)
Follow-up to P3-H. The bulk surface was previously limited to the 5
entities with a direct *CompId column. This PR extends it to the
remaining 7 soft-deletable entities, whose auth scope is resolved
*through* a parent FK rather than carried directly:
Customer-scoped (parent → Customer.custCompId):
- POST /v1/job/bulk jobCustId
- POST /v1/invoice/bulk invCustId
- POST /v1/customerpayment/bulk cpayCustId
Job-scoped (parent → Job → Customer.custCompId):
- POST /v1/invoicejob/bulk injbJobId
- POST /v1/productentry/bulk pentJobId
Vendor/header-scoped:
- POST /v1/purchaseorderheader/bulk pohPovId → vendor.povCompId
- POST /v1/purchaseorderline/bulk polpoh → header → vendor
Mechanics:
- New factory `makeBulkCreateIndirect` in
`app/controllers/_bulk-helpers.js` parameterizes over
`parentFkField` + `resolveParentCompanyId(parentId)`. The 7
controllers gain ~10 LOC each instead of ~120.
- Per-entry validation: parent FK is REQUIRED on every entry.
For non-master keys the resolved parent company must equal the
caller's company (else 403 with the offending index); master
keys aren't pinned to a company so any resolved parent is fine.
- Same 500-entry cap and transactional all-or-nothing insert as
the direct family.
Together with P3-H, the bulk surface now covers all 13 soft-
deletable entities.
Tests
- `tests/api/bulk-indirect-scope.test.js`: 49 cases (7 entities x
7 assertions). Auth contract, outer-field 400s, empty/501-cap
400s, unknown-field 400, missing-parent-FK 400, route mounting.
- Full suite: 469 pass / 4 skip (was 420/4 — +49 net new tests).
- Lint clean.
Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments