pdf export

This commit is contained in:
2026-07-26 17:05:48 -05:00
parent 363a14d49b
commit e086fe8931
4 changed files with 473 additions and 27 deletions

View File

@@ -149,6 +149,8 @@ export function renderReportsView() {
class="px-3 py-1.5 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">Run</button>
<button onclick="window.reportsView.exportArAgingCsv()"
class="px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md text-sm font-medium border border-gray-300">⬇ Export CSV</button>
<button onclick="window.reportsView.exportArAgingPdf()"
class="px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md text-sm font-medium border border-gray-300">📄 Export PDF</button>
<label class="flex items-center gap-1 pt-5 text-xs text-gray-600 cursor-pointer">
<input type="checkbox" id="ar-anonymize" ${arAnonymize ? 'checked' : ''}
class="h-4 w-4 text-blue-600 border-gray-300 rounded">
@@ -173,6 +175,8 @@ export function renderReportsView() {
class="px-3 py-1.5 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">Run</button>
<button onclick="window.reportsView.exportRevenueCsv()"
class="px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md text-sm font-medium border border-gray-300">⬇ Export CSV</button>
<button onclick="window.reportsView.exportRevenuePdf()"
class="px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md text-sm font-medium border border-gray-300">📄 Export PDF</button>
<label class="flex items-center gap-1 pt-5 text-xs text-gray-600 cursor-pointer">
<input type="checkbox" id="rev-group-month" ${revGroupByMonth ? 'checked' : ''}
class="h-4 w-4 text-blue-600 border-gray-300 rounded">
@@ -394,6 +398,20 @@ export function exportArAgingCsv() {
downloadCsv(`ar-aging-${arData.asOf}${arData.anonymized ? '-anonymized' : ''}.csv`, lines);
}
/**
* PDF-Export nach dem Muster von exportCustomerRevenuePdf: Parameter direkt
* aus den Eingabefeldern, der Server holt die Daten neu. Der Report muss
* dafür nicht vorher ausgeführt worden sein.
*/
export function exportArAgingPdf() {
const asOfEl = document.getElementById('ar-asof');
if (!asOfEl?.value) return alert('Please select an as-of date first.');
const anonymize = document.getElementById('ar-anonymize')?.checked || false;
let url = `/api/reports/ar-aging/pdf?asOf=${asOfEl.value}`;
if (anonymize) url += '&anonymize=true';
window.open(url, '_blank');
}
// ── Report 2: Invoice-Level Revenue ─────────────────────────────────
export async function loadRevenue() {
@@ -540,6 +558,19 @@ export function exportRevenueCsv() {
downloadCsv(`revenue-${revData.from}_to_${revData.to}${revData.anonymized ? '-anonymized' : ''}.csv`, lines);
}
export function exportRevenuePdf() {
const fromEl = document.getElementById('rev-from');
const toEl = document.getElementById('rev-to');
if (!fromEl?.value || !toEl?.value) return alert('Please select both a from and a to date.');
if (fromEl.value > toEl.value) return alert('The from date must not be after the to date.');
const anonymize = document.getElementById('rev-anonymize')?.checked || false;
const groupByMonth = document.getElementById('rev-group-month')?.checked || false;
let url = `/api/reports/revenue/pdf?from=${fromEl.value}&to=${toEl.value}`;
if (anonymize) url += '&anonymize=true';
if (groupByMonth) url += '&groupByMonth=true';
window.open(url, '_blank');
}
// ────────────────────────────────────────────────────────────────────
// Aus accounting-view.js übernommene Reports
// Funktionskörper 1:1; geändert wurden nur die onclick-Namespaces im
@@ -678,8 +709,10 @@ window.reportsView = {
renderReportsView,
loadArAging,
exportArAgingCsv,
exportArAgingPdf,
loadRevenue,
exportRevenueCsv,
exportRevenuePdf,
loadProfitLoss,
loadBalanceSheet,
loadTaxSummary,