@things-factory/sales 10.1.304 → 10.1.310

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.
Files changed (34) hide show
  1. package/dist-client/entity360/opportunity-360.js +4 -3
  2. package/dist-client/list-filters.d.ts +3 -2
  3. package/dist-client/list-filters.js +4 -3
  4. package/dist-client/opportunity-words.d.ts +2 -0
  5. package/dist-client/opportunity-words.js +11 -1
  6. package/dist-client/pages/opportunity-editor.d.ts +12 -5
  7. package/dist-client/pages/opportunity-editor.js +60 -23
  8. package/dist-client/pages/opportunity-list.js +2 -2
  9. package/dist-client/pages/quotation-list.d.ts +1 -0
  10. package/dist-client/pages/quotation-list.js +14 -1
  11. package/dist-client/route.d.ts +1 -1
  12. package/dist-server/service/index.d.ts +2 -2
  13. package/dist-server/service/opportunity/index.d.ts +1 -1
  14. package/dist-server/service/opportunity/opportunity-event.js +2 -2
  15. package/dist-server/service/opportunity/opportunity-mutation.d.ts +3 -0
  16. package/dist-server/service/opportunity/opportunity-mutation.js +47 -1
  17. package/dist-server/service/opportunity/opportunity-query.js +1 -1
  18. package/dist-server/service/opportunity/opportunity-rules.d.ts +14 -7
  19. package/dist-server/service/opportunity/opportunity-rules.js +25 -11
  20. package/dist-server/service/opportunity/opportunity-service.d.ts +22 -5
  21. package/dist-server/service/opportunity/opportunity-service.js +60 -14
  22. package/dist-server/service/opportunity/opportunity-type.d.ts +1 -1
  23. package/dist-server/service/opportunity/opportunity-type.js +3 -3
  24. package/dist-server/service/opportunity/opportunity.d.ts +3 -2
  25. package/dist-server/service/opportunity/opportunity.js +10 -5
  26. package/dist-server/service/quotation/index.d.ts +2 -2
  27. package/dist-server/service/sales-read.js +3 -2
  28. package/package.json +2 -2
  29. package/translations/en.json +20 -5
  30. package/translations/es.json +20 -5
  31. package/translations/ja.json +20 -5
  32. package/translations/ko.json +20 -5
  33. package/translations/ms.json +20 -5
  34. package/translations/zh.json +20 -5
@@ -6,7 +6,7 @@ import { QueryController } from '@operato/graphql';
6
6
  import { i18next } from '@operato/i18n';
7
7
  import { entity360Answer, entity360Name, registerEntity360Kind, registerEntity360Section } from '@operato/layout';
8
8
  import { documentAmount } from '@things-factory/invoice/dist-client';
9
- import { opportunityStageWord } from '../opportunity-words';
9
+ import { opportunityReasonLabel, opportunityStageWord } from '../opportunity-words';
10
10
  /** An opportunity's 360 (ADR-0067). The module draws the opportunity; an application hangs its own sections on 'opportunity'. */
