feat: Improve trial balance display and PDF export with class totals
- Change totals display to single horizontal line using shared CSS - Rename column headers from "Sold Prec" to "Sume Prec" (correct terminology) - Add class totals (TOTAL CLASA 1-7) and grand total to PDF export - Style class totals with light gray background, grand total with darker gray - Update CLAUDE.md with rule to use shared CSS instead of creating new styles 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -121,11 +121,16 @@ export const exportToPDF = (data, columns, filename, header) => {
|
||||
const tableColumns = columns.map((col) => col.header);
|
||||
const totalRowIndices = new Set(); // Track which rows are totals
|
||||
|
||||
const grandTotalRowIndices = new Set(); // Track grand total rows
|
||||
|
||||
const tableRows = data.map((row, rowIndex) => {
|
||||
// Track total rows for special styling
|
||||
if (row._isTotal) {
|
||||
totalRowIndices.add(rowIndex);
|
||||
}
|
||||
if (row._isGrandTotal) {
|
||||
grandTotalRowIndices.add(rowIndex);
|
||||
}
|
||||
|
||||
return columns.map((col) => {
|
||||
const value = row[col.field];
|
||||
@@ -180,8 +185,8 @@ export const exportToPDF = (data, columns, filename, header) => {
|
||||
const defaultWidths = {
|
||||
0: totalWidth * 0.07, // Cont: ~20mm
|
||||
1: totalWidth * 0.33, // Denumire: ~93mm
|
||||
2: totalWidth * 0.1, // Sold Prec D: ~28mm
|
||||
3: totalWidth * 0.1, // Sold Prec C: ~28mm
|
||||
2: totalWidth * 0.1, // Sume Prec D: ~28mm
|
||||
3: totalWidth * 0.1, // Sume Prec C: ~28mm
|
||||
4: totalWidth * 0.1, // Rulaj D: ~28mm
|
||||
5: totalWidth * 0.1, // Rulaj C: ~28mm
|
||||
6: totalWidth * 0.1, // Sold Final D: ~28mm
|
||||
@@ -313,10 +318,16 @@ export const exportToPDF = (data, columns, filename, header) => {
|
||||
const colIndex = data.column.index;
|
||||
const column = columns[colIndex];
|
||||
|
||||
// Style total rows differently (bold, light gray background)
|
||||
if (totalRowIndices.has(rowIndex)) {
|
||||
// Style grand total rows (bold, darker gray background)
|
||||
if (grandTotalRowIndices.has(rowIndex)) {
|
||||
data.cell.styles.fontStyle = "bold";
|
||||
data.cell.styles.fillColor = [230, 230, 230]; // Light gray
|
||||
data.cell.styles.fillColor = [200, 200, 200]; // Darker gray
|
||||
data.cell.styles.fontSize = 10;
|
||||
}
|
||||
// Style class total rows (bold, light gray background)
|
||||
else if (totalRowIndices.has(rowIndex)) {
|
||||
data.cell.styles.fontStyle = "bold";
|
||||
data.cell.styles.fillColor = [235, 235, 235]; // Light gray
|
||||
}
|
||||
|
||||
if (column) {
|
||||
@@ -332,6 +343,15 @@ export const exportToPDF = (data, columns, filename, header) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
willDrawCell: function (data) {
|
||||
// Draw double line above grand total row
|
||||
if (data.section === "body" && grandTotalRowIndices.has(data.row.index)) {
|
||||
const doc = data.doc;
|
||||
doc.setDrawColor(100, 100, 100);
|
||||
doc.setLineWidth(0.5);
|
||||
doc.line(data.cell.x, data.cell.y, data.cell.x + data.cell.width, data.cell.y);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Add footer to all pages AFTER table generation
|
||||
|
||||
Reference in New Issue
Block a user