@huloglobal/vendure-plugin-quotations 0.2.0 → 0.3.0

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 CHANGED
@@ -5,6 +5,17 @@ documented here. The format follows
5
5
  [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project
6
6
  adheres to [semantic versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.0] — 2026-09-01
9
+
10
+ ### Changed
11
+ - **Step-by-step quote wizard.** The editor is now four guided steps —
12
+ Customer → Items → Pricing → Review & send — with a progress bar,
13
+ per-step validation hints ("a name and a valid email unlock the next
14
+ step"), clickable completed steps, and a final review that mirrors what
15
+ the customer will see with one big "Send quote" button. Sensible
16
+ channel defaults mean most quotes never need the Pricing step touched.
17
+ - The admin nav entry now lives only under Sales.
18
+
8
19
  ## [0.2.0] — 2026-09-01
9
20
 
10
21
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huloglobal/vendure-plugin-quotations",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "End-to-end quotation engine for Vendure: build, send, track, chase and convert quotes to orders \u2014 with signatures, expiry, VAT and multi-channel branding.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "test:watch": "vitest"
24
24
  },
25
25
  "dependencies": {
26
- "@huloglobal/vendure-licence-sdk": "^0.10.0"
26
+ "@huloglobal/vendure-licence-sdk": "^0.11.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@vendure/core": ">=3.5.0 <4.0.0",
@@ -195,91 +195,133 @@ interface QuoteLine {
195
195
  </vdr-page-block>
196
196
  </ng-container>
197
197
 
198
- <!-- EDITOR -->
198
+ <!-- EDITOR (step-by-step wizard) -->
199
199
  <ng-container *ngIf="!loading && tab==='editor'">
200
200
  <vdr-page-block>
201
201
  <div class="card"><div class="card-block">
202
- <h3 class="step-title">{{ editing.id ? 'Edit ' + editing.reference : 'New quote' }}</h3>
203
- <div class="form-grid">
204
- <div class="form-row" *ngIf="configs.length > 1"><label>Channel</label>
205
- <select class="form-select" [(ngModel)]="editing.channelId" [disabled]="!!editing.id">
206
- <option *ngFor="let c of configs" [ngValue]="c.channelId">{{ c.channelCode }}</option>
207
- </select></div>
208
- <div class="form-row wide" style="position:relative"><label>Find existing customer</label>
209
- <input class="form-input" placeholder="Search customers by name or email — or fill the fields below manually" [(ngModel)]="customerSearch" (ngModelChange)="searchCustomers()">
210
- <div class="dropdown" *ngIf="customerResults.length">
211
- <div class="dropdown-item" *ngFor="let c of customerResults" (click)="pickCustomer(c)">
212
- {{ c.firstName }} {{ c.lastName }} <span class="hint">{{ c.emailAddress }}<span *ngIf="c.company"> · {{ c.company }}</span></span>
213
- </div>
214
- </div></div>
215
- <div class="form-row"><label>Customer name *</label><input class="form-input" [(ngModel)]="editing.customerName" placeholder="Jane Smith"></div>
216
- <div class="form-row"><label>Customer email *</label><input class="form-input" [(ngModel)]="editing.customerEmail" placeholder="jane@company.com"></div>
217
- <div class="form-row"><label>Company</label><input class="form-input" [(ngModel)]="editing.customerCompany"></div>
218
- <div class="form-row"><label>Phone</label><input class="form-input" [(ngModel)]="editing.customerPhone"></div>
219
- <div class="form-row" style="position:relative"><label>Send as (member of staff)</label>
220
- <input class="form-input" [(ngModel)]="staffSearch" (ngModelChange)="searchStaff()" [placeholder]="editing.preparedByName || 'Search staff…'">
221
- <div class="dropdown" *ngIf="staffResults.length">
222
- <div class="dropdown-item" *ngFor="let st of staffResults" (click)="pickStaff(st)">
223
- {{ st.firstName }} {{ st.lastName }} <span class="hint">{{ st.emailAddress }}</span>
202
+ <div class="wiz-head">
203
+ <h3 class="step-title" style="margin:0">{{ editing.id ? 'Edit ' + editing.reference : 'New quote' }}</h3>
204
+ <div class="wiz-steps" role="tablist">
205
+ <button *ngFor="let st of wizSteps; let i = index" class="wiz-step" role="tab"
206
+ [class.active]="step === i + 1" [class.done]="step > i + 1" [class.locked]="!canJump(i + 1)"
207
+ (click)="goStep(i + 1)">
208
+ <span class="wiz-dot">{{ step > i + 1 ? '✓' : i + 1 }}</span>{{ st }}
209
+ </button>
210
+ </div>
211
+ </div>
212
+
213
+ <!-- STEP 1 · Who is it for? -->
214
+ <div *ngIf="step === 1">
215
+ <p class="hint">Who is this quote for — and who is it from? Search your customers, or just type the details.</p>
216
+ <div class="form-grid">
217
+ <div class="form-row wide" style="position:relative"><label>Find an existing customer</label>
218
+ <input class="form-input" placeholder="Start typing a name or email…" [(ngModel)]="customerSearch" (ngModelChange)="searchCustomers()">
219
+ <div class="dropdown" *ngIf="customerResults.length">
220
+ <div class="dropdown-item" *ngFor="let c of customerResults" (click)="pickCustomer(c)">
221
+ {{ c.firstName }} {{ c.lastName }} <span class="hint">{{ c.emailAddress }}<span *ngIf="c.company"> · {{ c.company }}</span></span>
222
+ </div>
223
+ </div></div>
224
+ <div class="form-row"><label>Customer name *</label><input class="form-input" [(ngModel)]="editing.customerName" placeholder="Jane Smith"></div>
225
+ <div class="form-row"><label>Customer email *</label><input class="form-input" [(ngModel)]="editing.customerEmail" placeholder="jane@company.com"></div>
226
+ <div class="form-row"><label>Company <small>(optional)</small></label><input class="form-input" [(ngModel)]="editing.customerCompany"></div>
227
+ <div class="form-row"><label>Phone <small>(optional)</small></label><input class="form-input" [(ngModel)]="editing.customerPhone"></div>
228
+ <div class="form-row" *ngIf="configs.length > 1"><label>Sales channel</label>
229
+ <select class="form-select" [(ngModel)]="editing.channelId" [disabled]="!!editing.id">
230
+ <option *ngFor="let c of configs" [ngValue]="c.channelId">{{ c.channelCode }}</option>
231
+ </select></div>
232
+ <div class="form-row" style="position:relative"><label>Send as</label>
233
+ <input class="form-input" [(ngModel)]="staffSearch" (ngModelChange)="searchStaff()" [placeholder]="editing.preparedByName || 'Search staff…'">
234
+ <div class="dropdown" *ngIf="staffResults.length">
235
+ <div class="dropdown-item" *ngFor="let st of staffResults" (click)="pickStaff(st)">
236
+ {{ st.firstName }} {{ st.lastName }} <span class="hint">{{ st.emailAddress }}</span>
237
+ </div>
224
238
  </div>
225
- </div>
226
- <div class="hint" style="margin-top:4px" *ngIf="editing.preparedByName">Sending as <strong>{{ editing.preparedByName }}</strong> ({{ editing.preparedByEmail }}) — their name fronts the email and replies go to them.</div></div>
239
+ <div class="hint" style="margin-top:4px" *ngIf="editing.preparedByName">From <strong>{{ editing.preparedByName }}</strong> — replies go to {{ editing.preparedByEmail }}</div></div>
240
+ </div>
227
241
  </div>
228
242
 
229
- <h4 class="step-title" style="margin-top:14px">Lines</h4>
230
- <div class="picker" style="position:relative">
231
- <input class="form-input" style="min-width:320px" placeholder="Search catalogue by name or SKU…" [(ngModel)]="variantSearch" (ngModelChange)="searchVariants()">
232
- <button class="gbtn gbtn-outline gbtn-sm" (click)="addCustomLine()">+ Custom line</button>
233
- <div class="dropdown" *ngIf="variantResults.length">
234
- <div class="dropdown-item" *ngFor="let v of variantResults" (click)="addVariantLine(v)">
235
- {{ v.name }} <span class="hint">{{ v.sku }} · {{ money(v.pricePence) }}</span>
243
+ <!-- STEP 2 · What are you quoting? -->
244
+ <div *ngIf="step === 2">
245
+ <p class="hint">Search your catalogue — the current price fills in automatically — or add a custom line for services and one-offs.</p>
246
+ <div class="picker" style="position:relative">
247
+ <input class="form-input" style="min-width:320px" placeholder="Search products by name or SKU…" [(ngModel)]="variantSearch" (ngModelChange)="searchVariants()">
248
+ <button class="gbtn gbtn-outline gbtn-sm" (click)="addCustomLine()">+ Custom line</button>
249
+ <div class="dropdown" *ngIf="variantResults.length">
250
+ <div class="dropdown-item" *ngFor="let v of variantResults" (click)="addVariantLine(v)">
251
+ {{ v.name }} <span class="hint">{{ v.sku }} · {{ money(v.pricePence) }}</span>
252
+ </div>
236
253
  </div>
237
254
  </div>
255
+ <table class="table" *ngIf="editing.lines.length">
256
+ <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>
257
+ <tbody>
258
+ <tr *ngFor="let l of editing.lines; let i = index">
259
+ <td><input class="form-input" [(ngModel)]="l.description"><div class="hint" *ngIf="l.sku">{{ l.sku }}</div></td>
260
+ <td><input class="form-input num-in" type="number" min="1" [(ngModel)]="l.quantity"></td>
261
+ <td><input class="form-input num-in" type="number" min="0" step="0.01" [ngModel]="l.unitPricePence / 100" (ngModelChange)="l.unitPricePence = toPence($event)"></td>
262
+ <td><input class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="l.lineDiscountPercent"></td>
263
+ <td class="num">{{ money(lineTotal(l)) }}</td>
264
+ <td><button class="gbtn gbtn-outline gbtn-sm" (click)="editing.lines.splice(i, 1)">✕</button></td>
265
+ </tr>
266
+ </tbody>
267
+ </table>
268
+ <p class="hint" *ngIf="!editing.lines.length">Nothing added yet — search above or add a custom line.</p>
269
+ <div class="totals-preview" *ngIf="editing.lines.length"><strong>Items total {{ money(preview().subTotalPence) }}</strong></div>
238
270
  </div>
239
- <table class="table" *ngIf="editing.lines.length">
240
- <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>
241
- <tbody>
242
- <tr *ngFor="let l of editing.lines; let i = index">
243
- <td><input class="form-input" [(ngModel)]="l.description"><div class="hint" *ngIf="l.sku">{{ l.sku }}</div></td>
244
- <td><input class="form-input num-in" type="number" min="1" [(ngModel)]="l.quantity"></td>
245
- <td><input class="form-input num-in" type="number" min="0" step="0.01" [ngModel]="l.unitPricePence / 100" (ngModelChange)="l.unitPricePence = toPence($event)"></td>
246
- <td><input class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="l.lineDiscountPercent"></td>
247
- <td class="num">{{ money(lineTotal(l)) }}</td>
248
- <td><button class="gbtn gbtn-outline gbtn-sm" (click)="editing.lines.splice(i, 1)">✕</button></td>
249
- </tr>
250
- </tbody>
251
- </table>
252
- <p class="hint" *ngIf="!editing.lines.length">Search the catalogue above, or add a custom line.</p>
253
-
254
- <div class="form-grid" style="margin-top:12px">
255
- <div class="form-row"><label>Quote discount</label>
256
- <div class="picker">
257
- <select class="form-select" [(ngModel)]="editing.discountType">
258
- <option value="none">None</option><option value="percent">Percent</option><option value="fixed">Fixed £</option>
259
- </select>
260
- <input class="form-input num-in" type="number" min="0" [disabled]="editing.discountType==='none'"
261
- [ngModel]="editing.discountType==='fixed' ? editing.discountValue / 100 : editing.discountValue"
262
- (ngModelChange)="editing.discountValue = editing.discountType==='fixed' ? toPence($event) : $event">
263
- </div></div>
264
- <div class="form-row"><label>VAT rate %</label><input class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="editing.vatRate"></div>
265
- <div class="form-row"><label>Valid for (days)</label><input class="form-input num-in" type="number" min="1" [(ngModel)]="editing.validityDays"></div>
266
- </div>
267
- <div class="totals-preview">
268
- <span>Subtotal {{ money(preview().subTotalPence) }}</span>
269
- <span *ngIf="preview().discountPence">− {{ money(preview().discountPence) }}</span>
270
- <span>VAT {{ money(preview().vatPence) }}</span>
271
- <strong>Total {{ money(preview().totalPence) }}</strong>
271
+
272
+ <!-- STEP 3 · Pricing & terms -->
273
+ <div *ngIf="step === 3">
274
+ <p class="hint">Fine-tune the deal. The defaults come from your channel settings — most quotes need no changes here.</p>
275
+ <div class="form-grid">
276
+ <div class="form-row"><label>Quote discount</label>
277
+ <div class="picker">
278
+ <select class="form-select" [(ngModel)]="editing.discountType">
279
+ <option value="none">None</option><option value="percent">Percent</option><option value="fixed">Fixed £</option>
280
+ </select>
281
+ <input class="form-input num-in" type="number" min="0" [disabled]="editing.discountType==='none'"
282
+ [ngModel]="editing.discountType==='fixed' ? editing.discountValue / 100 : editing.discountValue"
283
+ (ngModelChange)="editing.discountValue = editing.discountType==='fixed' ? toPence($event) : $event">
284
+ </div></div>
285
+ <div class="form-row"><label>VAT rate %</label><input class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="editing.vatRate"></div>
286
+ <div class="form-row"><label>Valid for (days)</label><input class="form-input num-in" type="number" min="1" [(ngModel)]="editing.validityDays"></div>
287
+ <div class="form-row wide"><label>Note to the customer <small>(optional — shown on the quote)</small></label><textarea class="form-input" rows="2" [(ngModel)]="editing.notes"></textarea></div>
288
+ <div class="form-row wide"><label>Terms</label><textarea class="form-input" rows="3" [(ngModel)]="editing.terms"></textarea></div>
289
+ <div class="form-row wide"><label>Internal notes <small>(your team only — never shown to the customer)</small></label><textarea class="form-input" rows="2" [(ngModel)]="editing.internalNotes"></textarea></div>
290
+ </div>
272
291
  </div>
273
292
 
274
- <div class="form-grid" style="margin-top:12px">
275
- <div class="form-row wide"><label>Notes (customer-visible)</label><textarea class="form-input" rows="2" [(ngModel)]="editing.notes"></textarea></div>
276
- <div class="form-row wide"><label>Terms</label><textarea class="form-input" rows="3" [(ngModel)]="editing.terms"></textarea></div>
277
- <div class="form-row wide"><label>Internal notes (never shown to the customer)</label><textarea class="form-input" rows="2" [(ngModel)]="editing.internalNotes"></textarea></div>
293
+ <!-- STEP 4 · Review & send -->
294
+ <div *ngIf="step === 4">
295
+ <p class="hint">This is what {{ editing.customerName || 'the customer' }} will see. Happy? Send it — or save it as a draft to finish later.</p>
296
+ <div class="review-card">
297
+ <div class="review-head">
298
+ <span><strong>{{ editing.customerName }}</strong><span *ngIf="editing.customerCompany"> · {{ editing.customerCompany }}</span><br><span class="hint">{{ editing.customerEmail }}</span></span>
299
+ <span class="hint" style="text-align:right">From {{ editing.preparedByName || '—' }}<br>Valid {{ editing.validityDays }} days</span>
300
+ </div>
301
+ <table class="table">
302
+ <tbody>
303
+ <tr *ngFor="let l of editing.lines">
304
+ <td>{{ l.description }}</td>
305
+ <td class="num">{{ l.quantity }} × {{ money(l.unitPricePence) }}<span *ngIf="l.lineDiscountPercent > 0"> −{{ l.lineDiscountPercent }}%</span></td>
306
+ <td class="num">{{ money(lineTotal(l)) }}</td>
307
+ </tr>
308
+ <tr><td colspan="2" class="num hint">Subtotal</td><td class="num">{{ money(preview().subTotalPence) }}</td></tr>
309
+ <tr *ngIf="preview().discountPence"><td colspan="2" class="num hint">Discount</td><td class="num">−{{ money(preview().discountPence) }}</td></tr>
310
+ <tr><td colspan="2" class="num hint">VAT ({{ editing.vatRate }}%)</td><td class="num">{{ money(preview().vatPence) }}</td></tr>
311
+ <tr><td colspan="2" class="num"><strong>Total</strong></td><td class="num"><strong>{{ money(preview().totalPence) }}</strong></td></tr>
312
+ </tbody>
313
+ </table>
314
+ </div>
278
315
  </div>
279
- <div class="picker" style="margin-top:14px">
280
- <button class="gbtn gbtn-primary" (click)="save(false)" [disabled]="busy || !valid()">{{ busy ? 'Saving…' : 'Save draft' }}</button>
281
- <button class="gbtn gbtn-primary" (click)="save(true)" [disabled]="busy || !valid()">Save &amp; send</button>
316
+
317
+ <div class="wiz-footer">
318
+ <button class="gbtn gbtn-outline" *ngIf="step > 1" (click)="step = step - 1">‹ Back</button>
319
+ <span class="wiz-hint hint">{{ stepHint() }}</span>
320
+ <span style="flex:1"></span>
282
321
  <button class="gbtn gbtn-outline" (click)="go('quotes')">Cancel</button>
322
+ <button class="gbtn gbtn-outline" *ngIf="step === 4" (click)="save(false)" [disabled]="busy || !valid()">{{ busy ? 'Saving…' : 'Save draft' }}</button>
323
+ <button class="gbtn gbtn-primary" *ngIf="step < 4" (click)="nextStep()" [disabled]="!canNext()">Next ›</button>
324
+ <button class="gbtn gbtn-primary" *ngIf="step === 4" (click)="save(true)" [disabled]="busy || !valid()">Send quote →</button>
283
325
  </div>
284
326
  </div></div>
285
327
  </vdr-page-block>
@@ -478,6 +520,18 @@ interface QuoteLine {
478
520
  .st-sent, .st-viewed { background: #eff6ff; color: #1d4ed8; }
479
521
  .st-draft { background: #f1f5f9; color: #475569; }
480
522
  .st-declined, .st-expired, .st-cancelled { background: #fef2f2; color: #b91c1c; }
523
+ .wiz-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
524
+ .wiz-steps { display: flex; gap: 6px; flex-wrap: wrap; }
525
+ .wiz-step { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--color-component-border-200, #e2e8f0); background: transparent; border-radius: 999px; padding: 6px 14px 6px 7px; cursor: pointer; font-size: 13px; color: var(--color-text-200, #475569); }
526
+ .wiz-step.active { border-color: var(--color-primary-500, #1d4ed8); color: var(--color-primary-600, #1d4ed8); font-weight: 600; }
527
+ .wiz-step.done { color: #047857; }
528
+ .wiz-step.locked { opacity: .45; cursor: not-allowed; }
529
+ .wiz-dot { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--color-component-bg-200, #f1f5f9); font-size: 12px; font-weight: 700; }
530
+ .wiz-step.active .wiz-dot { background: var(--color-primary-500, #1d4ed8); color: #fff; }
531
+ .wiz-step.done .wiz-dot { background: #ecfdf5; color: #047857; }
532
+ .wiz-footer { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--color-component-border-100, #f1f5f9); }
533
+ .review-card { border: 1px solid var(--color-component-border-200, #e2e8f0); border-radius: 12px; padding: 16px 18px; }
534
+ .review-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
481
535
  `],
482
536
  })
483
537
  export class QuotationsComponent implements OnInit {
@@ -499,6 +553,8 @@ export class QuotationsComponent implements OnInit {
499
553
  statuses = ['draft', 'sent', 'viewed', 'accepted', 'declined', 'expired', 'converted', 'cancelled'];
500
554
 
501
555
  editing: any = this.blankQuote();
556
+ step = 1;
557
+ wizSteps = ['Customer', 'Items', 'Pricing', 'Review & send'];
502
558
  variantSearch = '';
503
559
  variantResults: any[] = [];
504
560
  customerSearch = '';
@@ -638,7 +694,25 @@ export class QuotationsComponent implements OnInit {
638
694
  };
639
695
  }
640
696
 
697
+ step1ok(): boolean { return !!(this.editing.customerName && /.+@.+\..+/.test(this.editing.customerEmail || '')); }
698
+ step2ok(): boolean { return this.editing.lines.length > 0; }
699
+ canNext(): boolean { return this.step === 1 ? this.step1ok() : this.step === 2 ? this.step2ok() : true; }
700
+ canJump(target: number): boolean {
701
+ if (target <= this.step) return true;
702
+ if (target >= 2 && !this.step1ok()) return false;
703
+ if (target >= 3 && !this.step2ok()) return false;
704
+ return true;
705
+ }
706
+ goStep(target: number) { if (this.canJump(target)) this.step = target; }
707
+ nextStep() { if (this.canNext() && this.step < 4) this.step++; }
708
+ stepHint(): string {
709
+ if (this.step === 1 && !this.step1ok()) return 'A name and a valid email unlock the next step';
710
+ if (this.step === 2 && !this.step2ok()) return 'Add at least one line to continue';
711
+ return '';
712
+ }
713
+
641
714
  newQuote() {
715
+ this.step = 1;
642
716
  this.editing = this.blankQuote();
643
717
  const c = this.cfg || this.configs[0];
644
718
  if (c) {
@@ -663,6 +737,7 @@ export class QuotationsComponent implements OnInit {
663
737
  quantity: l.quantity, unitPricePence: l.unitPricePence, lineDiscountPercent: Number(l.lineDiscountPercent),
664
738
  })),
665
739
  };
740
+ this.step = 1;
666
741
  this.tab = 'editor';
667
742
  }
668
743