feat(erpsetup): catalogue for Leistungsbeschreibung 1.0.0, opt-in -sync-catalog #115

Merged
sharang merged 1 commits from feat/erp-catalog-lb-1.0.0 into main 2026-11-06 16:20:22 +00:00
Owner

Brings the ERPNext sales catalogue in line with the frozen Leistungsbeschreibungen 1.0.0. This PR changes code and tests only. No ERP was called; the live run is yours, using the erpsetup CLI.

Dry run first (with the flag; only this path prints field old → new)

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 -sync-catalog -dry-run

(ERP_LEAD_DOCTYPE is optional, as before.) Leave out -dry-run for the real run.

What a run does with and without -sync-catalog

without the flag (as today) with -sync-catalog
New items, unit "Prüftag", their list prices created created
Item description updated (this already happens on every run today) updated
Item item_name, disabled untouched updated when they differ
Standard Selling price_list_rate (rows without a customer) set once, never changed updated when it differs
Customer-specific Item Prices untouched untouched
Quote print format (Mehrverbrauch row) updated updated

A plain run is not inert. It creates the 5 new items, the new unit and 5 new prices, rewrites every changed description, and updates the quote template. Only names, the disabled flags and price changes wait for the flag. Nothing is ever deleted. Only the doctypes Item, Item Price and UOM are touched beyond what erpsetup already manages.

Catalogue changes

Code Status Price old → new (EUR)
PLT-CORE-CLD-STD/BUS/ENT keep (name "Breakpilot …", new text) 290 / 790 / 1990 (unchanged)
PLT-BNDL-CLD-STD new Starter-Modulpaket 990
PLT-BNDL-CLD-ADD new Weiteres Modul 499
CRA-CSA-CLD-STD keep 1490 → 490
CRA-CSA-CLD-BUS keep 3990 → 1290
CRA-CSA-CLD-ENT keep 9900 → 0 (Preis nach Vereinbarung: a quote shows 0,00 € unless the rate is entered by hand)
CRA-CSA-CLD-TGT new extra Prüfobjekt / Monat 5.99
CRA-CSA-CLD-DAY new Prüftag (unit Prüftag) 9.99
CRA-CSA-CLD-SCAN disable 12 (unchanged)
CRA-WBK-CLD-STD/BUS/ENT disable unchanged
DEV-WP-CLD-STD keep ("Werkpilot Cloud") 59
DEV-WP-CLD-BUS/ENT disable unchanged
DEV-WP-OPR-, DEV-FWK-OPR-, INF-GIT-OPR-, INF-CI-OPR- keep, new texts unchanged
DEV-FWK-CLD-STD keep ("Firmwerk Cloud") 89
DEV-FWK-CLD-BUS/ENT disable unchanged
INF-GIT-CLD-STD/BUS/ENT keep, new texts 190 / 390 / 790
INF-GIT-CLD-USR new extra user 19
INF-CI-CLD-STD/BUS/ENT keep, new texts 149 / 290 / 590

The item group stays "BreakPilot Abonnements".

Correction to the spec, applied here: PLT-CORE-CLD-STD no longer mentions "Rechnungen", because LB Plattform §2(3) says the portal provides no invoices. The text is now "Arbeitsbereich mit Anmeldung und Team für bis 25 Nutzer, Standard-Support. Module werden einzeln gebucht." No other item text mentions invoices, and a test now checks that none does.

Other changes

  • sku.Disabled is sent to ERPNext as the Item field disabled: 1. Disabled items stay in ERPNext so old documents keep working. Since the disabled items already exist on prod, their flag only changes with -sync-catalog.
  • Quote, Mehrverbrauch row: "Zusätzliche Prüfobjekte werden mit {TGT} netto je Monat berechnet, Prüftage nach verbrauchtem Monatskontingent mit {DAY} netto (Leistungsbeschreibung Prüfwerk, Abschnitt 7)." If a rate is missing, the text says "gemäß der jeweils gültigen Preisliste" instead, per rate. If both are missing, one combined sentence is printed. Quotes with INF-GIT-CLD-STD/BUS/ENT or PLT-BNDL-* add the sentence on extra users (Leistungsbeschreibung Breakpilot Plattform, Abschnitt 4). The Jinja was parsed and rendered locally with jinja2 against mocks for eight item mixes.
  • Migration 0026 adds CRA-CSA-CLD-TGT and -DAY to the pruefwerk product. SCAN stays so old orders still map. The up is guarded so it can run twice; the down removes the two SKUs. DefaultProducts and the ERP mock's SKU list follow. Run migrate-up with the deploy. Without it, TGT/DAY lines on an order log "sales order item without catalog product".
  • 0 € module lines: nothing needed fixing. Neither the webhook path nor reconcile reads the rate: the webhook template sends only item_code and qty, and SubscriptionPlan has no rate. A new test covers both paths: a bundle order with modules at rate 0 and qty 15 gives an active tenant, plan standard, and seats 15 per module.

