@things-factory/invoice 10.1.273 → 10.1.278
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/document/document-party.d.ts +3 -3
- package/dist-client/document/document-party.js +3 -3
- package/dist-client/document/document-party.js.map +1 -1
- package/dist-client/entity360/invoice-360.js +6 -1
- package/dist-client/entity360/invoice-360.js.map +1 -1
- package/dist-client/invoice-preview.d.ts +10 -0
- package/dist-client/invoice-preview.js +26 -0
- package/dist-client/invoice-preview.js.map +1 -0
- package/dist-client/pages/invoice-editor.d.ts +0 -4
- package/dist-client/pages/invoice-editor.js +3 -20
- package/dist-client/pages/invoice-editor.js.map +1 -1
- package/dist-client/pages/invoice-list.d.ts +3 -2
- package/dist-client/pages/invoice-list.js +22 -10
- package/dist-client/pages/invoice-list.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/invoice/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-shared/screen-money.js +3 -6
- package/dist-shared/screen-money.js.map +1 -1
- package/package.json +9 -9
- package/shared/screen-money.ts +3 -6
- package/tsconfig.shared.tsbuildinfo +1 -1
|
@@ -2,8 +2,8 @@ import type { CounterpartyPick } from '@things-factory/biz-base/dist-client';
|
|
|
2
2
|
/** A counterparty as a document's party - which one, its name and registration number (biz-base `CounterpartyPick`). */
|
|
3
3
|
export type DocumentParty = CounterpartyPick;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Resolve a unique counterparty by normalized name, ignoring case and spaces. Search by the longest token
|
|
6
|
+
* to accommodate registration-prefix spacing. Return null for no match, ambiguity or lookup failure. Select
|
|
7
|
+
* through counterparty-select.
|
|
8
8
|
*/
|
|
9
9
|
export declare function partyOfName(name: unknown): Promise<DocumentParty | null>;
|
|
@@ -9,9 +9,9 @@ const CHOICES = gql `
|
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Resolve a unique counterparty by normalized name, ignoring case and spaces. Search by the longest token
|
|
13
|
+
* to accommodate registration-prefix spacing. Return null for no match, ambiguity or lookup failure. Select
|
|
14
|
+
* through counterparty-select.
|
|
15
15
|
*/
|
|
16
16
|
export async function partyOfName(name) {
|
|
17
17
|
const word = String(name ?? '')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-party.js","sourceRoot":"","sources":["../../client/document/document-party.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAA;AAKlF,MAAM,OAAO,GAAG,GAAG,CAAA;;;;;;CAMlB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAa;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SAC5B,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9E,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;QAClJ,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,CAAoB,CAAC,IAAI,IAAI,CAAA;IAClG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { client } from '@operato/graphql'\nimport type { CounterpartyPick } from '@things-factory/biz-base/dist-client'\nimport { partyNamed } from '@things-factory/invoice/dist-shared/document-start.js'\n\n/** A counterparty as a document's party - which one, its name and registration number (biz-base `CounterpartyPick`). */\nexport type DocumentParty = CounterpartyPick\n\nconst CHOICES = gql`\n query ($search: String, $pagination: Pagination) {\n counterparties: counterpartyChoices(search: $search, pagination: $pagination) {\n items { id name businessNumber }\n }\n }\n`\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"document-party.js","sourceRoot":"","sources":["../../client/document/document-party.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAA;AAKlF,MAAM,OAAO,GAAG,GAAG,CAAA;;;;;;CAMlB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAa;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SAC5B,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9E,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;QAClJ,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,CAAoB,CAAC,IAAI,IAAI,CAAA;IAClG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { client } from '@operato/graphql'\nimport type { CounterpartyPick } from '@things-factory/biz-base/dist-client'\nimport { partyNamed } from '@things-factory/invoice/dist-shared/document-start.js'\n\n/** A counterparty as a document's party - which one, its name and registration number (biz-base `CounterpartyPick`). */\nexport type DocumentParty = CounterpartyPick\n\nconst CHOICES = gql`\n query ($search: String, $pagination: Pagination) {\n counterparties: counterpartyChoices(search: $search, pagination: $pagination) {\n items { id name businessNumber }\n }\n }\n`\n\n/**\n * Resolve a unique counterparty by normalized name, ignoring case and spaces. Search by the longest token\n * to accommodate registration-prefix spacing. Return null for no match, ambiguity or lookup failure. Select\n * through counterparty-select.\n */\nexport async function partyOfName(name: unknown): Promise<DocumentParty | null> {\n const word = String(name ?? '')\n .split(/\\s+/)\n .reduce((longest, one) => (one.length > longest.length ? one : longest), '')\n if (!word) return null\n try {\n const response = await client.query({ query: CHOICES, variables: { search: word, pagination: { page: 1, limit: 100 } }, fetchPolicy: 'no-cache' })\n return partyNamed(name, (response.data?.counterparties?.items ?? []) as DocumentParty[]) ?? null\n } catch {\n return null\n }\n}\n"]}
|
|
@@ -5,8 +5,10 @@ import { customElement, property } from 'lit/decorators.js';
|
|
|
5
5
|
import { QueryController } from '@operato/graphql';
|
|
6
6
|
import { i18next } from '@operato/i18n';
|
|
7
7
|
import { entity360Answer, entity360Name, registerEntity360Kind, registerEntity360Section } from '@operato/layout';
|
|
8
|
+
import { ButtonStyles } from '@operato/styles';
|
|
8
9
|
import { DocumentFormStyles, renderDocumentTotals } from '../document/document-form';
|
|
9
10
|
import { invoice360Query } from '../invoice-attach';
|
|
11
|
+
import { previewInvoice } from '../invoice-preview';
|
|
10
12
|
import '../invoice-files';
|
|
11
13
|
/** The other party: the buyer of a sale, the supplier of a purchase. */
|
|
12
14
|
export const counterpartOf = (value) => (value.direction === 'PURCHASE' ? value.supplierName : value.buyerName) || '';
|
|
@@ -40,13 +42,14 @@ let InvoiceOverviewSection = class InvoiceOverviewSection extends LitElement {
|
|
|
40
42
|
this.invoice = new QueryController(this, gql(`
|
|
41
43
|
query ($id: String!) {
|
|
42
44
|
invoice: ${invoice360Query()}(id: $id) {
|
|
43
|
-
id number status direction currency issueDate dueDate counterpartyId supplierName buyerName purchaseOrder
|
|
45
|
+
id number status direction currency language issueDate dueDate counterpartyId supplierName buyerName purchaseOrder
|
|
44
46
|
supplyAmount taxAmount totalAmount taxGroups { taxKind taxRate supplyAmount taxAmount }
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
`), { variables: () => (this.subject?.id ? { id: this.subject.id } : undefined) });
|
|
48
50
|
}
|
|
49
51
|
static { this.styles = [
|
|
52
|
+
ButtonStyles,
|
|
50
53
|
DocumentFormStyles,
|
|
51
54
|
css `
|
|
52
55
|
:host {
|
|
@@ -74,7 +77,9 @@ let InvoiceOverviewSection = class InvoiceOverviewSection extends LitElement {
|
|
|
74
77
|
}
|
|
75
78
|
render() {
|
|
76
79
|
const one = this.answer?.data;
|
|
80
|
+
/* The invoice itself, as it goes out - its lines and notes are read there (the user, 2026-11-13: a list opens a record to read). */
|
|
77
81
|
return html `<ox-entity360-section .heading=${i18next.t('title.invoice')} .state=${this.answer?.state ?? 'loading'} .message=${this.answer?.message ?? ''}>
|
|
82
|
+
${one ? html `<button slot="actions" quiet small @click=${() => previewInvoice(one)}>${i18next.t('button.preview')}</button>` : ''}
|
|
78
83
|
${one
|
|
79
84
|
? html `<dl>
|
|
80
85
|
<dt>${i18next.t('field.invoice-number')}</dt>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-360.js","sourceRoot":"","sources":["../../client/entity360/invoice-360.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,qBAAqB,EAAE,wBAAwB,EAAyB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"invoice-360.js","sourceRoot":"","sources":["../../client/entity360/invoice-360.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,qBAAqB,EAAE,wBAAwB,EAAyB,MAAM,iBAAiB,CAAA;AACxI,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,cAAc,EA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+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;uDAA2B;AA1B/C,sBAAsB;IADlC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,sBAAsB,CAqElC","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { QueryController } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { entity360Answer, entity360Name, registerEntity360Kind, registerEntity360Section, type Entity360Subject } from '@operato/layout'\nimport { ButtonStyles } from '@operato/styles'\n\nimport { DocumentFormStyles, renderDocumentTotals } from '../document/document-form'\nimport { invoice360Query } from '../invoice-attach'\nimport { previewInvoice } from '../invoice-preview'\nimport '../invoice-files'\n\n/** The other party: the buyer of a sale, the supplier of a purchase. */\nexport const counterpartOf = (value: { direction?: string; supplierName?: string; buyerName?: string }) =>\n (value.direction === 'PURCHASE' ? value.supplierName : value.buyerName) || ''\n\n/** The other party as printed - a link to its counterparty's 360 when the invoice names one, else the printed name. */\nexport const counterpartCell = (value: { counterpartyId?: string | null; direction?: string; supplierName?: string; buyerName?: string }) =>\n value.counterpartyId ? entity360Name({ __typename: 'Counterparty', id: value.counterpartyId, name: counterpartOf(value) }, counterpartOf(value)) : counterpartOf(value)\n\nexport const invoiceStatusWord = (status?: string) =>\n status === 'ISSUED' ? i18next.t('text.invoice-status-issued') : status === 'VOID' ? i18next.t('text.invoice-status-void') : i18next.t('text.invoice-status-draft')\n\n/** An invoice's 360 (ADR-0067). The module draws the invoice; an application hangs its own sections on 'invoice'. */\nexport function registerInvoiceKind() {\n registerEntity360Kind({\n kind: 'invoice',\n typenames: ['Invoice'],\n assistantSubject: true,\n title: ({ value }) => `${i18next.t('title.invoice')} · ${counterpartOf(value) || value.number || ''}`,\n context: ({ value }) => [value.number, value.issueDate, value.status ? invoiceStatusWord(value.status) : ''].filter(Boolean).join(' · ')\n })\n registerEntity360Section('invoice', {\n name: 'overview',\n order: 10,\n render: subject => html`<invoice-overview-section .subject=${subject}></invoice-overview-section>`\n })\n registerEntity360Section('invoice', {\n name: 'files',\n order: 20,\n render: subject => html`<ox-entity360-section .heading=${i18next.t('text.invoice-section-files')} .state=${'ready'}><invoice-files .invoiceId=${subject.id}></invoice-files></ox-entity360-section>`\n })\n}\n\n@customElement('invoice-overview-section')\nexport class InvoiceOverviewSection extends LitElement {\n static styles = [\n ButtonStyles,\n DocumentFormStyles,\n css`\n :host {\n font-size: var(--ui-t-body);\n line-height: 1.5;\n }\n dl {\n margin: 0 0 var(--spacing-large);\n display: grid;\n grid-template-columns: max-content 1fr;\n gap: var(--spacing-small) var(--spacing-large);\n }\n dt {\n color: var(--ui-muted);\n }\n dd {\n margin: 0;\n overflow-wrap: anywhere;\n font-variant-numeric: tabular-nums;\n }\n `\n ]\n\n @property({ attribute: false }) subject?: Entity360Subject\n /* The invoice of the subject shown (ADR-0190). */\n private invoice = new QueryController(\n this,\n gql(`\n query ($id: String!) {\n invoice: ${invoice360Query()}(id: $id) {\n id number status direction currency language issueDate dueDate counterpartyId supplierName buyerName purchaseOrder\n supplyAmount taxAmount totalAmount taxGroups { taxKind taxRate supplyAmount taxAmount }\n }\n }\n `),\n { variables: () => (this.subject?.id ? { id: this.subject.id } : undefined) }\n )\n\n get answer() {\n return entity360Answer(this.invoice, data => data?.invoice)\n }\n\n render() {\n const one = this.answer?.data\n /* The invoice itself, as it goes out - its lines and notes are read there (the user, 2026-11-13: a list opens a record to read). */\n return html`<ox-entity360-section .heading=${i18next.t('title.invoice')} .state=${this.answer?.state ?? 'loading'} .message=${this.answer?.message ?? ''}>\n ${one ? html`<button slot=\"actions\" quiet small @click=${() => previewInvoice(one)}>${i18next.t('button.preview')}</button>` : ''}\n ${one\n ? html`<dl>\n <dt>${i18next.t('field.invoice-number')}</dt>\n <dd>${one.number} · ${invoiceStatusWord(one.status)}</dd>\n <dt>${i18next.t('field.counterparty')}</dt>\n <dd>${one.counterpartyId ? counterpartCell(one) : '—'}</dd>\n <dt>${i18next.t('field.invoice-supplier-name')}</dt>\n <dd>${one.supplierName}</dd>\n <dt>${i18next.t('field.invoice-buyer-name')}</dt>\n <dd>${one.buyerName}</dd>\n <dt>${i18next.t('field.invoice-issue-date')}</dt>\n <dd>${one.issueDate ?? '—'}</dd>\n <dt>${i18next.t('field.invoice-due-date')}</dt>\n <dd>${one.dueDate ?? '—'}</dd>\n </dl>\n ${renderDocumentTotals(one)}`\n : ''}\n </ox-entity360-section>`\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the
|
|
3
|
+
* invoice's own first, to download as PDF or print. What is on screen and not saved is not in it. The editor and the
|
|
4
|
+
* invoice's 360 open the same preview.
|
|
5
|
+
*/
|
|
6
|
+
export declare function previewInvoice({ id, number, language }: {
|
|
7
|
+
id: string;
|
|
8
|
+
number?: string | null;
|
|
9
|
+
language?: string | null;
|
|
10
|
+
}): import("@operato/popup").PopupHandle<unknown>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
import { client } from '@operato/graphql';
|
|
3
|
+
import { i18next } from '@operato/i18n';
|
|
4
|
+
import { openDocumentPreview } from './document/document-preview';
|
|
5
|
+
/**
|
|
6
|
+
* The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the
|
|
7
|
+
* invoice's own first, to download as PDF or print. What is on screen and not saved is not in it. The editor and the
|
|
8
|
+
* invoice's 360 open the same preview.
|
|
9
|
+
*/
|
|
10
|
+
export function previewInvoice({ id, number, language }) {
|
|
11
|
+
return openDocumentPreview(async (format, lng) => {
|
|
12
|
+
const response = await client.query({
|
|
13
|
+
query: gql `
|
|
14
|
+
query ($id: String!, $format: DocumentFileFormat!, $language: String) {
|
|
15
|
+
invoiceDocumentFile(id: $id, format: $format, language: $language) { fileName mimeType content }
|
|
16
|
+
}
|
|
17
|
+
`,
|
|
18
|
+
variables: { id, format, language: lng },
|
|
19
|
+
fetchPolicy: 'no-cache'
|
|
20
|
+
});
|
|
21
|
+
if (!response.data?.invoiceDocumentFile)
|
|
22
|
+
throw response.errors?.[0] ?? new Error(i18next.t('text.invoice-not-found'));
|
|
23
|
+
return response.data.invoiceDocumentFile;
|
|
24
|
+
}, language, `${i18next.t('title.preview')} · ${number ?? ''}`);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=invoice-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-preview.js","sourceRoot":"","sources":["../client/invoice-preview.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,mBAAmB,EAA2B,MAAM,6BAA6B,CAAA;AAE1F;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAoE;IACvH,OAAO,mBAAmB,CACxB,KAAK,EAAE,MAA0B,EAAE,GAAW,EAAE,EAAE;QAChD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;YAClC,KAAK,EAAE,GAAG,CAAA;;;;SAIT;YACD,SAAS,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE;YACxC,WAAW,EAAE,UAAU;SACxB,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,mBAAmB;YAAE,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAA;QACrH,OAAO,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAA;IAC1C,CAAC,EACD,QAAQ,EACR,GAAG,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,MAAM,IAAI,EAAE,EAAE,CAClD,CAAA;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\n\nimport { openDocumentPreview, type DocumentFileFormat } from './document/document-preview'\n\n/**\n * The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the\n * invoice's own first, to download as PDF or print. What is on screen and not saved is not in it. The editor and the\n * invoice's 360 open the same preview.\n */\nexport function previewInvoice({ id, number, language }: { id: string; number?: string | null; language?: string | null }) {\n return 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 invoiceDocumentFile(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?.invoiceDocumentFile) throw response.errors?.[0] ?? new Error(i18next.t('text.invoice-not-found'))\n return response.data.invoiceDocumentFile\n },\n language,\n `${i18next.t('title.preview')} · ${number ?? ''}`\n )\n}\n"]}
|
|
@@ -105,10 +105,6 @@ export declare class InvoiceEditor extends InvoiceEditor_base {
|
|
|
105
105
|
/** Asked first - to whom and how much, fixed after - then save what is on screen and issue it. */
|
|
106
106
|
private issue;
|
|
107
107
|
private void;
|
|
108
|
-
/**
|
|
109
|
-
* The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the
|
|
110
|
-
* invoice's own first, to download as PDF or print. What is on screen and not saved is not in it.
|
|
111
|
-
*/
|
|
112
108
|
private preview;
|
|
113
109
|
}
|
|
114
110
|
export {};
|
|
@@ -6,7 +6,7 @@ import gql from 'graphql-tag';
|
|
|
6
6
|
import { css, html, nothing } from 'lit';
|
|
7
7
|
import { customElement, query, state } from 'lit/decorators.js';
|
|
8
8
|
import { DataGrist } from '@operato/data-grist';
|
|
9
|
-
import {
|
|
9
|
+
import { MutationController, QueryController } from '@operato/graphql';
|
|
10
10
|
import { i18next, localize } from '@operato/i18n';
|
|
11
11
|
import { notify } from '@operato/layout';
|
|
12
12
|
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
@@ -19,9 +19,9 @@ import { DocumentFormStyles, renderDocumentHead, renderDocumentTotals } from '..
|
|
|
19
19
|
import { documentLinesConfig, linesOf, onLineChange, reckonLines } from '../document/document-lines';
|
|
20
20
|
import { partyOfName } from '../document/document-party';
|
|
21
21
|
import { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast } from '../document/document-defaults';
|
|
22
|
-
import { openDocumentPreview } from '../document/document-preview';
|
|
23
22
|
import { invoiceStatusWord } from '../entity360/invoice-360';
|
|
24
23
|
import { invoiceLinkSection } from '../invoice-attach';
|
|
24
|
+
import { previewInvoice } from '../invoice-preview';
|
|
25
25
|
import '../invoice-files';
|
|
26
26
|
import '@things-factory/biz-base/dist-client';
|
|
27
27
|
const FIELDS = `
|
|
@@ -426,26 +426,9 @@ let InvoiceEditor = class InvoiceEditor extends localize(i18next)(PageView) {
|
|
|
426
426
|
return;
|
|
427
427
|
await this.voiding.submit(sent => this.saves.void.run({ id: this.invoiceId, reason: (sent.reason ?? '').trim() }));
|
|
428
428
|
}
|
|
429
|
-
/**
|
|
430
|
-
* The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the
|
|
431
|
-
* invoice's own first, to download as PDF or print. What is on screen and not saved is not in it.
|
|
432
|
-
*/
|
|
433
429
|
preview() {
|
|
434
430
|
const { id, number, language } = this.invoice;
|
|
435
|
-
|
|
436
|
-
const response = await client.query({
|
|
437
|
-
query: gql `
|
|
438
|
-
query ($id: String!, $format: DocumentFileFormat!, $language: String) {
|
|
439
|
-
invoiceDocumentFile(id: $id, format: $format, language: $language) { fileName mimeType content }
|
|
440
|
-
}
|
|
441
|
-
`,
|
|
442
|
-
variables: { id, format, language: lng },
|
|
443
|
-
fetchPolicy: 'no-cache'
|
|
444
|
-
});
|
|
445
|
-
if (!response.data?.invoiceDocumentFile)
|
|
446
|
-
throw response.errors?.[0] ?? new Error(i18next.t('text.invoice-not-found'));
|
|
447
|
-
return response.data.invoiceDocumentFile;
|
|
448
|
-
}, language, `${i18next.t('title.preview')} · ${number}`);
|
|
431
|
+
previewInvoice({ id, number, language });
|
|
449
432
|
}
|
|
450
433
|
};
|
|
451
434
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-editor.js","sourceRoot":"","sources":["../../client/pages/invoice-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,iCAAiC,CAAA;AACxC,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,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,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,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;AAEpE,OAAO,EAAE,SAAS,EAAE,iBAAiB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QACd,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK,EAAE;QAClB,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,YAAY;QACtB,cAAc,EAAE,CAAC;QACjB,KAAK,EAAE,EAAE;KACV,CAAA;AACH,CAAC","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/list-state/ox-page-state.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 { notify } from '@operato/layout'\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'\n\nimport { daysAfter, nextInvoiceNumber } from '@things-factory/invoice/dist-shared/document-start.js'\n\nimport { documentAmount } from '../document/document-amount'\nimport { DocumentFormStyles, renderDocumentHead, renderDocumentTotals, type DocumentValue } from '../document/document-form'\nimport { documentLinesConfig, linesOf, onLineChange, reckonLines } from '../document/document-lines'\nimport { partyOfName, type DocumentParty } from '../document/document-party'\nimport { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast, type DocumentDefaults } from '../document/document-defaults'\nimport { openDocumentPreview, type DocumentFileFormat } from '../document/document-preview'\nimport { invoiceStatusWord } from '../entity360/invoice-360'\nimport { invoiceLinkSection } from '../invoice-attach'\nimport '../invoice-files'\nimport '@things-factory/biz-base/dist-client'\n\nconst FIELDS = `\n id number status direction currency language counterpartyId counterparty { id name } supplierName supplierAddress supplierRegistrationNumber buyerName buyerAddress\n buyerRegistrationNumber issueDate dueDate purchaseOrder paymentTerms bankDetails notes sourceReference taxBasis voidReason\n discountAmount lineSupplyAmount supplyAmount taxAmount totalAmount taxRounding currencyDigits\n items { position description quantity unit unitPrice discount taxKind taxRate supplyAmount receivedTaxAmount }\n taxGroups { taxKind taxRate supplyAmount taxAmount }\n`\n\nconst HEAD = [\n 'number',\n 'counterpartyId',\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'issueDate',\n 'dueDate',\n 'purchaseOrder',\n 'paymentTerms',\n 'bankDetails',\n 'notes',\n 'sourceReference',\n 'taxBasis',\n 'discountAmount'\n]\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\n/** Days an invoice is due after its issue unless the company says otherwise (ADR-0170 decision 11). */\nconst PAYMENT_DAYS = 30\n\ntype Party = DocumentParty\n\n/**\n * 청구서 편집 — the head, the lines, the totals by tax kind and rate, and what an application links it to.\n *\n * A draft is written and saved; 「발행」 saves what is on screen and issues it, after which its amounts never change.\n * An issued invoice is voided with a reason, in its own section. While a request runs only the inputs wait.\n */\n@customElement('invoice-editor')\nexport class InvoiceEditor 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 `\n ]\n\n /** What the address opens: an invoice by id, or a new one. */\n @state() private address?: { id?: string }\n @state() gristConfig: any\n /** The totals of the lines as typed - reckoned as the invoice will keep them, shown before it is saved. */\n @state() private typedAmounts: Partial<DocumentValue> | null = null\n /** Whether this person may read the company's words - unknown, and nothing read, until asked. */\n @state() private defaultsReadable = false\n\n /* The company's words, the invoice the address names, and the last sales invoice a new one follows (ADR-0190). */\n private companyDefaults = new QueryController(this, DOCUMENT_DEFAULTS, { variables: () => (this.defaultsReadable ? {} : undefined) })\n private record = new QueryController(this, gql(`query ($id: String!) { invoice(id: $id) { ${FIELDS} } }`), {\n variables: () => (this.invoiceId ? { id: this.invoiceId } : undefined)\n })\n private last = new QueryController(\n this,\n gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n invoices(filters: $filters, pagination: $pagination, sortings: $sortings) { items { number ${OUR_SIDE_FIELDS.join(' ')} } }\n }\n `,\n {\n variables: () =>\n this.address && !this.address.id\n ? { filters: [{ name: 'direction', operator: 'eq', value: 'SALES' }], pagination: { page: 1, limit: 1 }, sortings: [{ name: 'createdAt', desc: true }] }\n : undefined\n }\n )\n\n /* What is typed over the invoice 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 an issued one is voided with. */\n private voiding = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.address })\n\n /* Every change of the invoice reads it again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($invoice: NewInvoice!) { invoice: createInvoice(invoice: $invoice) { id } }`),\n update: this.saving(gql`mutation ($id: String!, $invoice: NewInvoice!) { invoice: updateInvoice(id: $id, invoice: $invoice) { id } }`),\n issue: this.saving(gql`mutation ($id: String!) { invoice: issueInvoice(id: $id) { id } }`),\n void: this.saving(gql`mutation ($id: String!, $reason: String!) { invoice: voidInvoice(id: $id, reason: $reason) { id } }`)\n }\n\n private saving(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get invoiceId() {\n return this.address?.id ?? ''\n }\n\n /** The company's words a new invoice starts with, and the payment terms it offers (ADR-0170) - none until read. */\n get defaults(): DocumentDefaults | null {\n return this.companyDefaults.data?.documentDefaults ?? null\n }\n\n get invoice(): DocumentValue | null {\n return (this.invoiceId && this.record.data?.invoice) || null\n }\n\n /** What the form shows unedited: the invoice 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.invoice ?? 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 invoice keeps them. */\n get amounts(): Partial<DocumentValue> {\n return this.typedAmounts ?? this.invoice ?? {}\n }\n\n get voidReason() {\n return this.voiding.value('reason') ?? ''\n }\n\n /** A failed read, or an invoice the address names that is not there. */\n get error(): unknown {\n if (this.record.error) return this.record.error\n return this.invoiceId && this.record.data && !this.record.data.invoice ? new Error(i18next.t('text.invoice-not-found')) : null\n }\n\n get loading() {\n return this.record.loading\n }\n\n /** Runs one request at a time. */\n get busy() {\n return Object.values(this.saves).some(save => save.pending)\n }\n\n @query('ox-grist') private grist?: DataGrist\n\n private get received() {\n return this.form.taxBasis === 'RECEIVED'\n }\n\n get editable() {\n return !this.invoice || this.invoice.status === 'DRAFT'\n }\n\n get context() {\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.invoice-issue'), icon: 'send', emphasis: { raised: true }, action: () => this.issue() })\n }\n if (this.invoice) actions.push({ title: i18next.t('button.preview'), icon: 'preview', action: () => this.preview() })\n return {\n title: this.invoice ? `${i18next.t('title.invoice')} ${this.invoice.number}` : i18next.t('title.invoice-new'),\n ...(this.invoice ? { description: invoiceStatusWord(this.invoice.status) } : {}),\n frame: 'document',\n /* Opened from the invoice list; the menu marks it. */\n menu: 'invoice-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 = lifecycle?.params?.id\n if (!this.defaultsReadable) hasPrivilege(DOCUMENT_DEFAULTS_READER).then(may => (this.defaultsReadable = !!may))\n this.address = id ? { id } : {}\n }\n\n /* The lines and their totals are the grid's: a new answer, or another invoice, 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.invoiceId ? this.invoice : 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 links = this.invoice ? invoiceLinkSection() : undefined\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.invoice-section-head')}</h3></header>\n ${renderDocumentHead(this.form, this.editable && !this.busy, patch => this.edit(patch), this.renderTerms(), 'field.invoice-number', {\n terms: this.defaults?.paymentTerms,\n party: this.renderParty(this.editable && !this.busy)\n })}\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.invoice-section-lines')}</h3></header>\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, this.received, this.form.discountAmount))}\n ></ox-grist>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.invoice-section-totals')}</h3></header>\n ${renderDocumentTotals(\n { ...this.amounts, currency: this.form.currency },\n { value: this.form.discountAmount, editable: this.editable && !this.busy, change: value => this.discount(value) }\n )}\n </section>\n ${this.invoice\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.invoice-section-files')}</h3></header>\n <invoice-files .invoiceId=${this.invoice.id}></invoice-files>\n </section>`\n : nothing}\n ${links && this.invoice\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${links.heading()}</h3></header>\n ${links.render(this.invoice as any)}\n </section>`\n : nothing}\n ${this.invoice?.status === 'ISSUED' ? this.renderVoid() : nothing}\n </div>\n </ox-page-state>`\n }\n\n private renderTerms() {\n const editable = this.editable && !this.busy\n return html`<label\n >${i18next.t('field.invoice-due-date')}\n <ox-input-date type=\"date\" .value=${this.form.dueDate ?? ''} ?disabled=${!editable} @change=${(e: any) => this.put({ dueDate: e.target.value })}></ox-input-date></label>\n ${this.form.direction === 'PURCHASE'\n ? html`<label\n >${i18next.t('field.invoice-tax-basis')}\n <select ?disabled=${!editable} @change=${(e: any) => this.changeTaxBasis(e.target.value)}>\n <option value=\"CALCULATED\" ?selected=${this.form.taxBasis !== 'RECEIVED'}>${i18next.t('text.invoice-tax-basis-calculated')}</option>\n <option value=\"RECEIVED\" ?selected=${this.form.taxBasis === 'RECEIVED'}>${i18next.t('text.invoice-tax-basis-received')}</option>\n </select></label\n >`\n : nothing}`\n }\n\n /**\n * Who the other party is among the domain's counterparties - the buyer of a sale, the supplier of a purchase. Found by\n * name or business number; choosing one writes its name and number onto the printed side, which stays editable. A\n * saved invoice whose party is none of them says so under the picker (ADR-0170 decision 11).\n */\n private renderParty(editable: boolean) {\n const name = this.form.direction === 'PURCHASE' ? this.form.supplierName : this.form.buyerName\n return html`<label\n >${i18next.t('field.counterparty')}\n <counterparty-select .party=${this.form.counterparty ?? null} ?disabled=${!editable} @counterparty=${(e: CustomEvent) => this.chooseParty(e.detail)}></counterparty-select>\n ${this.invoice && !this.form.counterpartyId && String(name ?? '').trim() ? html`<span class=\"quiet\">${i18next.t('text.invoice-counterparty-unlinked')}</span>` : nothing}\n </label>`\n }\n\n /**\n * A party typed by name and not picked is the counterparty of that name when exactly one is - case and spaces aside;\n * otherwise it stays unlinked and the editor says so. Looked up for the save and shown nowhere: the invoice read after\n * it shows the link.\n */\n private async linkByName(): Promise<Party | null> {\n if (this.form.counterpartyId) return null\n return partyOfName(this.form.direction === 'PURCHASE' ? this.form.supplierName : this.form.buyerName)\n }\n\n /**\n * What a new invoice starts with, so a person writes only what is new: the number after the last sales invoice's, the\n * due date the company's days after the issue, the company's own words (ADR-0170 decision 6), and what they leave\n * blank of our side as the last sales invoice wrote it.\n */\n private get start(): DocumentValue {\n const form = blank()\n const head = { ...form, ...headFromDefaults(form, this.defaults) }\n return {\n ...head,\n ...oursFromLast(head, this.last.data?.invoices?.items?.[0]),\n number: this.suggestedNumber,\n dueDate: daysAfter(form.issueDate, this.paymentDays)\n }\n }\n\n /** The number a new invoice is offered once the last one is read - it follows the direction while the person leaves it. */\n private get suggestedNumber() {\n if (!this.last.answeredAt && !this.last.error) return ''\n const last = this.last.data?.invoices?.items?.[0]\n return nextInvoiceNumber(last?.number, Number(today().slice(0, 4)))\n }\n\n /** Days an invoice is due - the company's, or thirty. */\n private get paymentDays() {\n return this.defaults?.paymentDays ?? PAYMENT_DAYS\n }\n\n private chooseParty(party: Party | null) {\n const side = this.form.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n this.put({\n counterpartyId: party?.id ?? null,\n counterparty: party,\n ...(party ? { [`${side}Name`]: party.name, [`${side}RegistrationNumber`]: party.businessNumber ?? this.form[`${side}RegistrationNumber`] } : {})\n })\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 private renderVoid() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.invoice-section-void')}</h3>\n <div class=\"page-section-actions\">\n <button danger ?disabled=${this.busy || !this.voidReason.trim()} @click=${() => this.void()}>${i18next.t('button.invoice-void')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.invoice-void-reason')}\n <input .value=${this.voidReason} ?disabled=${this.busy} @input=${(e: any) => this.voiding.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n private changeTaxBasis(taxBasis: string) {\n this.put({ items: linesOf(this.grist), taxBasis })\n this.configure()\n this.updateComplete.then(() => (this.typedAmounts = reckonLines(this.grist, this.form.currency, this.received, this.form.discountAmount)))\n }\n\n /** The discount of the whole invoice 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, this.received, value)\n }\n\n /**\n * A change of the head; a new currency reckons the lines in its minor unit; the due date follows a moved issue date\n * while it is the one offered. A new invoice's offered number is ours - a purchase carries its sender's, so it goes\n * while the person leaves it, and comes back with a sale.\n */\n private edit(patch: DocumentValue) {\n const currency = this.form.currency\n const following = patch.issueDate && this.form.dueDate === daysAfter(this.form.issueDate, this.paymentDays)\n const number =\n this.invoice || !patch.direction\n ? {}\n : patch.direction === 'PURCHASE' && this.form.number === this.suggestedNumber\n ? { number: '' }\n : patch.direction === 'SALES' && !String(this.form.number ?? '').trim()\n ? { number: this.suggestedNumber }\n : {}\n this.put({ ...patch, ...number, ...(following ? { dueDate: daysAfter(patch.issueDate, this.paymentDays) } : {}) })\n if (patch.currency && patch.currency !== currency) {\n this.configure()\n this.typedAmounts = reckonLines(this.grist, this.form.currency, this.received, this.form.discountAmount)\n }\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, received: this.form.taxBasis === 'RECEIVED', 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.taxBasis = input.direction === 'PURCHASE' ? input.taxBasis || 'CALCULATED' : 'CALCULATED'\n input.items = linesOf(this.grist)\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 invoice's id. */\n private async save(): Promise<string | undefined> {\n if (this.busy) return undefined\n const id = this.invoiceId\n const linked = await this.linkByName()\n const saved = await this.draft.submit(() => {\n const invoice = { ...this.input(), ...(linked ? { counterpartyId: linked.id } : {}) }\n return id ? this.saves.update.run({ id, invoice }) : this.saves.create.run({ invoice })\n })\n if (!saved) return undefined\n if (!id) {\n /* The lines went with it: the grid keeps them as saved while the new invoice opens. */\n this.grist?.commit()\n navigate(`invoice-editor?id=${saved.invoice.id}`)\n }\n return saved.invoice.id\n }\n\n /** Asked first - to whom and how much, fixed after - then save what is on screen and issue it. */\n private async issue() {\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.invoice-issue'),\n text: purchase ? i18next.t('text.invoice-issue-confirm-purchase', words) : i18next.t('text.invoice-issue-confirm', words),\n confirmButton: { text: i18next.t('button.invoice-issue') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n const saved = await this.save()\n if (!saved) return\n const issued = await this.saves.issue.run({ id: saved })\n if (issued) notify({ level: 'info', message: i18next.t('text.invoice-issued') })\n }\n\n private async void() {\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.invoice-void'),\n text: i18next.t('text.invoice-void-confirm'),\n confirmButton: { text: i18next.t('button.invoice-void'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n await this.voiding.submit(sent => this.saves.void.run({ id: this.invoiceId, reason: (sent.reason ?? '').trim() }))\n }\n\n /**\n * The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the\n * invoice'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, language } = this.invoice!\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 invoiceDocumentFile(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?.invoiceDocumentFile) throw response.errors?.[0] ?? new Error(i18next.t('text.invoice-not-found'))\n return response.data.invoiceDocumentFile\n },\n language,\n `${i18next.t('title.preview')} · ${number}`\n )\n }\n}\n\nfunction blank(): DocumentValue {\n return {\n number: '',\n direction: 'SALES',\n currency: 'KRW',\n language: 'ko',\n supplierName: '',\n buyerName: '',\n issueDate: today(),\n dueDate: '',\n taxBasis: 'CALCULATED',\n discountAmount: 0,\n items: []\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"invoice-editor.js","sourceRoot":"","sources":["../../client/pages/invoice-editor.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,iCAAiC,CAAA;AACxC,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,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAU,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC9E,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;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;AAEpE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAA;AAEpG,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAsB,MAAM,2BAA2B,CAAA;AAC5H,OA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AAI,CAAC,OAAQ,CAAA;QAC9C,cAAc,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1C,CAAC;;AArYgB;IAAhB,KAAK,EAAE;;8CAAkC;AACjC;IAAR,KAAK,EAAE;;kDAAiB;AAER;IAAhB,KAAK,EAAE;;mDAA2D;AAElD;IAAhB,KAAK,EAAE;;uDAAiC;AAuFd;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;4CAAA;AA5GjC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAuZzB;;AAED,SAAS,KAAK;IACZ,OAAO;QACL,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,KAAK,EAAE;QAClB,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,YAAY;QACtB,cAAc,EAAE,CAAC;QACjB,KAAK,EAAE,EAAE;KACV,CAAA;AACH,CAAC","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/list-state/ox-page-state.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 { notify } from '@operato/layout'\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'\n\nimport { daysAfter, nextInvoiceNumber } from '@things-factory/invoice/dist-shared/document-start.js'\n\nimport { documentAmount } from '../document/document-amount'\nimport { DocumentFormStyles, renderDocumentHead, renderDocumentTotals, type DocumentValue } from '../document/document-form'\nimport { documentLinesConfig, linesOf, onLineChange, reckonLines } from '../document/document-lines'\nimport { partyOfName, type DocumentParty } from '../document/document-party'\nimport { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast, type DocumentDefaults } from '../document/document-defaults'\nimport { invoiceStatusWord } from '../entity360/invoice-360'\nimport { invoiceLinkSection } from '../invoice-attach'\nimport { previewInvoice } from '../invoice-preview'\nimport '../invoice-files'\nimport '@things-factory/biz-base/dist-client'\n\nconst FIELDS = `\n id number status direction currency language counterpartyId counterparty { id name } supplierName supplierAddress supplierRegistrationNumber buyerName buyerAddress\n buyerRegistrationNumber issueDate dueDate purchaseOrder paymentTerms bankDetails notes sourceReference taxBasis voidReason\n discountAmount lineSupplyAmount supplyAmount taxAmount totalAmount taxRounding currencyDigits\n items { position description quantity unit unitPrice discount taxKind taxRate supplyAmount receivedTaxAmount }\n taxGroups { taxKind taxRate supplyAmount taxAmount }\n`\n\nconst HEAD = [\n 'number',\n 'counterpartyId',\n 'direction',\n 'currency',\n 'language',\n 'supplierName',\n 'supplierAddress',\n 'supplierRegistrationNumber',\n 'buyerName',\n 'buyerAddress',\n 'buyerRegistrationNumber',\n 'issueDate',\n 'dueDate',\n 'purchaseOrder',\n 'paymentTerms',\n 'bankDetails',\n 'notes',\n 'sourceReference',\n 'taxBasis',\n 'discountAmount'\n]\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\n/** Days an invoice is due after its issue unless the company says otherwise (ADR-0170 decision 11). */\nconst PAYMENT_DAYS = 30\n\ntype Party = DocumentParty\n\n/**\n * 청구서 편집 — the head, the lines, the totals by tax kind and rate, and what an application links it to.\n *\n * A draft is written and saved; 「발행」 saves what is on screen and issues it, after which its amounts never change.\n * An issued invoice is voided with a reason, in its own section. While a request runs only the inputs wait.\n */\n@customElement('invoice-editor')\nexport class InvoiceEditor 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 `\n ]\n\n /** What the address opens: an invoice by id, or a new one. */\n @state() private address?: { id?: string }\n @state() gristConfig: any\n /** The totals of the lines as typed - reckoned as the invoice will keep them, shown before it is saved. */\n @state() private typedAmounts: Partial<DocumentValue> | null = null\n /** Whether this person may read the company's words - unknown, and nothing read, until asked. */\n @state() private defaultsReadable = false\n\n /* The company's words, the invoice the address names, and the last sales invoice a new one follows (ADR-0190). */\n private companyDefaults = new QueryController(this, DOCUMENT_DEFAULTS, { variables: () => (this.defaultsReadable ? {} : undefined) })\n private record = new QueryController(this, gql(`query ($id: String!) { invoice(id: $id) { ${FIELDS} } }`), {\n variables: () => (this.invoiceId ? { id: this.invoiceId } : undefined)\n })\n private last = new QueryController(\n this,\n gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n invoices(filters: $filters, pagination: $pagination, sortings: $sortings) { items { number ${OUR_SIDE_FIELDS.join(' ')} } }\n }\n `,\n {\n variables: () =>\n this.address && !this.address.id\n ? { filters: [{ name: 'direction', operator: 'eq', value: 'SALES' }], pagination: { page: 1, limit: 1 }, sortings: [{ name: 'createdAt', desc: true }] }\n : undefined\n }\n )\n\n /* What is typed over the invoice 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 an issued one is voided with. */\n private voiding = new DraftController<{ reason: string }>(this, { read: () => ({ reason: '' }), key: () => this.address })\n\n /* Every change of the invoice reads it again once it is done. */\n private saves = {\n create: new MutationController(this, gql`mutation ($invoice: NewInvoice!) { invoice: createInvoice(invoice: $invoice) { id } }`),\n update: this.saving(gql`mutation ($id: String!, $invoice: NewInvoice!) { invoice: updateInvoice(id: $id, invoice: $invoice) { id } }`),\n issue: this.saving(gql`mutation ($id: String!) { invoice: issueInvoice(id: $id) { id } }`),\n void: this.saving(gql`mutation ($id: String!, $reason: String!) { invoice: voidInvoice(id: $id, reason: $reason) { id } }`)\n }\n\n private saving(mutation: any) {\n return new MutationController(this, mutation, { refetch: () => [this.record] })\n }\n\n private get invoiceId() {\n return this.address?.id ?? ''\n }\n\n /** The company's words a new invoice starts with, and the payment terms it offers (ADR-0170) - none until read. */\n get defaults(): DocumentDefaults | null {\n return this.companyDefaults.data?.documentDefaults ?? null\n }\n\n get invoice(): DocumentValue | null {\n return (this.invoiceId && this.record.data?.invoice) || null\n }\n\n /** What the form shows unedited: the invoice 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.invoice ?? 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 invoice keeps them. */\n get amounts(): Partial<DocumentValue> {\n return this.typedAmounts ?? this.invoice ?? {}\n }\n\n get voidReason() {\n return this.voiding.value('reason') ?? ''\n }\n\n /** A failed read, or an invoice the address names that is not there. */\n get error(): unknown {\n if (this.record.error) return this.record.error\n return this.invoiceId && this.record.data && !this.record.data.invoice ? new Error(i18next.t('text.invoice-not-found')) : null\n }\n\n get loading() {\n return this.record.loading\n }\n\n /** Runs one request at a time. */\n get busy() {\n return Object.values(this.saves).some(save => save.pending)\n }\n\n @query('ox-grist') private grist?: DataGrist\n\n private get received() {\n return this.form.taxBasis === 'RECEIVED'\n }\n\n get editable() {\n return !this.invoice || this.invoice.status === 'DRAFT'\n }\n\n get context() {\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.invoice-issue'), icon: 'send', emphasis: { raised: true }, action: () => this.issue() })\n }\n if (this.invoice) actions.push({ title: i18next.t('button.preview'), icon: 'preview', action: () => this.preview() })\n return {\n title: this.invoice ? `${i18next.t('title.invoice')} ${this.invoice.number}` : i18next.t('title.invoice-new'),\n ...(this.invoice ? { description: invoiceStatusWord(this.invoice.status) } : {}),\n frame: 'document',\n /* Opened from the invoice list; the menu marks it. */\n menu: 'invoice-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 = lifecycle?.params?.id\n if (!this.defaultsReadable) hasPrivilege(DOCUMENT_DEFAULTS_READER).then(may => (this.defaultsReadable = !!may))\n this.address = id ? { id } : {}\n }\n\n /* The lines and their totals are the grid's: a new answer, or another invoice, 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.invoiceId ? this.invoice : 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 links = this.invoice ? invoiceLinkSection() : undefined\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.invoice-section-head')}</h3></header>\n ${renderDocumentHead(this.form, this.editable && !this.busy, patch => this.edit(patch), this.renderTerms(), 'field.invoice-number', {\n terms: this.defaults?.paymentTerms,\n party: this.renderParty(this.editable && !this.busy)\n })}\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.invoice-section-lines')}</h3></header>\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, this.received, this.form.discountAmount))}\n ></ox-grist>\n </section>\n <section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.invoice-section-totals')}</h3></header>\n ${renderDocumentTotals(\n { ...this.amounts, currency: this.form.currency },\n { value: this.form.discountAmount, editable: this.editable && !this.busy, change: value => this.discount(value) }\n )}\n </section>\n ${this.invoice\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${i18next.t('text.invoice-section-files')}</h3></header>\n <invoice-files .invoiceId=${this.invoice.id}></invoice-files>\n </section>`\n : nothing}\n ${links && this.invoice\n ? html`<section class=\"page-section\">\n <header class=\"page-section-header\"><h3>${links.heading()}</h3></header>\n ${links.render(this.invoice as any)}\n </section>`\n : nothing}\n ${this.invoice?.status === 'ISSUED' ? this.renderVoid() : nothing}\n </div>\n </ox-page-state>`\n }\n\n private renderTerms() {\n const editable = this.editable && !this.busy\n return html`<label\n >${i18next.t('field.invoice-due-date')}\n <ox-input-date type=\"date\" .value=${this.form.dueDate ?? ''} ?disabled=${!editable} @change=${(e: any) => this.put({ dueDate: e.target.value })}></ox-input-date></label>\n ${this.form.direction === 'PURCHASE'\n ? html`<label\n >${i18next.t('field.invoice-tax-basis')}\n <select ?disabled=${!editable} @change=${(e: any) => this.changeTaxBasis(e.target.value)}>\n <option value=\"CALCULATED\" ?selected=${this.form.taxBasis !== 'RECEIVED'}>${i18next.t('text.invoice-tax-basis-calculated')}</option>\n <option value=\"RECEIVED\" ?selected=${this.form.taxBasis === 'RECEIVED'}>${i18next.t('text.invoice-tax-basis-received')}</option>\n </select></label\n >`\n : nothing}`\n }\n\n /**\n * Who the other party is among the domain's counterparties - the buyer of a sale, the supplier of a purchase. Found by\n * name or business number; choosing one writes its name and number onto the printed side, which stays editable. A\n * saved invoice whose party is none of them says so under the picker (ADR-0170 decision 11).\n */\n private renderParty(editable: boolean) {\n const name = this.form.direction === 'PURCHASE' ? this.form.supplierName : this.form.buyerName\n return html`<label\n >${i18next.t('field.counterparty')}\n <counterparty-select .party=${this.form.counterparty ?? null} ?disabled=${!editable} @counterparty=${(e: CustomEvent) => this.chooseParty(e.detail)}></counterparty-select>\n ${this.invoice && !this.form.counterpartyId && String(name ?? '').trim() ? html`<span class=\"quiet\">${i18next.t('text.invoice-counterparty-unlinked')}</span>` : nothing}\n </label>`\n }\n\n /**\n * A party typed by name and not picked is the counterparty of that name when exactly one is - case and spaces aside;\n * otherwise it stays unlinked and the editor says so. Looked up for the save and shown nowhere: the invoice read after\n * it shows the link.\n */\n private async linkByName(): Promise<Party | null> {\n if (this.form.counterpartyId) return null\n return partyOfName(this.form.direction === 'PURCHASE' ? this.form.supplierName : this.form.buyerName)\n }\n\n /**\n * What a new invoice starts with, so a person writes only what is new: the number after the last sales invoice's, the\n * due date the company's days after the issue, the company's own words (ADR-0170 decision 6), and what they leave\n * blank of our side as the last sales invoice wrote it.\n */\n private get start(): DocumentValue {\n const form = blank()\n const head = { ...form, ...headFromDefaults(form, this.defaults) }\n return {\n ...head,\n ...oursFromLast(head, this.last.data?.invoices?.items?.[0]),\n number: this.suggestedNumber,\n dueDate: daysAfter(form.issueDate, this.paymentDays)\n }\n }\n\n /** The number a new invoice is offered once the last one is read - it follows the direction while the person leaves it. */\n private get suggestedNumber() {\n if (!this.last.answeredAt && !this.last.error) return ''\n const last = this.last.data?.invoices?.items?.[0]\n return nextInvoiceNumber(last?.number, Number(today().slice(0, 4)))\n }\n\n /** Days an invoice is due - the company's, or thirty. */\n private get paymentDays() {\n return this.defaults?.paymentDays ?? PAYMENT_DAYS\n }\n\n private chooseParty(party: Party | null) {\n const side = this.form.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n this.put({\n counterpartyId: party?.id ?? null,\n counterparty: party,\n ...(party ? { [`${side}Name`]: party.name, [`${side}RegistrationNumber`]: party.businessNumber ?? this.form[`${side}RegistrationNumber`] } : {})\n })\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 private renderVoid() {\n return html`<section class=\"page-section\">\n <header class=\"page-section-header\">\n <h3>${i18next.t('text.invoice-section-void')}</h3>\n <div class=\"page-section-actions\">\n <button danger ?disabled=${this.busy || !this.voidReason.trim()} @click=${() => this.void()}>${i18next.t('button.invoice-void')}</button>\n </div>\n </header>\n <div class=\"form\">\n <label class=\"wide\"\n >${i18next.t('field.invoice-void-reason')}\n <input .value=${this.voidReason} ?disabled=${this.busy} @input=${(e: any) => this.voiding.set('reason', e.target.value)}\n /></label>\n </div>\n </section>`\n }\n\n private changeTaxBasis(taxBasis: string) {\n this.put({ items: linesOf(this.grist), taxBasis })\n this.configure()\n this.updateComplete.then(() => (this.typedAmounts = reckonLines(this.grist, this.form.currency, this.received, this.form.discountAmount)))\n }\n\n /** The discount of the whole invoice 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, this.received, value)\n }\n\n /**\n * A change of the head; a new currency reckons the lines in its minor unit; the due date follows a moved issue date\n * while it is the one offered. A new invoice's offered number is ours - a purchase carries its sender's, so it goes\n * while the person leaves it, and comes back with a sale.\n */\n private edit(patch: DocumentValue) {\n const currency = this.form.currency\n const following = patch.issueDate && this.form.dueDate === daysAfter(this.form.issueDate, this.paymentDays)\n const number =\n this.invoice || !patch.direction\n ? {}\n : patch.direction === 'PURCHASE' && this.form.number === this.suggestedNumber\n ? { number: '' }\n : patch.direction === 'SALES' && !String(this.form.number ?? '').trim()\n ? { number: this.suggestedNumber }\n : {}\n this.put({ ...patch, ...number, ...(following ? { dueDate: daysAfter(patch.issueDate, this.paymentDays) } : {}) })\n if (patch.currency && patch.currency !== currency) {\n this.configure()\n this.typedAmounts = reckonLines(this.grist, this.form.currency, this.received, this.form.discountAmount)\n }\n }\n\n private configure() {\n this.gristConfig = documentLinesConfig({ editable: this.editable, received: this.form.taxBasis === 'RECEIVED', 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.taxBasis = input.direction === 'PURCHASE' ? input.taxBasis || 'CALCULATED' : 'CALCULATED'\n input.items = linesOf(this.grist)\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 invoice's id. */\n private async save(): Promise<string | undefined> {\n if (this.busy) return undefined\n const id = this.invoiceId\n const linked = await this.linkByName()\n const saved = await this.draft.submit(() => {\n const invoice = { ...this.input(), ...(linked ? { counterpartyId: linked.id } : {}) }\n return id ? this.saves.update.run({ id, invoice }) : this.saves.create.run({ invoice })\n })\n if (!saved) return undefined\n if (!id) {\n /* The lines went with it: the grid keeps them as saved while the new invoice opens. */\n this.grist?.commit()\n navigate(`invoice-editor?id=${saved.invoice.id}`)\n }\n return saved.invoice.id\n }\n\n /** Asked first - to whom and how much, fixed after - then save what is on screen and issue it. */\n private async issue() {\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.invoice-issue'),\n text: purchase ? i18next.t('text.invoice-issue-confirm-purchase', words) : i18next.t('text.invoice-issue-confirm', words),\n confirmButton: { text: i18next.t('button.invoice-issue') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n const saved = await this.save()\n if (!saved) return\n const issued = await this.saves.issue.run({ id: saved })\n if (issued) notify({ level: 'info', message: i18next.t('text.invoice-issued') })\n }\n\n private async void() {\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.invoice-void'),\n text: i18next.t('text.invoice-void-confirm'),\n confirmButton: { text: i18next.t('button.invoice-void'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n await this.voiding.submit(sent => this.saves.void.run({ id: this.invoiceId, reason: (sent.reason ?? '').trim() }))\n }\n\n private preview() {\n const { id, number, language } = this.invoice!\n previewInvoice({ id, number, language })\n }\n\n}\n\nfunction blank(): DocumentValue {\n return {\n number: '',\n direction: 'SALES',\n currency: 'KRW',\n language: 'ko',\n supplierName: '',\n buyerName: '',\n issueDate: today(),\n dueDate: '',\n taxBasis: 'CALCULATED',\n discountAmount: 0,\n items: []\n }\n}\n"]}
|
|
@@ -4,8 +4,8 @@ import { FetchOption } from '@operato/data-grist';
|
|
|
4
4
|
import { PageView } from '@operato/shell';
|
|
5
5
|
declare const InvoiceList_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
|
|
6
6
|
/**
|
|
7
|
-
* 청구서 — every invoice the domain sent or received.
|
|
8
|
-
* opens the editor. Search is the server's: number, parties, purchase order and notes. Rows picked go to the assistant
|
|
7
|
+
* 청구서 — every invoice the domain sent or received. A click or a tap on the row opens the invoice's 360 to read; with
|
|
8
|
+
* one row picked, 「수정」 on the bar opens the editor. Search is the server's: number, parties, purchase order and notes. Rows picked go to the assistant
|
|
9
9
|
* (「AI와 작업」) as `invoice:<uuid>`, read by the invoice list's read (server invoice-read.ts). The headroom narrows it by
|
|
10
10
|
* status, direction and issue period - the grid's own column filters, kept in the address with search, sort and page
|
|
11
11
|
* (FOOTER-BUTTON-REVIEW G09); the totals of the rows shown stand over it (ADR-0170 decision 11).
|
|
@@ -42,6 +42,7 @@ export declare class InvoiceList extends InvoiceList_base {
|
|
|
42
42
|
data: () => any[];
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
+
private editAction;
|
|
45
46
|
render(): import("lit-html").TemplateResult<1>;
|
|
46
47
|
pageInitialized(): Promise<void>;
|
|
47
48
|
fetchHandler({ page, limit, sortings, filters, search }: FetchOption): Promise<{
|
|
@@ -7,7 +7,7 @@ import { customElement, query, state } from 'lit/decorators.js';
|
|
|
7
7
|
import { DataGrist, isFilterCondition } from '@operato/data-grist';
|
|
8
8
|
import { client } from '@operato/graphql';
|
|
9
9
|
import { i18next, localize } from '@operato/i18n';
|
|
10
|
-
import { entity360Name } from '@operato/layout';
|
|
10
|
+
import { entity360Name, openEntity360Kind } from '@operato/layout';
|
|
11
11
|
import { navigate, PageView } from '@operato/shell';
|
|
12
12
|
import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
|
|
13
13
|
import { isMobileDevice } from '@operato/utils';
|
|
@@ -17,8 +17,8 @@ import { documentAmount } from '../document/document-amount';
|
|
|
17
17
|
import { counterpartCell, counterpartOf, invoiceStatusWord } from '../entity360/invoice-360';
|
|
18
18
|
const today = () => new Date().toLocaleDateString('en-CA');
|
|
19
19
|
/**
|
|
20
|
-
* 청구서 — every invoice the domain sent or received.
|
|
21
|
-
* opens the editor. Search is the server's: number, parties, purchase order and notes. Rows picked go to the assistant
|
|
20
|
+
* 청구서 — every invoice the domain sent or received. A click or a tap on the row opens the invoice's 360 to read; with
|
|
21
|
+
* one row picked, 「수정」 on the bar opens the editor. Search is the server's: number, parties, purchase order and notes. Rows picked go to the assistant
|
|
22
22
|
* (「AI와 작업」) as `invoice:<uuid>`, read by the invoice list's read (server invoice-read.ts). The headroom narrows it by
|
|
23
23
|
* status, direction and issue period - the grid's own column filters, kept in the address with search, sort and page
|
|
24
24
|
* (FOOTER-BUTTON-REVIEW G09); the totals of the rows shown stand over it (ADR-0170 decision 11).
|
|
@@ -28,6 +28,17 @@ let InvoiceList = class InvoiceList extends localize(i18next)(PageView) {
|
|
|
28
28
|
super(...arguments);
|
|
29
29
|
/** The totals of the rows on the page, by direction and currency. */
|
|
30
30
|
this.totals = [];
|
|
31
|
+
/* Changing it is apart from reading it: one picked row, 「수정」 on the bar over the list (the user, 2026-11-13). */
|
|
32
|
+
this.editAction = {
|
|
33
|
+
title: i18next.t('button.edit'),
|
|
34
|
+
icon: 'edit',
|
|
35
|
+
single: true,
|
|
36
|
+
action: () => {
|
|
37
|
+
const row = this.grist.selected?.[0];
|
|
38
|
+
if (row?.id)
|
|
39
|
+
navigate(`invoice-editor?id=${row.id}`);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
31
42
|
}
|
|
32
43
|
static { this.styles = [
|
|
33
44
|
WorkSurfacePageStyles,
|
|
@@ -79,6 +90,7 @@ let InvoiceList = class InvoiceList extends localize(i18next)(PageView) {
|
|
|
79
90
|
list="invoices"
|
|
80
91
|
axis="invoice"
|
|
81
92
|
.labelOf=${(row) => [row.number, counterpartOf(row)].filter(Boolean).join(' · ')}
|
|
93
|
+
.actions=${[this.editAction]}
|
|
82
94
|
></ox-assistant-selection-bar>
|
|
83
95
|
<ox-grist
|
|
84
96
|
class="page-fill"
|
|
@@ -94,6 +106,7 @@ let InvoiceList = class InvoiceList extends localize(i18next)(PageView) {
|
|
|
94
106
|
</ox-grist>`;
|
|
95
107
|
}
|
|
96
108
|
async pageInitialized() {
|
|
109
|
+
const open = (record) => record?.id && openEntity360Kind('invoice', record);
|
|
97
110
|
const readonly = (type, name, header, width, extra = {}) => ({
|
|
98
111
|
type,
|
|
99
112
|
name,
|
|
@@ -106,19 +119,18 @@ let InvoiceList = class InvoiceList extends localize(i18next)(PageView) {
|
|
|
106
119
|
/* The headroom's choices - a select of the column's values, the first one no condition. */
|
|
107
120
|
const choices = (all, values) => ({ type: 'select', operator: 'eq', options: [{ value: '', display: i18next.t(all) }, ...values] });
|
|
108
121
|
this.gristConfig = {
|
|
109
|
-
|
|
122
|
+
/* The row's picker (a gutter) picks it for the bar; the rest of the row opens its 360 to read. */
|
|
123
|
+
rows: {
|
|
124
|
+
appendable: false,
|
|
125
|
+
selectable: { multiple: true },
|
|
126
|
+
handlers: { click: (_c, _d, column, record) => column?.type !== 'gutter' && open(record) }
|
|
127
|
+
},
|
|
110
128
|
pagination: { limit: 50, pages: [50, 100, 500] },
|
|
111
129
|
emptyNote: { title: i18next.t('text.invoice-empty'), description: i18next.t('text.invoice-empty-description') },
|
|
112
130
|
list: { fields: ['number', 'counterpart'], details: ['status', 'dueDate', 'totalAmount'] },
|
|
113
131
|
columns: [
|
|
114
132
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
115
133
|
SELECTION_ROW_PICKER,
|
|
116
|
-
{
|
|
117
|
-
type: 'gutter',
|
|
118
|
-
gutterName: 'button',
|
|
119
|
-
icon: 'edit_note',
|
|
120
|
-
handlers: { click: (_columns, _data, _column, record) => record?.id && navigate(`invoice-editor?id=${record.id}`) }
|
|
121
|
-
},
|
|
122
134
|
/* The number is the invoice's own name and opens its 360; the other party opens the counterparty's (ADR-0067 decision 1). */
|
|
123
135
|
/* Narrow enough that the total stays in view on a laptop. */
|
|
124
136
|
readonly('string', 'number', i18next.t('field.invoice-number'), 130, {
|