From e8d0e284158ef618ba22043d6fe0c552404b8d18 Mon Sep 17 00:00:00 2001 From: Mikhail Chusavitin Date: Mon, 9 Feb 2026 11:02:36 +0300 Subject: [PATCH] export: add project name to CSV filename format Update filename format to include both project and quotation names: YYYY-MM-DD (PROJECT-NAME) QUOTATION-NAME BOM.csv Changes: - Add ProjectName field to ExportRequest (optional) - Update ExportCSV: use project_name if provided, otherwise fall back to name - Update ExportConfigCSV: use config name for both project and quotation Example filenames: 2026-02-09 (OPS-1957) config1 BOM.csv 2026-02-09 (MyProject) MyQuotation BOM.csv Co-Authored-By: Claude Haiku 4.5 --- internal/handlers/export.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/handlers/export.go b/internal/handlers/export.go index ec84a53..7b9ab50 100644 --- a/internal/handlers/export.go +++ b/internal/handlers/export.go @@ -29,8 +29,9 @@ func NewExportHandler( } type ExportRequest struct { - Name string `json:"name" binding:"required"` - Items []struct { + Name string `json:"name" binding:"required"` + ProjectName string `json:"project_name"` + Items []struct { LotName string `json:"lot_name" binding:"required"` Quantity int `json:"quantity" binding:"required,min=1"` UnitPrice float64 `json:"unit_price"` @@ -54,7 +55,11 @@ func (h *ExportHandler) ExportCSV(c *gin.Context) { } // Set headers before streaming - filename := fmt.Sprintf("%s (%s) BOM.csv", time.Now().Format("2006-01-02"), req.Name) + projectName := req.ProjectName + if projectName == "" { + projectName = req.Name + } + filename := fmt.Sprintf("%s (%s) %s BOM.csv", time.Now().Format("2006-01-02"), projectName, req.Name) c.Header("Content-Type", "text/csv; charset=utf-8") c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename)) @@ -124,7 +129,8 @@ func (h *ExportHandler) ExportConfigCSV(c *gin.Context) { } // Set headers before streaming - filename := fmt.Sprintf("%s (%s) BOM.csv", config.CreatedAt.Format("2006-01-02"), config.Name) + // For config export, use config name for both project and quotation name + filename := fmt.Sprintf("%s (%s) %s BOM.csv", config.CreatedAt.Format("2006-01-02"), config.Name, config.Name) c.Header("Content-Type", "text/csv; charset=utf-8") c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))