Decisions the spec did not cover

  1. No Prüfwerk Mehrverbrauch sentence on Enterprise quotes. CRA-CSA-CLD-ENT is "ohne Begrenzung". Edge case: a quote with both -STD and -ENT also prints no Prüfwerk sentence. The extra-users sentence is not affected.
  2. The run without the flag still writes descriptions, as Run has done until now (see the table).
  3. -sync-catalog only changes Item Price rows without a customer. If there are several such rows for an item, the run reports "not synced". If there are none, it creates the list price.
  4. The quote template's Item Price lookup still has no customer filter (unchanged from before).
  5. INF-GIT-OPR texts: STD uses the spec text exactly, so "kein Quellcode verlässt das Haus" is gone. BUS keeps "für mittelgroße Teams" and loses "schnellerer Patch-Rhythmus", like CI. ENT says "für große Entwicklungsorganisationen".
  6. INF-CI-OPR texts differ only by size ("mindestens 2 vCPU / 4 GB" etc.); "für größere/umfangreiche Builds" was dropped.
  7. DEV-WP-OPR and DEV-FWK-OPR texts: the tier phrase sits after "im eigenen Netz", e.g. "Werkpilot im eigenen Netz für mittlere Teams, mit einem vom Kunden betriebenen KI-Modell; …".
  8. TGT/DAY quantities on an order or subscription count toward Prüfwerk seats, exactly as SCAN already does. Not changed here.
  9. Bundle revenue goes to cost center Plattform (PLT-*). Module lines at 0 € book nothing on Prüfwerk, Firmwerk or Werkpilot. Whether to allocate it is an accounting decision for you.
  10. The dry run prints texts in full (no truncation), so the wording can be read before it goes live.
  11. TestEverySKUHasAListPrice now allows exactly one item at 0: CRA-CSA-CLD-ENT.
  12. The ERP mock's DefaultSKUs now also lists PLT-BNDL-* and CRA-CSA-CLD-TGT/DAY.

Tests

go build ./... && go vet ./... && go test ./... all pass. The Postgres testcontainers suites ran (podman socket) with no skips: server 463 s, migrations 32 s. New tests:

  • catalogue consistency: unique codes, units, disabled set, prices including 5.99/9.99, brand spelling
  • TestSyncCatalog: the dry run writes nothing and names every change; the run updates name, description, disabled and price and keeps the customer price; a second run makes no updates; without the flag only the description changes
  • quote template phrases
  • TestMigrate_productsSeedMatchesDefaults: seed equals DefaultProducts, 0026 applied twice, down
  • TestErp_zeroRateModuleLinesEntitle: webhook and reconcile, memory and Postgres

🤖 Generated with Claude Code

