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 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-02-09 11:02:36 +03:00
parent 08feda9af6
commit e8d0e28415

View File

@@ -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))