Skip to content

Commit 877c530

Browse files
committed
fix: Update PDF report generation to include footer on the last page and optimize asset pagination
1 parent 88b9d22 commit 877c530

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

.no-env-here!

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
# This file is intentionally left empty: you can add optional variables
55
# only if you decide to extend the project with personal integrations.
66

7-
# Example (optional):
8-
# VITE_APP_NAME="3ASYWEALTH"
7+
VITE_APP_NAME="3ASYWEALTH"

src/lib/pdfReport.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const createReportHTML = (data: ReportData): string => {
9696
// Assets table HTML - diviso per pagine (inizia da pagina 2)
9797
const assetsPerPage = 15 // Numero di asset per pagina
9898
const assetPages: string[] = []
99+
const totalAssetPages = Math.ceil(assets.length / assetsPerPage)
99100

100101
for (let i = 0; i < assets.length; i += assetsPerPage) {
101102
const pageAssets = assets.slice(i, i + assetsPerPage)
@@ -114,8 +115,10 @@ const createReportHTML = (data: ReportData): string => {
114115
}).join('')
115116

116117
const pageNumber = Math.floor(i / assetsPerPage) + 2 // Inizia da pagina 2
118+
const isLastPage = (i + assetsPerPage) >= assets.length
119+
117120
assetPages.push(`
118-
<div class="page" style="page-break-after: always;">
121+
<div class="page"${isLastPage ? '' : ' style="page-break-after: always;"'}>
119122
<div class="page-header">
120123
<h2>${t('pdfReport.assets.title')} (${t('pdfReport.page')} ${pageNumber})</h2>
121124
</div>
@@ -134,6 +137,14 @@ const createReportHTML = (data: ReportData): string => {
134137
${assetsHTML}
135138
</tbody>
136139
</table>
140+
141+
${isLastPage ? `
142+
<!-- Footer (last page) -->
143+
<div class="footer">
144+
<p><strong>${t('pdfReport.footer.generated')} 3ASYWEALTH v1.0.0</strong></p>
145+
<p>${t('pdfReport.footer.opensource')} | ${t('pdfReport.footer.privacy')}</p>
146+
</div>
147+
` : ''}
137148
</div>
138149
`)
139150
}
@@ -346,12 +357,6 @@ const createReportHTML = (data: ReportData): string => {
346357
347358
<!-- PAGES 2+: Asset Details -->
348359
${assetPages.join('\n')}
349-
350-
<!-- Footer (last page) -->
351-
<div class="footer">
352-
<p><strong>${t('pdfReport.footer.generated')} 3ASYWEALTH v1.0.0</strong></p>
353-
<p>${t('pdfReport.footer.opensource')} | ${t('pdfReport.footer.privacy')}</p>
354-
</div>
355360
</body>
356361
</html>
357362
`

0 commit comments

Comments
 (0)