11
11
  export function registerOpportunityKind() {
12
12
  registerEntity360Kind({
@@ -28,7 +28,7 @@ let OpportunityOverviewSection = class OpportunityOverviewSection extends LitEle
28
28
  this.opportunity = new QueryController(this, gql `
29
29
  query ($id: String!) {
30
30
  opportunity(id: $id) {
31
- id name stage probability amount currency expectedCloseMonth closedOn lostReason description
31
+ id name stage probability amount currency expectedCloseMonth closedOn stageReason heldUntil description
32
32
  counterparty { id name } endCustomer { id name } owner { id name }
33
33
  }
34
34
  }
@@ -80,7 +80,8 @@ let OpportunityOverviewSection = class OpportunityOverviewSection extends LitEle
80
80
  <dt>${i18next.t('field.opportunity-owner')}</dt>
81
81
  <dd>${one.owner?.name ?? '—'}</dd>
82
82
  ${one.closedOn ? html `<dt>${i18next.t('field.opportunity-closed-on')}</dt><dd>${one.closedOn}</dd>` : ''}
83
- ${one.lostReason ? html `<dt>${i18next.t('field.opportunity-lost-reason')}</dt><dd>${one.lostReason}</dd>` : ''}
83
+ ${one.heldUntil ? html `<dt>${i18next.t('field.opportunity-held-until')}</dt><dd>${one.heldUntil}</dd>` : ''}
84
+ ${one.stageReason ? html `<dt>${opportunityReasonLabel(one.stage)}</dt><dd>${one.stageReason}</dd>` : ''}
84
85
  ${one.description ? html `<dt>${i18next.t('field.opportunity-description')}</dt><dd class="text">${one.description}</dd>` : ''}
85
86
  </dl>`
86
87
  : ''}
@@ -5,8 +5,9 @@ export type GridFilter = {
5
5
  };
6
6
  /** 상품: the 사용 chip (`active` / `inactive`) as the boolean condition the server reads. */
7
7
  export declare function salesProductFilters(filters: readonly GridFilter[]): GridFilter[];
8
- /** The opportunity stages a person still moves an opportunity through - the list opens on them, won and lost left out. */
9
- export declare const OPEN_STAGES: string[];
8
+ /** The opportunity stages a person still moves an opportunity through, and on hold - the list opens on them, so a held
9
+ * one stays in sight; won, lost and cancelled are left out (ADR-0233 decision 8). */
10
+ export declare const LISTED_STAGES: string[];
10
11
  export declare const STAGES: string[];
11
12
  /**
12
13
  * 영업 기회: the person in charge (the `owner` column, a user id) as `ownerId`, and the expected-close period (the
@@ -14,9 +14,10 @@ export function salesProductFilters(filters) {
14
14
  ? { name: 'active', operator: one.value === 'active' ? 'is_true' : 'is_not_true', value: null }
15
15
  : one);
16
16
  }
17
- /** The opportunity stages a person still moves an opportunity through - the list opens on them, won and lost left out. */
18
- export const OPEN_STAGES = ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION'];
19
- export const STAGES = [...OPEN_STAGES, 'WON', 'LOST'];
17
+ /** The opportunity stages a person still moves an opportunity through, and on hold - the list opens on them, so a held
18
+ * one stays in sight; won, lost and cancelled are left out (ADR-0233 decision 8). */
19
+ export const LISTED_STAGES = ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION', 'ON_HOLD'];
20
+ export const STAGES = [...LISTED_STAGES, 'WON', 'LOST', 'CANCELLED'];
20
21
  /**
21
22
  * 영업 기회: the person in charge (the `owner` column, a user id) as `ownerId`, and the expected-close period (the
22
23
  * `expectedCloseMonth` column, `this-month` … `this-year`) as the months it covers on `today` (`YYYY-MM-DD`). The stages
@@ -1 +1,3 @@
1
1
  export declare const opportunityStageWord: (stage?: string) => string;
2
+ /** What the reason an opportunity carries is called at its stage - lost, cancelled or on hold (ADR-0233). */
3
+ export declare const opportunityReasonLabel: (stage?: string) => string;
@@ -9,5 +9,15 @@ export const opportunityStageWord = (stage) => stage === 'PROPOSAL'
9
9
  ? i18next.t('text.opportunity-stage-won')
10
10
  : stage === 'LOST'
11
11
  ? i18next.t('text.opportunity-stage-lost')
12
- : i18next.t('text.opportunity-stage-lead');
12
+ : stage === 'CANCELLED'
13
+ ? i18next.t('text.opportunity-stage-cancelled')
14
+ : stage === 'ON_HOLD'
15
+ ? i18next.t('text.opportunity-stage-on-hold')
16
+ : i18next.t('text.opportunity-stage-lead');
17
+ /** What the reason an opportunity carries is called at its stage - lost, cancelled or on hold (ADR-0233). */
18
+ export const opportunityReasonLabel = (stage) => stage === 'CANCELLED'
19
+ ? i18next.t('field.opportunity-cancel-reason')
20
+ : stage === 'ON_HOLD'
21
+ ? i18next.t('field.opportunity-hold-reason')
22
+ : i18next.t('field.opportunity-lost-reason');
13
23
  //# sourceMappingURL=opportunity-words.js.map
@@ -7,8 +7,8 @@ declare const OpportunityEditor_base: (new (...args: any[]) => import("lit").Lit
7
7
  * 영업 기회 편집 — with whom, for how much, by when and how likely.
8
8
  *
9
9
  * A person moves an open opportunity through the stages; changing the stage puts that stage's probability in, and the
10
- * person may change it. An open one is closed as lost with the reason; a lost one is opened again by choosing an open
11
- * stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.
10
+ * person may change it. An open one is closed as lost or cancelled, or put on hold until a review day, each with the
11
+ * reason; a held one is resumed or closed; a lost or cancelled one is opened again by choosing an open stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.
12
12
  */
13
13
  export declare class OpportunityEditor extends OpportunityEditor_base {
14
14
  static styles: import("lit").CSSResult[];
@@ -19,7 +19,7 @@ export declare class OpportunityEditor extends OpportunityEditor_base {
19
19
  private choices;
20
20
  private record;
21
21
  private draft;
22
- private loss;
22
+ private closing;
23
23
  private saves;
24
24
  private change;
25
25
  private get opportunity();
@@ -29,6 +29,7 @@ export declare class OpportunityEditor extends OpportunityEditor_base {
29
29
  /** The form as it shows: each field's edit, else what was read (blank while it is read). */
30
30
  private get form();
31
31
  private get reason();
32
+ private get heldUntil();
32
33
  /** A failed read, or an opportunity the address names that is not there. */
33
34
  private get error();
34
35
  private get loading();
@@ -47,7 +48,11 @@ export declare class OpportunityEditor extends OpportunityEditor_base {
47
48
  render(): import("lit-html").TemplateResult<1>;
48
49
  /** A counterparty of the domain, found as it is typed - or registered there when it is not one yet (ADR-0195). */
49
50
  private renderParty;
50
- private renderLose;
51
+ /**
52
+ * 종결·보류 (ADR-0233 decision 8): lost, cancelled or on hold, each with the reason; a hold also with its review day. A
53
+ * held one is resumed at the stage it was held from, or closed from the hold.
54
+ */
55
+ private renderClose;
51
56
  /** The quotations that answer this opportunity; a new one is written from here and answers it. */
52
57
  private renderQuotations;
53
58
  private renderEvents;
@@ -57,6 +62,8 @@ export declare class OpportunityEditor extends OpportunityEditor_base {
57
62
  private input;
58
63
  /** A new one is opened once it is made; the edits sent are cleared once the save answered. */
59
64
  private save;
60
- private lose;
65
+ private close;
66
+ private hold;
67
+ private resume;
61
68
  }
62
69
  export {};
@@ -11,10 +11,10 @@ import { navigate, PageView, DraftController } from '@operato/shell';
11
11
  import { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles';
12
12
  import { currencyChoices, documentAmount, DocumentFormStyles } from '@things-factory/invoice/dist-client';
13
13
  import { opportunitySection } from '../opportunity-attach';
14
- import { opportunityStageWord } from '../opportunity-words';
14
+ import { opportunityReasonLabel, opportunityStageWord } from '../opportunity-words';
15
15
  import { quotationStatusWord } from '../quotation-words';
16
16
  const FIELDS = `
17
- id name stage probability amount currency expectedCloseMonth closedOn lostReason description
17
+ id name stage probability amount currency expectedCloseMonth closedOn stageReason heldUntil description
18
18
  counterpartyId endCustomerId ownerId counterparty { id name } endCustomer { id name } owner { id name }
19
19
  quotations { id number version status issueDate validUntil totalAmount currency }
20
20
  `;
@@ -29,8 +29,8 @@ const thisMonth = () => new Date().toLocaleDateString('en-CA').slice(0, 7);
29
29
  * 영업 기회 편집 — with whom, for how much, by when and how likely.
30
30
  *
31
31
  * A person moves an open opportunity through the stages; changing the stage puts that stage's probability in, and the
32
- * person may change it. An open one is closed as lost with the reason; a lost one is opened again by choosing an open
33
- * stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.
32
+ * person may change it. An open one is closed as lost or cancelled, or put on hold until a review day, each with the
33
+ * reason; a held one is resumed or closed; a lost or cancelled one is opened again by choosing an open stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.
34
34
  */
35
35
  let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageView) {
36
36
  constructor() {
@@ -49,13 +49,16 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
49
49
  this.record = new QueryController(this, READ, { variables: () => (this.opportunityId ? { id: this.opportunityId } : undefined) });
50
50
  /* What is typed over the opportunity read - a new one starts blank, at the first stage. */
51
51
  this.draft = new DraftController(this, { read: () => (this.opportunityId ? this.opportunity && formOf(this.opportunity) : blank(this.stages)), key: () => this.opportunityId });
52
- /* The reason a lost one is closed with. */
53
- this.loss = new DraftController(this, { read: () => ({ reason: '' }), key: () => this.opportunityId });
52
+ /* The reason an opportunity is lost, cancelled or held with, and the review day of a hold (ADR-0233). */
53
+ this.closing = new DraftController(this, { read: () => ({ reason: '', heldUntil: '' }), key: () => this.opportunityId });
54
54
  /* Every change reads the opportunity again once it is done. */
55
55
  this.saves = {
56
56
  create: new MutationController(this, gql `mutation ($opportunity: NewOpportunity!) { opportunity: createOpportunity(opportunity: $opportunity) { id } }`),
57
57
  update: this.change(gql `mutation ($id: String!, $opportunity: NewOpportunity!) { opportunity: updateOpportunity(id: $id, opportunity: $opportunity) { id } }`),
58
- lose: this.change(gql `mutation ($id: String!, $reason: String!) { loseOpportunity(id: $id, reason: $reason) { id } }`)
58
+ lose: this.change(gql `mutation ($id: String!, $reason: String!) { loseOpportunity(id: $id, reason: $reason) { id } }`),
59
+ cancel: this.change(gql `mutation ($id: String!, $reason: String!) { cancelOpportunity(id: $id, reason: $reason) { id } }`),
60
+ hold: this.change(gql `mutation ($id: String!, $reason: String!, $heldUntil: String!) { holdOpportunity(id: $id, reason: $reason, heldUntil: $heldUntil) { id } }`),
61
+ resume: this.change(gql `mutation ($id: String!) { resumeOpportunity(id: $id) { id } }`)
59
62
  };
60
63
  }
61
64
  static { this.styles = [
@@ -106,7 +109,10 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
106
109
  return Object.fromEntries(Object.entries(blank(this.stages)).map(([name, given]) => [name, this.draft.value(name) ?? given]));
107
110
  }
108
111
  get reason() {
109
- return this.loss.value('reason') ?? '';
112
+ return this.closing.value('reason') ?? '';
113
+ }
114
+ get heldUntil() {
115
+ return this.closing.value('heldUntil') ?? '';
110
116
  }
111
117
  /** A failed read, or an opportunity the address names that is not there. */
112
118
  get error() {
@@ -208,13 +214,14 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
208
214
  : nothing}
209
215
  </div>
210
216
  </section>
211
- ${this.opportunity && this.isOpen(this.opportunity.stage) ? this.renderLose() : nothing}
212
- ${this.opportunity?.lostReason
217
+ ${this.opportunity?.stageReason
213
218
  ? html `<section class="page-section">
214
- <header class="page-section-header"><h3>${i18next.t('field.opportunity-lost-reason')}</h3></header>
215
- <p>${this.opportunity.lostReason}</p>
219
+ <header class="page-section-header"><h3>${opportunityReasonLabel(this.opportunity.stage)}</h3></header>
220
+ <p>${this.opportunity.stageReason}</p>
221
+ ${this.opportunity.heldUntil ? html `<p>${i18next.t('field.opportunity-held-until')} <strong>${this.opportunity.heldUntil}</strong></p>` : nothing}
216
222
  </section>`
217
223
  : nothing}
224
+ ${this.opportunity && (this.isOpen(this.opportunity.stage) || this.opportunity.stage === 'ON_HOLD') ? this.renderClose() : nothing}
218
225
  ${this.opportunity ? this.renderQuotations() : nothing}
219
226
  ${attached && this.opportunity
220
227
  ? html `<section class="page-section" @opportunity-changed=${() => this.record.refetch()}>
@@ -233,19 +240,32 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
233
240
  <counterparty-select .party=${this.form[which] ?? null} ?disabled=${!editable} @counterparty=${(e) => this.edit({ [which]: e.detail })}></counterparty-select>
234
241
  </label>`;
235
242
  }
236
- renderLose() {
243
+ /**
244
+ * 종결·보류 (ADR-0233 decision 8): lost, cancelled or on hold, each with the reason; a hold also with its review day. A
245
+ * held one is resumed at the stage it was held from, or closed from the hold.
246
+ */
247
+ renderClose() {
248
+ const held = this.opportunity.stage === 'ON_HOLD';
249
+ const reasoned = !this.busy && !!this.reason.trim();
237
250
  return html `<section class="page-section">
238
251
  <header class="page-section-header">
239
- <h3>${i18next.t('text.opportunity-section-lose')}</h3>
252
+ <h3>${i18next.t('text.opportunity-section-close')}</h3>
240
253
  <div class="page-section-actions">
241
- <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.lose()}>${i18next.t('button.opportunity-lose')}</button>
254
+ ${held ? html `<button ?disabled=${this.busy} @click=${() => this.resume()}>${i18next.t('button.opportunity-resume')}</button>` : nothing}
255
+ <button ?disabled=${!reasoned || !this.heldUntil} @click=${() => this.hold()}>${i18next.t('button.opportunity-hold')}</button>
256
+ <button ?disabled=${!reasoned} @click=${() => this.close('cancel')}>${i18next.t('button.opportunity-cancel')}</button>
257
+ <button ?disabled=${!reasoned} @click=${() => this.close('lose')}>${i18next.t('button.opportunity-lose')}</button>
242
258
  </div>
243
259
  </header>
244
260
  <div class="form">
245
261
  <label class="wide"
246
- >${i18next.t('field.opportunity-lost-reason')}
247
- <input .value=${this.reason} ?disabled=${this.busy} @input=${(e) => this.loss.set('reason', e.target.value)}
262
+ >${i18next.t('field.opportunity-reason')}
263
+ <input .value=${this.reason} ?disabled=${this.busy} @input=${(e) => this.closing.set('reason', e.target.value)}
248
264
  /></label>
265
+ <label
266
+ >${i18next.t('field.opportunity-held-until')}
267
+ <ox-input-date type="date" .value=${this.heldUntil} ?disabled=${this.busy} @change=${(e) => this.closing.set('heldUntil', e.target.value)}></ox-input-date>
268
+ </label>
249
269
  </div>
250
270
  </section>`;
251
271
  }
@@ -256,7 +276,7 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
256
276
  <header class="page-section-header">
257
277
  <h3>${i18next.t('text.opportunity-section-quotations')}</h3>
258
278
  <div class="page-section-actions">
259
- <button ?disabled=${this.busy || this.opportunity.stage === 'WON' || this.opportunity.stage === 'LOST'} @click=${() => navigate(`quotation-editor?opportunity=${this.opportunity.id}`)}>
279
+ <button ?disabled=${this.busy || !this.isOpen(this.opportunity.stage)} @click=${() => navigate(`quotation-editor?opportunity=${this.opportunity.id}`)}>
260
280
  ${i18next.t('button.opportunity-new-quotation')}
261
281
  </button>
262
282
  </div>
@@ -343,11 +363,22 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
343
363
  if (saved && !id)
344
364
  navigate(`opportunity-editor?id=${saved.opportunity.id}`);
345
365
  }
346
- async lose() {
366
+ async close(how) {
367
+ if (this.busy)
368
+ return;
369
+ const id = this.opportunityId;
370
+ await this.closing.submit(sent => this.saves[how].run({ id, reason: (sent.reason ?? '').trim() }));
371
+ }
372
+ async hold() {
347
373
  if (this.busy)
348
374
  return;
349
375
  const id = this.opportunityId;
350
- await this.loss.submit(sent => this.saves.lose.run({ id, reason: (sent.reason ?? '').trim() }));
376
+ await this.closing.submit(sent => this.saves.hold.run({ id, reason: (sent.reason ?? '').trim(), heldUntil: sent.heldUntil ?? '' }));
377
+ }
378
+ async resume() {
379
+ if (this.busy)
380
+ return;
381
+ await this.saves.resume.run({ id: this.opportunityId });
351
382
  }
352
383
  };
353
384
  __decorate([
@@ -370,9 +401,15 @@ const eventWord = (action) => action === 'CREATED'
370
401
  ? i18next.t('text.opportunity-event-won')
371
402
  : action === 'LOST'
372
403
  ? i18next.t('text.opportunity-event-lost')
373
- : action === 'REOPENED'
374
- ? i18next.t('text.opportunity-event-reopened')
375
- : i18next.t('text.opportunity-event-updated');
404
+ : action === 'CANCELLED'
405
+ ? i18next.t('text.opportunity-event-cancelled')
406
+ : action === 'HELD'
407
+ ? i18next.t('text.opportunity-event-held')
408
+ : action === 'RESUMED'
409
+ ? i18next.t('text.opportunity-event-resumed')
410
+ : action === 'REOPENED'
411
+ ? i18next.t('text.opportunity-event-reopened')
412
+ : i18next.t('text.opportunity-event-updated');
376
413
  /** The form of an opportunity as read. */
377
414
  function formOf(opportunity) {
378
415
  return {
@@ -13,7 +13,7 @@ import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePage
13
13
  import { isMobileDevice } from '@operato/utils';
14
14
  import { SELECTION_ROW_PICKER } from '@things-factory/ai-assistant/dist-client/index.js';
15
15
  import { documentAmount } from '@things-factory/invoice/dist-client';
16
- import { OPEN_STAGES, opportunityFilters, STAGES } from '../list-filters';
16
+ import { LISTED_STAGES, opportunityFilters, STAGES } from '../list-filters';
17
17
  import { opportunityStageWord } from '../opportunity-words';
18
18
  const today = () => new Date().toLocaleDateString('en-CA');
19
19
  /**
@@ -123,7 +123,7 @@ let OpportunityList = class OpportunityList extends localize(i18next)(PageView)
123
123
  readonly('string', 'stage', i18next.t('field.opportunity-stage'), 90, {
124
124
  record: { renderer: (value) => opportunityStageWord(value) },
125
125
  /* Chips with their counts; the list opens on the open stages, and none pressed is every stage. */
126
- filter: { type: 'select-buttons', operator: 'in', value: OPEN_STAGES, options: STAGES.map(stage => ({ value: stage, display: opportunityStageWord(stage) })) }
126
+ filter: { type: 'select-buttons', operator: 'in', value: LISTED_STAGES, options: STAGES.map(stage => ({ value: stage, display: opportunityStageWord(stage) })) }
127
127
  }),
128
128
  readonly('integer', 'probability', i18next.t('field.opportunity-probability'), 70, { record: { align: 'right', renderer: (value) => `${value ?? 0}%` } }),
129
129
  readonly('float', 'amount', i18next.t('field.opportunity-amount'), 150, {
@@ -39,6 +39,7 @@ export declare class QuotationList extends QuotationList_base {
39
39
  };
40
40
  };
41
41
  private editAction;
42
+ private previewAction;
42
43
  render(): import("lit-html").TemplateResult<1>;
43
44
  pageInitialized(): Promise<void>;
44
45
  private conditions;
@@ -14,6 +14,7 @@ import { isMobileDevice } from '@operato/utils';
14
14
  import { SELECTION_ROW_PICKER } from '@things-factory/ai-assistant/dist-client/index.js';
15
15
  import { counterpartOf, documentAmount, issuePeriodOf } from '@things-factory/invoice/dist-client';
16
16
  import { QUOTATION_STATUSES, quotationFilters } from '../list-filters';
17
+ import { previewQuotation } from '../quotation-preview';
17
18
  import { quotationStatusWord } from '../quotation-words';
18
19
  const today = () => new Date().toLocaleDateString('en-CA');
19
20
  /**
@@ -39,6 +40,17 @@ let QuotationList = class QuotationList extends localize(i18next)(PageView) {
39
40
  navigate(`quotation-editor?id=${row.id}`);
40
41
  }
41
42
  };
43
+ /* The picked quotation as it goes out - the same preview the editor and the 360 open (the user, 2026-11-24). */
44
+ this.previewAction = {
45
+ title: i18next.t('button.preview'),
46
+ icon: 'preview',
47
+ single: true,
48
+ action: () => {
49
+ const row = this.grist.selected?.[0];
50
+ if (row?.id)
51
+ previewQuotation({ id: row.id, number: row.number, version: row.version, language: row.language });
52
+ }
53
+ };
42
54
  }
43
55
  static { this.styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]; }
44
56
  get context() {
@@ -77,7 +89,7 @@ let QuotationList = class QuotationList extends localize(i18next)(PageView) {
77
89
  list="quotations"
78
90
  axis="quotation"
79
91
  .labelOf=${(row) => [row.number && `${row.number} v${row.version}`, counterpartOf(row)].filter(Boolean).join(' · ')}
80
- .actions=${[this.editAction]}
92
+ .actions=${[this.previewAction, this.editAction]}
81
93
  ></ox-assistant-selection-bar>
82
94
  <div slot="headroom" class="header">
83
95
  <div class="filters"><ox-filters-form without-search></ox-filters-form></div>
@@ -163,6 +175,7 @@ let QuotationList = class QuotationList extends localize(i18next)(PageView) {
163
175
  number
164
176
  version
165
177
  status
178
+ language
166
179
  direction
167
180
  currency
168
181
  supplierName
@@ -1 +1 @@
1
- export default function route(page: string): "quotation-list" | "quotation-editor" | "opportunity-list" | "opportunity-editor" | "sales-product-list" | undefined;
1
+ export default function route(page: string): "opportunity-list" | "quotation-list" | "quotation-editor" | "opportunity-editor" | "sales-product-list" | undefined;
@@ -14,8 +14,8 @@ export * from './sales-product/sales-product-rules';
14
14
  export * from './sales-product/sales-product-service';
15
15
  export * from './sales-product/sales-product-type';
16
16
  export * from './sales-read';
17
- export declare const entities: (typeof import("./opportunity/opportunity").Opportunity | typeof import("./quotation/quotation-item").QuotationItem | typeof import("./quotation/quotation").Quotation | typeof import("./quotation/quotation-event").QuotationEvent | typeof import("./opportunity/opportunity-event").OpportunityEvent | typeof import("./sales-product/sales-product").SalesProduct)[];
17
+ export declare const entities: (typeof import("./quotation/quotation").Quotation | typeof import("./quotation/quotation-item").QuotationItem | typeof import("./quotation/quotation-event").QuotationEvent | typeof import("./opportunity/opportunity").Opportunity | typeof import("./opportunity/opportunity-event").OpportunityEvent | typeof import("./sales-product/sales-product").SalesProduct)[];
18
18
  export declare const subscribers: any[];
19
19
  export declare const schema: {
20
- resolverClasses: (typeof import("./opportunity/opportunity-event-query").OpportunityEventQuery | typeof import("./opportunity/opportunity-mutation").OpportunityMutation | typeof import("./opportunity/opportunity-query").OpportunityQuery | typeof import("./quotation/quotation-event-query").QuotationEventQuery | typeof import("./quotation/quotation-item-query").QuotationItemQuery | typeof import("./quotation/quotation-mutation").QuotationMutation | typeof import("./quotation/quotation-query").QuotationQuery | typeof import("./sales-product/sales-product-mutation").SalesProductMutation | typeof import("./sales-product/sales-product-query").SalesProductQuery)[];
20
+ resolverClasses: (typeof import("./quotation/quotation-query").QuotationQuery | typeof import("./quotation/quotation-mutation").QuotationMutation | typeof import("./quotation/quotation-item-query").QuotationItemQuery | typeof import("./quotation/quotation-event-query").QuotationEventQuery | typeof import("./opportunity/opportunity-query").OpportunityQuery | typeof import("./opportunity/opportunity-mutation").OpportunityMutation | typeof import("./opportunity/opportunity-event-query").OpportunityEventQuery | typeof import("./sales-product/sales-product-query").SalesProductQuery | typeof import("./sales-product/sales-product-mutation").SalesProductMutation)[];
21
21
  };
@@ -4,5 +4,5 @@ import { OpportunityEventQuery } from './opportunity-event-query';
4
4
  import { OpportunityMutation } from './opportunity-mutation';
5
5
  import { OpportunityQuery } from './opportunity-query';
6
6
  export declare const entities: (typeof Opportunity | typeof OpportunityEvent)[];
7
- export declare const resolvers: (typeof OpportunityEventQuery | typeof OpportunityMutation | typeof OpportunityQuery)[];
7
+ export declare const resolvers: (typeof OpportunityQuery | typeof OpportunityMutation | typeof OpportunityEventQuery)[];
8
8
  export declare const subscribers: any[];
@@ -37,7 +37,7 @@ tslib_1.__decorate([
37
37
  ], OpportunityEvent.prototype, "opportunityId", void 0);
38
38
  tslib_1.__decorate([
39
39
  (0, typeorm_1.Column)(),
40
- (0, type_graphql_1.Field)({ description: 'What happened: CREATED, UPDATED, STAGED, WON, LOST, or REOPENED when the record a win became was undone' }),
40
+ (0, type_graphql_1.Field)({ description: 'What happened: CREATED, UPDATED, STAGED, WON, LOST, CANCELLED, HELD, RESUMED, or REOPENED when the record a win became was undone' }),
41
41
  tslib_1.__metadata("design:type", String)
42
42
  ], OpportunityEvent.prototype, "action", void 0);
43
43
  tslib_1.__decorate([
@@ -57,7 +57,7 @@ tslib_1.__decorate([
57
57
  ], OpportunityEvent.prototype, "probability", void 0);
58
58
  tslib_1.__decorate([
59
59
  (0, typeorm_1.Column)({ nullable: true }),
60
- (0, type_graphql_1.Field)({ nullable: true, description: 'Why, when it was lost' }),
60
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Why, when it was lost, cancelled, held, resumed or reopened' }),
61
61
  tslib_1.__metadata("design:type", String)
62
62
  ], OpportunityEvent.prototype, "reason", void 0);
63
63
  tslib_1.__decorate([
@@ -4,4 +4,7 @@ export declare class OpportunityMutation {
4
4
  createOpportunity(opportunity: NewOpportunity, context: ResolverContext): Promise<Opportunity>;
5
5
  updateOpportunity(id: string, opportunity: NewOpportunity, context: ResolverContext): Promise<Opportunity>;
6
6
  loseOpportunity(id: string, reason: string, closedOn: string, context: ResolverContext): Promise<Opportunity>;
7
+ cancelOpportunity(id: string, reason: string, closedOn: string, context: ResolverContext): Promise<Opportunity>;
8
+ holdOpportunity(id: string, reason: string, heldUntil: string, context: ResolverContext): Promise<Opportunity>;
9
+ resumeOpportunity(id: string, context: ResolverContext): Promise<Opportunity>;
7
10
  }
@@ -22,6 +22,18 @@ let OpportunityMutation = class OpportunityMutation {
22
22
  const { tx, domain, user } = context.state;
23
23
  return (0, opportunity_service_1.closeOpportunity)(tx, domain, user, id, opportunity_rules_1.OpportunityStage.LOST, { reason, closedOn });
24
24
  }
25
+ cancelOpportunity(id, reason, closedOn, context) {
26
+ const { tx, domain, user } = context.state;
27
+ return (0, opportunity_service_1.closeOpportunity)(tx, domain, user, id, opportunity_rules_1.OpportunityStage.CANCELLED, { reason, closedOn });
28
+ }
29
+ holdOpportunity(id, reason, heldUntil, context) {
30
+ const { tx, domain, user } = context.state;
31
+ return (0, opportunity_service_1.holdOpportunity)(tx, domain, user, id, { reason, heldUntil });
32
+ }
33
+ resumeOpportunity(id, context) {
34
+ const { tx, domain, user } = context.state;
35
+ return (0, opportunity_service_1.resumeOpportunity)(tx, domain, user, id);
36
+ }
25
37
  };
26
38
  exports.OpportunityMutation = OpportunityMutation;
27
39
  tslib_1.__decorate([
@@ -48,7 +60,7 @@ tslib_1.__decorate([
48
60
  tslib_1.__decorate([
49
61
  (0, type_graphql_1.Directive)('@transaction'),
50
62
  (0, type_graphql_1.Directive)('@privilege(category: "sales", privilege: "mutation", domainOwnerGranted: true)'),
51
- (0, type_graphql_1.Mutation)(type => opportunity_1.Opportunity, { description: 'To close an open opportunity as lost, with the reason' }),
63
+ (0, type_graphql_1.Mutation)(type => opportunity_1.Opportunity, { description: 'To close an open or held opportunity as lost, with the reason' }),
52
64
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
53
65
  tslib_1.__param(1, (0, type_graphql_1.Arg)('reason')),
54
66
  tslib_1.__param(2, (0, type_graphql_1.Arg)('closedOn', { nullable: true })),
@@ -57,6 +69,40 @@ tslib_1.__decorate([
57
69
  tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
58
70
  tslib_1.__metadata("design:returntype", void 0)
59
71
  ], OpportunityMutation.prototype, "loseOpportunity", null);
72
+ tslib_1.__decorate([
73
+ (0, type_graphql_1.Directive)('@transaction'),
74
+ (0, type_graphql_1.Directive)('@privilege(category: "sales", privilege: "mutation", domainOwnerGranted: true)'),
75
+ (0, type_graphql_1.Mutation)(type => opportunity_1.Opportunity, { description: 'To close an open or held opportunity as cancelled - the customer dropped the work - with the reason' }),
76
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
77
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('reason')),
78
+ tslib_1.__param(2, (0, type_graphql_1.Arg)('closedOn', { nullable: true })),
79
+ tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
80
+ tslib_1.__metadata("design:type", Function),
81
+ tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
82
+ tslib_1.__metadata("design:returntype", void 0)
83
+ ], OpportunityMutation.prototype, "cancelOpportunity", null);
84
+ tslib_1.__decorate([
85
+ (0, type_graphql_1.Directive)('@transaction'),
86
+ (0, type_graphql_1.Directive)('@privilege(category: "sales", privilege: "mutation", domainOwnerGranted: true)'),
87
+ (0, type_graphql_1.Mutation)(type => opportunity_1.Opportunity, { description: 'To put an open opportunity on hold until a review day, with the reason, or change the reason and day of a held one' }),
88
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
89
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('reason')),
90
+ tslib_1.__param(2, (0, type_graphql_1.Arg)('heldUntil')),
91
+ tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
92
+ tslib_1.__metadata("design:type", Function),
93
+ tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
94
+ tslib_1.__metadata("design:returntype", void 0)
95
+ ], OpportunityMutation.prototype, "holdOpportunity", null);
96
+ tslib_1.__decorate([
97
+ (0, type_graphql_1.Directive)('@transaction'),
98
+ (0, type_graphql_1.Directive)('@privilege(category: "sales", privilege: "mutation", domainOwnerGranted: true)'),
99
+ (0, type_graphql_1.Mutation)(type => opportunity_1.Opportunity, { description: 'To resume a held opportunity at the open stage it was held from' }),
100
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
101
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
102
+ tslib_1.__metadata("design:type", Function),
103
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
104
+ tslib_1.__metadata("design:returntype", void 0)
105
+ ], OpportunityMutation.prototype, "resumeOpportunity", null);
60
106
  exports.OpportunityMutation = OpportunityMutation = tslib_1.__decorate([
61
107
  (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
62
108
  (0, type_graphql_1.Resolver)(opportunity_1.Opportunity)
@@ -34,7 +34,7 @@ let OpportunityQuery = class OpportunityQuery {
34
34
  return (0, shell_1.getRepository)(opportunity_event_1.OpportunityEvent).find({ where: { domain: { id: context.state.domain.id }, opportunity: { id: opportunityId } }, order: { createdAt: 'ASC' } });
35
35
  }
36
36
  opportunityStages() {
37
- return Object.values(opportunity_rules_1.OpportunityStage).map(stage => ({ stage, probability: opportunity_rules_1.STAGE_PROBABILITY[stage], open: (0, opportunity_rules_1.isOpen)(stage) }));
37
+ return Object.values(opportunity_rules_1.OpportunityStage).map(stage => ({ stage, probability: opportunity_rules_1.STAGE_PROBABILITY[stage] ?? null, open: (0, opportunity_rules_1.isOpen)(stage) }));
38
38
  }
39
39
  opportunityOwners(context) {
40
40
  return (0, auth_base_1.getDomainAssignees)(context.state.domain);
@@ -3,20 +3,27 @@ export declare enum OpportunityStage {
3
3
  PROPOSAL = "PROPOSAL",
4
4
  QUOTED = "QUOTED",
5
5
  NEGOTIATION = "NEGOTIATION",
6
+ ON_HOLD = "ON_HOLD",
6
7
  WON = "WON",
7
- LOST = "LOST"
8
+ LOST = "LOST",
9
+ CANCELLED = "CANCELLED"
8
10
  }
9
- /** The stages a person moves an opportunity through, in order; the two after them close it. */
11
+ /** The stages a person moves an opportunity through, in order; hold pauses it, the three after it close it (ADR-0233). */
10
12
  export declare const OPEN_STAGES: OpportunityStage[];
11
- export declare const STAGE_PROBABILITY: Record<OpportunityStage, number>;
13
+ export declare const CLOSED_STAGES: OpportunityStage[];
14
+ export declare const STAGE_PROBABILITY: Record<Exclude<OpportunityStage, OpportunityStage.ON_HOLD>, number>;
12
15
  export declare const isOpen: (stage: string) => boolean;
16
+ export declare const isClosed: (stage: string) => boolean;
17
+ /** The longest a hold runs before its review day, in days (ADR-0233 decision 2). */
18
+ export declare const HOLD_DAYS_MAX = 180;
13
19
  /**
14
- * Whether an opportunity may go from one stage to another. A person moves an open one to any open stage, or closes it
15
- * as lost; a lost one may be opened again. Winning closes it for good — an application turns the win into its own
16
- * record (a contract) and only it closes an opportunity as won.
20
+ * Whether an opportunity may go from one stage to another. A person moves an open one to any open stage, holds it, or
21
+ * closes it as lost or cancelled; a held one is closed as lost or cancelled, or resumed (`resumeOpportunity`, back to
22
+ * the stage it was held from); a lost or cancelled one may be opened again. Winning closes it for good — an application
23
+ * turns the win into its own record (a contract) and only it closes an opportunity as won, from an open stage.
17
24
  */
18
25
  export declare function stageMove(from: string, to: string): boolean;
19
- /** The probability an opportunity keeps after a stage change: the one a person gave, or the stage's own. */
26
+ /** The probability an opportunity keeps after a stage change: the one a person gave, or the stage's own; a hold keeps it. */
20
27
  export declare function probabilityAfter(stage: OpportunityStage, given?: number | null): number;
21
28
  export declare const validProbability: (value: unknown) => boolean;
22
29
  export declare const validMonth: (value: unknown) => boolean;