@things-factory/sales 10.1.267 → 10.1.269

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.
@@ -1,3 +1,4 @@
1
+ import '@operato/input/ox-input-date.js';
1
2
  import '@operato/list-state/ox-page-state.js';
2
3
  import '@things-factory/biz-base/dist-client';
3
4
  import { PageView } from '@operato/shell';
@@ -1,4 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
+ import '@operato/input/ox-input-date.js';
2
3
  import '@operato/list-state/ox-page-state.js';
3
4
  import '@things-factory/biz-base/dist-client';
4
5
  import gql from 'graphql-tag';
@@ -175,8 +176,7 @@ let OpportunityEditor = class OpportunityEditor extends localize(i18next)(PageVi
175
176
  </label>
176
177
  <label
177
178
  >${i18next.t('field.opportunity-expected-close-month')}
178
- <input type="month" .value=${this.form.expectedCloseMonth} ?disabled=${!editable} @input=${(e) => set({ expectedCloseMonth: e.target.value })}
179
- /></label>
179
+ <ox-input-date type="month" .value=${this.form.expectedCloseMonth} ?disabled=${!editable} @change=${(e) => set({ expectedCloseMonth: e.target.value })}></ox-input-date></label>
180
180
  <label
181
181
  >${i18next.t('field.opportunity-owner')}
182
182
  <select .value=${this.form.ownerId} ?disabled=${!editable} @change=${(e) => set({ ownerId: e.target.value })}>
@@ -1 +1 @@
1
- {"version":3,"file":"opportunity-editor.js","sourceRoot":"","sources":["../../client/pages/opportunity-editor.ts"],"names":[],"mappings":";AAAA,OAAO,sCAAsC,CAAA;AAC7C,OAAO,sCAAsC,CAAA;AAE7C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,QAAQ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E,WAAW,CAAC,IAAI;QACtB,YAAY,EAAE,WAAW,CAAC,YAAY;QACtC,WAAW,EAAE,WAAW,CAAC,WAAW;QACpC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,CAAC;QACvC,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;QAClD,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC;QAC5C,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,EAAE;QAClC,WAAW,EAAE,WAAW,CAAC,WAAW,IAAI,EAAE;KAC3C,CAAA;AACH,CAAC;AAED,SAAS,KAAK,CAAC,SAAmD,EAAE;IAClE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,CAAA;IACrD,OAAO;QACL,IAAI,EAAE,EAAE;QACR,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,GAAG;QACX,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,SAAS,EAAE;QAC/B,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;KAChB,CAAA;AACH,CAAC","sourcesContent":["import '@operato/list-state/ox-page-state.js'\nimport '@things-factory/biz-base/dist-client'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView, DraftController } from '@operato/shell'\nimport { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles'\nimport { currencyChoices, documentAmount, DocumentFormStyles } from '@things-factory/invoice/dist-client'\n\nimport { opportunitySection } from '../opportunity-attach'\nimport { opportunityStageWord } from '../opportunity-words'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id name stage probability amount currency expectedCloseMonth closedOn lostReason description\n counterpartyId endCustomerId ownerId counterparty { id name } endCustomer { id name } owner { id name }\n quotations { id number version status issueDate validUntil totalAmount currency }\n`\n\ntype Party = { id: string; name: string; businessNumber?: string }\ntype Form = {\n name: string\n counterparty: Party | null\n endCustomer: Party | null\n amount: string\n currency: string\n expectedCloseMonth: string\n stage: string\n probability: string\n ownerId: string\n description: string\n}\n\nconst READ = gql(`\n query ($id: String!) {\n opportunity(id: $id) { ${FIELDS} }\n opportunityEvents(opportunityId: $id) { id action fromStage stage probability reason createdAt actor { id name } }\n }\n`)\n\nconst thisMonth = () => new Date().toLocaleDateString('en-CA').slice(0, 7)\n\n/**\n * 영업 기회 편집 — with whom, for how much, by when and how likely.\n *\n * A person moves an open opportunity through the stages; changing the stage puts that stage's probability in, and the\n * person may change it. An open one is closed as lost with the reason; a lost one is opened again by choosing an open\n * stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.\n */\n@customElement('opportunity-editor')\nexport class OpportunityEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n DocumentFormStyles,\n css`\n table {\n width: 100%;\n border-collapse: collapse;\n font-variant-numeric: tabular-nums;\n }\n th,\n td {\n text-align: left;\n padding: var(--spacing-small);\n border-bottom: 1px solid var(--ui-line-soft);\n font-size: var(--ui-t-body);\n }\n th.number,\n td.number {\n text-align: right;\n }\n td a {\n color: inherit;\n text-decoration: underline;\n }\n `\n ]\n\n /** The opportunity the address names; none for a new one. */\n @state() private opportunityId = ''\n /** Whether the application's section is this person's to read - asked once, before it is shown. */\n @state() sectionReadable = false\n\n /* The stages with their probabilities and who may own one, and the opportunity the address names (ADR-0190). */\n private choices = new QueryController(\n this,\n gql`\n query {\n opportunityStages { stage probability open }\n opportunityOwners { id name email }\n }\n `\n )\n private record = new QueryController(this, READ, { variables: () => (this.opportunityId ? { id: this.opportunityId } : undefined) })\n\n /* What is typed over the opportunity read - a new one starts blank, at the first stage. */\n private draft = new DraftController<Form>(this, { read: () => (this.opportunityId ? this.opportunity && formOf(this.opportunity) : blank(this.stages)), key: () => this.opportunityId })\n /* The reason a lost one is closed with. */\n private loss = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.opportunityId })\n\n /* Every change reads the opportunity again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($opportunity: NewOpportunity!) { opportunity: createOpportunity(opportunity: $opportunity) { id } }`),\n update: this.change(gql`mutation ($id: String!, $opportunity: NewOpportunity!) { opportunity: updateOpportunity(id: $id, opportunity: $opportunity) { id } }`),\n lose: this.change(gql`mutation ($id: String!, $reason: String!) { loseOpportunity(id: $id, reason: $reason) { id } }`)\n }\n\n private change(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get opportunity(): any {\n return (this.opportunityId && this.record.data?.opportunity) || null\n }\n\n private get events(): any[] {\n return (this.opportunityId && this.record.data?.opportunityEvents) || []\n }\n\n private get stages(): { stage: string; probability: number; open: boolean }[] {\n return this.choices.data?.opportunityStages ?? []\n }\n\n private get owners(): { id: string; name: string; email?: string }[] {\n return this.choices.data?.opportunityOwners ?? []\n }\n\n /** The form as it shows: each field's edit, else what was read (blank while it is read). */\n private get form(): Form {\n return Object.fromEntries(Object.entries(blank(this.stages)).map(([name, given]) => [name, this.draft.value(name as keyof Form) ?? given])) as Form\n }\n\n private get reason() {\n return this.loss.value('reason') ?? ''\n }\n\n /** A failed read, or an opportunity the address names that is not there. */\n private get error(): unknown {\n if (this.choices.error || this.record.error) return this.choices.error ?? this.record.error\n return this.opportunityId && this.record.data && !this.record.data.opportunity ? new Error(i18next.t('text.opportunity-not-found')) : null\n }\n\n private get loading() {\n return this.choices.loading || this.record.loading\n }\n\n private get busy() {\n return Object.values(this.saves).some(save => save.pending)\n }\n\n private isOpen(stage: string) {\n return this.stages.some(one => one.stage === stage && one.open)\n }\n\n /** Won is final; a lost one is changed only by being opened again. */\n get editable() {\n return !this.busy && this.opportunity?.stage !== 'WON' && this.isOpen(this.form.stage)\n }\n\n get context() {\n const actions: any[] = []\n if (this.editable) actions.push({ title: i18next.t('button.save'), icon: 'save', emphasis: { raised: true }, action: () => this.save() })\n return {\n title: this.opportunity ? `${i18next.t('title.opportunity')} ${this.opportunity.name}` : i18next.t('title.opportunity-new'),\n ...(this.opportunity ? { description: opportunityStageWord(this.opportunity.stage) } : {}),\n frame: 'document',\n /* Opened from the opportunity list; the menu marks it. */\n menu: 'opportunity-list',\n actions: this.error ? [] : actions\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const section = opportunitySection()\n if (section && !this.sectionReadable) (section.readable?.() ?? Promise.resolve(true)).then(may => (this.sectionReadable = !!may))\n this.opportunityId = lifecycle?.params?.id ?? ''\n }\n\n render() {\n const attached = this.opportunity && this.sectionReadable ? opportunitySection() : undefined\n const editable = this.editable\n const set = (patch: Partial<Form>) => this.edit(patch)\n const stageChoices = this.stages.filter(one => one.open || one.stage === this.opportunity?.stage)\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => (this.choices.refetch(), this.record.refetch())}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-head')}</h3></header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-name')}\n <input .value=${this.form.name} ?disabled=${!editable} @input=${(e: any) => set({ name: e.target.value })}\n /></label>\n ${this.renderParty('counterparty', i18next.t('field.opportunity-counterparty'), editable)}\n ${this.renderParty('endCustomer', i18next.t('field.opportunity-end-customer'), editable)}\n <label\n >${i18next.t('field.opportunity-amount')}\n <input type=\"number\" min=\"0\" .value=${this.form.amount} ?disabled=${!editable} @input=${(e: any) => set({ amount: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-currency')}\n <select .value=${this.form.currency} ?disabled=${!editable} @change=${(e: any) => set({ currency: e.target.value })}>\n ${currencyChoices().map((code: string) => html`<option value=${code} ?selected=${code === this.form.currency}>${code}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-expected-close-month')}\n <input type=\"month\" .value=${this.form.expectedCloseMonth} ?disabled=${!editable} @input=${(e: any) => set({ expectedCloseMonth: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-owner')}\n <select .value=${this.form.ownerId} ?disabled=${!editable} @change=${(e: any) => set({ ownerId: e.target.value })}>\n ${this.form.ownerId ? nothing : html`<option value=\"\" selected>${i18next.t('text.opportunity-owner-me')}</option>`}\n ${this.owners.map(one => html`<option value=${one.id} ?selected=${one.id === this.form.ownerId}>${one.name}</option>`)}\n </select>\n </label>\n <label class=\"wide\"\n >${i18next.t('field.opportunity-description')}\n <textarea .value=${this.form.description} ?disabled=${!editable} @input=${(e: any) => set({ description: e.target.value })}></textarea>\n </label>\n </div>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-stage')}</h3></header>\n <div class=\"form\">\n <label\n >${i18next.t('field.opportunity-stage')}\n <select .value=${this.form.stage} ?disabled=${this.busy || this.opportunity?.stage === 'WON'} @change=${(e: any) => this.chooseStage(e.target.value)}>\n ${stageChoices.map(one => html`<option value=${one.stage} ?selected=${one.stage === this.form.stage} ?disabled=${!one.open}>${opportunityStageWord(one.stage)}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-probability')}\n <input type=\"number\" min=\"0\" max=\"100\" step=\"1\" .value=${this.form.probability} ?disabled=${!editable} @input=${(e: any) => set({ probability: e.target.value })}\n /></label>\n ${this.opportunity?.closedOn\n ? html`<label>${i18next.t('field.opportunity-closed-on')} <strong>${this.opportunity.closedOn}</strong></label>`\n : nothing}\n </div>\n </section>\n ${this.opportunity && this.isOpen(this.opportunity.stage) ? this.renderLose() : nothing}\n ${this.opportunity?.lostReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.opportunity-lost-reason')}</h3></header>\n <p>${this.opportunity.lostReason}</p>\n </section>`\n : nothing}\n ${this.opportunity ? this.renderQuotations() : nothing}\n ${attached && this.opportunity\n ? html`<section class=\"page-section\" @opportunity-changed=${() => this.record.refetch()}>\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.opportunity)}\n </section>`\n : nothing}\n ${this.events.length ? this.renderEvents() : nothing}\n </div>\n </ox-page-state>`\n }\n\n /** A counterparty of the domain, found as it is typed - or registered there when it is not one yet (ADR-0195). */\n private renderParty(which: 'counterparty' | 'endCustomer', label: string, editable: boolean) {\n return html`<label\n >${label}\n <counterparty-select .party=${this.form[which] ?? null} ?disabled=${!editable} @counterparty=${(e: CustomEvent) => this.edit({ [which]: e.detail })}></counterparty-select>\n </label>`\n }\n\n private renderLose() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-lose')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.lose()}>${i18next.t('button.opportunity-lose')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-lost-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => this.loss.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n /** The quotations that answer this opportunity; a new one is written from here and answers it. */\n private renderQuotations() {\n const quotations: any[] = this.opportunity.quotations ?? []\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-quotations')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || this.opportunity.stage === 'WON' || this.opportunity.stage === 'LOST'} @click=${() => navigate(`quotation-editor?opportunity=${this.opportunity.id}`)}>\n ${i18next.t('button.opportunity-new-quotation')}\n </button>\n </div>\n </header>\n ${quotations.length\n ? html`<table>\n <thead>\n <tr>\n <th>${i18next.t('field.quotation-number')}</th>\n <th>${i18next.t('field.quotation-version')}</th>\n <th>${i18next.t('field.quotation-status')}</th>\n <th>${i18next.t('field.quotation-issue-date')}</th>\n <th class=\"number\">${i18next.t('field.quotation-total-amount')}</th>\n </tr>\n </thead>\n <tbody>\n ${quotations.map(\n one => html`<tr>\n <td><a href=${`quotation-editor?id=${one.id}`}>${one.number}</a></td>\n <td>v${one.version}</td>\n <td>${quotationStatusWord(one.status)}</td>\n <td>${one.issueDate ?? ''}</td>\n <td class=\"number\">${documentAmount(one.totalAmount, one.currency || 'KRW')}</td>\n </tr>`\n )}\n </tbody>\n </table>`\n : nothing}\n </section>`\n }\n\n private renderEvents() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-history')}</h3></header>\n <table>\n <thead>\n <tr>\n <th>${i18next.t('field.opportunity-event-at')}</th>\n <th>${i18next.t('field.opportunity-event-actor')}</th>\n <th>${i18next.t('field.opportunity-event-action')}</th>\n <th>${i18next.t('field.opportunity-stage')}</th>\n <th class=\"number\">${i18next.t('field.opportunity-probability')}</th>\n </tr>\n </thead>\n <tbody>\n ${this.events.map(\n one => html`<tr>\n <td>${one.createdAt ? new Date(one.createdAt).toLocaleString() : ''}</td>\n <td>${one.actor?.name ?? ''}</td>\n <td>${eventWord(one.action)}${one.reason ? ` · ${one.reason}` : ''}</td>\n <td>${one.fromStage ? `${opportunityStageWord(one.fromStage)} → ` : ''}${opportunityStageWord(one.stage)}</td>\n <td class=\"number\">${one.probability}%</td>\n </tr>`\n )}\n </tbody>\n </table>\n </section>`\n }\n\n private edit(patch: Partial<Form>) {\n for (const [name, value] of Object.entries(patch)) this.draft.set(name as keyof Form, value)\n }\n\n /** The stage's own probability comes in with it; the person may change it afterwards. */\n private chooseStage(stage: string) {\n const given = this.stages.find(one => one.stage === stage)\n this.edit({ stage, probability: given ? String(given.probability) : this.form.probability })\n }\n\n private input() {\n const { name, counterparty, endCustomer, amount, currency, expectedCloseMonth, stage, probability, ownerId, description } = this.form\n return {\n name,\n counterpartyId: counterparty?.id ?? '',\n endCustomerId: endCustomer?.id ?? null,\n amount: Number(amount || 0),\n currency,\n expectedCloseMonth,\n stage,\n probability: probability === '' ? null : Number(probability),\n ownerId: ownerId || null,\n description\n }\n }\n\n /** A new one is opened once it is made; the edits sent are cleared once the save answered. */\n private async save() {\n if (this.busy) return\n const id = this.opportunityId\n const saved = await this.draft.submit(() =>\n id ? this.saves.update.run({ id, opportunity: this.input() }) : this.saves.create.run({ opportunity: this.input() })\n )\n if (saved && !id) navigate(`opportunity-editor?id=${saved.opportunity.id}`)\n }\n\n private async lose() {\n if (this.busy) return\n const id = this.opportunityId\n await this.loss.submit(sent => this.saves.lose.run({ id, reason: (sent.reason ?? '').trim() }))\n }\n}\n\nconst eventWord = (action?: string) =>\n action === 'CREATED'\n ? i18next.t('text.opportunity-event-created')\n : action === 'STAGED'\n ? i18next.t('text.opportunity-event-staged')\n : action === 'WON'\n ? i18next.t('text.opportunity-event-won')\n : action === 'LOST'\n ? i18next.t('text.opportunity-event-lost')\n : action === 'REOPENED'\n ? i18next.t('text.opportunity-event-reopened')\n : i18next.t('text.opportunity-event-updated')\n\n/** The form of an opportunity as read. */\nfunction formOf(opportunity: any): Form {\n return {\n name: opportunity.name,\n counterparty: opportunity.counterparty,\n endCustomer: opportunity.endCustomer,\n amount: String(opportunity.amount ?? 0),\n currency: opportunity.currency,\n expectedCloseMonth: opportunity.expectedCloseMonth,\n stage: opportunity.stage,\n probability: String(opportunity.probability),\n ownerId: opportunity.ownerId ?? '',\n description: opportunity.description ?? ''\n }\n}\n\nfunction blank(stages: { stage: string; probability: number }[] = []): Form {\n const lead = stages.find(one => one.stage === 'LEAD')\n return {\n name: '',\n counterparty: null,\n endCustomer: null,\n amount: '0',\n currency: 'KRW',\n expectedCloseMonth: thisMonth(),\n stage: 'LEAD',\n probability: lead ? String(lead.probability) : '',\n ownerId: '',\n description: ''\n }\n}\n"]}
1
+ {"version":3,"file":"opportunity-editor.js","sourceRoot":"","sources":["../../client/pages/opportunity-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,sCAAsC,CAAA;AAE7C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAEzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,MAAM,GAAG;;;;CAId,CAAA;AAgBD,MAAM,IAAI,GAAG,GAAG,CAAC;;6BAEY,MAAM;;;CAGlC,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAE1E;;;;;;GAMG;AAEI,IAA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GAAG;QACX,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,SAAS,EAAE;QAC/B,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;KAChB,CAAA;AACH,CAAC","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@operato/list-state/ox-page-state.js'\nimport '@things-factory/biz-base/dist-client'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView, DraftController } from '@operato/shell'\nimport { ButtonStyles, DocumentPageStyles, FormFieldStyles } from '@operato/styles'\nimport { currencyChoices, documentAmount, DocumentFormStyles } from '@things-factory/invoice/dist-client'\n\nimport { opportunitySection } from '../opportunity-attach'\nimport { opportunityStageWord } from '../opportunity-words'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id name stage probability amount currency expectedCloseMonth closedOn lostReason description\n counterpartyId endCustomerId ownerId counterparty { id name } endCustomer { id name } owner { id name }\n quotations { id number version status issueDate validUntil totalAmount currency }\n`\n\ntype Party = { id: string; name: string; businessNumber?: string }\ntype Form = {\n name: string\n counterparty: Party | null\n endCustomer: Party | null\n amount: string\n currency: string\n expectedCloseMonth: string\n stage: string\n probability: string\n ownerId: string\n description: string\n}\n\nconst READ = gql(`\n query ($id: String!) {\n opportunity(id: $id) { ${FIELDS} }\n opportunityEvents(opportunityId: $id) { id action fromStage stage probability reason createdAt actor { id name } }\n }\n`)\n\nconst thisMonth = () => new Date().toLocaleDateString('en-CA').slice(0, 7)\n\n/**\n * 영업 기회 편집 — with whom, for how much, by when and how likely.\n *\n * A person moves an open opportunity through the stages; changing the stage puts that stage's probability in, and the\n * person may change it. An open one is closed as lost with the reason; a lost one is opened again by choosing an open\n * stage. Winning is the application's: it closes the opportunity when the opportunity becomes its contract.\n */\n@customElement('opportunity-editor')\nexport class OpportunityEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n DocumentFormStyles,\n css`\n table {\n width: 100%;\n border-collapse: collapse;\n font-variant-numeric: tabular-nums;\n }\n th,\n td {\n text-align: left;\n padding: var(--spacing-small);\n border-bottom: 1px solid var(--ui-line-soft);\n font-size: var(--ui-t-body);\n }\n th.number,\n td.number {\n text-align: right;\n }\n td a {\n color: inherit;\n text-decoration: underline;\n }\n `\n ]\n\n /** The opportunity the address names; none for a new one. */\n @state() private opportunityId = ''\n /** Whether the application's section is this person's to read - asked once, before it is shown. */\n @state() sectionReadable = false\n\n /* The stages with their probabilities and who may own one, and the opportunity the address names (ADR-0190). */\n private choices = new QueryController(\n this,\n gql`\n query {\n opportunityStages { stage probability open }\n opportunityOwners { id name email }\n }\n `\n )\n private record = new QueryController(this, READ, { variables: () => (this.opportunityId ? { id: this.opportunityId } : undefined) })\n\n /* What is typed over the opportunity read - a new one starts blank, at the first stage. */\n private draft = new DraftController<Form>(this, { read: () => (this.opportunityId ? this.opportunity && formOf(this.opportunity) : blank(this.stages)), key: () => this.opportunityId })\n /* The reason a lost one is closed with. */\n private loss = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.opportunityId })\n\n /* Every change reads the opportunity again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($opportunity: NewOpportunity!) { opportunity: createOpportunity(opportunity: $opportunity) { id } }`),\n update: this.change(gql`mutation ($id: String!, $opportunity: NewOpportunity!) { opportunity: updateOpportunity(id: $id, opportunity: $opportunity) { id } }`),\n lose: this.change(gql`mutation ($id: String!, $reason: String!) { loseOpportunity(id: $id, reason: $reason) { id } }`)\n }\n\n private change(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get opportunity(): any {\n return (this.opportunityId && this.record.data?.opportunity) || null\n }\n\n private get events(): any[] {\n return (this.opportunityId && this.record.data?.opportunityEvents) || []\n }\n\n private get stages(): { stage: string; probability: number; open: boolean }[] {\n return this.choices.data?.opportunityStages ?? []\n }\n\n private get owners(): { id: string; name: string; email?: string }[] {\n return this.choices.data?.opportunityOwners ?? []\n }\n\n /** The form as it shows: each field's edit, else what was read (blank while it is read). */\n private get form(): Form {\n return Object.fromEntries(Object.entries(blank(this.stages)).map(([name, given]) => [name, this.draft.value(name as keyof Form) ?? given])) as Form\n }\n\n private get reason() {\n return this.loss.value('reason') ?? ''\n }\n\n /** A failed read, or an opportunity the address names that is not there. */\n private get error(): unknown {\n if (this.choices.error || this.record.error) return this.choices.error ?? this.record.error\n return this.opportunityId && this.record.data && !this.record.data.opportunity ? new Error(i18next.t('text.opportunity-not-found')) : null\n }\n\n private get loading() {\n return this.choices.loading || this.record.loading\n }\n\n private get busy() {\n return Object.values(this.saves).some(save => save.pending)\n }\n\n private isOpen(stage: string) {\n return this.stages.some(one => one.stage === stage && one.open)\n }\n\n /** Won is final; a lost one is changed only by being opened again. */\n get editable() {\n return !this.busy && this.opportunity?.stage !== 'WON' && this.isOpen(this.form.stage)\n }\n\n get context() {\n const actions: any[] = []\n if (this.editable) actions.push({ title: i18next.t('button.save'), icon: 'save', emphasis: { raised: true }, action: () => this.save() })\n return {\n title: this.opportunity ? `${i18next.t('title.opportunity')} ${this.opportunity.name}` : i18next.t('title.opportunity-new'),\n ...(this.opportunity ? { description: opportunityStageWord(this.opportunity.stage) } : {}),\n frame: 'document',\n /* Opened from the opportunity list; the menu marks it. */\n menu: 'opportunity-list',\n actions: this.error ? [] : actions\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const section = opportunitySection()\n if (section && !this.sectionReadable) (section.readable?.() ?? Promise.resolve(true)).then(may => (this.sectionReadable = !!may))\n this.opportunityId = lifecycle?.params?.id ?? ''\n }\n\n render() {\n const attached = this.opportunity && this.sectionReadable ? opportunitySection() : undefined\n const editable = this.editable\n const set = (patch: Partial<Form>) => this.edit(patch)\n const stageChoices = this.stages.filter(one => one.open || one.stage === this.opportunity?.stage)\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => (this.choices.refetch(), this.record.refetch())}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-head')}</h3></header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-name')}\n <input .value=${this.form.name} ?disabled=${!editable} @input=${(e: any) => set({ name: e.target.value })}\n /></label>\n ${this.renderParty('counterparty', i18next.t('field.opportunity-counterparty'), editable)}\n ${this.renderParty('endCustomer', i18next.t('field.opportunity-end-customer'), editable)}\n <label\n >${i18next.t('field.opportunity-amount')}\n <input type=\"number\" min=\"0\" .value=${this.form.amount} ?disabled=${!editable} @input=${(e: any) => set({ amount: e.target.value })}\n /></label>\n <label\n >${i18next.t('field.opportunity-currency')}\n <select .value=${this.form.currency} ?disabled=${!editable} @change=${(e: any) => set({ currency: e.target.value })}>\n ${currencyChoices().map((code: string) => html`<option value=${code} ?selected=${code === this.form.currency}>${code}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-expected-close-month')}\n <ox-input-date type=\"month\" .value=${this.form.expectedCloseMonth} ?disabled=${!editable} @change=${(e: any) => set({ expectedCloseMonth: e.target.value })}></ox-input-date></label>\n <label\n >${i18next.t('field.opportunity-owner')}\n <select .value=${this.form.ownerId} ?disabled=${!editable} @change=${(e: any) => set({ ownerId: e.target.value })}>\n ${this.form.ownerId ? nothing : html`<option value=\"\" selected>${i18next.t('text.opportunity-owner-me')}</option>`}\n ${this.owners.map(one => html`<option value=${one.id} ?selected=${one.id === this.form.ownerId}>${one.name}</option>`)}\n </select>\n </label>\n <label class=\"wide\"\n >${i18next.t('field.opportunity-description')}\n <textarea .value=${this.form.description} ?disabled=${!editable} @input=${(e: any) => set({ description: e.target.value })}></textarea>\n </label>\n </div>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-stage')}</h3></header>\n <div class=\"form\">\n <label\n >${i18next.t('field.opportunity-stage')}\n <select .value=${this.form.stage} ?disabled=${this.busy || this.opportunity?.stage === 'WON'} @change=${(e: any) => this.chooseStage(e.target.value)}>\n ${stageChoices.map(one => html`<option value=${one.stage} ?selected=${one.stage === this.form.stage} ?disabled=${!one.open}>${opportunityStageWord(one.stage)}</option>`)}\n </select>\n </label>\n <label\n >${i18next.t('field.opportunity-probability')}\n <input type=\"number\" min=\"0\" max=\"100\" step=\"1\" .value=${this.form.probability} ?disabled=${!editable} @input=${(e: any) => set({ probability: e.target.value })}\n /></label>\n ${this.opportunity?.closedOn\n ? html`<label>${i18next.t('field.opportunity-closed-on')} <strong>${this.opportunity.closedOn}</strong></label>`\n : nothing}\n </div>\n </section>\n ${this.opportunity && this.isOpen(this.opportunity.stage) ? this.renderLose() : nothing}\n ${this.opportunity?.lostReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.opportunity-lost-reason')}</h3></header>\n <p>${this.opportunity.lostReason}</p>\n </section>`\n : nothing}\n ${this.opportunity ? this.renderQuotations() : nothing}\n ${attached && this.opportunity\n ? html`<section class=\"page-section\" @opportunity-changed=${() => this.record.refetch()}>\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.opportunity)}\n </section>`\n : nothing}\n ${this.events.length ? this.renderEvents() : nothing}\n </div>\n </ox-page-state>`\n }\n\n /** A counterparty of the domain, found as it is typed - or registered there when it is not one yet (ADR-0195). */\n private renderParty(which: 'counterparty' | 'endCustomer', label: string, editable: boolean) {\n return html`<label\n >${label}\n <counterparty-select .party=${this.form[which] ?? null} ?disabled=${!editable} @counterparty=${(e: CustomEvent) => this.edit({ [which]: e.detail })}></counterparty-select>\n </label>`\n }\n\n private renderLose() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-lose')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.lose()}>${i18next.t('button.opportunity-lose')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.opportunity-lost-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => this.loss.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n /** The quotations that answer this opportunity; a new one is written from here and answers it. */\n private renderQuotations() {\n const quotations: any[] = this.opportunity.quotations ?? []\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.opportunity-section-quotations')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || this.opportunity.stage === 'WON' || this.opportunity.stage === 'LOST'} @click=${() => navigate(`quotation-editor?opportunity=${this.opportunity.id}`)}>\n ${i18next.t('button.opportunity-new-quotation')}\n </button>\n </div>\n </header>\n ${quotations.length\n ? html`<table>\n <thead>\n <tr>\n <th>${i18next.t('field.quotation-number')}</th>\n <th>${i18next.t('field.quotation-version')}</th>\n <th>${i18next.t('field.quotation-status')}</th>\n <th>${i18next.t('field.quotation-issue-date')}</th>\n <th class=\"number\">${i18next.t('field.quotation-total-amount')}</th>\n </tr>\n </thead>\n <tbody>\n ${quotations.map(\n one => html`<tr>\n <td><a href=${`quotation-editor?id=${one.id}`}>${one.number}</a></td>\n <td>v${one.version}</td>\n <td>${quotationStatusWord(one.status)}</td>\n <td>${one.issueDate ?? ''}</td>\n <td class=\"number\">${documentAmount(one.totalAmount, one.currency || 'KRW')}</td>\n </tr>`\n )}\n </tbody>\n </table>`\n : nothing}\n </section>`\n }\n\n private renderEvents() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.opportunity-section-history')}</h3></header>\n <table>\n <thead>\n <tr>\n <th>${i18next.t('field.opportunity-event-at')}</th>\n <th>${i18next.t('field.opportunity-event-actor')}</th>\n <th>${i18next.t('field.opportunity-event-action')}</th>\n <th>${i18next.t('field.opportunity-stage')}</th>\n <th class=\"number\">${i18next.t('field.opportunity-probability')}</th>\n </tr>\n </thead>\n <tbody>\n ${this.events.map(\n one => html`<tr>\n <td>${one.createdAt ? new Date(one.createdAt).toLocaleString() : ''}</td>\n <td>${one.actor?.name ?? ''}</td>\n <td>${eventWord(one.action)}${one.reason ? ` · ${one.reason}` : ''}</td>\n <td>${one.fromStage ? `${opportunityStageWord(one.fromStage)} → ` : ''}${opportunityStageWord(one.stage)}</td>\n <td class=\"number\">${one.probability}%</td>\n </tr>`\n )}\n </tbody>\n </table>\n </section>`\n }\n\n private edit(patch: Partial<Form>) {\n for (const [name, value] of Object.entries(patch)) this.draft.set(name as keyof Form, value)\n }\n\n /** The stage's own probability comes in with it; the person may change it afterwards. */\n private chooseStage(stage: string) {\n const given = this.stages.find(one => one.stage === stage)\n this.edit({ stage, probability: given ? String(given.probability) : this.form.probability })\n }\n\n private input() {\n const { name, counterparty, endCustomer, amount, currency, expectedCloseMonth, stage, probability, ownerId, description } = this.form\n return {\n name,\n counterpartyId: counterparty?.id ?? '',\n endCustomerId: endCustomer?.id ?? null,\n amount: Number(amount || 0),\n currency,\n expectedCloseMonth,\n stage,\n probability: probability === '' ? null : Number(probability),\n ownerId: ownerId || null,\n description\n }\n }\n\n /** A new one is opened once it is made; the edits sent are cleared once the save answered. */\n private async save() {\n if (this.busy) return\n const id = this.opportunityId\n const saved = await this.draft.submit(() =>\n id ? this.saves.update.run({ id, opportunity: this.input() }) : this.saves.create.run({ opportunity: this.input() })\n )\n if (saved && !id) navigate(`opportunity-editor?id=${saved.opportunity.id}`)\n }\n\n private async lose() {\n if (this.busy) return\n const id = this.opportunityId\n await this.loss.submit(sent => this.saves.lose.run({ id, reason: (sent.reason ?? '').trim() }))\n }\n}\n\nconst eventWord = (action?: string) =>\n action === 'CREATED'\n ? i18next.t('text.opportunity-event-created')\n : action === 'STAGED'\n ? i18next.t('text.opportunity-event-staged')\n : action === 'WON'\n ? i18next.t('text.opportunity-event-won')\n : action === 'LOST'\n ? i18next.t('text.opportunity-event-lost')\n : action === 'REOPENED'\n ? i18next.t('text.opportunity-event-reopened')\n : i18next.t('text.opportunity-event-updated')\n\n/** The form of an opportunity as read. */\nfunction formOf(opportunity: any): Form {\n return {\n name: opportunity.name,\n counterparty: opportunity.counterparty,\n endCustomer: opportunity.endCustomer,\n amount: String(opportunity.amount ?? 0),\n currency: opportunity.currency,\n expectedCloseMonth: opportunity.expectedCloseMonth,\n stage: opportunity.stage,\n probability: String(opportunity.probability),\n ownerId: opportunity.ownerId ?? '',\n description: opportunity.description ?? ''\n }\n}\n\nfunction blank(stages: { stage: string; probability: number }[] = []): Form {\n const lead = stages.find(one => one.stage === 'LEAD')\n return {\n name: '',\n counterparty: null,\n endCustomer: null,\n amount: '0',\n currency: 'KRW',\n expectedCloseMonth: thisMonth(),\n stage: 'LEAD',\n probability: lead ? String(lead.probability) : '',\n ownerId: '',\n description: ''\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import '@operato/input/ox-input-date.js';
1
2
  import '@operato/data-grist/ox-grist.js';
2
3
  import '@operato/list-state/ox-page-state.js';
3
4
  import '@operato/input/ox-select.js';
@@ -1,4 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
+ import '@operato/input/ox-input-date.js';
2
3
  import '@operato/data-grist/ox-grist.js';
3
4
  import '@operato/list-state/ox-page-state.js';
4
5
  import '@operato/input/ox-select.js';
@@ -284,8 +285,7 @@ let QuotationEditor = class QuotationEditor extends localize(i18next)(PageView)
284
285
  <header class="page-section-header"><h3>${i18next.t('text.quotation-section-head')}</h3></header>
285
286
  ${renderDocumentHead(this.form, editable, patch => this.edit(patch), html `<label
286
287
  >${i18next.t('field.quotation-valid-until')}
287
- <input type="date" .value=${this.form.validUntil ?? ''} ?disabled=${!editable} @input=${(e) => this.put({ validUntil: e.target.value })}
288
- /></label>
288
+ <ox-input-date type="date" .value=${this.form.validUntil ?? ''} ?disabled=${!editable} @change=${(e) => this.put({ validUntil: e.target.value })}></ox-input-date></label>
289
289
  ${this.renderOpportunity(editable)}`, 'field.quotation-number', {
290
290
  terms: this.defaults?.paymentTerms,
291
291
  /* In the group it fills - the buyer's of a sale, the supplier's of a purchase. */
@@ -1 +1 @@
1
- {"version":3,"file":"quotation-editor.js","sourceRoot":"","sources":["../../client/pages/quotation-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,6BAA6B,CAAA;AACpC,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACvH,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,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ist.js'\nimport '@operato/list-state/ox-page-state.js'\nimport '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\nimport type { PropertyValues } from 'lit'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client, MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { navigate, PageView, DraftController } from '@operato/shell'\nimport { ButtonStyles, CommonGristStyles, DocumentPageStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\nimport {\n daysAfter,\n documentAmount,\n DocumentFormStyles,\n documentLinesConfig,\n linesOf,\n onLineChange,\n openDocumentPreview,\n reckonLines,\n renderDocumentHead,\n renderDocumentTotals,\n DOCUMENT_DEFAULTS,\n DOCUMENT_DEFAULTS_READER,\n headFromDefaults,\n nextInvoiceNumber,\n OUR_SIDE_FIELDS,\n oursFromLast,\n partyOfName,\n type DocumentDefaults,\n type DocumentFileFormat,\n type DocumentParty,\n type DocumentValue\n} from '@things-factory/invoice/dist-client'\n\nimport '@things-factory/biz-base/dist-client'\n\nimport { quotationSection } from '../quotation-attach'\nimport '../sales-product-pick'\nimport { lineOfProduct, type PickedProduct } from '../sales-product-pick'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id number version status validUntil outcomeReason opportunityId opportunity { id name } direction currency language supplierName supplierAddress supplierRegistrationNumber\n buyerName buyerAddress buyerRegistrationNumber issueDate purchaseOrder paymentTerms bankDetails notes sourceReference\n discountAmount lineSupplyAmount supplyAmount taxAmount totalAmount taxRounding currencyDigits\n items { position description quantity unit unitPrice discount taxKind taxRate supplyAmount }\n taxGroups { taxKind taxRate supplyAmount taxAmount }\n`\n\nconst HEAD = [\n 'number',\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'issueDate',\n 'purchaseOrder',\n 'paymentTerms',\n 'bankDetails',\n 'notes',\n 'sourceReference',\n 'validUntil',\n 'opportunityId',\n 'discountAmount'\n]\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\n/** What an invoice made from a quotation takes of its head as it is. */\nconst INVOICE_HEAD = [\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'paymentTerms',\n 'bankDetails',\n 'notes'\n]\n\n/** A step of a quotation's life - each answers with the quotation it leaves (a revision is a new one). */\nconst step = (name: string, reason = false) =>\n gql(\n reason\n ? `mutation ($id: String!, $reason: String!) { quotation: ${name}(id: $id, reason: $reason) { id } }`\n : `mutation ($id: String!) { quotation: ${name}(id: $id) { id } }`\n )\n\n/** How long an offer holds unless the person writes another last day. */\nconst VALID_DAYS = 30\n\n/** Days an invoice made from a quotation is due unless the company says otherwise - the invoice editor's. */\nconst PAYMENT_DAYS = 30\n\n/** The next quotation number of a year after those given - 「Q2026-001」, 「Q2026-002」 … */\nexport function nextQuotationNumber(numbers: string[], year: number): string {\n const prefix = `Q${year}-`\n const last = Math.max(0, ...numbers.filter(one => one?.startsWith(prefix)).map(one => Number(one.slice(prefix.length)) || 0))\n return `${prefix}${String(last + 1).padStart(3, '0')}`\n}\n\n/**\n * 견적 편집 — the same head, lines and totals as an invoice, valid until a day.\n *\n * A draft is saved and sent; once sent its amounts are fixed, and the buyer's answer is recorded — accepted, or\n * declined with a reason. To change a sent quotation, revise it: the next version keeps the number.\n */\n@customElement('quotation-editor')\nexport class QuotationEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n CommonGristStyles,\n ScrollbarStyles,\n DocumentFormStyles,\n css`\n ox-grist {\n height: calc(var(--form-element-height-medium) * 10);\n }\n /* 상품에서 추가 sits over the lines, as wide as a head field. */\n .pick {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small);\n max-width: 480px;\n margin-bottom: var(--spacing-medium);\n font-size: var(--ui-t-micro);\n color: var(--ui-muted);\n }\n `\n ]\n\n /** What the address opens: a quotation by id, or a new one - written from an opportunity, it answers that one. */\n @state() private address?: { id?: string; opportunity?: string }\n @state() gristConfig: any\n /** Whether this person may read the company's words - unknown, and nothing read, until asked. */\n @state() private defaultsReadable = false\n /** The totals of the lines as typed - reckoned as the quotation will keep them, shown before it is saved. */\n @state() private typedAmounts: Partial<DocumentValue> | null = null\n /** Whether this person may write invoices - an accepted quotation then makes one. */\n @state() invoiceWriter = false\n /** Whether the application's section is this person's to read - asked once, before it is shown. */\n @state() sectionReadable = false\n /** An invoice being made of this quotation - its look-ups and its save. */\n @state() private making = false\n\n /* The company's words, the open opportunities a draft may answer, the quotation the address names, and what a new one starts from (ADR-0190). */\n private companyDefaults = new QueryController(this, DOCUMENT_DEFAULTS, { variables: () => (this.defaultsReadable ? {} : undefined) })\n private openOpportunities = new QueryController(\n this,\n gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n opportunities(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items { id name counterparty { id name businessNumber } }\n }\n }\n `,\n {\n variables: () => ({\n filters: [{ name: 'stage', operator: 'in', value: ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION'] }],\n pagination: { page: 1, limit: 500 },\n sortings: [{ name: 'name' }]\n })\n }\n )\n private record = new QueryController(this, gql(`query ($id: String!) { quotation(id: $id) { ${FIELDS} } }`), {\n variables: () => (this.quotationId ? { id: this.quotationId } : undefined)\n })\n private starts = new QueryController(\n this,\n gql`\n query ($filters: [Filter!], $sortings: [Sorting!]) {\n numbered: quotations(filters: $filters, pagination: { page: 1, limit: 1000 }) { items { number } }\n last: quotations(pagination: { page: 1, limit: 1 }, sortings: $sortings) { items { direction ${OUR_SIDE_FIELDS.join(' ')} } }\n }\n `,\n {\n variables: () =>\n this.address && !this.address.id ? { filters: [{ name: 'number', operator: 'like', value: `Q${today().slice(0, 4)}-%` }], sortings: [{ name: 'createdAt', desc: true }] } : undefined\n }\n )\n\n /* What is typed over the quotation read, or over what a new one starts with; the lines are the grid's. */\n private draft = new DraftController<DocumentValue>(this, { read: () => this.formRead, key: () => this.address })\n /* The reason the buyer declined with. */\n private decline = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.address })\n\n /* Every change of the quotation reads it again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($quotation: NewQuotation!) { quotation: createQuotation(quotation: $quotation) { id } }`),\n update: this.saving(gql`mutation ($id: String!, $quotation: NewQuotation!) { quotation: updateQuotation(id: $id, quotation: $quotation) { id } }`),\n sendQuotation: this.saving(step('sendQuotation')),\n expireQuotation: this.saving(step('expireQuotation')),\n acceptQuotation: this.saving(step('acceptQuotation')),\n reviseQuotation: this.saving(step('reviseQuotation')),\n rejectQuotation: this.saving(step('rejectQuotation', true)),\n invoice: new MutationController(\n this,\n gql`\n mutation ($invoice: NewInvoice!) {\n created: createInvoice(invoice: $invoice) { id }\n }\n `\n )\n }\n\n private saving(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get quotationId() {\n return this.address?.id ?? ''\n }\n\n /** The company's words a new quotation starts with, the terms it offers and how long an offer holds (ADR-0170) - none until read. */\n get defaults(): DocumentDefaults | null {\n return this.companyDefaults.data?.documentDefaults ?? null\n }\n\n get quotation(): DocumentValue | null {\n return (this.quotationId && this.record.data?.quotation) || null\n }\n\n private get opportunities(): { id: string; name: string; counterparty?: DocumentParty | null }[] {\n return this.openOpportunities.data?.opportunities?.items ?? []\n }\n\n /** What the form shows unedited: the quotation read, or what a new one starts with. */\n private get formRead(): DocumentValue | undefined {\n if (!this.address) return undefined\n return this.address.id ? (this.quotation ?? undefined) : this.start\n }\n\n /** The form as it shows: each field's edit, else what was read. */\n get form(): DocumentValue {\n return { ...blank(), ...this.formRead, ...this.draft.edits }\n }\n\n /** The totals of the lines as typed, else as the quotation keeps them. */\n get amounts(): Partial<DocumentValue> {\n return this.typedAmounts ?? this.quotation ?? {}\n }\n\n get reason() {\n return this.decline.value('reason') ?? ''\n }\n\n /** A failed read, or a quotation the address names that is not there. */\n get error(): unknown {\n if (this.record.error) return this.record.error\n return this.quotationId && this.record.data && !this.record.data.quotation ? new Error(i18next.t('text.quotation-not-found')) : null\n }\n\n get loading() {\n return this.record.loading\n }\n\n get busy() {\n return this.making || Object.values(this.saves).some(save => save.pending)\n }\n\n @query('ox-grist') private grist?: DataGrist\n\n get editable() {\n return !this.quotation || this.quotation.status === 'DRAFT'\n }\n\n get context() {\n const status = this.quotation?.status\n const actions: any[] = []\n if (this.editable) {\n actions.push({ title: i18next.t('button.save'), icon: 'save', action: () => this.save() })\n actions.push({ title: i18next.t('button.quotation-send'), icon: 'send', emphasis: { raised: true }, action: () => this.send() })\n }\n if (status === 'SENT') {\n if (this.quotation!.validUntil < today()) actions.push({ title: i18next.t('button.quotation-expire'), action: () => this.change('expireQuotation') })\n else actions.push({ title: i18next.t('button.quotation-accept'), emphasis: { raised: true }, action: () => this.change('acceptQuotation') })\n }\n if (status === 'ACCEPTED' && this.invoiceWriter) actions.push({ title: i18next.t('button.quotation-make-invoice'), icon: 'receipt_long', emphasis: { raised: true }, action: () => this.makeInvoice() })\n if (['SENT', 'REJECTED', 'EXPIRED'].includes(status)) actions.push({ title: i18next.t('button.quotation-revise'), icon: 'edit_document', action: () => this.change('reviseQuotation') })\n if (this.quotation) actions.push({ title: i18next.t('button.preview'), icon: 'preview', action: () => this.preview() })\n return {\n title: this.quotation ? `${i18next.t('title.quotation')} ${this.quotation.number} · v${this.quotation.version}` : i18next.t('title.quotation-new'),\n ...(this.quotation ? { description: quotationStatusWord(status) } : {}),\n frame: 'document',\n /* Opened from the quotation list; the menu marks it. */\n menu: 'quotation-list',\n actions: this.error ? [] : actions\n }\n }\n\n pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const { id, opportunity } = lifecycle?.params ?? {}\n if (!this.defaultsReadable) hasPrivilege(DOCUMENT_DEFAULTS_READER).then(may => (this.defaultsReadable = !!may))\n const section = quotationSection()\n if (section && !this.sectionReadable) (section.readable?.() ?? Promise.resolve(true)).then(may => (this.sectionReadable = !!may))\n hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true }).then(writer => {\n this.invoiceWriter = !!writer\n this.updateContext()\n })\n /* Written from an opportunity, the draft answers it. */\n this.address = id ? { id } : { opportunity: opportunity ?? '' }\n }\n\n /* The lines and their totals are the grid's: a new answer, or another quotation, puts the lines read in it again. */\n private lined?: unknown\n private relined = false\n\n willUpdate(changes: PropertyValues) {\n super.willUpdate(changes)\n const source = this.quotationId ? this.quotation : JSON.stringify(this.address ?? null)\n if (source === this.lined) return\n this.lined = source\n this.typedAmounts = null\n this.configure()\n this.relined = true\n }\n\n updated(changes: PropertyValues) {\n super.updated(changes)\n if (!this.relined) return\n this.relined = false\n this.grist?.fetch()\n }\n\n render() {\n const attached = this.quotation && this.sectionReadable ? quotationSection() : undefined\n const editable = this.editable && !this.busy\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.record.refetch()}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-head')}</h3></header>\n ${renderDocumentHead(\n this.form,\n editable,\n patch => this.edit(patch),\n html`<label\n >${i18next.t('field.quotation-valid-until')}\n <input type=\"date\" .value=${this.form.validUntil ?? ''} ?disabled=${!editable} @input=${(e: any) => this.put({ validUntil: e.target.value })}\n /></label>\n ${this.renderOpportunity(editable)}`,\n 'field.quotation-number',\n {\n terms: this.defaults?.paymentTerms,\n /* In the group it fills - the buyer's of a sale, the supplier's of a purchase. */\n party: html`<label\n >${i18next.t('field.counterparty')}\n <counterparty-select .party=${this.form.party ?? null} ?disabled=${!editable} @counterparty=${(e: CustomEvent) => this.takeParty(e.detail)}></counterparty-select>\n </label>`\n }\n )}\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-lines')}</h3></header>\n ${editable\n ? html`<label class=\"pick\"\n >${i18next.t('field.sales-product-pick')}\n <sales-product-pick .currency=${this.form.currency || 'KRW'} @product=${(e: CustomEvent) => this.addProduct(e.detail)}></sales-product-pick>\n </label>`\n : nothing}\n <ox-grist\n mode=\"GRID\"\n .config=${this.gristConfig}\n .fetchHandler=${() => ({ total: (this.form.items ?? []).length, records: (this.form.items ?? []).map((item: any) => ({ ...item })) })}\n @record-change=${(e: CustomEvent) => (this.typedAmounts = onLineChange(this.grist, e, this.form.currency, false, this.form.discountAmount))}\n ></ox-grist>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-totals')}</h3></header>\n ${renderDocumentTotals(\n { ...this.amounts, currency: this.form.currency },\n { value: this.form.discountAmount, editable, change: value => this.discount(value) }\n )}\n </section>\n ${this.quotation?.status === 'SENT' ? this.renderDecline() : nothing}\n ${this.quotation?.outcomeReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.quotation-outcome-reason')}</h3></header>\n <p>${this.quotation.outcomeReason}</p>\n </section>`\n : nothing}\n ${attached && this.quotation\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.quotation as any)}\n </section>`\n : nothing}\n </div>\n </ox-page-state>`\n }\n\n private renderDecline() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.quotation-section-decline')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.decline.submit(sent => this.change('rejectQuotation', (sent.reason ?? '').trim()))}>${i18next.t('button.quotation-reject')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.quotation-outcome-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => this.decline.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n /**\n * A line made from a product, after the lines there are - a copy the person then changes like any line (ADR-0171) -\n * and the totals reckoned with it.\n */\n private async addProduct(product: PickedProduct) {\n const grist = this.grist\n if (!grist || !product) return\n grist.addRecord(lineOfProduct(product))\n await grist.updateComplete\n this.typedAmounts = reckonLines(grist, this.form.currency, false, this.form.discountAmount)\n grist.refresh()\n }\n\n /** The discount of the whole quotation as typed, and the totals after it. */\n private discount(value: string) {\n this.put({ discountAmount: value })\n this.typedAmounts = reckonLines(this.grist, this.form.currency, false, value)\n }\n\n /** Edits of several fields at once. */\n private put(patch: DocumentValue) {\n for (const [name, value] of Object.entries(patch)) this.draft.set(name, value)\n }\n\n /** A change of the head; a new currency reckons the lines in its minor unit; the last day follows a moved issue day. */\n private edit(patch: DocumentValue) {\n const currency = this.form.currency\n const following = patch.issueDate && this.form.validUntil === daysAfter(this.form.issueDate, this.validDays)\n this.put({ ...patch, ...(following ? { validUntil: daysAfter(patch.issueDate, this.validDays) } : {}) })\n if (patch.currency && patch.currency !== currency) {\n this.configure()\n this.typedAmounts = reckonLines(this.grist, this.form.currency, false, this.form.discountAmount)\n }\n }\n\n /** The opportunity it answers - found by typing; choosing one takes its counterparty as the buyer when none is written. */\n private renderOpportunity(editable: boolean) {\n const choices = this.opportunityChoices()\n const chosen = choices.find(one => one.id === this.form.opportunityId)\n const label = (one: { name: string; counterparty?: DocumentParty | null }) => `${one.name}${one.counterparty?.name ? ` · ${one.counterparty.name}` : ''}`\n return html`<label\n >${i18next.t('field.quotation-opportunity')}\n <ox-select\n .value=${this.form.opportunityId ?? ''}\n ?disabled=${!editable}\n aria-label=${i18next.t('field.quotation-opportunity')}\n @change=${(e: CustomEvent) => {\n const id = String(e.detail ?? '')\n if (id === (this.form.opportunityId ?? '')) return\n const opportunity = choices.find(one => one.id === id)\n this.put({ opportunityId: id })\n if (opportunity?.counterparty && !String(this.form.buyerName ?? '').trim()) this.takeParty(opportunity.counterparty)\n }}\n >\n <span slot=\"label\">${chosen ? label(chosen) : '—'}</span>\n <ox-popup-list align-left nowrap with-search>\n <div option value=\"\">—</div>\n ${choices.map(one => html`<div option value=${one.id}>${label(one)}</div>`)}\n </ox-popup-list>\n </ox-select>\n </label>`\n }\n\n /** A counterparty as the other side: the buyer of a sale, the supplier of a purchase. */\n private takeParty(party: DocumentParty | null) {\n this.put(party ? partyFields(this.form, party) : { party: null })\n }\n\n /**\n * What a new quotation starts with, so a person writes only what is new: the next number of the year, the last day an\n * offer holds, the company's own words (ADR-0170), what they leave blank of our side as the last sales quotation\n * wrote it, and the counterparty of the opportunity it answers.\n */\n private get start(): DocumentValue {\n const form: DocumentValue = { ...blank(), opportunityId: this.address?.opportunity ?? '' }\n const started = this.starts.data\n const last = (started?.last?.items ?? []).find((one: any) => one.direction === 'SALES')\n const head = { ...form, ...headFromDefaults(form, this.defaults) }\n const filled = {\n ...head,\n ...oursFromLast(head, last),\n number: started ? nextQuotationNumber((started.numbered?.items ?? []).map((one: any) => one.number), Number(form.issueDate.slice(0, 4))) : '',\n validUntil: daysAfter(form.issueDate, this.validDays)\n }\n const opportunity = this.opportunities.find(one => one.id === form.opportunityId)\n return opportunity?.counterparty ? { ...filled, ...partyFields(filled, opportunity.counterparty) } : filled\n }\n\n /** Days an offer holds - the company's, or thirty. */\n private get validDays() {\n return this.defaults?.validDays || VALID_DAYS\n }\n\n private opportunityChoices() {\n const answered = this.quotation?.opportunity\n return answered && !this.opportunities.some(one => one.id === answered.id) ? [answered, ...this.opportunities] : this.opportunities\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, currency: this.form.currency || 'KRW' })\n }\n\n private input() {\n const input: DocumentValue = Object.fromEntries(HEAD.map(key => [key, this.form[key] === '' ? null : this.form[key] ?? null]))\n input.items = linesOf(this.grist).map(({ receivedTaxAmount, ...line }: any) => line)\n input.discountAmount = input.discountAmount === null ? 0 : Number(input.discountAmount)\n return input\n }\n\n /** A new one is opened once it is made; the edits sent are cleared once the save answered. Answers the quotation's id. */\n private async save(): Promise<string | undefined> {\n if (this.busy) return undefined\n const id = this.quotationId\n const saved = await this.draft.submit(() => (id ? this.saves.update.run({ id, quotation: this.input() }) : this.saves.create.run({ quotation: this.input() })))\n if (!saved) return undefined\n if (!id) {\n /* The lines went with it: the grid keeps them as saved while the new quotation opens. */\n this.grist?.commit()\n navigate(`quotation-editor?id=${saved.quotation.id}`)\n }\n return saved.quotation.id\n }\n\n /** Asked first - to whom and how much, fixed after - then save what is on screen and send it. */\n private async send() {\n const purchase = this.form.direction === 'PURCHASE'\n const words = {\n party: (purchase ? this.form.supplierName : this.form.buyerName) || '—',\n total: documentAmount(this.amounts.totalAmount ?? 0, this.form.currency || 'KRW')\n }\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.quotation-send'),\n text: purchase ? i18next.t('text.quotation-send-confirm-purchase', words) : i18next.t('text.quotation-send-confirm', words),\n confirmButton: { text: i18next.t('button.quotation-send') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n const saved = await this.save()\n if (saved) await this.change('sendQuotation', undefined, saved)\n }\n\n /** A step of the quotation's life; a revision opens the new version. */\n private async change(name: 'sendQuotation' | 'expireQuotation' | 'acceptQuotation' | 'reviseQuotation' | 'rejectQuotation', reason?: string, id = this.quotationId) {\n if (this.busy) return undefined\n const changed = await this.saves[name].run({ id, ...(reason === undefined ? {} : { reason }) })\n if (changed && changed.quotation.id !== id) navigate(`quotation-editor?id=${changed.quotation.id}`)\n return changed\n }\n\n /**\n * An invoice draft of an accepted quotation (ADR-0170 decision 11): its parties, currency, language, terms, account,\n * notes, discount and lines as the quotation has them, issued today and due the company's days after, the quotation\n * named as its source - then opened to be checked and issued. The counterparty is the one of the other party's name,\n * as the invoice editor links it.\n */\n private async makeInvoice() {\n if (this.busy) return\n const quotation = this.quotation!\n this.making = true\n try {\n /* Looked up for the invoice, shown nowhere: the number after the last sales invoice's, and the counterparty. */\n const last = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n invoices(filters: $filters, pagination: $pagination, sortings: $sortings) { items { number } }\n }\n `,\n variables: { filters: [{ name: 'direction', operator: 'eq', value: 'SALES' }], pagination: { page: 1, limit: 1 }, sortings: [{ name: 'createdAt', desc: true }] },\n fetchPolicy: 'no-cache'\n })\n const issueDate = today()\n const party = await partyOfName(quotation.direction === 'PURCHASE' ? quotation.supplierName : quotation.buyerName)\n const made = await this.saves.invoice.run({\n invoice: {\n number: nextInvoiceNumber(last.data?.invoices?.items?.[0]?.number, Number(issueDate.slice(0, 4))),\n counterpartyId: party?.id ?? null,\n ...Object.fromEntries(INVOICE_HEAD.map(key => [key, quotation[key] ?? null])),\n issueDate,\n dueDate: daysAfter(issueDate, this.defaults?.paymentDays ?? PAYMENT_DAYS),\n sourceReference: i18next.t('text.quotation-invoice-source', { number: quotation.number, version: quotation.version }),\n taxBasis: 'CALCULATED',\n discountAmount: Number(quotation.discountAmount ?? 0),\n items: quotation.items.map(({ description, quantity, unit, unitPrice, discount, taxKind, taxRate }: any) => ({\n description,\n quantity,\n unit: unit ?? null,\n unitPrice,\n discount,\n taxKind,\n taxRate\n }))\n }\n })\n const created = made?.created\n if (created) navigate(`invoice-editor?id=${created.id}`)\n } catch {\n /* The look-up's failure is told by the GraphQL link. */\n } finally {\n this.making = false\n }\n }\n\n /**\n * The saved quotation as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the\n * quotation's own first, to download as PDF or print. What is on screen and not saved is not in it.\n */\n private preview() {\n const { id, number, version, language } = this.quotation!\n openDocumentPreview(\n async (format: DocumentFileFormat, lng: string) => {\n const response = await client.query({\n query: gql`\n query ($id: String!, $format: DocumentFileFormat!, $language: String) {\n quotationDocumentFile(id: $id, format: $format, language: $language) { fileName mimeType content }\n }\n `,\n variables: { id, format, language: lng },\n fetchPolicy: 'no-cache'\n })\n if (!response.data?.quotationDocumentFile) throw response.errors?.[0] ?? new Error(i18next.t('text.quotation-not-found'))\n return response.data.quotationDocumentFile\n },\n language,\n `${i18next.t('title.preview')} · ${number} · v${version}`\n )\n }\n}\n\n/** A counterparty as the other side of `form`: the buyer of a sale, the supplier of a purchase. */\nfunction partyFields(form: DocumentValue, party: DocumentParty): DocumentValue {\n const side = form.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n return { party, [`${side}Name`]: party.name, [`${side}RegistrationNumber`]: party.businessNumber ?? form[`${side}RegistrationNumber`] ?? '' }\n}\n\nfunction blank(): DocumentValue {\n return { number: '', direction: 'SALES', currency: 'KRW', language: 'ko', supplierName: '', buyerName: '', issueDate: today(), validUntil: '', discountAmount: 0, items: [] }\n}\n"]}
1
+ {"version":3,"file":"quotation-editor.js","sourceRoot":"","sources":["../../client/pages/quotation-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,6BAA6B,CAAA;AACpC,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,YAAY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E,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAC/K,CAAC","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/list-state/ox-page-state.js'\nimport '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\nimport type { PropertyValues } from 'lit'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client, MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { navigate, PageView, DraftController } from '@operato/shell'\nimport { ButtonStyles, CommonGristStyles, DocumentPageStyles, FormFieldStyles, ScrollbarStyles } from '@operato/styles'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\nimport {\n daysAfter,\n documentAmount,\n DocumentFormStyles,\n documentLinesConfig,\n linesOf,\n onLineChange,\n openDocumentPreview,\n reckonLines,\n renderDocumentHead,\n renderDocumentTotals,\n DOCUMENT_DEFAULTS,\n DOCUMENT_DEFAULTS_READER,\n headFromDefaults,\n nextInvoiceNumber,\n OUR_SIDE_FIELDS,\n oursFromLast,\n partyOfName,\n type DocumentDefaults,\n type DocumentFileFormat,\n type DocumentParty,\n type DocumentValue\n} from '@things-factory/invoice/dist-client'\n\nimport '@things-factory/biz-base/dist-client'\n\nimport { quotationSection } from '../quotation-attach'\nimport '../sales-product-pick'\nimport { lineOfProduct, type PickedProduct } from '../sales-product-pick'\nimport { quotationStatusWord } from '../quotation-words'\n\nconst FIELDS = `\n id number version status validUntil outcomeReason opportunityId opportunity { id name } direction currency language supplierName supplierAddress supplierRegistrationNumber\n buyerName buyerAddress buyerRegistrationNumber issueDate purchaseOrder paymentTerms bankDetails notes sourceReference\n discountAmount lineSupplyAmount supplyAmount taxAmount totalAmount taxRounding currencyDigits\n items { position description quantity unit unitPrice discount taxKind taxRate supplyAmount }\n taxGroups { taxKind taxRate supplyAmount taxAmount }\n`\n\nconst HEAD = [\n 'number',\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'issueDate',\n 'purchaseOrder',\n 'paymentTerms',\n 'bankDetails',\n 'notes',\n 'sourceReference',\n 'validUntil',\n 'opportunityId',\n 'discountAmount'\n]\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\n/** What an invoice made from a quotation takes of its head as it is. */\nconst INVOICE_HEAD = [\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'paymentTerms',\n 'bankDetails',\n 'notes'\n]\n\n/** A step of a quotation's life - each answers with the quotation it leaves (a revision is a new one). */\nconst step = (name: string, reason = false) =>\n gql(\n reason\n ? `mutation ($id: String!, $reason: String!) { quotation: ${name}(id: $id, reason: $reason) { id } }`\n : `mutation ($id: String!) { quotation: ${name}(id: $id) { id } }`\n )\n\n/** How long an offer holds unless the person writes another last day. */\nconst VALID_DAYS = 30\n\n/** Days an invoice made from a quotation is due unless the company says otherwise - the invoice editor's. */\nconst PAYMENT_DAYS = 30\n\n/** The next quotation number of a year after those given - 「Q2026-001」, 「Q2026-002」 … */\nexport function nextQuotationNumber(numbers: string[], year: number): string {\n const prefix = `Q${year}-`\n const last = Math.max(0, ...numbers.filter(one => one?.startsWith(prefix)).map(one => Number(one.slice(prefix.length)) || 0))\n return `${prefix}${String(last + 1).padStart(3, '0')}`\n}\n\n/**\n * 견적 편집 — the same head, lines and totals as an invoice, valid until a day.\n *\n * A draft is saved and sent; once sent its amounts are fixed, and the buyer's answer is recorded — accepted, or\n * declined with a reason. To change a sent quotation, revise it: the next version keeps the number.\n */\n@customElement('quotation-editor')\nexport class QuotationEditor extends localize(i18next)(PageView) {\n static styles = [\n FormFieldStyles,\n ButtonStyles,\n DocumentPageStyles,\n CommonGristStyles,\n ScrollbarStyles,\n DocumentFormStyles,\n css`\n ox-grist {\n height: calc(var(--form-element-height-medium) * 10);\n }\n /* 상품에서 추가 sits over the lines, as wide as a head field. */\n .pick {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small);\n max-width: 480px;\n margin-bottom: var(--spacing-medium);\n font-size: var(--ui-t-micro);\n color: var(--ui-muted);\n }\n `\n ]\n\n /** What the address opens: a quotation by id, or a new one - written from an opportunity, it answers that one. */\n @state() private address?: { id?: string; opportunity?: string }\n @state() gristConfig: any\n /** Whether this person may read the company's words - unknown, and nothing read, until asked. */\n @state() private defaultsReadable = false\n /** The totals of the lines as typed - reckoned as the quotation will keep them, shown before it is saved. */\n @state() private typedAmounts: Partial<DocumentValue> | null = null\n /** Whether this person may write invoices - an accepted quotation then makes one. */\n @state() invoiceWriter = false\n /** Whether the application's section is this person's to read - asked once, before it is shown. */\n @state() sectionReadable = false\n /** An invoice being made of this quotation - its look-ups and its save. */\n @state() private making = false\n\n /* The company's words, the open opportunities a draft may answer, the quotation the address names, and what a new one starts from (ADR-0190). */\n private companyDefaults = new QueryController(this, DOCUMENT_DEFAULTS, { variables: () => (this.defaultsReadable ? {} : undefined) })\n private openOpportunities = new QueryController(\n this,\n gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n opportunities(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items { id name counterparty { id name businessNumber } }\n }\n }\n `,\n {\n variables: () => ({\n filters: [{ name: 'stage', operator: 'in', value: ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION'] }],\n pagination: { page: 1, limit: 500 },\n sortings: [{ name: 'name' }]\n })\n }\n )\n private record = new QueryController(this, gql(`query ($id: String!) { quotation(id: $id) { ${FIELDS} } }`), {\n variables: () => (this.quotationId ? { id: this.quotationId } : undefined)\n })\n private starts = new QueryController(\n this,\n gql`\n query ($filters: [Filter!], $sortings: [Sorting!]) {\n numbered: quotations(filters: $filters, pagination: { page: 1, limit: 1000 }) { items { number } }\n last: quotations(pagination: { page: 1, limit: 1 }, sortings: $sortings) { items { direction ${OUR_SIDE_FIELDS.join(' ')} } }\n }\n `,\n {\n variables: () =>\n this.address && !this.address.id ? { filters: [{ name: 'number', operator: 'like', value: `Q${today().slice(0, 4)}-%` }], sortings: [{ name: 'createdAt', desc: true }] } : undefined\n }\n )\n\n /* What is typed over the quotation read, or over what a new one starts with; the lines are the grid's. */\n private draft = new DraftController<DocumentValue>(this, { read: () => this.formRead, key: () => this.address })\n /* The reason the buyer declined with. */\n private decline = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.address })\n\n /* Every change of the quotation reads it again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($quotation: NewQuotation!) { quotation: createQuotation(quotation: $quotation) { id } }`),\n update: this.saving(gql`mutation ($id: String!, $quotation: NewQuotation!) { quotation: updateQuotation(id: $id, quotation: $quotation) { id } }`),\n sendQuotation: this.saving(step('sendQuotation')),\n expireQuotation: this.saving(step('expireQuotation')),\n acceptQuotation: this.saving(step('acceptQuotation')),\n reviseQuotation: this.saving(step('reviseQuotation')),\n rejectQuotation: this.saving(step('rejectQuotation', true)),\n invoice: new MutationController(\n this,\n gql`\n mutation ($invoice: NewInvoice!) {\n created: createInvoice(invoice: $invoice) { id }\n }\n `\n )\n }\n\n private saving(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get quotationId() {\n return this.address?.id ?? ''\n }\n\n /** The company's words a new quotation starts with, the terms it offers and how long an offer holds (ADR-0170) - none until read. */\n get defaults(): DocumentDefaults | null {\n return this.companyDefaults.data?.documentDefaults ?? null\n }\n\n get quotation(): DocumentValue | null {\n return (this.quotationId && this.record.data?.quotation) || null\n }\n\n private get opportunities(): { id: string; name: string; counterparty?: DocumentParty | null }[] {\n return this.openOpportunities.data?.opportunities?.items ?? []\n }\n\n /** What the form shows unedited: the quotation read, or what a new one starts with. */\n private get formRead(): DocumentValue | undefined {\n if (!this.address) return undefined\n return this.address.id ? (this.quotation ?? undefined) : this.start\n }\n\n /** The form as it shows: each field's edit, else what was read. */\n get form(): DocumentValue {\n return { ...blank(), ...this.formRead, ...this.draft.edits }\n }\n\n /** The totals of the lines as typed, else as the quotation keeps them. */\n get amounts(): Partial<DocumentValue> {\n return this.typedAmounts ?? this.quotation ?? {}\n }\n\n get reason() {\n return this.decline.value('reason') ?? ''\n }\n\n /** A failed read, or a quotation the address names that is not there. */\n get error(): unknown {\n if (this.record.error) return this.record.error\n return this.quotationId && this.record.data && !this.record.data.quotation ? new Error(i18next.t('text.quotation-not-found')) : null\n }\n\n get loading() {\n return this.record.loading\n }\n\n get busy() {\n return this.making || Object.values(this.saves).some(save => save.pending)\n }\n\n @query('ox-grist') private grist?: DataGrist\n\n get editable() {\n return !this.quotation || this.quotation.status === 'DRAFT'\n }\n\n get context() {\n const status = this.quotation?.status\n const actions: any[] = []\n if (this.editable) {\n actions.push({ title: i18next.t('button.save'), icon: 'save', action: () => this.save() })\n actions.push({ title: i18next.t('button.quotation-send'), icon: 'send', emphasis: { raised: true }, action: () => this.send() })\n }\n if (status === 'SENT') {\n if (this.quotation!.validUntil < today()) actions.push({ title: i18next.t('button.quotation-expire'), action: () => this.change('expireQuotation') })\n else actions.push({ title: i18next.t('button.quotation-accept'), emphasis: { raised: true }, action: () => this.change('acceptQuotation') })\n }\n if (status === 'ACCEPTED' && this.invoiceWriter) actions.push({ title: i18next.t('button.quotation-make-invoice'), icon: 'receipt_long', emphasis: { raised: true }, action: () => this.makeInvoice() })\n if (['SENT', 'REJECTED', 'EXPIRED'].includes(status)) actions.push({ title: i18next.t('button.quotation-revise'), icon: 'edit_document', action: () => this.change('reviseQuotation') })\n if (this.quotation) actions.push({ title: i18next.t('button.preview'), icon: 'preview', action: () => this.preview() })\n return {\n title: this.quotation ? `${i18next.t('title.quotation')} ${this.quotation.number} · v${this.quotation.version}` : i18next.t('title.quotation-new'),\n ...(this.quotation ? { description: quotationStatusWord(status) } : {}),\n frame: 'document',\n /* Opened from the quotation list; the menu marks it. */\n menu: 'quotation-list',\n actions: this.error ? [] : actions\n }\n }\n\n pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const { id, opportunity } = lifecycle?.params ?? {}\n if (!this.defaultsReadable) hasPrivilege(DOCUMENT_DEFAULTS_READER).then(may => (this.defaultsReadable = !!may))\n const section = quotationSection()\n if (section && !this.sectionReadable) (section.readable?.() ?? Promise.resolve(true)).then(may => (this.sectionReadable = !!may))\n hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true }).then(writer => {\n this.invoiceWriter = !!writer\n this.updateContext()\n })\n /* Written from an opportunity, the draft answers it. */\n this.address = id ? { id } : { opportunity: opportunity ?? '' }\n }\n\n /* The lines and their totals are the grid's: a new answer, or another quotation, puts the lines read in it again. */\n private lined?: unknown\n private relined = false\n\n willUpdate(changes: PropertyValues) {\n super.willUpdate(changes)\n const source = this.quotationId ? this.quotation : JSON.stringify(this.address ?? null)\n if (source === this.lined) return\n this.lined = source\n this.typedAmounts = null\n this.configure()\n this.relined = true\n }\n\n updated(changes: PropertyValues) {\n super.updated(changes)\n if (!this.relined) return\n this.relined = false\n this.grist?.fetch()\n }\n\n render() {\n const attached = this.quotation && this.sectionReadable ? quotationSection() : undefined\n const editable = this.editable && !this.busy\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.record.refetch()}>\n <div class=\"page\">\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-head')}</h3></header>\n ${renderDocumentHead(\n this.form,\n editable,\n patch => this.edit(patch),\n html`<label\n >${i18next.t('field.quotation-valid-until')}\n <ox-input-date type=\"date\" .value=${this.form.validUntil ?? ''} ?disabled=${!editable} @change=${(e: any) => this.put({ validUntil: e.target.value })}></ox-input-date></label>\n ${this.renderOpportunity(editable)}`,\n 'field.quotation-number',\n {\n terms: this.defaults?.paymentTerms,\n /* In the group it fills - the buyer's of a sale, the supplier's of a purchase. */\n party: html`<label\n >${i18next.t('field.counterparty')}\n <counterparty-select .party=${this.form.party ?? null} ?disabled=${!editable} @counterparty=${(e: CustomEvent) => this.takeParty(e.detail)}></counterparty-select>\n </label>`\n }\n )}\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-lines')}</h3></header>\n ${editable\n ? html`<label class=\"pick\"\n >${i18next.t('field.sales-product-pick')}\n <sales-product-pick .currency=${this.form.currency || 'KRW'} @product=${(e: CustomEvent) => this.addProduct(e.detail)}></sales-product-pick>\n </label>`\n : nothing}\n <ox-grist\n mode=\"GRID\"\n .config=${this.gristConfig}\n .fetchHandler=${() => ({ total: (this.form.items ?? []).length, records: (this.form.items ?? []).map((item: any) => ({ ...item })) })}\n @record-change=${(e: CustomEvent) => (this.typedAmounts = onLineChange(this.grist, e, this.form.currency, false, this.form.discountAmount))}\n ></ox-grist>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.quotation-section-totals')}</h3></header>\n ${renderDocumentTotals(\n { ...this.amounts, currency: this.form.currency },\n { value: this.form.discountAmount, editable, change: value => this.discount(value) }\n )}\n </section>\n ${this.quotation?.status === 'SENT' ? this.renderDecline() : nothing}\n ${this.quotation?.outcomeReason\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('field.quotation-outcome-reason')}</h3></header>\n <p>${this.quotation.outcomeReason}</p>\n </section>`\n : nothing}\n ${attached && this.quotation\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${attached.heading()}</h3></header>\n ${attached.render(this.quotation as any)}\n </section>`\n : nothing}\n </div>\n </ox-page-state>`\n }\n\n private renderDecline() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.quotation-section-decline')}</h3>\n <div class=\"page-section-actions\">\n <button ?disabled=${this.busy || !this.reason.trim()} @click=${() => this.decline.submit(sent => this.change('rejectQuotation', (sent.reason ?? '').trim()))}>${i18next.t('button.quotation-reject')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.quotation-outcome-reason')}\n <input .value=${this.reason} ?disabled=${this.busy} @input=${(e: any) => this.decline.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n /**\n * A line made from a product, after the lines there are - a copy the person then changes like any line (ADR-0171) -\n * and the totals reckoned with it.\n */\n private async addProduct(product: PickedProduct) {\n const grist = this.grist\n if (!grist || !product) return\n grist.addRecord(lineOfProduct(product))\n await grist.updateComplete\n this.typedAmounts = reckonLines(grist, this.form.currency, false, this.form.discountAmount)\n grist.refresh()\n }\n\n /** The discount of the whole quotation as typed, and the totals after it. */\n private discount(value: string) {\n this.put({ discountAmount: value })\n this.typedAmounts = reckonLines(this.grist, this.form.currency, false, value)\n }\n\n /** Edits of several fields at once. */\n private put(patch: DocumentValue) {\n for (const [name, value] of Object.entries(patch)) this.draft.set(name, value)\n }\n\n /** A change of the head; a new currency reckons the lines in its minor unit; the last day follows a moved issue day. */\n private edit(patch: DocumentValue) {\n const currency = this.form.currency\n const following = patch.issueDate && this.form.validUntil === daysAfter(this.form.issueDate, this.validDays)\n this.put({ ...patch, ...(following ? { validUntil: daysAfter(patch.issueDate, this.validDays) } : {}) })\n if (patch.currency && patch.currency !== currency) {\n this.configure()\n this.typedAmounts = reckonLines(this.grist, this.form.currency, false, this.form.discountAmount)\n }\n }\n\n /** The opportunity it answers - found by typing; choosing one takes its counterparty as the buyer when none is written. */\n private renderOpportunity(editable: boolean) {\n const choices = this.opportunityChoices()\n const chosen = choices.find(one => one.id === this.form.opportunityId)\n const label = (one: { name: string; counterparty?: DocumentParty | null }) => `${one.name}${one.counterparty?.name ? ` · ${one.counterparty.name}` : ''}`\n return html`<label\n >${i18next.t('field.quotation-opportunity')}\n <ox-select\n .value=${this.form.opportunityId ?? ''}\n ?disabled=${!editable}\n aria-label=${i18next.t('field.quotation-opportunity')}\n @change=${(e: CustomEvent) => {\n const id = String(e.detail ?? '')\n if (id === (this.form.opportunityId ?? '')) return\n const opportunity = choices.find(one => one.id === id)\n this.put({ opportunityId: id })\n if (opportunity?.counterparty && !String(this.form.buyerName ?? '').trim()) this.takeParty(opportunity.counterparty)\n }}\n >\n <span slot=\"label\">${chosen ? label(chosen) : '—'}</span>\n <ox-popup-list align-left nowrap with-search>\n <div option value=\"\">—</div>\n ${choices.map(one => html`<div option value=${one.id}>${label(one)}</div>`)}\n </ox-popup-list>\n </ox-select>\n </label>`\n }\n\n /** A counterparty as the other side: the buyer of a sale, the supplier of a purchase. */\n private takeParty(party: DocumentParty | null) {\n this.put(party ? partyFields(this.form, party) : { party: null })\n }\n\n /**\n * What a new quotation starts with, so a person writes only what is new: the next number of the year, the last day an\n * offer holds, the company's own words (ADR-0170), what they leave blank of our side as the last sales quotation\n * wrote it, and the counterparty of the opportunity it answers.\n */\n private get start(): DocumentValue {\n const form: DocumentValue = { ...blank(), opportunityId: this.address?.opportunity ?? '' }\n const started = this.starts.data\n const last = (started?.last?.items ?? []).find((one: any) => one.direction === 'SALES')\n const head = { ...form, ...headFromDefaults(form, this.defaults) }\n const filled = {\n ...head,\n ...oursFromLast(head, last),\n number: started ? nextQuotationNumber((started.numbered?.items ?? []).map((one: any) => one.number), Number(form.issueDate.slice(0, 4))) : '',\n validUntil: daysAfter(form.issueDate, this.validDays)\n }\n const opportunity = this.opportunities.find(one => one.id === form.opportunityId)\n return opportunity?.counterparty ? { ...filled, ...partyFields(filled, opportunity.counterparty) } : filled\n }\n\n /** Days an offer holds - the company's, or thirty. */\n private get validDays() {\n return this.defaults?.validDays || VALID_DAYS\n }\n\n private opportunityChoices() {\n const answered = this.quotation?.opportunity\n return answered && !this.opportunities.some(one => one.id === answered.id) ? [answered, ...this.opportunities] : this.opportunities\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, currency: this.form.currency || 'KRW' })\n }\n\n private input() {\n const input: DocumentValue = Object.fromEntries(HEAD.map(key => [key, this.form[key] === '' ? null : this.form[key] ?? null]))\n input.items = linesOf(this.grist).map(({ receivedTaxAmount, ...line }: any) => line)\n input.discountAmount = input.discountAmount === null ? 0 : Number(input.discountAmount)\n return input\n }\n\n /** A new one is opened once it is made; the edits sent are cleared once the save answered. Answers the quotation's id. */\n private async save(): Promise<string | undefined> {\n if (this.busy) return undefined\n const id = this.quotationId\n const saved = await this.draft.submit(() => (id ? this.saves.update.run({ id, quotation: this.input() }) : this.saves.create.run({ quotation: this.input() })))\n if (!saved) return undefined\n if (!id) {\n /* The lines went with it: the grid keeps them as saved while the new quotation opens. */\n this.grist?.commit()\n navigate(`quotation-editor?id=${saved.quotation.id}`)\n }\n return saved.quotation.id\n }\n\n /** Asked first - to whom and how much, fixed after - then save what is on screen and send it. */\n private async send() {\n const purchase = this.form.direction === 'PURCHASE'\n const words = {\n party: (purchase ? this.form.supplierName : this.form.buyerName) || '—',\n total: documentAmount(this.amounts.totalAmount ?? 0, this.form.currency || 'KRW')\n }\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.quotation-send'),\n text: purchase ? i18next.t('text.quotation-send-confirm-purchase', words) : i18next.t('text.quotation-send-confirm', words),\n confirmButton: { text: i18next.t('button.quotation-send') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n const saved = await this.save()\n if (saved) await this.change('sendQuotation', undefined, saved)\n }\n\n /** A step of the quotation's life; a revision opens the new version. */\n private async change(name: 'sendQuotation' | 'expireQuotation' | 'acceptQuotation' | 'reviseQuotation' | 'rejectQuotation', reason?: string, id = this.quotationId) {\n if (this.busy) return undefined\n const changed = await this.saves[name].run({ id, ...(reason === undefined ? {} : { reason }) })\n if (changed && changed.quotation.id !== id) navigate(`quotation-editor?id=${changed.quotation.id}`)\n return changed\n }\n\n /**\n * An invoice draft of an accepted quotation (ADR-0170 decision 11): its parties, currency, language, terms, account,\n * notes, discount and lines as the quotation has them, issued today and due the company's days after, the quotation\n * named as its source - then opened to be checked and issued. The counterparty is the one of the other party's name,\n * as the invoice editor links it.\n */\n private async makeInvoice() {\n if (this.busy) return\n const quotation = this.quotation!\n this.making = true\n try {\n /* Looked up for the invoice, shown nowhere: the number after the last sales invoice's, and the counterparty. */\n const last = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n invoices(filters: $filters, pagination: $pagination, sortings: $sortings) { items { number } }\n }\n `,\n variables: { filters: [{ name: 'direction', operator: 'eq', value: 'SALES' }], pagination: { page: 1, limit: 1 }, sortings: [{ name: 'createdAt', desc: true }] },\n fetchPolicy: 'no-cache'\n })\n const issueDate = today()\n const party = await partyOfName(quotation.direction === 'PURCHASE' ? quotation.supplierName : quotation.buyerName)\n const made = await this.saves.invoice.run({\n invoice: {\n number: nextInvoiceNumber(last.data?.invoices?.items?.[0]?.number, Number(issueDate.slice(0, 4))),\n counterpartyId: party?.id ?? null,\n ...Object.fromEntries(INVOICE_HEAD.map(key => [key, quotation[key] ?? null])),\n issueDate,\n dueDate: daysAfter(issueDate, this.defaults?.paymentDays ?? PAYMENT_DAYS),\n sourceReference: i18next.t('text.quotation-invoice-source', { number: quotation.number, version: quotation.version }),\n taxBasis: 'CALCULATED',\n discountAmount: Number(quotation.discountAmount ?? 0),\n items: quotation.items.map(({ description, quantity, unit, unitPrice, discount, taxKind, taxRate }: any) => ({\n description,\n quantity,\n unit: unit ?? null,\n unitPrice,\n discount,\n taxKind,\n taxRate\n }))\n }\n })\n const created = made?.created\n if (created) navigate(`invoice-editor?id=${created.id}`)\n } catch {\n /* The look-up's failure is told by the GraphQL link. */\n } finally {\n this.making = false\n }\n }\n\n /**\n * The saved quotation as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the\n * quotation's own first, to download as PDF or print. What is on screen and not saved is not in it.\n */\n private preview() {\n const { id, number, version, language } = this.quotation!\n openDocumentPreview(\n async (format: DocumentFileFormat, lng: string) => {\n const response = await client.query({\n query: gql`\n query ($id: String!, $format: DocumentFileFormat!, $language: String) {\n quotationDocumentFile(id: $id, format: $format, language: $language) { fileName mimeType content }\n }\n `,\n variables: { id, format, language: lng },\n fetchPolicy: 'no-cache'\n })\n if (!response.data?.quotationDocumentFile) throw response.errors?.[0] ?? new Error(i18next.t('text.quotation-not-found'))\n return response.data.quotationDocumentFile\n },\n language,\n `${i18next.t('title.preview')} · ${number} · v${version}`\n )\n }\n}\n\n/** A counterparty as the other side of `form`: the buyer of a sale, the supplier of a purchase. */\nfunction partyFields(form: DocumentValue, party: DocumentParty): DocumentValue {\n const side = form.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n return { party, [`${side}Name`]: party.name, [`${side}RegistrationNumber`]: party.businessNumber ?? form[`${side}RegistrationNumber`] ?? '' }\n}\n\nfunction blank(): DocumentValue {\n return { number: '', direction: 'SALES', currency: 'KRW', language: 'ko', supplierName: '', buyerName: '', issueDate: today(), validUntil: '', discountAmount: 0, items: [] }\n}\n"]}
@@ -1 +1 @@
1
- export default function route(page: string): "opportunity-list" | "quotation-list" | "quotation-editor" | "opportunity-editor" | "sales-product-list" | undefined;
1
+ export default function route(page: string): "quotation-list" | "opportunity-list" | "quotation-editor" | "opportunity-editor" | "sales-product-list" | undefined;