Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-03 11:26:52 +03:00
parent cbcf08728a
commit c57c04e12a
2 changed files with 15 additions and 1 deletions

View File

@@ -284,7 +284,7 @@ func drawCustomerBalancePDF(
if t == "" {
t = "-"
}
return pdf.SplitLines([]byte(t), w)
return splitLinesSafe(pdf, t, w)
}
calcWrappedRowHeight := func(row []string, widths []float64, wrapIdx map[int]bool, lineH float64, minH float64) float64 {

View File

@@ -7,8 +7,10 @@ import (
"bytes"
"database/sql"
"fmt"
"log"
"math"
"net/http"
"runtime/debug"
"sort"
"strconv"
"strings"
@@ -76,6 +78,13 @@ type agingMasterPDF struct {
func ExportStatementAgingPDFHandler(_ *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
defer func() {
if rec := recover(); rec != nil {
log.Printf("PANIC ExportStatementAgingPDFHandler: %v\n%s", rec, string(debug.Stack()))
http.Error(w, "internal server error", http.StatusInternalServerError)
}
}()
claims, ok := auth.GetClaimsFromContext(r.Context())
if !ok || claims == nil {
http.Error(w, "unauthorized", http.StatusUnauthorized)
@@ -99,6 +108,11 @@ func ExportStatementAgingPDFHandler(_ *sql.DB) http.HandlerFunc {
excludeZero12 := parseBoolQuery(r.URL.Query().Get("exclude_zero_12"))
excludeZero13 := parseBoolQuery(r.URL.Query().Get("exclude_zero_13"))
if err := queries.RebuildStatementAgingCache(r.Context()); err != nil {
http.Error(w, "cache rebuild error: "+err.Error(), http.StatusInternalServerError)
return
}
rows, err := queries.GetStatementAgingBalanceList(r.Context(), listParams)
if err != nil {
http.Error(w, "db error: "+err.Error(), http.StatusInternalServerError)