250 lines
18 KiB
Go
250 lines
18 KiB
Go
package erpsetup
|
||
|
||
import "strings"
|
||
|
||
// The sales catalogue in ERPNext: the SKU items (codes as in the registry's
|
||
// products table and the "Breakpilot SKU + SLA" sheet), their units and item
|
||
// group, the SEPA direct-debit mandate on the Customer and the payment method.
|
||
// Names, descriptions and list prices follow the Leistungsbeschreibungen
|
||
// (versions in lbVersions). Every run writes the item description and creates what is missing;
|
||
// a list price (net EUR) goes on the Standard Selling price list once. Only a
|
||
// run with -sync-catalog (Config.SyncCatalog) brings existing items' name,
|
||
// description and disabled flag and the list prices back to these values;
|
||
// without it, price changes made in ERPNext stay.
|
||
|
||
// lbVersions are the frozen Leistungsbeschreibungen a quote names under
|
||
// "Vertragsgrundlagen" (each LB's § 1: "Maßgeblich ist die im Angebot …
|
||
// genannte Version"). The platform's applies to every quote; a module's when
|
||
// the quote has a line whose code starts with one of its prefixes. Raise a
|
||
// version here when a new one is frozen in Sellable Documents/
|
||
// Leistungsbeschreibung/<version>/FINAL.
|
||
var lbVersions = []struct {
|
||
Module, Version string
|
||
Prefixes []string // item code prefixes; none = every quote
|
||
}{
|
||
{"Breakpilot Plattform", "1.0.0", nil},
|
||
{"Prüfwerk", "1.0.3", []string{"CRA-CSA-CLD-"}},
|
||
{"Managed Git", "1.0.0", []string{"INF-GIT-CLD-"}},
|
||
{"Build-Runner", "1.0.0", []string{"INF-CI-CLD-"}},
|
||
{"Werkpilot", "1.0.0", []string{"DEV-WP-"}},
|
||
{"Firmwerk", "1.0.0", []string{"DEV-FWK-"}},
|
||
}
|
||
|
||
// lbVersionsJinja is a Jinja expression for the quote template: the names
|
||
// and versions of the Leistungsbeschreibungen that apply, comma-separated.
|
||
// It reads item_codes (" CODE CODE … ", set by the template).
|
||
func lbVersionsJinja() string {
|
||
var parts []string
|
||
for _, lb := range lbVersions {
|
||
name := lb.Module + " " + lb.Version
|
||
if len(lb.Prefixes) == 0 {
|
||
parts = append(parts, `"`+name+`"`)
|
||
continue
|
||
}
|
||
var conds []string
|
||
for _, p := range lb.Prefixes {
|
||
conds = append(conds, `" `+p+`" in item_codes`)
|
||
}
|
||
parts = append(parts, `(", `+name+`" if `+strings.Join(conds, " or ")+` else "")`)
|
||
}
|
||
return strings.Join(parts, " ~ ")
|
||
}
|
||
|
||
// itemGroup keeps its old spelling: renaming it would touch every item.
|
||
const itemGroup = "BreakPilot Abonnements"
|
||
|
||
type sku struct {
|
||
Code, Name, UOM, Description string
|
||
Price float64 // list price, net EUR per UOM
|
||
// Disabled items are no longer sold; they stay in ERPNext (disabled: 1)
|
||
// so documents that carry them keep working.
|
||
Disabled bool
|
||
}
|
||
|
||
// priceList carries the list prices.
|
||
const priceList = "Standard Selling"
|
||
|
||
// skus lists every item a sales order may carry. The registry unlocks a
|
||
// product for the product SKUs; the platform fee (PLT-CORE-*) and the Starter
|
||
// bundle (PLT-BNDL-*) are billed but unlock nothing on their own: a bundle's
|
||
// modules are their own lines at 0,00 €, and those unlock the products. So
|
||
// are Managed Git (INF-GIT-*, with extra users INF-GIT-CLD-USR) and its build
|
||
// runners (INF-CI-*) until the registry has a `git` product (instances and
|
||
// runners are provisioned by hand, v0). Runner prices are per runner.
|
||
func skus() []sku {
|
||
return []sku{
|
||
{Code: "PLT-CORE-CLD-STD", Name: "Breakpilot Plattform – Starter", UOM: "Monat", Description: "Arbeitsbereich mit Anmeldung und Team für bis 25 Nutzer, Standard-Support. Module werden einzeln gebucht.", Price: 290},
|
||
{Code: "PLT-CORE-CLD-BUS", Name: "Breakpilot Plattform – Growth", UOM: "Monat", Description: "Arbeitsbereich für bis 100 Nutzer, Business-Support.", Price: 790},
|
||
{Code: "PLT-CORE-CLD-ENT", Name: "Breakpilot Plattform – Enterprise", UOM: "Monat", Description: "Arbeitsbereich ohne Nutzergrenze, Enterprise-Support und benannte Ansprechperson.", Price: 1990},
|
||
{Code: "PLT-BNDL-CLD-STD", Name: "Breakpilot Starter-Modulpaket", UOM: "Monat", Description: "Plattform Starter (bis 25 Nutzer) mit drei Modulen nach Wahl, je bis 15 Nutzer. Die gewählten Module stehen im Angebot als eigene Positionen zu 0,00 €.", Price: 990},
|
||
{Code: "PLT-BNDL-CLD-ADD", Name: "Weiteres Modul im Starter-Modulpaket", UOM: "Monat", Description: "Ein weiteres Modul zum Starter-Modulpaket, bis 15 Nutzer. Das Modul steht im Angebot als eigene Position zu 0,00 €.", Price: 499},
|
||
{Code: "CRA-CSA-CLD-STD", Name: "Prüfwerk Cloud – Standard", UOM: "Monat", Description: "Automatisierte Sicherheitsanalyse von Quellcode, Firmware und SPS-Programmen mit SBOM und Codegraph: 5 enthaltene Prüfobjekte mit unbegrenzten Prüfungen nach Änderungen, dazu 100 weitere Prüfungen im Monat.", Price: 490},
|
||
{Code: "CRA-CSA-CLD-BUS", Name: "Prüfwerk Cloud – Business", UOM: "Monat", Description: "Prüfwerk mit 25 enthaltenen Prüfobjekten und 500 weiteren Prüfungen im Monat.", Price: 1290},
|
||
{Code: "CRA-CSA-CLD-ENT", Name: "Prüfwerk Cloud – Enterprise", UOM: "Monat", Description: "Prüfwerk ohne Begrenzung der Prüfobjekte und Prüfungen. Preis nach Vereinbarung.", Price: 0},
|
||
{Code: "CRA-CSA-CLD-MON", Name: "Prüfwerk Cloud – Monitor", UOM: "Monat", Description: "Überwachung eines Produkts auf neue Schwachstellen: 1 enthaltenes Prüfobjekt, täglicher Abgleich mit bekannten Schwachstellen und 10 Prüfungen im Monat. Keine zusätzlichen Prüfobjekte und keine Prüftage.", Price: 149},
|
||
{Code: "CRA-CSA-CLD-TGT", Name: "Prüfwerk – Zusätzliches Prüfobjekt", UOM: "Monat", Description: "Prüfobjekt über die im Leistungspaket enthaltenen hinaus; seine Prüfungen zählen zum Monatskontingent. Berechnet wird die höchste Zahl gleichzeitig angelegter zusätzlicher Prüfobjekte im Monat.", Price: 5.99},
|
||
{Code: "CRA-CSA-CLD-DAY", Name: "Prüfwerk – Prüftag", UOM: "Prüftag", Description: "Nach verbrauchtem Monatskontingent: bis zu 6 weitere Prüfungen eines Prüfobjekts am selben Kalendertag.", Price: 9.99},
|
||
// Replaced by CRA-CSA-CLD-TGT and -DAY.
|
||
{Code: "CRA-CSA-CLD-SCAN", Name: "Prüfwerk – Zusätzliche Prüfung", UOM: "Prüfung", Description: "Einzelne Prüfung über das Monatskontingent hinaus; nur zu einem aktiven Prüfwerk-Abonnement.", Price: 12, Disabled: true},
|
||
// Werkbank is not on prod.
|
||
{Code: "CRA-WBK-CLD-STD", Name: "Werkbank Runner Cloud – Standard", UOM: "Monat", Description: "Prüfmaschine für aktive Tests externer Systeme (1 vCPU / 2 GB); Zusatz zu Prüfwerk.", Price: 490, Disabled: true},
|
||
{Code: "CRA-WBK-CLD-BUS", Name: "Werkbank Runner Cloud – Business", UOM: "Monat", Description: "Prüfmaschine mit parallelen Prüfungen (2 vCPU / 4 GB); Zusatz zu Prüfwerk.", Price: 990, Disabled: true},
|
||
{Code: "CRA-WBK-CLD-ENT", Name: "Werkbank Runner Cloud – Enterprise", UOM: "Monat", Description: "Prüfmaschine mit eigenen Prüfmodulen (4 vCPU / 8 GB); Zusatz zu Prüfwerk.", Price: 1990, Disabled: true},
|
||
{Code: "DEV-WP-CLD-STD", Name: "Werkpilot Cloud", UOM: "Monat", Description: "KI-Assistent für Code und SPS-Programme in der Kommandozeile, KI-Modelle des Anbieters; je Nutzer und Monat.", Price: 59},
|
||
// Werkpilot and Firmwerk Cloud: no real tier difference yet.
|
||
{Code: "DEV-WP-CLD-BUS", Name: "Werkpilot Cloud – Business", UOM: "Monat", Description: "Werkpilot mit reservierter KI-Kapazität und Single Sign-on; je Nutzer und Monat.", Price: 119, Disabled: true},
|
||
{Code: "DEV-WP-CLD-ENT", Name: "Werkpilot Cloud – Enterprise", UOM: "Monat", Description: "Werkpilot auf eigener KI-Instanz, optional auf Ihren Code abgestimmt; je Nutzer und Monat.", Price: 249, Disabled: true},
|
||
{Code: "DEV-WP-OPR-STD", Name: "Werkpilot On-Prem – Standard", UOM: "Jahr", Description: "Werkpilot im eigenen Netz für kleine Teams, mit einem vom Kunden betriebenen KI-Modell; kein Quellcode verlässt das Haus; Jahreslizenz.", Price: 7900},
|
||
{Code: "DEV-WP-OPR-BUS", Name: "Werkpilot On-Prem – Business", UOM: "Jahr", Description: "Werkpilot im eigenen Netz für mittlere Teams, mit einem vom Kunden betriebenen KI-Modell; kein Quellcode verlässt das Haus; Jahreslizenz.", Price: 19900},
|
||
{Code: "DEV-WP-OPR-ENT", Name: "Werkpilot On-Prem – Enterprise", UOM: "Jahr", Description: "Werkpilot im eigenen Netz für große Entwicklungsorganisationen, mit einem vom Kunden betriebenen KI-Modell; kein Quellcode verlässt das Haus; Jahreslizenz.", Price: 49900},
|
||
{Code: "DEV-FWK-CLD-STD", Name: "Firmwerk Cloud", UOM: "Monat", Description: "Reproduzierbare Firmware-Builds mit Software-Stückliste (SBOM) und signiertem Herkunftsnachweis; je Nutzer und Monat.", Price: 89},
|
||
{Code: "DEV-FWK-CLD-BUS", Name: "Firmwerk Cloud – Business", UOM: "Monat", Description: "Firmwerk mit beliebig vielen Umgebungen und Team-Freigabe; je Nutzer und Monat.", Price: 149, Disabled: true},
|
||
{Code: "DEV-FWK-CLD-ENT", Name: "Firmwerk Cloud – Enterprise", UOM: "Monat", Description: "Firmwerk mit eigenen Toolchains und LTS-Stand; je Nutzer und Monat.", Price: 299, Disabled: true},
|
||
{Code: "DEV-FWK-OPR-STD", Name: "Firmwerk On-Prem – Standard", UOM: "Jahr", Description: "Firmwerk im eigenen Netz für kleine Teams; Jahreslizenz.", Price: 6900},
|
||
{Code: "DEV-FWK-OPR-BUS", Name: "Firmwerk On-Prem – Business", UOM: "Jahr", Description: "Firmwerk im eigenen Netz für größere Teams; Jahreslizenz.", Price: 15900},
|
||
{Code: "DEV-FWK-OPR-ENT", Name: "Firmwerk On-Prem – Enterprise", UOM: "Jahr", Description: "Firmwerk im eigenen Netz für große Organisationen; Jahreslizenz.", Price: 39900},
|
||
{Code: "INF-GIT-CLD-STD", Name: "Managed Git Cloud – Standard", UOM: "Monat", Description: "Eigene Gitea-Instanz, betrieben von Breakpilot in Deutschland: Anmeldung über das Breakpilot-Konto, Sicherung und Updates inklusive; bis 5 Nutzer.", Price: 190},
|
||
{Code: "INF-GIT-CLD-BUS", Name: "Managed Git Cloud – Business", UOM: "Monat", Description: "Eigene Gitea-Instanz wie Standard, bis 25 Nutzer.", Price: 390},
|
||
{Code: "INF-GIT-CLD-ENT", Name: "Managed Git Cloud – Enterprise", UOM: "Monat", Description: "Eigene Gitea-Instanz wie Standard, bis 100 Nutzer.", Price: 790},
|
||
{Code: "INF-GIT-CLD-USR", Name: "Managed Git – Weiterer Nutzer", UOM: "Monat", Description: "Nutzer über die enthaltenen Nutzer hinaus; je Nutzer und Monat.", Price: 19},
|
||
{Code: "INF-GIT-OPR-STD", Name: "Managed Git On-Prem – Standard", UOM: "Jahr", Description: "Gitea im eigenen Netz; Installation, Sicherheitsaktualisierungen und Überwachung durch Breakpilot; Jahreslizenz.", Price: 4900},
|
||
{Code: "INF-GIT-OPR-BUS", Name: "Managed Git On-Prem – Business", UOM: "Jahr", Description: "Gitea im eigenen Netz für mittelgroße Teams; Installation, Sicherheitsaktualisierungen und Überwachung durch Breakpilot; Jahreslizenz.", Price: 9900},
|
||
{Code: "INF-GIT-OPR-ENT", Name: "Managed Git On-Prem – Enterprise", UOM: "Jahr", Description: "Gitea im eigenen Netz für große Entwicklungsorganisationen; Installation, Sicherheitsaktualisierungen und Überwachung durch Breakpilot; Jahreslizenz.", Price: 19900},
|
||
{Code: "INF-CI-CLD-STD", Name: "Build-Runner Cloud – Standard", UOM: "Monat", Description: "Eigene Build-Maschine zu Managed Git, betrieben von Breakpilot in Deutschland und nicht mit anderen Kunden geteilt: mindestens 2 vCPU / 4 GB; Preis je Runner.", Price: 149},
|
||
{Code: "INF-CI-CLD-BUS", Name: "Build-Runner Cloud – Business", UOM: "Monat", Description: "Wie Standard, mindestens 4 vCPU / 8 GB; Preis je Runner.", Price: 290},
|
||
{Code: "INF-CI-CLD-ENT", Name: "Build-Runner Cloud – Enterprise", UOM: "Monat", Description: "Wie Standard, mindestens 8 vCPU / 16 GB; Preis je Runner.", Price: 590},
|
||
{Code: "INF-CI-OPR-STD", Name: "Build-Runner On-Prem – Standard", UOM: "Jahr", Description: "Build-Maschine im eigenen Netz (mindestens 2 vCPU / 4 GB); Einrichtung, Sicherheitsaktualisierungen und Überwachung durch Breakpilot; Jahreslizenz je Runner.", Price: 2900},
|
||
{Code: "INF-CI-OPR-BUS", Name: "Build-Runner On-Prem – Business", UOM: "Jahr", Description: "Build-Maschine im eigenen Netz (mindestens 4 vCPU / 8 GB); Einrichtung, Sicherheitsaktualisierungen und Überwachung durch Breakpilot; Jahreslizenz je Runner.", Price: 5900},
|
||
{Code: "INF-CI-OPR-ENT", Name: "Build-Runner On-Prem – Enterprise", UOM: "Jahr", Description: "Build-Maschine im eigenen Netz (mindestens 8 vCPU / 16 GB); Einrichtung, Sicherheitsaktualisierungen und Überwachung durch Breakpilot; Jahreslizenz je Runner.", Price: 11900},
|
||
}
|
||
}
|
||
|
||
func uoms() []map[string]any {
|
||
out := []map[string]any{}
|
||
for _, u := range []string{"Monat", "Jahr", "Prüfung", "Prüftag"} {
|
||
out = append(out, map[string]any{"doctype": "UOM", "name": u, "uom_name": u, "must_be_whole_number": 1})
|
||
}
|
||
return out
|
||
}
|
||
|
||
func itemGroupDoc() map[string]any {
|
||
return map[string]any{"doctype": "Item Group", "name": itemGroup, "item_group_name": itemGroup, "parent_item_group": "All Item Groups", "is_group": 0}
|
||
}
|
||
|
||
func itemDoc(s sku) map[string]any {
|
||
return map[string]any{
|
||
"doctype": "Item", "name": s.Code, "item_code": s.Code, "item_name": s.Name,
|
||
"item_group": itemGroup, "stock_uom": s.UOM, "description": s.Description,
|
||
"is_stock_item": 0, "is_sales_item": 1, "is_purchase_item": 0, "include_item_in_manufacturing": 0,
|
||
"disabled": boolInt(s.Disabled),
|
||
}
|
||
}
|
||
|
||
// boolInt is a Frappe Check value.
|
||
func boolInt(b bool) int {
|
||
if b {
|
||
return 1
|
||
}
|
||
return 0
|
||
}
|
||
|
||
// sepaFields put the direct-debit mandate on the Customer: reference, date of
|
||
// signature and type (Basislastschrift/CORE or Firmenlastschrift/B2B).
|
||
func sepaFields() []map[string]any {
|
||
section := customField("Customer", "sepa_section", "SEPA-Lastschriftmandat", "Section Break", "tenant_slug", false)
|
||
ref := customField("Customer", "sepa_mandate_reference", "Mandatsreferenz", "Data", "sepa_section", false)
|
||
date := customField("Customer", "sepa_mandate_date", "Mandat unterschrieben am", "Date", "sepa_mandate_reference", false)
|
||
kind := customField("Customer", "sepa_mandate_type", "Mandatsart", "Select", "sepa_mandate_date", false)
|
||
kind["options"] = "\nBasislastschrift (CORE)\nFirmenlastschrift (B2B)"
|
||
for _, f := range []map[string]any{section, ref, date, kind} {
|
||
f["description"] = "SEPA-Lastschriftmandat des Kunden; von Hand gepflegt."
|
||
}
|
||
section["collapsible"] = 1
|
||
return []map[string]any{section, ref, date, kind}
|
||
}
|
||
|
||
func modeOfPaymentDoc() map[string]any {
|
||
return map[string]any{"doctype": "Mode of Payment", "name": "SEPA-Lastschrift", "mode_of_payment": "SEPA-Lastschrift", "type": "Bank", "enabled": 1}
|
||
}
|
||
|
||
// invoiceSeries is the outgoing-invoice number range from the GoBD
|
||
// Verfahrensdokumentation (§ 9): RE-JJJJ-NNNN, a new range each calendar year
|
||
// (the year is part of the series key), one range for invoices and returns.
|
||
const invoiceSeries = "RE-.YYYY.-.####"
|
||
|
||
// invoiceSeriesSetters make it the only and the default naming series of the
|
||
// Sales Invoice (ERPNext ships ACC-SINV-.YYYY.- and ACC-SINV-RET-.YYYY.-).
|
||
func invoiceSeriesSetters() []map[string]any {
|
||
setter := func(prop, typ string) map[string]any {
|
||
return map[string]any{
|
||
"doctype": "Property Setter", "name": "Sales Invoice-naming_series-" + prop,
|
||
"doctype_or_field": "DocField", "doc_type": "Sales Invoice", "field_name": "naming_series",
|
||
"property": prop, "property_type": typ, "value": invoiceSeries,
|
||
}
|
||
}
|
||
return []map[string]any{setter("options", "Text"), setter("default", "Text")}
|
||
}
|
||
|
||
func itemPriceDoc(s sku) map[string]any {
|
||
return map[string]any{
|
||
"doctype": "Item Price", "item_code": s.Code, "price_list": priceList, "uom": s.UOM,
|
||
"price_list_rate": s.Price, "currency": "EUR", "selling": 1,
|
||
}
|
||
}
|
||
|
||
// Customers created from now on are numbered K-00001, K-00002, … (the
|
||
// number is what documents show as "Kundennummer"); existing customers keep
|
||
// their name. The registry stores whatever name ERPNext assigns.
|
||
const customerSeries = "K-.#####"
|
||
|
||
func customerNumbering() (settings map[string]any, setters []map[string]any) {
|
||
settings = map[string]any{"doctype": "Selling Settings", "name": "Selling Settings", "cust_master_name": "Naming Series"}
|
||
setter := func(prop string) map[string]any {
|
||
return map[string]any{
|
||
"doctype": "Property Setter", "name": "Customer-naming_series-" + prop,
|
||
"doctype_or_field": "DocField", "doc_type": "Customer", "field_name": "naming_series",
|
||
"property": prop, "property_type": "Text", "value": customerSeries,
|
||
}
|
||
}
|
||
return settings, []map[string]any{setter("options"), setter("default")}
|
||
}
|
||
|
||
// paymentTerms21 is the default for new customers: SEPA direct debit 21 days
|
||
// after the invoice date, so the invoice (the SEPA pre-notification) reaches
|
||
// the customer at least 14 days before the debit.
|
||
const paymentTerms21 = "SEPA-Lastschrift 21 Tage"
|
||
|
||
func paymentTermDoc() map[string]any {
|
||
return map[string]any{
|
||
"doctype": "Payment Term", "name": paymentTerms21, "payment_term_name": paymentTerms21,
|
||
"invoice_portion": 100, "mode_of_payment": "SEPA-Lastschrift",
|
||
"due_date_based_on": "Day(s) after invoice date", "credit_days": 21,
|
||
"description": "Der Rechnungsbetrag wird per SEPA-Lastschrift von Ihrem Konto eingezogen.",
|
||
}
|
||
}
|
||
|
||
func paymentTemplateDoc() map[string]any {
|
||
return map[string]any{
|
||
"doctype": "Payment Terms Template", "name": paymentTerms21, "template_name": paymentTerms21,
|
||
"terms": []map[string]any{{
|
||
"payment_term": paymentTerms21, "invoice_portion": 100, "mode_of_payment": "SEPA-Lastschrift",
|
||
"due_date_based_on": "Day(s) after invoice date", "credit_days": 21,
|
||
"description": "Der Rechnungsbetrag wird per SEPA-Lastschrift von Ihrem Konto eingezogen.",
|
||
}},
|
||
}
|
||
}
|
||
|
||
// contractBasisFields: "Vertragsgrundlage" on order and invoice, filled by
|
||
// hand for now (e.g. "SaaS-Vertrag vom 30.09.2026"); printed only when set.
|
||
func contractBasisFields() []map[string]any {
|
||
out := []map[string]any{}
|
||
for _, dt := range []string{"Sales Order", "Sales Invoice"} {
|
||
f := customField(dt, "vertragsgrundlage", "Vertragsgrundlage", "Data", "po_no", false)
|
||
f["description"] = "Z. B. \"SaaS-Vertrag vom 30.09.2026\". Erscheint auf Auftragsbestätigung und Rechnung."
|
||
f["allow_on_submit"] = 0
|
||
delete(f, "no_copy") // carried from the order to the invoice
|
||
out = append(out, f)
|
||
}
|
||
return out
|
||
}
|