@huloglobal/vendure-plugin-quotations 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +57 -0
- package/dist/client-ip.d.ts +59 -0
- package/dist/client-ip.d.ts.map +1 -0
- package/dist/client-ip.js +145 -0
- package/dist/client-ip.js.map +1 -0
- package/dist/email-layout.d.ts +104 -0
- package/dist/email-layout.d.ts.map +1 -0
- package/dist/email-layout.js +250 -0
- package/dist/email-layout.js.map +1 -0
- package/dist/emails.d.ts +57 -0
- package/dist/emails.d.ts.map +1 -0
- package/dist/emails.js +124 -0
- package/dist/emails.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/payment.service.d.ts.map +1 -1
- package/dist/payment.service.js +4 -1
- package/dist/payment.service.js.map +1 -1
- package/dist/pdf.d.ts.map +1 -1
- package/dist/pdf.js +18 -9
- package/dist/pdf.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/dist/pricing.d.ts +58 -3
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +90 -9
- package/dist/pricing.js.map +1 -1
- package/dist/pro.service.d.ts.map +1 -1
- package/dist/pro.service.js +25 -5
- package/dist/pro.service.js.map +1 -1
- package/dist/quotation.controller.d.ts +5 -3
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +30 -27
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +31 -5
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +161 -38
- package/dist/quotation.service.js.map +1 -1
- package/dist/quote-version.d.ts.map +1 -1
- package/dist/quote-version.js +3 -0
- package/dist/quote-version.js.map +1 -1
- package/dist/rate-limit.d.ts +15 -0
- package/dist/rate-limit.d.ts.map +1 -0
- package/dist/rate-limit.js +35 -0
- package/dist/rate-limit.js.map +1 -0
- package/dist/templates.d.ts +0 -3
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +2 -39
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +20 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -4
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
- package/ui/components/quotations.component.ts +51 -15
package/dist/templates.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderQuoteEmailText = renderQuoteEmailText;
|
|
4
|
-
exports.renderQuoteEmailHtml = renderQuoteEmailHtml;
|
|
5
3
|
exports.renderQuotePage = renderQuotePage;
|
|
6
4
|
const pricing_1 = require("./pricing");
|
|
7
5
|
const quote_version_1 = require("./quote-version");
|
|
@@ -14,38 +12,6 @@ function fmtDate(d) {
|
|
|
14
12
|
const dt = new Date(d);
|
|
15
13
|
return dt.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
|
|
16
14
|
}
|
|
17
|
-
function renderQuoteEmailText(body) {
|
|
18
|
-
return body;
|
|
19
|
-
}
|
|
20
|
-
/** Simple, mail-client-safe HTML wrapper around the (already rendered) body. */
|
|
21
|
-
function renderQuoteEmailHtml(body, q, cfg, url, buttonLabel) {
|
|
22
|
-
const accent = cfg.accentColor || '#1d4ed8';
|
|
23
|
-
const paragraphs = body
|
|
24
|
-
.split(/\n{2,}/)
|
|
25
|
-
.map(p => `<p style="margin:0 0 14px;line-height:1.6">${esc(p).replace(/\n/g, '<br>')}</p>`)
|
|
26
|
-
.join('');
|
|
27
|
-
return `<!doctype html><html><body style="margin:0;background:#f4f6fb;font-family:Arial,Helvetica,sans-serif;color:#1f2937">
|
|
28
|
-
<div style="max-width:560px;margin:24px auto;background:#ffffff;border-radius:10px;overflow:hidden;border:1px solid #e5e7eb">
|
|
29
|
-
<div style="background:${esc(accent)};padding:18px 28px">
|
|
30
|
-
${cfg.logoUrl ? `<img src="${esc(cfg.logoUrl)}" alt="${esc(cfg.businessName)}" style="max-height:36px">`
|
|
31
|
-
: `<span style="color:#ffffff;font-size:18px;font-weight:bold">${esc(cfg.businessName || 'Quotation')}</span>`}
|
|
32
|
-
</div>
|
|
33
|
-
<div style="padding:26px 28px">
|
|
34
|
-
${paragraphs}
|
|
35
|
-
<table role="presentation" cellpadding="0" cellspacing="0" style="margin:18px 0"><tr><td style="border-radius:8px;background:${esc(accent)}">
|
|
36
|
-
<a href="${esc(url)}" style="display:inline-block;padding:13px 26px;color:#ffffff;text-decoration:none;font-weight:bold">${esc(buttonLabel || `View & respond to quote ${q.reference}`)} →</a>
|
|
37
|
-
</td></tr></table>
|
|
38
|
-
<p style="font-size:12px;color:#6b7280;margin:18px 0 0">Total: <strong>${esc((0, pricing_1.formatMoney)(q.totalPence, q.currency))}</strong> inc. VAT · valid until ${esc(fmtDate(q.validUntil))}</p>
|
|
39
|
-
</div>
|
|
40
|
-
<div style="border-top:1px solid #e5e7eb;background:#f8fafc;padding:16px 28px;font-size:11.5px;color:#94a3b8;line-height:1.7">
|
|
41
|
-
<strong style="color:#64748b">${esc(cfg.businessName || '')}</strong>
|
|
42
|
-
${cfg.addressText ? `<br>${esc(cfg.addressText).replace(/\n/g, ', ')}` : ''}
|
|
43
|
-
${cfg.phone || cfg.websiteUrl ? `<br>${[cfg.phone ? esc(cfg.phone) : '', cfg.websiteUrl ? `<a href="${esc(cfg.websiteUrl)}" style="color:#64748b">${esc(cfg.websiteUrl.replace(/^https?:\/\//, ''))}</a>` : ''].filter(Boolean).join(' · ')}` : ''}
|
|
44
|
-
${cfg.footerNote ? `<br>${esc(cfg.footerNote)}` : ''}
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</body></html>`;
|
|
48
|
-
}
|
|
49
15
|
function renderQuotePage(q, cfg, opts = {}) {
|
|
50
16
|
const accent = cfg.accentColor || '#1d4ed8';
|
|
51
17
|
const extra = opts.extra || {};
|
|
@@ -146,14 +112,11 @@ function renderQuotePage(q, cfg, opts = {}) {
|
|
|
146
112
|
${q.preparedByName ? `<div>Prepared by<strong>${esc(q.preparedByName)}</strong></div>` : ''}
|
|
147
113
|
</div>
|
|
148
114
|
<table class="lines">
|
|
149
|
-
<thead><tr><th>Item</th><th style="text-align:right">Qty</th><th style="text-align:right"
|
|
115
|
+
<thead><tr><th>Item</th><th style="text-align:right">Qty</th><th style="text-align:right">${(0, pricing_1.isInclusive)(q) ? 'Unit inc. VAT' : 'Unit'}</th><th style="text-align:right">Disc.</th><th style="text-align:right">Total</th></tr></thead>
|
|
150
116
|
<tbody>${rows}</tbody>
|
|
151
117
|
</table>
|
|
152
118
|
<div class="totals">
|
|
153
|
-
|
|
154
|
-
${q.discountPence > 0 ? `<div><span>Discount</span><span>−${esc(money(q.discountPence))}</span></div>` : ''}
|
|
155
|
-
<div><span>VAT (${esc(Number(q.vatRate).toFixed(1).replace(/\.0$/, ''))}%)</span><span>${esc(money(q.vatPence))}</span></div>
|
|
156
|
-
<div class="grand"><span>Total</span><span>${esc(money(q.totalPence))}</span></div>
|
|
119
|
+
${(0, pricing_1.totalsRows)(q).map(r => `<div${r.grand ? ' class="grand"' : ''}${r.muted ? ' style="color:#6b7280;font-size:13px"' : ''}><span>${esc(r.label)}</span><span>${r.negative ? '−' : ''}${esc(money(r.pence))}</span></div>`).join('\n ')}
|
|
157
120
|
</div>
|
|
158
121
|
${extra.depositText ? `<div class="notes"><strong>${esc(extra.depositText)}</strong></div>` : ''}
|
|
159
122
|
${q.notes ? `<div class="notes"><h3>Notes</h3><div>${esc(q.notes).replace(/\n/g, '<br>')}</div></div>` : ''}
|
package/dist/templates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"templates.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AG,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;MACjI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,2BAA2B,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;;;;QAI9O,CAAC;AACT,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface QuoteLineInput {
|
|
|
5
5
|
sku?: string;
|
|
6
6
|
description: string;
|
|
7
7
|
quantity: number;
|
|
8
|
-
/** unit price in minor units (pence) excluding VAT */
|
|
8
|
+
/** unit price in minor units (pence): excluding VAT, or including it when the quote's `pricesIncludeTax` is set */
|
|
9
9
|
unitPricePence: number;
|
|
10
10
|
/** 0–100, per-line percentage discount */
|
|
11
11
|
lineDiscountPercent?: number;
|
|
@@ -22,6 +22,12 @@ export interface QuoteInput {
|
|
|
22
22
|
internalNotes?: string;
|
|
23
23
|
terms?: string;
|
|
24
24
|
vatRate?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Line prices (and a fixed discount) include VAT, as on a Vendure channel
|
|
27
|
+
* with "prices include tax". Default: the channel's setting for a new
|
|
28
|
+
* quote, the quote's own setting on an edit.
|
|
29
|
+
*/
|
|
30
|
+
pricesIncludeTax?: boolean;
|
|
25
31
|
discountType?: DiscountType;
|
|
26
32
|
/** percent (0–100) when discountType=percent, pence when fixed */
|
|
27
33
|
discountValue?: number;
|
|
@@ -35,6 +41,8 @@ export interface QuoteInput {
|
|
|
35
41
|
export interface QuoteChannelConfig {
|
|
36
42
|
channelId: number;
|
|
37
43
|
channelCode?: string;
|
|
44
|
+
/** read-only, from the Vendure channel: catalogue prices include tax */
|
|
45
|
+
channelPricesIncludeTax?: boolean;
|
|
38
46
|
numberPrefix: string;
|
|
39
47
|
nextNumber: number;
|
|
40
48
|
defaultValidityDays: number;
|
|
@@ -65,7 +73,7 @@ export interface QuoteChannelConfig {
|
|
|
65
73
|
footerNote: string;
|
|
66
74
|
/** accept customer-initiated quote requests via POST /quotations/request */
|
|
67
75
|
acceptRequests: boolean;
|
|
68
|
-
/**
|
|
76
|
+
/** acknowledgement text e-mailed to the customer when a request lands (sent in the shared e-mail design) */
|
|
69
77
|
requestAckBody: string;
|
|
70
78
|
/** create a HULO Payments pay link (and e-mail it) as soon as the customer accepts */
|
|
71
79
|
payLinkOnAccept: boolean;
|
|
@@ -114,5 +122,15 @@ export interface QuotationsPluginOptions {
|
|
|
114
122
|
payLinks?: import('./pay-links').QuotePayLinkProvider;
|
|
115
123
|
/** Let webhooks reach private / loopback addresses (tests and closed networks only). */
|
|
116
124
|
allowPrivateWebhooks?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Believe the shopper's address relayed by your storefront's server
|
|
127
|
+
* (`x-real-client-ip`) on POST /quotations/request, so the per-IP request
|
|
128
|
+
* limit counts visitors rather than the storefront server. Only when the
|
|
129
|
+
* request carries `secret` in `secretHeader` (default `x-quotations-proxy`;
|
|
130
|
+
* a host running HULO Checkout Guard can reuse `x-checkout-guard-proxy`
|
|
131
|
+
* and its secret) and, if `trustedProxies` is set, comes from one of those
|
|
132
|
+
* peers. Off by default.
|
|
133
|
+
*/
|
|
134
|
+
trustedClientIp?: import('./client-ip').QuotationsTrustedClientIpOptions;
|
|
117
135
|
}
|
|
118
136
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACjB,WAAW,GACX,OAAO,GACP,MAAM,GACN,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,CAAC;AAElB,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,cAAc;IAC3B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACjB,WAAW,GACX,OAAO,GACP,MAAM,GACN,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,CAAC;AAElB,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,cAAc;IAC3B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,mHAAmH;IACnH,cAAc,EAAE,MAAM,CAAC;IACvB,0CAA0C;IAC1C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,a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E,OAAO,CAAC;IACtB,+FAA+F;IAC/F,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAChF;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,aAAa,EAAE,oBAAoB,CAAC;IACtD,wFAAwF;IACxF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,aAAa,EAAE,gCAAgC,CAAC;CAC5E"}
|
package/dist/types.js
CHANGED
|
@@ -19,8 +19,8 @@ exports.DEFAULT_CONFIG = {
|
|
|
19
19
|
emailSubject: 'Your quotation {{reference}} from {{businessName}}',
|
|
20
20
|
emailBody: 'Hi {{customerName}},\n\nThank you for your enquiry. Your quotation {{reference}} for {{total}} is ready — ' +
|
|
21
21
|
'view it, and accept or decline online, at the link below:\n\n{{quoteUrl}}\n\n' +
|
|
22
|
-
'The quotation is valid until {{validUntil}}. If anything needs adjusting,
|
|
23
|
-
'
|
|
22
|
+
'The quotation is valid until {{validUntil}}. If anything needs adjusting, simply reply to this e-mail.\n\n' +
|
|
23
|
+
'Kind regards,\n{{staffName}}\n{{businessName}}',
|
|
24
24
|
notifyOnView: false,
|
|
25
25
|
websiteUrl: '',
|
|
26
26
|
phone: '',
|
|
@@ -28,9 +28,9 @@ exports.DEFAULT_CONFIG = {
|
|
|
28
28
|
footerNote: '',
|
|
29
29
|
acceptRequests: true,
|
|
30
30
|
requestAckBody: 'Hi {{customerName}},\n\nThanks for your quote request — your reference is {{reference}}. ' +
|
|
31
|
-
'One of our team will price it
|
|
31
|
+
'One of our team will price it and e-mail your formal quotation shortly.\n\n' +
|
|
32
32
|
'What you asked for:\n{{summary}}\n\n' +
|
|
33
|
-
'If you need to add anything,
|
|
33
|
+
'If you need to add anything, simply reply to this e-mail.\n\nKind regards,\n{{businessName}}',
|
|
34
34
|
payLinkOnAccept: false,
|
|
35
35
|
attachPdf: false,
|
|
36
36
|
};
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAsHa,QAAA,cAAc,GAA0D;IACjF,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,CAAC;IACb,mBAAmB,EAAE,EAAE;IACvB,cAAc,EAAE,EAAE;IAClB,YAAY,EACR,gLAAgL;IACpL,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,CAAC;IAClB,kBAAkB,EAAE,CAAC;IACrB,YAAY,EAAE,oDAAoD;IAClE,SAAS,EACL,4GAA4G;QAC5G,+EAA+E;QAC/E,4GAA4G;QAC5G,gDAAgD;IACpD,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,EAAE;IACd,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,EAAE;IACf,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,IAAI;IACpB,cAAc,EACV,2FAA2F;QAC3F,6EAA6E;QAC7E,sCAAsC;QACtC,8FAA8F;IAClG,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,KAAK;CACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huloglobal/vendure-plugin-quotations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "End-to-end quotation engine for Vendure: build, send, track, chase and convert quotes to orders — with signatures, PDFs, pay links, deposits, approvals, templates, follow-ups, webhooks and sales reports.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test:watch": "vitest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@huloglobal/vendure-licence-sdk": "^0.15.
|
|
28
|
+
"@huloglobal/vendure-licence-sdk": "^0.15.7"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@vendure/core": ">=3.5.0 <4.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"typeorm": ">=0.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"typescript": "^5.
|
|
40
|
-
"vitest": "^2.
|
|
41
|
-
"@types/nodemailer": "^6.4.
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"vitest": "^2.1.9",
|
|
41
|
+
"@types/nodemailer": "^6.4.24"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"vendure",
|
|
@@ -292,10 +292,7 @@ interface QuoteLine {
|
|
|
292
292
|
<td class="num">{{ l.lineDiscountPercent > 0 ? l.lineDiscountPercent + '%' : '—' }}</td>
|
|
293
293
|
<td class="num">{{ money(l.totalPence, detail.currency) }}</td>
|
|
294
294
|
</tr>
|
|
295
|
-
<tr><td colspan="4" class="num hint">
|
|
296
|
-
<tr *ngIf="detail.discountPence > 0"><td colspan="4" class="num hint">Discount</td><td class="num">−{{ money(detail.discountPence, detail.currency) }}</td></tr>
|
|
297
|
-
<tr><td colspan="4" class="num hint">VAT ({{ detail.vatRate }}%)</td><td class="num">{{ money(detail.vatPence, detail.currency) }}</td></tr>
|
|
298
|
-
<tr><td colspan="4" class="num"><strong>Total</strong></td><td class="num"><strong>{{ money(detail.totalPence, detail.currency) }}</strong></td></tr>
|
|
295
|
+
<tr *ngFor="let r of totalsRows(detail)"><td colspan="4" class="num" [class.hint]="!r.grand"><strong *ngIf="r.grand">{{ r.label }}</strong><span *ngIf="!r.grand">{{ r.label }}</span></td><td class="num"><strong *ngIf="r.grand">{{ money(r.pence, detail.currency) }}</strong><span *ngIf="!r.grand">{{ r.negative ? '−' : '' }}{{ money(r.pence, detail.currency) }}</span></td></tr>
|
|
299
296
|
</tbody>
|
|
300
297
|
</table>
|
|
301
298
|
<div *ngIf="detail.acceptedBy" class="hint" style="margin-top:8px">Signed: <strong>{{ detail.acceptedBy }}</strong><span *ngIf="detail.responseComment"> — “{{ detail.responseComment }}”</span></div>
|
|
@@ -374,7 +371,7 @@ interface QuoteLine {
|
|
|
374
371
|
</div>
|
|
375
372
|
</div>
|
|
376
373
|
<table class="table" *ngIf="editing.lines.length">
|
|
377
|
-
<thead><tr><th style="min-width:260px">Description</th><th>Qty</th><th>Unit £ (ex VAT)</th><th>Disc %</th><th class="num">Total</th><th></th></tr></thead>
|
|
374
|
+
<thead><tr><th style="min-width:260px">Description</th><th>Qty</th><th>Unit £ ({{ editing.pricesIncludeTax ? 'inc' : 'ex' }} VAT)</th><th>Disc %</th><th class="num">Total</th><th></th></tr></thead>
|
|
378
375
|
<tbody>
|
|
379
376
|
<tr *ngFor="let l of editing.lines; let i = index">
|
|
380
377
|
<td><input class="form-input" [(ngModel)]="l.description"><div class="hint" *ngIf="l.sku">{{ l.sku }}</div></td>
|
|
@@ -387,7 +384,7 @@ interface QuoteLine {
|
|
|
387
384
|
</tbody>
|
|
388
385
|
</table>
|
|
389
386
|
<p class="hint" *ngIf="!editing.lines.length">Nothing added yet — search above or add a custom line.</p>
|
|
390
|
-
<div class="totals-preview" *ngIf="editing.lines.length"><strong>Items total {{ money(
|
|
387
|
+
<div class="totals-preview" *ngIf="editing.lines.length"><strong>Items total {{ money(itemsTotal()) }} {{ editing.pricesIncludeTax ? 'inc' : 'ex' }} VAT</strong></div>
|
|
391
388
|
</div>
|
|
392
389
|
|
|
393
390
|
<!-- STEP 3 · Pricing & terms -->
|
|
@@ -410,6 +407,9 @@ interface QuoteLine {
|
|
|
410
407
|
</select>
|
|
411
408
|
<input *ngIf="vatCustom" class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="editing.vatRate">
|
|
412
409
|
</div></div>
|
|
410
|
+
<div class="form-row"><label>Prices</label>
|
|
411
|
+
<label class="hint"><input type="checkbox" [(ngModel)]="editing.pricesIncludeTax"> Line prices include VAT</label>
|
|
412
|
+
<div class="hint">{{ editing.pricesIncludeTax ? 'The total is the sum of the lines; the VAT inside it is shown separately.' : 'VAT is added on top of the lines.' }} Catalogue prices follow your channel's "prices include tax" setting.</div></div>
|
|
413
413
|
<div class="form-row"><label>Valid for</label>
|
|
414
414
|
<div class="picker">
|
|
415
415
|
<select class="form-select" [ngModel]="daysChoice(editing.validityDays)" (ngModelChange)="setValidity($event)">
|
|
@@ -442,10 +442,7 @@ interface QuoteLine {
|
|
|
442
442
|
<td class="num">{{ l.quantity }} × {{ money(l.unitPricePence) }}<span *ngIf="l.lineDiscountPercent > 0"> −{{ l.lineDiscountPercent }}%</span></td>
|
|
443
443
|
<td class="num">{{ money(lineTotal(l)) }}</td>
|
|
444
444
|
</tr>
|
|
445
|
-
<tr><td colspan="2" class="num hint">
|
|
446
|
-
<tr *ngIf="preview().discountPence"><td colspan="2" class="num hint">Discount</td><td class="num">−{{ money(preview().discountPence) }}</td></tr>
|
|
447
|
-
<tr><td colspan="2" class="num hint">VAT ({{ editing.vatRate }}%)</td><td class="num">{{ money(preview().vatPence) }}</td></tr>
|
|
448
|
-
<tr><td colspan="2" class="num"><strong>Total</strong></td><td class="num"><strong>{{ money(preview().totalPence) }}</strong></td></tr>
|
|
445
|
+
<tr *ngFor="let r of previewRows()"><td colspan="2" class="num" [class.hint]="!r.grand"><strong *ngIf="r.grand">{{ r.label }}</strong><span *ngIf="!r.grand">{{ r.label }}</span></td><td class="num"><strong *ngIf="r.grand">{{ money(r.pence) }}</strong><span *ngIf="!r.grand">{{ r.negative ? '−' : '' }}{{ money(r.pence) }}</span></td></tr>
|
|
449
446
|
</tbody>
|
|
450
447
|
</table>
|
|
451
448
|
</div>
|
|
@@ -1306,7 +1303,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
1306
1303
|
blankQuote(): any {
|
|
1307
1304
|
return {
|
|
1308
1305
|
channelId: 1, customerName: '', customerEmail: '', customerCompany: '', customerPhone: '',
|
|
1309
|
-
notes: '', internalNotes: '', terms: '', vatRate: 20, discountType: 'none', discountValue: 0,
|
|
1306
|
+
notes: '', internalNotes: '', terms: '', vatRate: 20, pricesIncludeTax: false, discountType: 'none', discountValue: 0,
|
|
1310
1307
|
validityDays: 30, currency: this.cfg?.currency || 'GBP',
|
|
1311
1308
|
preparedByName: this.me?.name || '', preparedByEmail: this.me?.email || '',
|
|
1312
1309
|
lines: [] as QuoteLine[],
|
|
@@ -1339,6 +1336,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
1339
1336
|
if (c) {
|
|
1340
1337
|
this.editing.channelId = c.channelId;
|
|
1341
1338
|
this.editing.vatRate = c.defaultVatRate;
|
|
1339
|
+
this.editing.pricesIncludeTax = !!c.channelPricesIncludeTax;
|
|
1342
1340
|
this.editing.terms = c.defaultTerms;
|
|
1343
1341
|
this.editing.validityDays = c.defaultValidityDays;
|
|
1344
1342
|
}
|
|
@@ -1351,7 +1349,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
1351
1349
|
customerName: q.customerName, customerEmail: q.customerEmail,
|
|
1352
1350
|
customerCompany: q.customerCompany, customerPhone: q.customerPhone,
|
|
1353
1351
|
notes: q.notes || '', internalNotes: q.internalNotes || '', terms: q.terms || '',
|
|
1354
|
-
vatRate: Number(q.vatRate), discountType: q.discountType, discountValue: Number(q.discountValue),
|
|
1352
|
+
vatRate: Number(q.vatRate), pricesIncludeTax: !!q.pricesIncludeTax, discountType: q.discountType, discountValue: Number(q.discountValue),
|
|
1355
1353
|
validityDays: Number(q.validityDays) || 30, currency: q.currency || 'GBP',
|
|
1356
1354
|
preparedByName: q.preparedByName || this.me?.name || '', preparedByEmail: q.preparedByEmail || this.me?.email || '',
|
|
1357
1355
|
lines: (q.lines || []).map((l: any) => ({
|
|
@@ -1463,13 +1461,51 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
1463
1461
|
return Math.round(Math.max(0, l.quantity) * Math.max(0, l.unitPricePence) * (1 - disc / 100));
|
|
1464
1462
|
}
|
|
1465
1463
|
|
|
1464
|
+
itemsTotal(): number {
|
|
1465
|
+
return this.editing.lines.reduce((s: number, l: QuoteLine) => s + this.lineTotal(l), 0);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/** Mirrors the server's quoteTotals (src/pricing.ts), VAT-inclusive prices included. */
|
|
1466
1469
|
preview() {
|
|
1467
|
-
const sub = this.
|
|
1470
|
+
const sub = this.itemsTotal();
|
|
1468
1471
|
let disc = 0;
|
|
1469
1472
|
if (this.editing.discountType === 'percent') disc = Math.round((sub * Math.min(100, Math.max(0, this.editing.discountValue))) / 100);
|
|
1470
1473
|
if (this.editing.discountType === 'fixed') disc = Math.min(sub, Math.max(0, Math.floor(this.editing.discountValue)));
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1474
|
+
const rate = Math.min(100, Math.max(0, Number(this.editing.vatRate) || 0));
|
|
1475
|
+
if (!this.editing.pricesIncludeTax) {
|
|
1476
|
+
const vat = Math.round(((sub - disc) * rate) / 100);
|
|
1477
|
+
return { subTotalPence: sub, discountPence: disc, vatPence: vat, totalPence: sub - disc + vat };
|
|
1478
|
+
}
|
|
1479
|
+
const net = (g: number) => rate ? Math.round((g * 100) / (100 + rate) + Number.EPSILON) : g;
|
|
1480
|
+
const total = sub - disc;
|
|
1481
|
+
const totalNet = net(total);
|
|
1482
|
+
const discNet = net(disc);
|
|
1483
|
+
return { subTotalPence: totalNet + discNet, discountPence: discNet, vatPence: total - totalNet, totalPence: total };
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
previewRows() {
|
|
1487
|
+
const p = this.preview();
|
|
1488
|
+
return this.totalsRows({ ...p, vatRate: this.editing.vatRate, pricesIncludeTax: this.editing.pricesIncludeTax,
|
|
1489
|
+
lines: this.editing.lines.map((l: QuoteLine) => ({ totalPence: this.lineTotal(l) })) });
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
/** Mirrors the server's totalsRows (src/pricing.ts). */
|
|
1493
|
+
totalsRows(q: any): Array<{ label: string; pence: number; negative?: boolean; grand?: boolean }> {
|
|
1494
|
+
const n = (v: any) => Number(v || 0);
|
|
1495
|
+
const pct = `${Number(q.vatRate || 0).toFixed(2).replace(/\.?0+$/, '')}%`;
|
|
1496
|
+
const inclusive = q.pricesIncludeTax === true || q.pricesIncludeTax === 1 || q.pricesIncludeTax === '1';
|
|
1497
|
+
if (!inclusive) {
|
|
1498
|
+
const rows: Array<{ label: string; pence: number; negative?: boolean; grand?: boolean }> = [{ label: 'Subtotal', pence: n(q.subTotalPence) }];
|
|
1499
|
+
if (n(q.discountPence) > 0) rows.push({ label: 'Discount', pence: n(q.discountPence), negative: true });
|
|
1500
|
+
rows.push({ label: `VAT (${pct})`, pence: n(q.vatPence) }, { label: 'Total', pence: n(q.totalPence), grand: true });
|
|
1501
|
+
return rows;
|
|
1502
|
+
}
|
|
1503
|
+
const gross = (q.lines || []).reduce((s: number, l: any) => s + n(l.totalPence), 0);
|
|
1504
|
+
const disc = Math.max(0, gross - n(q.totalPence));
|
|
1505
|
+
const rows: Array<{ label: string; pence: number; negative?: boolean; grand?: boolean }> = [{ label: 'Subtotal (inc. VAT)', pence: gross }];
|
|
1506
|
+
if (disc > 0) rows.push({ label: 'Discount', pence: disc, negative: true });
|
|
1507
|
+
rows.push({ label: 'Total', pence: n(q.totalPence), grand: true }, { label: `Includes VAT (${pct})`, pence: n(q.vatPence) });
|
|
1508
|
+
return rows;
|
|
1473
1509
|
}
|
|
1474
1510
|
|
|
1475
1511
|
valid(): boolean {
|