@huloglobal/vendure-plugin-quotations 0.10.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 +30 -0
- package/README.md +37 -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/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/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 +3 -0
- package/dist/pro.service.js.map +1 -1
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +6 -3
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +14 -1
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +82 -15
- 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/templates.d.ts.map +1 -1
- package/dist/templates.js +2 -5
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +19 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/ui/components/quotations.component.ts +51 -15
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.10.
|
|
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",
|
|
@@ -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 {
|