Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-17 12:15:30 +03:00
parent c779e93f43
commit e16d45002b
4 changed files with 57 additions and 16 deletions

View File

@@ -265,9 +265,8 @@ func drawCustomerBalancePDF(
summaryCols := []string{"Ana Cari Kod", "Ana Cari Detay", "Piyasa", "Temsilci", "Risk", "1_2 Pr.Br", "1_3 Pr.Br", "1_2 USD", "1_2 TRY", "1_3 USD", "1_3 TRY"}
summaryWeights := []float64{18, 42, 16, 16, 14, 24, 24, 14, 14, 14, 14}
if includeVadeColumns {
// Aging raporu (A4 dikey) için kolonlar sıkıştırılır.
summaryCols = append(summaryCols, "Vade Gun", "Belge Tarihi Gun")
summaryWeights = []float64{14, 28, 10, 10, 10, 13, 13, 9, 9, 9, 9, 8, 10}
summaryWeights = []float64{18, 38, 14, 14, 12, 20, 20, 12, 12, 12, 12, 10, 13}
}
summaryW := normalizeWidths(summaryWeights, tableW)
@@ -325,7 +324,8 @@ func drawCustomerBalancePDF(
}
drawSummaryHeader := func() {
pdf.SetFont("dejavu", "B", 7.5)
headerFont := 7.5
pdf.SetFont("dejavu", "B", headerFont)
pdf.SetFillColor(149, 113, 22)
pdf.SetTextColor(255, 255, 255)
y := pdf.GetY()
@@ -363,7 +363,8 @@ func drawCustomerBalancePDF(
header()
drawSummaryHeader()
pdf.SetFont("dejavu", "", 7.2)
bodyFont := 7.2
pdf.SetFont("dejavu", "", bodyFont)
pdf.SetTextColor(20, 20, 20)
totalUSD12, totalTRY12 := 0.0, 0.0
@@ -412,7 +413,7 @@ func drawCustomerBalancePDF(
totalsRow = append(totalsRow, formatDayUpPDF(totalVade), formatDayUpPDF(totalVadeBelge))
}
totalH := calcPDFRowHeightCapped(pdf, totalsRow, summaryW, map[int]int{0: 1, 1: 1, 2: 1, 3: 1, 5: 2, 6: 2}, 6.2, 3.4)
totalH := calcPDFRowHeightCapped(pdf, totalsRow, summaryW, map[int]int{0: 1, 1: 1, 2: 1, 3: 1, 5: 2, 6: 2}, 6.0, 3.4)
if needPage(totalH) {
header()
drawSummaryHeader()
@@ -442,7 +443,7 @@ func drawCustomerBalancePDF(
totalX += summaryW[i]
}
pdf.SetY(totalY + totalH)
pdf.SetFont("dejavu", "", 7.2)
pdf.SetFont("dejavu", "", bodyFont)
pdf.SetTextColor(20, 20, 20)
for _, s := range summaries {
@@ -463,11 +464,11 @@ func drawCustomerBalancePDF(
row = append(row, formatDayUpPDF(s.VadeGun), formatDayUpPDF(s.VadeBelge))
}
rowH := calcPDFRowHeightCapped(pdf, row, summaryW, map[int]int{0: 3, 1: 3, 2: 3, 3: 3}, 6.2, 3.6)
rowH := calcPDFRowHeightCapped(pdf, row, summaryW, map[int]int{0: 3, 1: 3, 2: 3, 3: 3, 4: 2, 5: 2, 6: 2}, 6.0, 3.4)
if needPage(rowH) {
header()
drawSummaryHeader()
pdf.SetFont("dejavu", "", 7.2)
pdf.SetFont("dejavu", "", bodyFont)
pdf.SetTextColor(20, 20, 20)
}
@@ -486,9 +487,11 @@ func drawCustomerBalancePDF(
align = "C"
}
if i <= 3 {
drawPDFCellWrappedCapped(pdf, v, x, y, summaryW[i], rowH, align, 3.6, 3)
drawPDFCellWrappedCapped(pdf, v, x, y, summaryW[i], rowH, align, 3.4, 3)
} else if i == 5 || i == 6 {
drawPDFCellWrappedCapped(pdf, v, x, y, summaryW[i], rowH, align, 3.4, 2)
} else {
drawPDFCellWrapped(pdf, v, x, y, summaryW[i], rowH, align, 3.6)
drawPDFCellWrapped(pdf, v, x, y, summaryW[i], rowH, align, 3.4)
}
x += summaryW[i]
}
@@ -733,7 +736,8 @@ func drawPDFCellWrapped(pdf *gofpdf.Fpdf, value string, x, y, w, h float64, alig
for _, ln := range lines {
pdf.SetXY(x+1, startY)
pdf.CellFormat(w-2, lineH, string(ln), "", 0, align, false, 0, "")
fitted := fitTextWithSuffixPDF(pdf, string(ln), w-2, "...")
pdf.CellFormat(w-2, lineH, fitted, "", 0, align, false, 0, "")
startY += lineH
}
}
@@ -804,7 +808,8 @@ func drawPDFCellWrappedCapped(pdf *gofpdf.Fpdf, value string, x, y, w, h float64
for _, ln := range lines {
pdf.SetXY(x+1, startY)
pdf.CellFormat(w-2, lineH, string(ln), "", 0, align, false, 0, "")
fitted := fitTextWithSuffixPDF(pdf, string(ln), w-2, "...")
pdf.CellFormat(w-2, lineH, fitted, "", 0, align, false, 0, "")
startY += lineH
}
}

View File

@@ -74,7 +74,7 @@ func ExportStatementAgingPDFHandler(_ *sql.DB) http.HandlerFunc {
rows = filterCustomerBalanceRowsForPDF(rows, excludeZero12, excludeZero13)
summaries, detailsByMaster := buildCustomerBalancePDFData(rows)
pdf := gofpdf.New("P", "mm", "A4", "")
pdf := gofpdf.New("L", "mm", "A4", "")
pdf.SetMargins(8, 8, 8)
pdf.SetAutoPageBreak(false, 12)
if err := registerDejavuFonts(pdf, "dejavu"); err != nil {
@@ -92,7 +92,7 @@ func ExportStatementAgingPDFHandler(_ *sql.DB) http.HandlerFunc {
summaries,
detailsByMaster,
); err != nil {
pdf = gofpdf.New("P", "mm", "A4", "")
pdf = gofpdf.New("L", "mm", "A4", "")
pdf.SetMargins(8, 8, 8)
pdf.SetAutoPageBreak(true, 12)
if ferr := registerDejavuFonts(pdf, "dejavu"); ferr != nil {