Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -71,7 +72,7 @@ func SendOrderMarketMailHandler(pg *sql.DB, mssql *sql.DB, ml *mailer.GraphMaile
|
||||
return
|
||||
}
|
||||
|
||||
pdfBytes, header, err := buildOrderPDFBytesForMail(mssql, orderID)
|
||||
pdfBytes, header, err := buildOrderPDFBytesForMail(mssql, pg, orderID)
|
||||
if err != nil {
|
||||
http.Error(w, "pdf build error: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -241,7 +242,7 @@ ORDER BY email
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func buildOrderPDFBytesForMail(db *sql.DB, orderID string) ([]byte, *OrderHeader, error) {
|
||||
func buildOrderPDFBytesForMail(db *sql.DB, pgDB *sql.DB, orderID string) ([]byte, *OrderHeader, error) {
|
||||
header, err := getOrderHeaderFromDB(db, orderID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -262,7 +263,19 @@ func buildOrderPDFBytesForMail(db *sql.DB, orderID string) ([]byte, *OrderHeader
|
||||
}
|
||||
}
|
||||
|
||||
rows := normalizeOrderLinesForPdf(lines)
|
||||
if pgDB == nil {
|
||||
return nil, nil, errors.New("product-size-match db not initialized")
|
||||
}
|
||||
sizeMatchData, err := loadProductSizeMatchData(pgDB)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
rows := normalizeOrderLinesForPdf(lines, sizeMatchData)
|
||||
for _, rr := range rows {
|
||||
if strings.TrimSpace(rr.Category) == "" {
|
||||
return nil, nil, fmt.Errorf("product-size-match unmapped row: %s/%s/%s", rr.Model, rr.GroupMain, rr.GroupSub)
|
||||
}
|
||||
}
|
||||
|
||||
pdf, err := newOrderPdf()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user