PDF Export Report

This commit is contained in:
2026-06-10 17:21:29 -05:00
parent ba6019751f
commit 8959064080
3 changed files with 246 additions and 1 deletions

View File

@@ -458,6 +458,7 @@ export function injectReportsControls() {
<option value="Cash" ${plAccountingMethod === 'Cash' ? 'selected' : ''}>Cash</option>
</select></div>
<button onclick="window.accountingView.loadProfitLoss()" 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.accountingView.exportProfitLossPdf()" 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">📄 PDF</button>
</div>
<div id="pl-result"></div>
</div>
@@ -474,6 +475,7 @@ export function injectReportsControls() {
<option value="Cash" ${bsAccountingMethod === 'Cash' ? 'selected' : ''}>Cash</option>
</select></div>
<button onclick="window.accountingView.loadBalanceSheet()" 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.accountingView.exportBalanceSheetPdf()" 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">📄 PDF</button>
</div>
<div id="bs-result"></div>
</div>
@@ -490,6 +492,7 @@ export function injectReportsControls() {
<option value="Cash" ${tsAccountingMethod === 'Cash' ? 'selected' : ''}>Cash</option>
</select></div>
<button onclick="window.accountingView.loadTaxSummary()" 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.accountingView.exportTaxSummaryPdf()" 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">📄 PDF</button>
</div>
<div id="ts-result"></div>
</div>
@@ -617,6 +620,31 @@ export function exportCustomerRevenuePdf() {
window.open(url, '_blank');
}
export function exportProfitLossPdf() {
const startEl = document.getElementById('pl-start');
const endEl = document.getElementById('pl-end');
const method = document.getElementById('pl-method')?.value || 'Accrual';
if (!startEl?.value || !endEl?.value) return alert('Please select start and end dates first.');
window.open(`/api/accounting/reports/profit-loss/pdf?startDate=${startEl.value}&endDate=${endEl.value}&accountingMethod=${method}`, '_blank');
}
export function exportBalanceSheetPdf() {
const asOf = document.getElementById('bs-asof');
const method = document.getElementById('bs-method')?.value || 'Accrual';
if (!asOf?.value) return alert('Please select an as-of date first.');
window.open(`/api/accounting/reports/balance-sheet/pdf?asOfDate=${asOf.value}&accountingMethod=${method}`, '_blank');
}
export function exportTaxSummaryPdf() {
const monthEl = document.getElementById('ts-month');
const method = document.getElementById('ts-method')?.value || 'Accrual';
if (!monthEl?.value) return alert('Please select a month first.');
const [y, m] = monthEl.value.split('-').map(Number);
const startDate = firstOfMonthISO(y, m - 1);
const endDate = lastOfMonthISO(y, m - 1);
window.open(`/api/accounting/reports/tax-summary/pdf?startDate=${startDate}&endDate=${endDate}&accountingMethod=${method}`, '_blank');
}
function renderQboReport(report) {
if (!report || !report.Header) return `<p class="text-sm text-gray-500">No report data.</p>`;
const cols = (report.Columns && report.Columns.Column) || [];
@@ -1388,5 +1416,8 @@ window.accountingView = {
recordTaxPayment,
markTaxPaidExternal,
loadCustomerRevenue,
exportCustomerRevenuePdf
exportCustomerRevenuePdf,
exportProfitLossPdf,
exportBalanceSheetPdf,
exportTaxSummaryPdf
};