Brings the ERPNext sales catalogue in line with the frozen Leistungsbeschreibungen 1.0.0. This PR changes code and tests only. No ERP was called; the live run is yours, using the erpsetup CLI. ## Dry run first (with the flag; only this path prints `field old → new`) ```sh 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 -sync-catalog -dry-run ``` (`ERP_LEAD_DOCTYPE` is optional, as before.) Leave out `-dry-run` for the real run. ## What a run does with and without `-sync-catalog` | | without the flag (as today) | with `-sync-catalog` | |---|---|---| | New items, unit "Prüftag", their list prices | created | created | | Item **description** | **updated (this already happens on every run today)** | updated | | Item `item_name`, `disabled` | untouched | updated when they differ | | Standard Selling `price_list_rate` (rows without a customer) | set once, never changed | updated when it differs | | Customer-specific Item Prices | untouched | untouched | | Quote print format (Mehrverbrauch row) | updated | updated | **A plain run is not inert.** It creates the 5 new items, the new unit and 5 new prices, rewrites every changed description, and updates the quote template. Only names, the disabled flags and price changes wait for the flag. Nothing is ever deleted. Only the doctypes Item, Item Price and UOM are touched beyond what erpsetup already manages. ## Catalogue changes | Code | Status | Price old → new (EUR) | |---|---|---| | PLT-CORE-CLD-STD/BUS/ENT | keep (name "Breakpilot …", new text) | 290 / 790 / 1990 (unchanged) | | PLT-BNDL-CLD-STD | **new** Starter-Modulpaket | 990 | | PLT-BNDL-CLD-ADD | **new** Weiteres Modul | 499 | | CRA-CSA-CLD-STD | keep | **1490 → 490** | | CRA-CSA-CLD-BUS | keep | **3990 → 1290** | | CRA-CSA-CLD-ENT | keep | **9900 → 0** (Preis nach Vereinbarung: a quote shows 0,00 € unless the rate is entered by hand) | | CRA-CSA-CLD-TGT | **new** extra Prüfobjekt / Monat | 5.99 | | CRA-CSA-CLD-DAY | **new** Prüftag (unit Prüftag) | 9.99 | | CRA-CSA-CLD-SCAN | **disable** | 12 (unchanged) | | CRA-WBK-CLD-STD/BUS/ENT | **disable** | unchanged | | DEV-WP-CLD-STD | keep ("Werkpilot Cloud") | 59 | | DEV-WP-CLD-BUS/ENT | **disable** | unchanged | | DEV-WP-OPR-*, DEV-FWK-OPR-*, INF-GIT-OPR-*, INF-CI-OPR-* | keep, new texts | unchanged | | DEV-FWK-CLD-STD | keep ("Firmwerk Cloud") | 89 | | DEV-FWK-CLD-BUS/ENT | **disable** | unchanged | | INF-GIT-CLD-STD/BUS/ENT | keep, new texts | 190 / 390 / 790 | | INF-GIT-CLD-USR | **new** extra user | 19 | | INF-CI-CLD-STD/BUS/ENT | keep, new texts | 149 / 290 / 590 | The item group stays "BreakPilot Abonnements". Correction to the spec, applied here: PLT-CORE-CLD-STD no longer mentions "Rechnungen", because LB Plattform §2(3) says the portal provides no invoices. The text is now "Arbeitsbereich mit Anmeldung und Team für bis 25 Nutzer, Standard-Support. Module werden einzeln gebucht." No other item text mentions invoices, and a test now checks that none does. ## Other changes - `sku.Disabled` is sent to ERPNext as the Item field `disabled: 1`. Disabled items stay in ERPNext so old documents keep working. Since the disabled items already exist on prod, their flag only changes with `-sync-catalog`. - **Quote, Mehrverbrauch row:** "Zusätzliche Prüfobjekte werden mit {TGT} netto je Monat berechnet, Prüftage nach verbrauchtem Monatskontingent mit {DAY} netto (Leistungsbeschreibung Prüfwerk, Abschnitt 7)." If a rate is missing, the text says "gemäß der jeweils gültigen Preisliste" instead, per rate. If both are missing, one combined sentence is printed. Quotes with INF-GIT-CLD-STD/BUS/ENT or PLT-BNDL-* add the sentence on extra users (Leistungsbeschreibung Breakpilot Plattform, Abschnitt 4). The Jinja was parsed and rendered locally with jinja2 against mocks for eight item mixes. - **Migration 0026** adds CRA-CSA-CLD-TGT and -DAY to the `pruefwerk` product. SCAN stays so old orders still map. The up is guarded so it can run twice; the down removes the two SKUs. `DefaultProducts` and the ERP mock's SKU list follow. **Run `migrate-up` with the deploy.** Without it, TGT/DAY lines on an order log "sales order item without catalog product". - **0 € module lines:** nothing needed fixing. Neither the webhook path nor reconcile reads the rate: the webhook template sends only `item_code` and `qty`, and `SubscriptionPlan` has no rate. A new test covers both paths: a bundle order with modules at rate 0 and qty 15 gives an active tenant, plan standard, and seats 15 per module. ## Decisions the spec did not cover 1. **No Prüfwerk Mehrverbrauch sentence on Enterprise quotes.** CRA-CSA-CLD-ENT is "ohne Begrenzung". Edge case: a quote with both -STD and -ENT also prints no Prüfwerk sentence. The extra-users sentence is not affected. 2. The run without the flag still writes descriptions, as `Run` has done until now (see the table). 3. `-sync-catalog` only changes Item Price rows without a `customer`. If there are several such rows for an item, the run reports "not synced". If there are none, it creates the list price. 4. The quote template's Item Price lookup still has no customer filter (unchanged from before). 5. INF-GIT-OPR texts: STD uses the spec text exactly, so "kein Quellcode verlässt das Haus" is gone. BUS keeps "für mittelgroße Teams" and loses "schnellerer Patch-Rhythmus", like CI. ENT says "für große Entwicklungsorganisationen". 6. INF-CI-OPR texts differ only by size ("mindestens 2 vCPU / 4 GB" etc.); "für größere/umfangreiche Builds" was dropped. 7. DEV-WP-OPR and DEV-FWK-OPR texts: the tier phrase sits after "im eigenen Netz", e.g. "Werkpilot im eigenen Netz für mittlere Teams, mit einem vom Kunden betriebenen KI-Modell; …". 8. TGT/DAY quantities on an order or subscription count toward Prüfwerk `seats`, exactly as SCAN already does. Not changed here. 9. Bundle revenue goes to cost center Plattform (PLT-*). Module lines at 0 € book nothing on Prüfwerk, Firmwerk or Werkpilot. Whether to allocate it is an accounting decision for you. 10. The dry run prints texts in full (no truncation), so the wording can be read before it goes live. 11. `TestEverySKUHasAListPrice` now allows exactly one item at 0: CRA-CSA-CLD-ENT. 12. The ERP mock's `DefaultSKUs` now also lists PLT-BNDL-* and CRA-CSA-CLD-TGT/DAY. ## Tests `go build ./... && go vet ./... && go test ./...` all pass. The Postgres testcontainers suites ran (podman socket) with no skips: server 463 s, migrations 32 s. New tests: - catalogue consistency: unique codes, units, disabled set, prices including 5.99/9.99, brand spelling - `TestSyncCatalog`: the dry run writes nothing and names every change; the run updates name, description, disabled and price and keeps the customer price; a second run makes no updates; without the flag only the description changes - quote template phrases - `TestMigrate_productsSeedMatchesDefaults`: seed equals `DefaultProducts`, 0026 applied twice, down - `TestErp_zeroRateModuleLinesEntitle`: webhook and reconcile, memory and Postgres 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-06 15:53:04 +00:00
feat(erpsetup): catalogue for Leistungsbeschreibung 1.0.0, opt-in -sync-catalog
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 26m34s
ci / image (pull_request) Skipped
c180807d19
Bring the ERPNext sales catalogue in line with the frozen
Leistungsbeschreibungen 1.0.0:

- New items PLT-BNDL-CLD-STD/-ADD (Starter bundle), CRA-CSA-CLD-TGT
  (extra Prüfobjekt, 5.99/Monat), CRA-CSA-CLD-DAY (Prüftag, 9.99) and
  INF-GIT-CLD-USR (extra Git user); new whole-number UOM "Prüftag".
- New names, descriptions and prices for the kept items, with the
  "Breakpilot" brand spelling. The item group name stays.
- sku.Disabled, sent as the Item field disabled: CRA-CSA-CLD-SCAN,
  CRA-WBK-CLD-*, DEV-WP-CLD-BUS/ENT and DEV-FWK-CLD-BUS/ENT stay in
  ERPNext, disabled, so old documents keep working.
- cmd/erpsetup -sync-catalog (Config.SyncCatalog): existing items get
  item_name, description and disabled, and the Standard Selling list
  price without a customer gets price_list_rate, when they differ. The
  dry run reports "field old → new". Without the flag, the run behaves
  as before.
- Quote "Mehrverbrauch" row: extra Prüfobjekte and Prüftage at the
  TGT/DAY list rates, falling back to the price list; not on an
  Enterprise quote. Adds the extra-users sentence for Managed Git Cloud
  and the Starter bundle.
- Migration 0026 adds CRA-CSA-CLD-TGT and -DAY to the pruefwerk product
  (SCAN stays); DefaultProducts and the ERP mock follow.
- Tests: catalogue consistency, the sync (dry run, run, idempotent,
  customer price kept), the seed against DefaultProducts and 0026
  up/down, and 0 € module lines granting entitlements via webhook and
  reconcile (no code change was needed: the rate is never read).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 1332ad7bc5 into main 2026-11-06 16:20:22 +00:00
sharang deleted branch feat/erp-catalog-lb-1.0.0 2026-11-06 16:20:22 +00:00
Sign in to join this conversation.