format
This commit is contained in:
parent
66736ef09d
commit
cc19cfcfad
44
server.js
44
server.js
|
|
@ -330,7 +330,9 @@ async function syncInvoiceToQbo(invoiceId, client) {
|
||||||
return { success: true, sync_token: updated.SyncToken };
|
return { success: true, sync_token: updated.SyncToken };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatMoney(val) {
|
||||||
|
return parseFloat(val).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
|
}
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// POST /api/invoices — Create + Auto QBO Export
|
// POST /api/invoices — Create + Auto QBO Export
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
@ -1231,19 +1233,19 @@ app.get('/api/quotes/:id/pdf', async (req, res) => {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Subtotal:</td>
|
<td colspan="3" class="total-label">Subtotal:</td>
|
||||||
<td class="total-amount">$${parseFloat(quote.subtotal).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(quote.subtotal)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
if (!quote.tax_exempt) {
|
if (!quote.tax_exempt) {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Tax (${quote.tax_rate}%):</td>
|
<td colspan="3" class="total-label">Tax (${quote.tax_rate}%):</td>
|
||||||
<td class="total-amount">$${parseFloat(quote.tax_amount).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(quote.tax_amount)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">TOTAL:</td>
|
<td colspan="3" class="total-label" style="font-size: 16px;">TOTAL:</td>
|
||||||
<td class="total-amount">$${parseFloat(quote.total).toFixed(2)}</td>
|
<td class="total-amount" style="font-size: 16px;">$${formatMoney(quote.total)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
||||||
|
|
@ -1353,13 +1355,13 @@ app.get('/api/invoices/:id/pdf', async (req, res) => {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Subtotal:</td>
|
<td colspan="3" class="total-label">Subtotal:</td>
|
||||||
<td class="total-amount">$${parseFloat(invoice.subtotal).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(invoice.subtotal)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
if (!invoice.tax_exempt) {
|
if (!invoice.tax_exempt) {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Tax (${invoice.tax_rate}%):</td>
|
<td colspan="3" class="total-label">Tax (${invoice.tax_rate}%):</td>
|
||||||
<td class="total-amount">$${parseFloat(invoice.tax_amount).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(invoice.tax_amount)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
const amountPaid = parseFloat(invoice.amount_paid) || 0;
|
const amountPaid = parseFloat(invoice.amount_paid) || 0;
|
||||||
|
|
@ -1367,19 +1369,19 @@ app.get('/api/invoices/:id/pdf', async (req, res) => {
|
||||||
|
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label" style="font-size: 14px;">TOTAL:</td>
|
<td colspan="3" class="total-label" style="font-size: 16px;">TOTAL:</td>
|
||||||
<td class="total-amount" style="font-size: 14px;">$${parseFloat(invoice.total).toFixed(2)}</td>
|
<td class="total-amount" style="font-size: 16px;">$${formatMoney(invoice.total)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
if (amountPaid > 0) {
|
if (amountPaid > 0) {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label" style="font-size: 14px; color: #059669;">Downpayment:</td>
|
<td colspan="3" class="total-label" style="color: #059669;">Downpayment:</td>
|
||||||
<td class="total-amount" style="color: #059669;">-$${amountPaid.toFixed(2)}</td>
|
<td class="total-amount" style="color: #059669;">-$${formatMoney(amountPaid)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">BALANCE DUE:</td>
|
<td colspan="3" class="total-label" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">BALANCE DUE:</td>
|
||||||
<td class="total-amount" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">$${balanceDue.toFixed(2)}</td>
|
<td class="total-amount" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">$${formatMoney(balanceDue)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1491,19 +1493,19 @@ app.get('/api/quotes/:id/html', async (req, res) => {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Subtotal:</td>
|
<td colspan="3" class="total-label">Subtotal:</td>
|
||||||
<td class="total-amount">$${parseFloat(quote.subtotal).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(quote.subtotal)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
if (!quote.tax_exempt) {
|
if (!quote.tax_exempt) {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Tax (${quote.tax_rate}%):</td>
|
<td colspan="3" class="total-label">Tax (${quote.tax_rate}%):</td>
|
||||||
<td class="total-amount">$${parseFloat(quote.tax_amount).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(quote.tax_amount)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">TOTAL:</td>
|
<td colspan="3" class="total-label" style="font-size: 16px;">TOTAL:</td>
|
||||||
<td class="total-amount">$${parseFloat(quote.total).toFixed(2)}</td>
|
<td class="total-amount" style="font-size: 16px;">$${formatMoney(quote.total)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
||||||
|
|
@ -1596,13 +1598,13 @@ app.get('/api/invoices/:id/html', async (req, res) => {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Subtotal:</td>
|
<td colspan="3" class="total-label">Subtotal:</td>
|
||||||
<td class="total-amount">$${parseFloat(invoice.subtotal).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(invoice.subtotal)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
if (!invoice.tax_exempt) {
|
if (!invoice.tax_exempt) {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">Tax (${invoice.tax_rate}%):</td>
|
<td colspan="3" class="total-label">Tax (${invoice.tax_rate}%):</td>
|
||||||
<td class="total-amount">$${parseFloat(invoice.tax_amount).toFixed(2)}</td>
|
<td class="total-amount">$${formatMoney(invoice.tax_amount)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
const amountPaid = parseFloat(invoice.amount_paid) || 0;
|
const amountPaid = parseFloat(invoice.amount_paid) || 0;
|
||||||
|
|
@ -1611,18 +1613,18 @@ app.get('/api/invoices/:id/html', async (req, res) => {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label" style="font-size: 16px;">TOTAL:</td>
|
<td colspan="3" class="total-label" style="font-size: 16px;">TOTAL:</td>
|
||||||
<td class="total-amount" style="font-size: 16px;">$${parseFloat(invoice.total).toFixed(2)}</td>
|
<td class="total-amount" style="font-size: 16px;">$${formatMoney(invoice.total)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
if (amountPaid > 0) {
|
if (amountPaid > 0) {
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label" style="color: #059669;">Downpayment:</td>
|
<td colspan="3" class="total-label" style="color: #059669;">Downpayment:</td>
|
||||||
<td class="total-amount" style="color: #059669;">-$${amountPaid.toFixed(2)}</td>
|
<td class="total-amount" style="color: #059669;">-$${formatMoney(amountPaid)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">BALANCE DUE:</td>
|
<td colspan="3" class="total-label" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">BALANCE DUE:</td>
|
||||||
<td class="total-amount" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">$${balanceDue.toFixed(2)}</td>
|
<td class="total-amount" style="font-weight: bold; font-size: 16px; border-top: 2px solid #333; padding-top: 8px;">$${formatMoney(balanceDue)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue