@things-factory/sales 10.1.227 → 10.1.228

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.
@@ -144,7 +144,7 @@ let QuotationEditor = class QuotationEditor extends localize(i18next)(PageView)
144
144
  if (['SENT', 'REJECTED', 'EXPIRED'].includes(status))
145
145
  actions.push({ title: i18next.t('button.quotation-revise'), icon: 'edit_document', action: () => this.change('reviseQuotation') });
146
146
  if (this.quotation)
147
- actions.push({ title: i18next.t('button.invoice-preview'), icon: 'preview', action: () => this.preview() });
147
+ actions.push({ title: i18next.t('button.preview'), icon: 'preview', action: () => this.preview() });
148
148
  return {
149
149
  title: this.quotation ? `${i18next.t('title.quotation')} ${this.quotation.number} · v${this.quotation.version}` : i18next.t('title.quotation-new'),
150
150
  ...(this.quotation ? { description: quotationStatusWord(status) } : {}),
@@ -195,7 +195,7 @@ let QuotationEditor = class QuotationEditor extends localize(i18next)(PageView)
195
195
  terms: this.defaults?.paymentTerms,
196
196
  /* In the group it fills - the buyer's of a sale, the supplier's of a purchase. */
197
197
  party: html `<label
198
- >${i18next.t('field.invoice-counterparty')}
198
+ >${i18next.t('field.counterparty')}
199
199
  <document-party-select .party=${this.party} ?disabled=${!editable} @party=${(e) => this.takeParty(e.detail)}></document-party-select>
200
200
  </label>`
201
201
  })}
@@ -565,7 +565,7 @@ let QuotationEditor = class QuotationEditor extends localize(i18next)(PageView)
565
565
  if (!response.data?.quotationDocumentFile)
566
566
  throw response.errors?.[0] ?? new Error(i18next.t('text.quotation-not-found'));
567
567
  return response.data.quotationDocumentFile;
568
- }, language, `${i18next.t('title.invoice-preview')} · ${number} · v${version}`);
568
+ }, language, `${i18next.t('title.preview')} · ${number} · v${version}`);
569
569
  }
570
570
  };
571
571
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"quotation-editor.js","sourceRoot":"","sources":["../../client/pages/quotation-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,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;;gDAAqC;AAEpC;IAAR,KAAK,EAAE;;sDAAsB;AAEH;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AA3CjC,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAgf3B;;AAED,SAAS,KAAK;IACZ,OAAO,EAAE,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/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'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { navigate, PageView } 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 documentDefaults,\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/invoice/dist-client/document/document-party.js'\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/** 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 @state() quotation: DocumentValue | null = null\n @state() form: DocumentValue = blank()\n @state() loading = false\n @state() error: unknown = null\n @state() busy = false\n @state() reason = ''\n @state() gristConfig: any\n /** The open opportunities a draft may answer, and the one it answers when that one is closed. */\n @state() opportunities: { id: string; name: string; counterparty?: DocumentParty | null }[] = []\n /** The company's words a new quotation starts with, the terms it offers and how long an offer holds (ADR-0170). */\n @state() defaults: DocumentDefaults | null = null\n /** The counterparty the buyer was taken from on this screen - shown in the picker. */\n @state() party: DocumentParty | null = null\n /** The totals of the lines as typed - reckoned as the quotation will keep them, shown before it is saved. */\n @state() amounts: Partial<DocumentValue> = {}\n /** Whether this person may write invoices - an accepted quotation then makes one. */\n @state() invoiceWriter = false\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.invoice-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 async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const id = lifecycle?.params?.id\n if (!this.opportunities.length) await this.readOpportunities()\n if (!this.defaults) this.defaults = await documentDefaults()\n hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true }).then(writer => {\n this.invoiceWriter = !!writer\n this.updateContext()\n })\n if (!id) {\n this.quotation = null\n /* Written from an opportunity, the draft answers it. */\n this.form = { ...blank(), opportunityId: lifecycle?.params?.opportunity ?? '' }\n this.amounts = {}\n this.party = null\n this.configure()\n await this.prefill()\n this.updateContext()\n return\n }\n if (id !== this.quotation?.id) await this.load(id)\n }\n\n render() {\n const attached = this.quotation ? quotationSection() : undefined\n const editable = this.editable && !this.busy\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.quotation && this.load(this.quotation.id)}>\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.form = { ...this.form, 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.invoice-counterparty')}\n <document-party-select .party=${this.party} ?disabled=${!editable} @party=${(e: CustomEvent) => this.takeParty(e.detail)}></document-party-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 })}\n @record-change=${(e: CustomEvent) => (this.amounts = 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.change('rejectQuotation', this.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.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.amounts = 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.form = { ...this.form, discountAmount: value }\n this.amounts = reckonLines(this.grist, this.form.currency, false, 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.form = { ...this.form, ...patch, ...(following ? { validUntil: daysAfter(patch.issueDate, this.validDays) } : {}) }\n if (patch.currency && patch.currency !== currency) {\n this.configure()\n this.amounts = 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.form = { ...this.form, 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.party = party\n if (!party) return\n const side = this.form.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n this.form = { ...this.form, [`${side}Name`]: party.name, [`${side}RegistrationNumber`]: party.businessNumber ?? this.form[`${side}RegistrationNumber`] ?? '' }\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), and what they leave blank of our side as the last sales quotation\n * wrote it.\n */\n private async prefill() {\n try {\n const year = Number(this.form.issueDate.slice(0, 4))\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n numbered: quotations(filters: $filters, pagination: { page: 1, limit: 1000 }) { items { number } }\n last: quotations(pagination: $pagination, sortings: $sortings) { items { direction ${OUR_SIDE_FIELDS.join(' ')} } }\n }\n `,\n variables: { filters: [{ name: 'number', operator: 'like', value: `Q${year}-%` }], pagination: { page: 1, limit: 1 }, sortings: [{ name: 'createdAt', desc: true }] },\n fetchPolicy: 'no-cache'\n })\n const last = (response.data?.last?.items ?? []).find((one: any) => one.direction === 'SALES')\n this.form = { ...this.form, ...headFromDefaults(this.form, this.defaults) }\n this.form = {\n ...this.form,\n ...oursFromLast(this.form, last),\n number: this.form.number || nextQuotationNumber((response.data?.numbered?.items ?? []).map((one: any) => one.number), year),\n validUntil: this.form.validUntil || daysAfter(this.form.issueDate, this.validDays)\n }\n } catch {\n /* Nothing to start from - the person writes it, as before. */\n }\n const opportunity = this.opportunities.find(one => one.id === this.form.opportunityId)\n if (opportunity?.counterparty && !String(this.form.buyerName ?? '').trim()) this.takeParty(opportunity.counterparty)\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 async readOpportunities() {\n try {\n const response = await client.query({\n query: 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 variables: {\n filters: [{ name: 'stage', operator: 'in', value: ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION'] }],\n pagination: { page: 1, limit: 500 },\n sortings: [{ name: 'name' }]\n },\n fetchPolicy: 'no-cache'\n })\n this.opportunities = response.data?.opportunities?.items ?? []\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.message ?? String(error) })\n }\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, currency: this.form.currency || 'KRW' })\n }\n\n private async load(id: string) {\n this.loading = true\n this.error = null\n try {\n const response = await client.query({ query: gql(`query ($id: String!) { quotation(id: $id) { ${FIELDS} } }`), variables: { id }, fetchPolicy: 'no-cache' })\n if (response.errors?.length) throw response\n if (!response.data.quotation) throw new Error(i18next.t('text.quotation-not-found'))\n this.show(response.data.quotation)\n } catch (error) {\n this.error = error\n } finally {\n this.loading = false\n this.updateContext()\n }\n }\n\n private show(quotation: DocumentValue) {\n this.quotation = quotation\n this.form = { ...quotation, items: quotation.items.map((item: any) => ({ ...item })) }\n this.amounts = quotation\n this.reason = ''\n this.configure()\n this.grist?.fetch()\n }\n\n private async run<T>(work: () => Promise<T>): Promise<T | undefined> {\n if (this.busy) return undefined\n this.busy = true\n try {\n return await work()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n return undefined\n } finally {\n this.busy = false\n }\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 private async save(): Promise<DocumentValue | undefined> {\n const id = this.quotation?.id\n const saved = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n id\n ? `mutation ($id: String!, $quotation: NewQuotation!) { quotation: updateQuotation(id: $id, quotation: $quotation) { ${FIELDS} } }`\n : `mutation ($quotation: NewQuotation!) { quotation: createQuotation(quotation: $quotation) { ${FIELDS} } }`\n ),\n variables: { ...(id ? { id } : {}), quotation: this.input() }\n })\n if (response.errors?.length) throw response\n return response.data.quotation as DocumentValue\n })\n if (!saved) return undefined\n this.show(saved)\n this.updateContext()\n if (!id) navigate(`quotation-editor?id=${saved.id}`)\n return saved\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')\n }\n\n private async change(mutation: string, reason?: string) {\n const changed = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n reason === undefined\n ? `mutation ($id: String!) { quotation: ${mutation}(id: $id) { ${FIELDS} } }`\n : `mutation ($id: String!, $reason: String!) { quotation: ${mutation}(id: $id, reason: $reason) { ${FIELDS} } }`\n ),\n variables: { id: this.quotation!.id, ...(reason === undefined ? {} : { reason }) }\n })\n if (response.errors?.length) throw response\n return response.data.quotation as DocumentValue\n })\n if (!changed) return\n if (changed.id !== this.quotation?.id) navigate(`quotation-editor?id=${changed.id}`)\n this.show(changed)\n this.updateContext()\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 const quotation = this.quotation!\n const created = await this.run(async () => {\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 response = await client.mutate({\n mutation: gql`\n mutation ($invoice: NewInvoice!) {\n createInvoice(invoice: $invoice) { id }\n }\n `,\n variables: {\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 })\n if (response.errors?.length) throw response\n return response.data.createInvoice as { id: string }\n })\n if (created) navigate(`invoice-editor?id=${created.id}`)\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.invoice-preview')} · ${number} · v${version}`\n )\n }\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,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;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAq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AE,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/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'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { navigate, PageView } 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 documentDefaults,\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/invoice/dist-client/document/document-party.js'\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/** 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 @state() quotation: DocumentValue | null = null\n @state() form: DocumentValue = blank()\n @state() loading = false\n @state() error: unknown = null\n @state() busy = false\n @state() reason = ''\n @state() gristConfig: any\n /** The open opportunities a draft may answer, and the one it answers when that one is closed. */\n @state() opportunities: { id: string; name: string; counterparty?: DocumentParty | null }[] = []\n /** The company's words a new quotation starts with, the terms it offers and how long an offer holds (ADR-0170). */\n @state() defaults: DocumentDefaults | null = null\n /** The counterparty the buyer was taken from on this screen - shown in the picker. */\n @state() party: DocumentParty | null = null\n /** The totals of the lines as typed - reckoned as the quotation will keep them, shown before it is saved. */\n @state() amounts: Partial<DocumentValue> = {}\n /** Whether this person may write invoices - an accepted quotation then makes one. */\n @state() invoiceWriter = false\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 async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !(changes.active || changes.params)) return\n const id = lifecycle?.params?.id\n if (!this.opportunities.length) await this.readOpportunities()\n if (!this.defaults) this.defaults = await documentDefaults()\n hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true }).then(writer => {\n this.invoiceWriter = !!writer\n this.updateContext()\n })\n if (!id) {\n this.quotation = null\n /* Written from an opportunity, the draft answers it. */\n this.form = { ...blank(), opportunityId: lifecycle?.params?.opportunity ?? '' }\n this.amounts = {}\n this.party = null\n this.configure()\n await this.prefill()\n this.updateContext()\n return\n }\n if (id !== this.quotation?.id) await this.load(id)\n }\n\n render() {\n const attached = this.quotation ? quotationSection() : undefined\n const editable = this.editable && !this.busy\n return html`<ox-page-state .loading=${this.loading} .error=${this.error} @retry=${() => this.quotation && this.load(this.quotation.id)}>\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.form = { ...this.form, 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 <document-party-select .party=${this.party} ?disabled=${!editable} @party=${(e: CustomEvent) => this.takeParty(e.detail)}></document-party-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 })}\n @record-change=${(e: CustomEvent) => (this.amounts = 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.change('rejectQuotation', this.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.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.amounts = 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.form = { ...this.form, discountAmount: value }\n this.amounts = reckonLines(this.grist, this.form.currency, false, 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.form = { ...this.form, ...patch, ...(following ? { validUntil: daysAfter(patch.issueDate, this.validDays) } : {}) }\n if (patch.currency && patch.currency !== currency) {\n this.configure()\n this.amounts = 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.form = { ...this.form, 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.party = party\n if (!party) return\n const side = this.form.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n this.form = { ...this.form, [`${side}Name`]: party.name, [`${side}RegistrationNumber`]: party.businessNumber ?? this.form[`${side}RegistrationNumber`] ?? '' }\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), and what they leave blank of our side as the last sales quotation\n * wrote it.\n */\n private async prefill() {\n try {\n const year = Number(this.form.issueDate.slice(0, 4))\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n numbered: quotations(filters: $filters, pagination: { page: 1, limit: 1000 }) { items { number } }\n last: quotations(pagination: $pagination, sortings: $sortings) { items { direction ${OUR_SIDE_FIELDS.join(' ')} } }\n }\n `,\n variables: { filters: [{ name: 'number', operator: 'like', value: `Q${year}-%` }], pagination: { page: 1, limit: 1 }, sortings: [{ name: 'createdAt', desc: true }] },\n fetchPolicy: 'no-cache'\n })\n const last = (response.data?.last?.items ?? []).find((one: any) => one.direction === 'SALES')\n this.form = { ...this.form, ...headFromDefaults(this.form, this.defaults) }\n this.form = {\n ...this.form,\n ...oursFromLast(this.form, last),\n number: this.form.number || nextQuotationNumber((response.data?.numbered?.items ?? []).map((one: any) => one.number), year),\n validUntil: this.form.validUntil || daysAfter(this.form.issueDate, this.validDays)\n }\n } catch {\n /* Nothing to start from - the person writes it, as before. */\n }\n const opportunity = this.opportunities.find(one => one.id === this.form.opportunityId)\n if (opportunity?.counterparty && !String(this.form.buyerName ?? '').trim()) this.takeParty(opportunity.counterparty)\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 async readOpportunities() {\n try {\n const response = await client.query({\n query: 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 variables: {\n filters: [{ name: 'stage', operator: 'in', value: ['LEAD', 'PROPOSAL', 'QUOTED', 'NEGOTIATION'] }],\n pagination: { page: 1, limit: 500 },\n sortings: [{ name: 'name' }]\n },\n fetchPolicy: 'no-cache'\n })\n this.opportunities = response.data?.opportunities?.items ?? []\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.message ?? String(error) })\n }\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, currency: this.form.currency || 'KRW' })\n }\n\n private async load(id: string) {\n this.loading = true\n this.error = null\n try {\n const response = await client.query({ query: gql(`query ($id: String!) { quotation(id: $id) { ${FIELDS} } }`), variables: { id }, fetchPolicy: 'no-cache' })\n if (response.errors?.length) throw response\n if (!response.data.quotation) throw new Error(i18next.t('text.quotation-not-found'))\n this.show(response.data.quotation)\n } catch (error) {\n this.error = error\n } finally {\n this.loading = false\n this.updateContext()\n }\n }\n\n private show(quotation: DocumentValue) {\n this.quotation = quotation\n this.form = { ...quotation, items: quotation.items.map((item: any) => ({ ...item })) }\n this.amounts = quotation\n this.reason = ''\n this.configure()\n this.grist?.fetch()\n }\n\n private async run<T>(work: () => Promise<T>): Promise<T | undefined> {\n if (this.busy) return undefined\n this.busy = true\n try {\n return await work()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n return undefined\n } finally {\n this.busy = false\n }\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 private async save(): Promise<DocumentValue | undefined> {\n const id = this.quotation?.id\n const saved = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n id\n ? `mutation ($id: String!, $quotation: NewQuotation!) { quotation: updateQuotation(id: $id, quotation: $quotation) { ${FIELDS} } }`\n : `mutation ($quotation: NewQuotation!) { quotation: createQuotation(quotation: $quotation) { ${FIELDS} } }`\n ),\n variables: { ...(id ? { id } : {}), quotation: this.input() }\n })\n if (response.errors?.length) throw response\n return response.data.quotation as DocumentValue\n })\n if (!saved) return undefined\n this.show(saved)\n this.updateContext()\n if (!id) navigate(`quotation-editor?id=${saved.id}`)\n return saved\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')\n }\n\n private async change(mutation: string, reason?: string) {\n const changed = await this.run(async () => {\n const response = await client.mutate({\n mutation: gql(\n reason === undefined\n ? `mutation ($id: String!) { quotation: ${mutation}(id: $id) { ${FIELDS} } }`\n : `mutation ($id: String!, $reason: String!) { quotation: ${mutation}(id: $id, reason: $reason) { ${FIELDS} } }`\n ),\n variables: { id: this.quotation!.id, ...(reason === undefined ? {} : { reason }) }\n })\n if (response.errors?.length) throw response\n return response.data.quotation as DocumentValue\n })\n if (!changed) return\n if (changed.id !== this.quotation?.id) navigate(`quotation-editor?id=${changed.id}`)\n this.show(changed)\n this.updateContext()\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 const quotation = this.quotation!\n const created = await this.run(async () => {\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 response = await client.mutate({\n mutation: gql`\n mutation ($invoice: NewInvoice!) {\n createInvoice(invoice: $invoice) { id }\n }\n `,\n variables: {\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 })\n if (response.errors?.length) throw response\n return response.data.createInvoice as { id: string }\n })\n if (created) navigate(`invoice-editor?id=${created.id}`)\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\nfunction blank(): DocumentValue {\n return { number: '', direction: 'SALES', currency: 'KRW', language: 'ko', supplierName: '', buyerName: '', issueDate: today(), validUntil: '', discountAmount: 0, items: [] }\n}\n"]}
@@ -102,9 +102,9 @@ let SalesProductList = class SalesProductList extends localize(i18next)(PageView
102
102
  record: {
103
103
  editable: true,
104
104
  options: [
105
- { value: 'TAXABLE', display: i18next.t('text.invoice-tax-kind-taxable') },
106
- { value: 'ZERO_RATED', display: i18next.t('text.invoice-tax-kind-zero-rated') },
107
- { value: 'EXEMPT', display: i18next.t('text.invoice-tax-kind-exempt') }
105
+ { value: 'TAXABLE', display: i18next.t('text.tax-kind-taxable') },
106
+ { value: 'ZERO_RATED', display: i18next.t('text.tax-kind-zero-rated') },
107
+ { value: 'EXEMPT', display: i18next.t('text.tax-kind-exempt') }
108
108
  ]
109
109
  }
110
110
  },
@@ -1 +1 @@
1
- {"version":3,"file":"sales-product-list.js","sourceRoot":"","sources":["../../client/pages/sales-product-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,E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,CAAC,UAAU,CAAC;8BAAiB,SAAS;+CAAA;AAJjC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAqK5B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { documentNumber } from '@things-factory/invoice/dist-client'\n\nimport { salesProductKindWord } from '../sales-product-words'\n\nconst KINDS = ['GOODS', 'SERVICE', 'LABOR']\n\n/** The fields a row writes - all of them for a new row, the changed ones otherwise. */\nconst FIELDS = ['code', 'name', 'kind', 'grade', 'spec', 'unit', 'unitPrice', 'currency', 'taxKind', 'active', 'description']\n\n/**\n * 상품 — what the domain sells and the price it offers it at: goods, a service, or labor by the grade of the people\n * (ADR-0171). Typed like a spreadsheet and saved together. A quotation line chosen from a product copies it at that\n * moment; changing a price here changes no written quotation.\n */\n@customElement('sales-product-list')\nexport class SalesProductList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.sales-product-list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n actions: [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ kind: 'GOODS', currency: 'KRW', taxKind: 'TAXABLE', active: true }) },\n { title: i18next.t('button.delete'), action: () => this.delete(), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ],\n exportable: { name: i18next.t('title.sales-product-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-grist\n class=\"page-fill\"\n search-mode=\"term\"\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n </div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const text = (name: string, header: string, width: number, extra: any = {}) => ({ type: 'string', name, header, width, sortable: true, ...extra, record: { editable: true, ...extra.record } })\n this.gristConfig = {\n rows: { appendable: true, selectable: { multiple: true } },\n pagination: { limit: 100, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.sales-product-empty'), description: i18next.t('text.sales-product-empty-description') },\n list: { fields: ['name', 'code'], details: ['kind', 'unit', 'unitPrice'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n text('code', i18next.t('field.sales-product-code'), 110, { record: { mandatory: true } }),\n text('name', i18next.t('field.sales-product-name'), 200, { record: { mandatory: true } }),\n {\n type: 'select',\n name: 'kind',\n header: i18next.t('field.sales-product-kind'),\n width: 80,\n sortable: true,\n record: { editable: true, options: KINDS.map(kind => ({ value: kind, display: salesProductKindWord(kind) })) },\n filter: { type: 'select', operator: 'eq', options: [{ display: '', value: '' }, ...KINDS.map(kind => ({ display: salesProductKindWord(kind), value: kind }))] }\n },\n text('grade', i18next.t('field.sales-product-grade'), 110),\n text('spec', i18next.t('field.sales-product-spec'), 160),\n text('unit', i18next.t('field.sales-product-unit'), 70, { record: { align: 'center' } }),\n {\n type: 'float',\n name: 'unitPrice',\n header: i18next.t('field.sales-product-unit-price'),\n width: 130,\n sortable: true,\n record: { editable: true, align: 'right', renderer: (value: number, _c: any, record: any) => documentNumber(value, record?.currency || 'KRW') }\n },\n text('currency', i18next.t('field.sales-product-currency'), 70, { record: { align: 'center' } }),\n {\n type: 'select',\n name: 'taxKind',\n header: i18next.t('field.sales-product-tax-kind'),\n width: 80,\n record: {\n editable: true,\n options: [\n { value: 'TAXABLE', display: i18next.t('text.invoice-tax-kind-taxable') },\n { value: 'ZERO_RATED', display: i18next.t('text.invoice-tax-kind-zero-rated') },\n { value: 'EXEMPT', display: i18next.t('text.invoice-tax-kind-exempt') }\n ]\n }\n },\n { type: 'checkbox', name: 'active', header: i18next.t('field.sales-product-active'), width: 60, sortable: true, record: { editable: true } },\n text('description', i18next.t('field.sales-product-description'), 220)\n ],\n sorters: [{ name: 'code' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: salesProducts(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items { id code name kind grade spec unit unitPrice currency taxKind active description }\n total\n }\n }\n `,\n variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.responses.total, records: response.data.responses.items }\n }\n\n /** New, changed and deleted rows together; a refusal is said in the server's words and nothing is kept. */\n private async save() {\n const patches = this.grist.dirtyRecords.map((record: any) => {\n const changed = record.__dirty__ === '+' ? FIELDS.filter(field => record[field] !== undefined) : Object.keys(record.__dirtyfields__ ?? {}).filter(field => FIELDS.includes(field))\n return { ...(record.id ? { id: record.id } : {}), cuFlag: record.__dirty__, ...Object.fromEntries(changed.map(field => [field, record[field] === '' ? null : record[field]])) }\n })\n if (!patches.length) return\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [SalesProductPatch!]!) {\n updateMultipleSalesProduct(patches: $patches) { id }\n }\n `,\n variables: { patches }\n })\n if (response.errors?.length) throw response\n notify({ level: 'info', message: i18next.t('text.sales-product-saved') })\n this.grist.fetch()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n }\n }\n\n private async delete() {\n const ids = this.grist.selected.map((record: any) => record.id).filter(Boolean)\n if (!ids.length) return\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.delete'),\n text: i18next.t('text.sales-product-delete-confirm', { count: ids.length }),\n confirmButton: { text: i18next.t('button.delete'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteSalesProducts(ids: $ids)\n }\n `,\n variables: { ids }\n })\n if (response.errors?.length) throw response\n this.grist.fetch()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n }\n }\n}\n"]}
1
+ {"version":3,"file":"sales-product-list.js","sourceRoot":"","sources":["../../client/pages/sales-product-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;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E,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;YAC3E,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE;YACtE,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE;SACnD,CAAC,CAAA;QACF,IAAI,CAAC,SAAS;YAAE,OAAM;QACtB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;gBACnC,QAAQ,EAAE,GAAG,CAAA;;;;SAIZ;gBACD,SAAS,EAAE,EAAE,GAAG,EAAE;aACnB,CAAC,CAAA;YACF,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAE,MAAM,QAAQ,CAAA;YAC3C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC3I,CAAC;IACH,CAAC;;AAjKQ;IAAR,KAAK,EAAE;;qDAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;+CAAA;AAJjC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAqK5B","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { documentNumber } from '@things-factory/invoice/dist-client'\n\nimport { salesProductKindWord } from '../sales-product-words'\n\nconst KINDS = ['GOODS', 'SERVICE', 'LABOR']\n\n/** The fields a row writes - all of them for a new row, the changed ones otherwise. */\nconst FIELDS = ['code', 'name', 'kind', 'grade', 'spec', 'unit', 'unitPrice', 'currency', 'taxKind', 'active', 'description']\n\n/**\n * 상품 — what the domain sells and the price it offers it at: goods, a service, or labor by the grade of the people\n * (ADR-0171). Typed like a spreadsheet and saved together. A quotation line chosen from a product copies it at that\n * moment; changing a price here changes no written quotation.\n */\n@customElement('sales-product-list')\nexport class SalesProductList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.sales-product-list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n actions: [\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ kind: 'GOODS', currency: 'KRW', taxKind: 'TAXABLE', active: true }) },\n { title: i18next.t('button.delete'), action: () => this.delete(), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ],\n exportable: { name: i18next.t('title.sales-product-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-grist\n class=\"page-fill\"\n search-mode=\"term\"\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n </div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const text = (name: string, header: string, width: number, extra: any = {}) => ({ type: 'string', name, header, width, sortable: true, ...extra, record: { editable: true, ...extra.record } })\n this.gristConfig = {\n rows: { appendable: true, selectable: { multiple: true } },\n pagination: { limit: 100, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.sales-product-empty'), description: i18next.t('text.sales-product-empty-description') },\n list: { fields: ['name', 'code'], details: ['kind', 'unit', 'unitPrice'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n text('code', i18next.t('field.sales-product-code'), 110, { record: { mandatory: true } }),\n text('name', i18next.t('field.sales-product-name'), 200, { record: { mandatory: true } }),\n {\n type: 'select',\n name: 'kind',\n header: i18next.t('field.sales-product-kind'),\n width: 80,\n sortable: true,\n record: { editable: true, options: KINDS.map(kind => ({ value: kind, display: salesProductKindWord(kind) })) },\n filter: { type: 'select', operator: 'eq', options: [{ display: '', value: '' }, ...KINDS.map(kind => ({ display: salesProductKindWord(kind), value: kind }))] }\n },\n text('grade', i18next.t('field.sales-product-grade'), 110),\n text('spec', i18next.t('field.sales-product-spec'), 160),\n text('unit', i18next.t('field.sales-product-unit'), 70, { record: { align: 'center' } }),\n {\n type: 'float',\n name: 'unitPrice',\n header: i18next.t('field.sales-product-unit-price'),\n width: 130,\n sortable: true,\n record: { editable: true, align: 'right', renderer: (value: number, _c: any, record: any) => documentNumber(value, record?.currency || 'KRW') }\n },\n text('currency', i18next.t('field.sales-product-currency'), 70, { record: { align: 'center' } }),\n {\n type: 'select',\n name: 'taxKind',\n header: i18next.t('field.sales-product-tax-kind'),\n width: 80,\n record: {\n editable: true,\n options: [\n { value: 'TAXABLE', display: i18next.t('text.tax-kind-taxable') },\n { value: 'ZERO_RATED', display: i18next.t('text.tax-kind-zero-rated') },\n { value: 'EXEMPT', display: i18next.t('text.tax-kind-exempt') }\n ]\n }\n },\n { type: 'checkbox', name: 'active', header: i18next.t('field.sales-product-active'), width: 60, sortable: true, record: { editable: true } },\n text('description', i18next.t('field.sales-product-description'), 220)\n ],\n sorters: [{ name: 'code' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: salesProducts(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items { id code name kind grade spec unit unitPrice currency taxKind active description }\n total\n }\n }\n `,\n variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return { total: response.data.responses.total, records: response.data.responses.items }\n }\n\n /** New, changed and deleted rows together; a refusal is said in the server's words and nothing is kept. */\n private async save() {\n const patches = this.grist.dirtyRecords.map((record: any) => {\n const changed = record.__dirty__ === '+' ? FIELDS.filter(field => record[field] !== undefined) : Object.keys(record.__dirtyfields__ ?? {}).filter(field => FIELDS.includes(field))\n return { ...(record.id ? { id: record.id } : {}), cuFlag: record.__dirty__, ...Object.fromEntries(changed.map(field => [field, record[field] === '' ? null : record[field]])) }\n })\n if (!patches.length) return\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [SalesProductPatch!]!) {\n updateMultipleSalesProduct(patches: $patches) { id }\n }\n `,\n variables: { patches }\n })\n if (response.errors?.length) throw response\n notify({ level: 'info', message: i18next.t('text.sales-product-saved') })\n this.grist.fetch()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n }\n }\n\n private async delete() {\n const ids = this.grist.selected.map((record: any) => record.id).filter(Boolean)\n if (!ids.length) return\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.delete'),\n text: i18next.t('text.sales-product-delete-confirm', { count: ids.length }),\n confirmButton: { text: i18next.t('button.delete'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteSalesProducts(ids: $ids)\n }\n `,\n variables: { ids }\n })\n if (response.errors?.length) throw response\n this.grist.fetch()\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error) })\n }\n }\n}\n"]}