Applies the live-ERPNext configuration the registry relies on. Each step checks first and creates only what is missing; -dry-run only reports. It never submits, cancels or deletes an ERP document.
Custom fields Customer.tenant_id (unique) and Customer.tenant_slug, <Lead>.tenant_id and <Lead>.requested_product (-lead-doctype "CRM Lead" for Frappe CRM).
Frappe Webhooks, security on (X-Frappe-Webhook-Signature, base64 HMAC-SHA256, which the receiver already verifies), with JSON bodies in the erp.WebhookEvent shape. modified goes into the fallback event id, because live Frappe sends no X-Frappe-Event-Id:
Sales Order on_submit → sales_order.submit
Sales Invoice on_update_after_submit when Overdue → sales_invoice.overdue (days via frappe.utils.date_diff)
Subscription on_update when Cancelled → subscription.cancel
Caveat to verify on the live ERP: ERPNext sets invoices to Overdue from a scheduled job, which may not fire on_update_after_submit. The 15-minute reconcile over Subscriptions remains the safety net for the ladder.
Run (after review, dry run first):
ERP_BASE_URL=https://erp.breakpilot.com ERP_API_KEY=… ERP_API_SECRET=… ERP_WEBHOOK_SECRET=… \
go run ./cmd/erpsetup -webhook-url https://registry.breakpilot.com/v1/internal/erp/webhook -dry-run
Reserved slugs
POST /v1/tenants answers 400 reserved_slug for paths the portal serves (admin, start, install, docs, …). This mirrors portal#40. demo stays allowed because the sales demo tenant uses it.
Tests: fake Frappe (create, then idempotent second run, dry run, CRM Lead, auth and 5xx errors); go test -short ./... green.
Production go-live, Track B (plan 2026-09-23).
## `cmd/erpsetup` (image path `/erpsetup`)
Applies the live-ERPNext configuration the registry relies on. Each step checks first and creates only what is missing; `-dry-run` only reports. It never submits, cancels or deletes an ERP document.
- Custom fields `Customer.tenant_id` (unique) and `Customer.tenant_slug`, `<Lead>.tenant_id` and `<Lead>.requested_product` (`-lead-doctype "CRM Lead"` for Frappe CRM).
- Custom DocType **Usage Record** (module Selling; customer, tenant_id, product, metric, qty, occurred_at, idempotency_key unique).
- Frappe **Webhooks**, security on (`X-Frappe-Webhook-Signature`, base64 HMAC-SHA256, which the receiver already verifies), with JSON bodies in the `erp.WebhookEvent` shape. `modified` goes into the fallback event id, because live Frappe sends no `X-Frappe-Event-Id`:
- Sales Order `on_submit` → `sales_order.submit`
- Sales Invoice `on_update_after_submit` when Overdue → `sales_invoice.overdue` (days via `frappe.utils.date_diff`)
- Payment Entry `on_submit` (party Customer) → `payment_entry.submit`
- Subscription `on_update` when Cancelled → `subscription.cancel`
**Caveat to verify on the live ERP:** ERPNext sets invoices to Overdue from a scheduled job, which may not fire `on_update_after_submit`. The 15-minute reconcile over Subscriptions remains the safety net for the ladder.
Run (after review, dry run first):
```
ERP_BASE_URL=https://erp.breakpilot.com ERP_API_KEY=… ERP_API_SECRET=… ERP_WEBHOOK_SECRET=… \
go run ./cmd/erpsetup -webhook-url https://registry.breakpilot.com/v1/internal/erp/webhook -dry-run
```
## Reserved slugs
`POST /v1/tenants` answers `400 reserved_slug` for paths the portal serves (admin, start, install, docs, …). This mirrors portal#40. `demo` stays allowed because the sales demo tenant uses it.
Tests: fake Frappe (create, then idempotent second run, dry run, CRM Lead, auth and 5xx errors); `go test -short ./...` green.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
cmd/erpsetup applies what the registry expects in a live ERPNext:
tenant_id/tenant_slug custom fields on Customer and Lead, the Usage
Record doctype, and Frappe Webhooks (Sales Order submit, Sales
Invoice overdue, Payment Entry submit, Subscription cancelled) signed
with the registry's webhook secret. It checks before it creates, so it
can run again at any time, and -dry-run only reports. It ships in the
image as /erpsetup.
Tenant creation refuses slugs the portal serves itself (admin, start,
install, docs, …), mirroring the portal's signup check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang
merged commit ceeff16f26 into main2026-09-23 17:16:25 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Production go-live, Track B (plan 2026-09-23).
cmd/erpsetup(image path/erpsetup)Applies the live-ERPNext configuration the registry relies on. Each step checks first and creates only what is missing;
-dry-runonly reports. It never submits, cancels or deletes an ERP document.Customer.tenant_id(unique) andCustomer.tenant_slug,<Lead>.tenant_idand<Lead>.requested_product(-lead-doctype "CRM Lead"for Frappe CRM).X-Frappe-Webhook-Signature, base64 HMAC-SHA256, which the receiver already verifies), with JSON bodies in theerp.WebhookEventshape.modifiedgoes into the fallback event id, because live Frappe sends noX-Frappe-Event-Id:on_submit→sales_order.submiton_update_after_submitwhen Overdue →sales_invoice.overdue(days viafrappe.utils.date_diff)on_submit(party Customer) →payment_entry.submiton_updatewhen Cancelled →subscription.cancelCaveat to verify on the live ERP: ERPNext sets invoices to Overdue from a scheduled job, which may not fire
on_update_after_submit. The 15-minute reconcile over Subscriptions remains the safety net for the ladder.Run (after review, dry run first):
Reserved slugs
POST /v1/tenantsanswers400 reserved_slugfor paths the portal serves (admin, start, install, docs, …). This mirrors portal#40.demostays allowed because the sales demo tenant uses it.Tests: fake Frappe (create, then idempotent second run, dry run, CRM Lead, auth and 5xx errors);
go test -short ./...green.🤖 Generated with Claude Code
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB