@huloglobal/vendure-plugin-quotations 0.1.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 +34 -0
- package/dist/plugin.d.ts +7 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -0
- package/dist/plugin.js.map +1 -1
- package/dist/quotation.controller.d.ts +11 -0
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +124 -0
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +24 -0
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +115 -16
- package/dist/quotation.service.js.map +1 -1
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +1 -0
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/hulo-global-logo.svg +26 -0
- package/logo.svg +9 -0
- package/package.json +16 -6
- package/ui/components/quotations.component.ts +244 -61
- package/ui/quotations-nav.module.ts +23 -0
|
@@ -147,6 +147,9 @@ interface QuoteLine {
|
|
|
147
147
|
<button class="gbtn gbtn-primary gbtn-sm" *ngIf="canSend(detail)" (click)="send(detail)" [disabled]="busy">{{ detail.sentAt ? 'Re-send' : 'Send to customer' }}</button>
|
|
148
148
|
<button class="gbtn gbtn-primary gbtn-sm" *ngIf="detail.status==='accepted'" (click)="convert(detail)" [disabled]="busy">Convert to order</button>
|
|
149
149
|
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="isEditable(detail)" (click)="edit(detail)">Edit</button>
|
|
150
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="previewEmail(detail)">Preview email</button>
|
|
151
|
+
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="canSend(detail)" (click)="testSend(detail)" [disabled]="busy">Test-send to me</button>
|
|
152
|
+
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="['sent','viewed','expired','draft'].includes(detail.status)" (click)="extend(detail)" [disabled]="busy">Extend validity</button>
|
|
150
153
|
<button class="gbtn gbtn-outline gbtn-sm" (click)="duplicate(detail)" [disabled]="busy">Duplicate</button>
|
|
151
154
|
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="detail.status==='draft'" (click)="removeQuote(detail)" [disabled]="busy">Delete</button>
|
|
152
155
|
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="!['accepted','converted','cancelled','draft'].includes(detail.status)" (click)="cancel(detail)" [disabled]="busy">Withdraw</button>
|
|
@@ -175,7 +178,12 @@ interface QuoteLine {
|
|
|
175
178
|
</tbody>
|
|
176
179
|
</table>
|
|
177
180
|
<div *ngIf="detail.acceptedBy" class="hint" style="margin-top:8px">Signed: <strong>{{ detail.acceptedBy }}</strong><span *ngIf="detail.responseComment"> — “{{ detail.responseComment }}”</span></div>
|
|
181
|
+
<div class="hint" *ngIf="detail.preparedByName" style="margin-top:8px">Sent as <strong>{{ detail.preparedByName }}</strong> ({{ detail.preparedByEmail }})</div>
|
|
178
182
|
<h4 class="step-title" style="margin-top:16px">Activity</h4>
|
|
183
|
+
<div class="picker" style="margin:0 0 8px">
|
|
184
|
+
<input class="form-input" style="min-width:320px" placeholder="Add an internal note (never shown to the customer)" [(ngModel)]="commentText" (keyup.enter)="addComment(detail)">
|
|
185
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="addComment(detail)" [disabled]="busy || !commentText">Add note</button>
|
|
186
|
+
</div>
|
|
179
187
|
<table class="table">
|
|
180
188
|
<tbody><tr *ngFor="let e of detail.events">
|
|
181
189
|
<td class="hint" style="white-space:nowrap">{{ e.createdAt | date:'d MMM HH:mm' }}</td>
|
|
@@ -187,76 +195,133 @@ interface QuoteLine {
|
|
|
187
195
|
</vdr-page-block>
|
|
188
196
|
</ng-container>
|
|
189
197
|
|
|
190
|
-
<!-- EDITOR -->
|
|
198
|
+
<!-- EDITOR (step-by-step wizard) -->
|
|
191
199
|
<ng-container *ngIf="!loading && tab==='editor'">
|
|
192
200
|
<vdr-page-block>
|
|
193
201
|
<div class="card"><div class="card-block">
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
<div class="
|
|
197
|
-
<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<div class="form-row"><label>Phone</label><input class="form-input" [(ngModel)]="editing.customerPhone"></div>
|
|
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>
|
|
204
211
|
</div>
|
|
205
212
|
|
|
206
|
-
|
|
207
|
-
<div
|
|
208
|
-
<
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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>
|
|
238
|
+
</div>
|
|
239
|
+
<div class="hint" style="margin-top:4px" *ngIf="editing.preparedByName">From <strong>{{ editing.preparedByName }}</strong> — replies go to {{ editing.preparedByEmail }}</div></div>
|
|
214
240
|
</div>
|
|
215
241
|
</div>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
<
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
</
|
|
241
|
-
|
|
242
|
-
<
|
|
242
|
+
|
|
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>
|
|
253
|
+
</div>
|
|
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>
|
|
243
270
|
</div>
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<
|
|
248
|
-
<
|
|
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>
|
|
249
291
|
</div>
|
|
250
292
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
<
|
|
254
|
-
<div class="
|
|
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>
|
|
255
315
|
</div>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
<button class="gbtn gbtn-
|
|
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>
|
|
259
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>
|
|
260
325
|
</div>
|
|
261
326
|
</div></div>
|
|
262
327
|
</vdr-page-block>
|
|
@@ -297,6 +362,11 @@ interface QuoteLine {
|
|
|
297
362
|
</span></div>
|
|
298
363
|
<div class="form-row"><label>Chase after (days)</label><input class="form-input num-in" type="number" min="1" [(ngModel)]="cfg.chaserAfterDays" [disabled]="!cfg.chaserEnabled"></div>
|
|
299
364
|
<div class="form-row"><label>Expiry reminder (days before, 0 = off)</label><input class="form-input num-in" type="number" min="0" [(ngModel)]="cfg.expiryReminderDays"></div>
|
|
365
|
+
<div class="form-row"><label>Email me when a quote is first opened</label>
|
|
366
|
+
<span class="gb-switch-group">
|
|
367
|
+
<button class="gb-switch" role="switch" [attr.aria-checked]="cfg.notifyOnView" [class.on]="cfg.notifyOnView" (click)="cfg.notifyOnView = !cfg.notifyOnView"><span class="gb-switch-knob"></span></button>
|
|
368
|
+
<span class="gb-switch-label">{{ cfg.notifyOnView ? 'On — great for timing the follow-up call' : 'Off' }}</span>
|
|
369
|
+
</span></div>
|
|
300
370
|
</div>
|
|
301
371
|
<h3 class="step-title" style="margin-top:14px">Quote email</h3>
|
|
302
372
|
<div class="form-grid">
|
|
@@ -450,6 +520,18 @@ interface QuoteLine {
|
|
|
450
520
|
.st-sent, .st-viewed { background: #eff6ff; color: #1d4ed8; }
|
|
451
521
|
.st-draft { background: #f1f5f9; color: #475569; }
|
|
452
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; }
|
|
453
535
|
`],
|
|
454
536
|
})
|
|
455
537
|
export class QuotationsComponent implements OnInit {
|
|
@@ -471,9 +553,19 @@ export class QuotationsComponent implements OnInit {
|
|
|
471
553
|
statuses = ['draft', 'sent', 'viewed', 'accepted', 'declined', 'expired', 'converted', 'cancelled'];
|
|
472
554
|
|
|
473
555
|
editing: any = this.blankQuote();
|
|
556
|
+
step = 1;
|
|
557
|
+
wizSteps = ['Customer', 'Items', 'Pricing', 'Review & send'];
|
|
474
558
|
variantSearch = '';
|
|
475
559
|
variantResults: any[] = [];
|
|
560
|
+
customerSearch = '';
|
|
561
|
+
customerResults: any[] = [];
|
|
562
|
+
staffSearch = '';
|
|
563
|
+
staffResults: any[] = [];
|
|
564
|
+
me: any = null;
|
|
565
|
+
commentText = '';
|
|
476
566
|
private searchTimer: any = null;
|
|
567
|
+
private custTimer: any = null;
|
|
568
|
+
private staffTimer: any = null;
|
|
477
569
|
|
|
478
570
|
updateDismissed = false;
|
|
479
571
|
updating = false;
|
|
@@ -488,7 +580,10 @@ export class QuotationsComponent implements OnInit {
|
|
|
488
580
|
|
|
489
581
|
constructor(private http: HttpClient, private notify: NotificationService, private cdr: ChangeDetectorRef) {}
|
|
490
582
|
|
|
491
|
-
ngOnInit() {
|
|
583
|
+
ngOnInit() {
|
|
584
|
+
this.reloadAll();
|
|
585
|
+
this.http.get<any>('/quotations/staff/me').subscribe({ next: m => { this.me = m?.email ? m : null; }, error: () => undefined });
|
|
586
|
+
}
|
|
492
587
|
|
|
493
588
|
reloadAll() {
|
|
494
589
|
this.loading = true;
|
|
@@ -594,11 +689,30 @@ export class QuotationsComponent implements OnInit {
|
|
|
594
689
|
return {
|
|
595
690
|
channelId: 1, customerName: '', customerEmail: '', customerCompany: '', customerPhone: '',
|
|
596
691
|
notes: '', internalNotes: '', terms: '', vatRate: 20, discountType: 'none', discountValue: 0,
|
|
597
|
-
validityDays: 30,
|
|
692
|
+
validityDays: 30, preparedByName: this.me?.name || '', preparedByEmail: this.me?.email || '',
|
|
693
|
+
lines: [] as QuoteLine[],
|
|
598
694
|
};
|
|
599
695
|
}
|
|
600
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
|
+
|
|
601
714
|
newQuote() {
|
|
715
|
+
this.step = 1;
|
|
602
716
|
this.editing = this.blankQuote();
|
|
603
717
|
const c = this.cfg || this.configs[0];
|
|
604
718
|
if (c) {
|
|
@@ -617,12 +731,13 @@ export class QuotationsComponent implements OnInit {
|
|
|
617
731
|
customerCompany: q.customerCompany, customerPhone: q.customerPhone,
|
|
618
732
|
notes: q.notes || '', internalNotes: q.internalNotes || '', terms: q.terms || '',
|
|
619
733
|
vatRate: Number(q.vatRate), discountType: q.discountType, discountValue: Number(q.discountValue),
|
|
620
|
-
validityDays: 30,
|
|
734
|
+
validityDays: 30, preparedByName: q.preparedByName || this.me?.name || '', preparedByEmail: q.preparedByEmail || this.me?.email || '',
|
|
621
735
|
lines: (q.lines || []).map((l: any) => ({
|
|
622
736
|
productVariantId: l.productVariantId, sku: l.sku, description: l.description,
|
|
623
737
|
quantity: l.quantity, unitPricePence: l.unitPricePence, lineDiscountPercent: Number(l.lineDiscountPercent),
|
|
624
738
|
})),
|
|
625
739
|
};
|
|
740
|
+
this.step = 1;
|
|
626
741
|
this.tab = 'editor';
|
|
627
742
|
}
|
|
628
743
|
|
|
@@ -648,6 +763,74 @@ export class QuotationsComponent implements OnInit {
|
|
|
648
763
|
this.editing.lines.push({ productVariantId: null, sku: '', description: '', quantity: 1, unitPricePence: 0, lineDiscountPercent: 0 });
|
|
649
764
|
}
|
|
650
765
|
|
|
766
|
+
searchCustomers() {
|
|
767
|
+
clearTimeout(this.custTimer);
|
|
768
|
+
if (!this.customerSearch || this.customerSearch.length < 2) { this.customerResults = []; return; }
|
|
769
|
+
this.custTimer = setTimeout(() => {
|
|
770
|
+
this.http.get<any[]>('/quotations/customers/search', { params: { q: this.customerSearch } })
|
|
771
|
+
.subscribe({ next: r => { this.customerResults = r || []; this.cdr.markForCheck(); }, error: () => undefined });
|
|
772
|
+
}, 250);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
pickCustomer(c: any) {
|
|
776
|
+
this.editing.customerId = c.customerId;
|
|
777
|
+
this.editing.customerName = [c.firstName, c.lastName].filter(Boolean).join(' ');
|
|
778
|
+
this.editing.customerEmail = c.emailAddress;
|
|
779
|
+
this.editing.customerCompany = c.company || this.editing.customerCompany;
|
|
780
|
+
this.editing.customerPhone = c.phoneNumber || this.editing.customerPhone;
|
|
781
|
+
this.customerSearch = '';
|
|
782
|
+
this.customerResults = [];
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
searchStaff() {
|
|
786
|
+
clearTimeout(this.staffTimer);
|
|
787
|
+
if (!this.staffSearch || this.staffSearch.length < 1) { this.staffResults = []; return; }
|
|
788
|
+
this.staffTimer = setTimeout(() => {
|
|
789
|
+
this.http.get<any[]>('/quotations/staff/search', { params: { q: this.staffSearch } })
|
|
790
|
+
.subscribe({ next: r => { this.staffResults = r || []; this.cdr.markForCheck(); }, error: () => undefined });
|
|
791
|
+
}, 250);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
pickStaff(st: any) {
|
|
795
|
+
this.editing.preparedByName = [st.firstName, st.lastName].filter(Boolean).join(' ');
|
|
796
|
+
this.editing.preparedByEmail = st.emailAddress;
|
|
797
|
+
this.staffSearch = '';
|
|
798
|
+
this.staffResults = [];
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
previewEmail(q: any) {
|
|
802
|
+
window.open(`/quotations/quotes/${q.id}/preview`, '_blank');
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
testSend(q: any) {
|
|
806
|
+
const to = this.me?.email || prompt('Send the test to which email?') || '';
|
|
807
|
+
if (!to) return;
|
|
808
|
+
this.busy = true;
|
|
809
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/test-send`, { to }).subscribe({
|
|
810
|
+
next: () => { this.busy = false; this.notify.success(`Test sent to ${to}`); this.cdr.markForCheck(); },
|
|
811
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.message || e?.error?.reason || 'Test send failed'); this.cdr.markForCheck(); },
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
extend(q: any) {
|
|
816
|
+
const days = Number(prompt('Extend validity by how many days?', '30') || 0);
|
|
817
|
+
if (!days) return;
|
|
818
|
+
this.busy = true;
|
|
819
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/extend`, { days }).subscribe({
|
|
820
|
+
next: () => { this.busy = false; this.notify.success('Validity extended'); this.openQuote(q.id); this.loadList(); },
|
|
821
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.error || 'Could not extend'); this.cdr.markForCheck(); },
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
addComment(q: any) {
|
|
826
|
+
if (!this.commentText) return;
|
|
827
|
+
this.busy = true;
|
|
828
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/comment`, { text: this.commentText }).subscribe({
|
|
829
|
+
next: () => { this.busy = false; this.commentText = ''; this.openQuote(q.id); },
|
|
830
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.error || 'Could not add the note'); this.cdr.markForCheck(); },
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
|
|
651
834
|
toPence(v: any): number { return Math.max(0, Math.round(Number(v || 0) * 100)); }
|
|
652
835
|
|
|
653
836
|
lineTotal(l: QuoteLine): number {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { SharedModule, addNavMenuItem } from '@vendure/admin-ui/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Registers the "Quotations" entry in the admin nav under Sales —
|
|
6
|
+
* quoting lives where orders live.
|
|
7
|
+
*/
|
|
8
|
+
@NgModule({
|
|
9
|
+
imports: [SharedModule],
|
|
10
|
+
providers: [
|
|
11
|
+
addNavMenuItem(
|
|
12
|
+
{
|
|
13
|
+
id: 'hulo-quotations',
|
|
14
|
+
label: 'Quotations',
|
|
15
|
+
routerLink: ['/extensions/quotations'],
|
|
16
|
+
icon: 'file-group',
|
|
17
|
+
requiresPermission: 'ReadSettings',
|
|
18
|
+
},
|
|
19
|
+
'sales',
|
|
20
|
+
),
|
|
21
|
+
],
|
|
22
|
+
})
|
|
23
|
+
export class QuotationsNavModule {}
|