Merge pull request 'fix(contracts): TOMs are available once the released TOM is listed' (#133) from fix/toms-status-available into main
ci / shared (push) Successful in 12s
ci / test (push) Successful in 7m18s
ci / image (push) Successful in 53s

This commit was merged in pull request #133.
This commit is contained in:
sharang committed 2026-11-16 22:00:02 +00:00
commit 8a72469e18
2 files changed
+14 -1

No files matched your search

+6 -1
View File
@@ -23,6 +23,7 @@ import (
type contractsView struct { type contractsView struct {
Trial json.RawMessage `json:"trial"` Trial json.RawMessage `json:"trial"`
AVV contractStatus `json:"avv"` AVV contractStatus `json:"avv"`
TOMs contractStatus `json:"toms"`
Documents []contractDocument `json:"documents"` Documents []contractDocument `json:"documents"`
} }
@@ -122,7 +123,7 @@ func TestContractCatalogueNamesKnownProductsAndServices(t *testing.T) {
func TestContractDocuments_gateOff(t *testing.T) { func TestContractDocuments_gateOff(t *testing.T) {
f := newContractFixture(t, false) f := newContractFixture(t, false)
v, raw := f.contracts(t) v, raw := f.contracts(t)
if !strings.Contains(raw, `"documents":[]`) || len(v.Documents) != 0 || v.AVV.Status != "not_concluded" { if !strings.Contains(raw, `"documents":[]`) || len(v.Documents) != 0 || v.AVV.Status != "not_concluded" || v.TOMs.Status != "pending" {
t.Fatalf("gate off: %s", raw) t.Fatalf("gate off: %s", raw)
} }
if code, _, _ := f.contractPDF(t, "lb-plattform.pdf"); code != 404 { if code, _, _ := f.contractPDF(t, "lb-plattform.pdf"); code != 404 {
@@ -144,6 +145,10 @@ func TestContractDocuments_leistungsbeschreibungen(t *testing.T) {
if got := docIDs(v.Documents); got != "agb,tom,lb-plattform,lb-pruefwerk,lb-firmwerk" { if got := docIDs(v.Documents); got != "agb,tom,lb-plattform,lb-pruefwerk,lb-firmwerk" {
t.Fatalf("documents: %s", got) t.Fatalf("documents: %s", got)
} }
// With the TOM listed, the TOMs are available rather than pending.
if v.TOMs.Status != "available" {
t.Errorf("toms status %q", v.TOMs.Status)
}
pw := v.Documents[3] pw := v.Documents[3]
if pw.Kind != "lb" || pw.Version != "1.0.3" || pw.Date != "09.11.2026" || pw.Product != "pruefwerk" || pw.TenantSpecific || if pw.Kind != "lb" || pw.Version != "1.0.3" || pw.Date != "09.11.2026" || pw.Product != "pruefwerk" || pw.TenantSpecific ||
pw.SHA256 != contractdocs.Default().Get("lb-pruefwerk").SHA256 || pw.Title != "Leistungsbeschreibung Prüfwerk" { pw.SHA256 != contractdocs.Default().Get("lb-pruefwerk").SHA256 || pw.Title != "Leistungsbeschreibung Prüfwerk" {
+8
View File
@@ -27,6 +27,7 @@ import (
"time" "time"
"unicode" "unicode"
"git.breakpilot.com/platform/tenant-registry/internal/legal/contractdocs"
"git.breakpilot.com/platform/tenant-registry/internal/legal/trialterms" "git.breakpilot.com/platform/tenant-registry/internal/legal/trialterms"
bpmail "git.breakpilot.com/platform/tenant-registry/internal/mail" bpmail "git.breakpilot.com/platform/tenant-registry/internal/mail"
"git.breakpilot.com/platform/tenant-registry/internal/store" "git.breakpilot.com/platform/tenant-registry/internal/store"
@@ -675,6 +676,13 @@ func (s *Server) listTenantContracts(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusInternalServerError, "internal", err.Error()) writeError(w, http.StatusInternalServerError, "internal", err.Error())
return return
} }
// The TOMs are "pending" until a released TOM is listed for this tenant
// (released 16.11.2026; listed only while CONTRACT_DOCUMENTS is on).
for _, d := range resp.Documents {
if d.Kind == contractdocs.KindTOM {
resp.TOMs = contractStatus{"available"}
}
}
writeJSON(w, http.StatusOK, resp) writeJSON(w, http.StatusOK, resp)
} }