This commit is contained in:
2026-08-23 20:49:40 +02:00
parent 3b678ca857
commit f3d4fb56ed
31 changed files with 3608 additions and 111 deletions
+13
View File
@@ -237,6 +237,13 @@ func (s *Service) flushCategoryBatch(ctx context.Context, companyID uuid.UUID, b
if err != nil {
return err
}
nameByUID := make(map[string]string, len(insUIDs))
for i, uid := range insUIDs {
if i < len(insNames) {
nameByUID[uid] = insNames[i]
}
}
var seedFormulas []DefaultFormulaTarget
for rows.Next() {
var id uuid.UUID
var uid, path string
@@ -246,6 +253,7 @@ func (s *Service) flushCategoryBatch(ctx context.Context, companyID uuid.UUID, b
return err
}
known[uid] = categoryPathInfo{id: id, path: path, level: level}
seedFormulas = append(seedFormulas, DefaultFormulaTarget{ID: id, UniqueID: uid, Name: nameByUID[uid]})
res.Created++
}
err = rows.Err()
@@ -253,6 +261,11 @@ func (s *Service) flushCategoryBatch(ctx context.Context, companyID uuid.UUID, b
if err != nil {
return err
}
// Imported categories get the platform-default formula too, so an imported
// taxonomy enhances into formula-shaped copy without further setup.
if err := ApplyDefaultCategoryFormulas(ctx, tx, companyID, seedFormulas...); err != nil {
return err
}
pendingInserts = next
}