added full settings options
This commit is contained in:
+8
-7
@@ -592,6 +592,7 @@ export async function generateQuotePDF(
|
||||
let displayDiscount = 0;
|
||||
let displayTax = 0;
|
||||
let displayTotal = 0;
|
||||
const showTax = appearance.showTaxLine && settings.taxEnabled !== false && settings.taxRate > 0;
|
||||
|
||||
if (hasMixed) {
|
||||
const split = computeSplitQuoteTotals(services, quote.discount || { value: 0, type: 'dollar' }, settings);
|
||||
@@ -616,7 +617,7 @@ export async function generateQuotePDF(
|
||||
if (discountValue > 0) {
|
||||
displayDiscount = discountType === 'percent' ? servicesTotal * (discountValue / 100) : discountValue;
|
||||
}
|
||||
const taxRate = settings.taxRate || 0;
|
||||
const taxRate = settings.taxEnabled === false ? 0 : settings.taxRate || 0;
|
||||
displayTax = (servicesTotal - displayDiscount + displayShopCharge) * (taxRate / 100);
|
||||
displayTotal = servicesTotal - displayDiscount + displayShopCharge + displayTax;
|
||||
}
|
||||
@@ -636,13 +637,13 @@ export async function generateQuotePDF(
|
||||
sumRows += 1; // combined subtotal
|
||||
if (appearance.showDiscountLine && displayDiscount > 0) sumRows += 1; // combined discount
|
||||
if (appearance.showShopChargeLine && displayShopCharge > 0) sumRows += 1; // combined capped shop charge
|
||||
if (appearance.showTaxLine && settings.taxRate > 0) sumRows += 1; // combined recalculated tax
|
||||
if (showTax) sumRows += 1; // combined recalculated tax
|
||||
sumRows += 2; // separator + grand total
|
||||
} else {
|
||||
sumRows = 1; // subtotal
|
||||
if (appearance.showDiscountLine && displayDiscount > 0) sumRows++;
|
||||
if (appearance.showShopChargeLine && displayShopCharge > 0) sumRows++;
|
||||
if (appearance.showTaxLine && settings.taxRate > 0) sumRows++;
|
||||
if (showTax) sumRows++;
|
||||
sumRows += 2; // separator + total
|
||||
}
|
||||
const sumContentH = (sumRows * getLineHeight(9, 1.2)) + 14 + (hasMixed ? mixedSectionGap * 2 : 0);
|
||||
@@ -676,7 +677,7 @@ export async function generateQuotePDF(
|
||||
doc.text(`$${approvedTotals.shopCharge.toFixed(2)}`, sumRight, y, { align: 'right' });
|
||||
y += getLineHeight(9);
|
||||
}
|
||||
if (appearance.showTaxLine && settings.taxRate > 0) {
|
||||
if (showTax) {
|
||||
applyTextStyle(doc, appearance.totals, DG);
|
||||
doc.text(settings.taxLabel || 'Tax', sumX, y);
|
||||
doc.setTextColor(...BL);
|
||||
@@ -702,7 +703,7 @@ export async function generateQuotePDF(
|
||||
doc.text(`$${pendingTotals.shopCharge.toFixed(2)}`, sumRight, y, { align: 'right' });
|
||||
y += getLineHeight(9);
|
||||
}
|
||||
if (appearance.showTaxLine && settings.taxRate > 0) {
|
||||
if (showTax) {
|
||||
applyTextStyle(doc, appearance.totals, DG);
|
||||
doc.text(settings.taxLabel || 'Tax', sumX, y);
|
||||
doc.setTextColor(...BL);
|
||||
@@ -739,7 +740,7 @@ export async function generateQuotePDF(
|
||||
y += getLineHeight(9);
|
||||
}
|
||||
|
||||
if (appearance.showTaxLine && settings.taxRate > 0) {
|
||||
if (showTax) {
|
||||
applyTextStyle(doc, appearance.totals, DG);
|
||||
doc.text(`${settings.taxLabel || 'Tax'} @ ${settings.taxRate}%`, sumX, y);
|
||||
doc.setTextColor(...GR);
|
||||
@@ -779,7 +780,7 @@ export async function generateQuotePDF(
|
||||
}
|
||||
|
||||
// Tax
|
||||
if (appearance.showTaxLine && settings.taxRate > 0) {
|
||||
if (showTax) {
|
||||
applyTextStyle(doc, appearance.totals, DG);
|
||||
doc.text(settings.taxLabel || 'Tax', sumX, y);
|
||||
doc.setTextColor(...BL);
|
||||
|
||||
Reference in New Issue
Block a user