@things-factory/invoice 10.1.226 → 10.1.227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist-client/document/document-amount.d.ts +7 -2
  2. package/dist-client/document/document-amount.js +11 -6
  3. package/dist-client/document/document-amount.js.map +1 -1
  4. package/dist-client/document/document-defaults.d.ts +24 -0
  5. package/dist-client/document/document-defaults.js +43 -0
  6. package/dist-client/document/document-defaults.js.map +1 -0
  7. package/dist-client/document/document-form.d.ts +24 -6
  8. package/dist-client/document/document-form.js +126 -15
  9. package/dist-client/document/document-form.js.map +1 -1
  10. package/dist-client/document/document-lines.d.ts +35 -1
  11. package/dist-client/document/document-lines.js +58 -9
  12. package/dist-client/document/document-lines.js.map +1 -1
  13. package/dist-client/document/document-party.d.ts +37 -0
  14. package/dist-client/document/document-party.js +217 -0
  15. package/dist-client/document/document-party.js.map +1 -0
  16. package/dist-client/document/document-preview.d.ts +37 -0
  17. package/dist-client/document/document-preview.js +181 -0
  18. package/dist-client/document/document-preview.js.map +1 -0
  19. package/dist-client/document/document-print.d.ts +3 -13
  20. package/dist-client/document/document-print.js +3 -45
  21. package/dist-client/document/document-print.js.map +1 -1
  22. package/dist-client/index.d.ts +9 -3
  23. package/dist-client/index.js +9 -3
  24. package/dist-client/index.js.map +1 -1
  25. package/dist-client/pages/invoice-editor.d.ts +37 -12
  26. package/dist-client/pages/invoice-editor.js +171 -79
  27. package/dist-client/pages/invoice-editor.js.map +1 -1
  28. package/dist-client/pages/invoice-list.d.ts +21 -1
  29. package/dist-client/pages/invoice-list.js +145 -14
  30. package/dist-client/pages/invoice-list.js.map +1 -1
  31. package/dist-client/tsconfig.tsbuildinfo +1 -1
  32. package/dist-client/viewparts/document-defaults-setting-let.d.ts +19 -0
  33. package/dist-client/viewparts/document-defaults-setting-let.js +139 -0
  34. package/dist-client/viewparts/document-defaults-setting-let.js.map +1 -0
  35. package/dist-server/role-tasks.js +5 -2
  36. package/dist-server/role-tasks.js.map +1 -1
  37. package/dist-server/service/document-defaults/document-defaults-resolver.d.ts +28 -0
  38. package/dist-server/service/document-defaults/document-defaults-resolver.js +136 -0
  39. package/dist-server/service/document-defaults/document-defaults-resolver.js.map +1 -0
  40. package/dist-server/service/document-defaults/document-defaults-rules.d.ts +25 -0
  41. package/dist-server/service/document-defaults/document-defaults-rules.js +50 -0
  42. package/dist-server/service/document-defaults/document-defaults-rules.js.map +1 -0
  43. package/dist-server/service/document-defaults/index.d.ts +6 -0
  44. package/dist-server/service/document-defaults/index.js +11 -0
  45. package/dist-server/service/document-defaults/index.js.map +1 -0
  46. package/dist-server/service/index.d.ts +2 -0
  47. package/dist-server/service/index.js +4 -1
  48. package/dist-server/service/index.js.map +1 -1
  49. package/dist-server/service/invoice/commercial-document.d.ts +2 -0
  50. package/dist-server/service/invoice/commercial-document.js +11 -1
  51. package/dist-server/service/invoice/commercial-document.js.map +1 -1
  52. package/dist-server/service/invoice/invoice-document-file.d.ts +20 -0
  53. package/dist-server/service/invoice/invoice-document-file.js +38 -0
  54. package/dist-server/service/invoice/invoice-document-file.js.map +1 -0
  55. package/dist-server/service/invoice/invoice-query.d.ts +3 -1
  56. package/dist-server/service/invoice/invoice-query.js +33 -0
  57. package/dist-server/service/invoice/invoice-query.js.map +1 -1
  58. package/dist-server/service/invoice/invoice-rules.d.ts +18 -11
  59. package/dist-server/service/invoice/invoice-rules.js +49 -96
  60. package/dist-server/service/invoice/invoice-rules.js.map +1 -1
  61. package/dist-server/service/invoice/invoice-service.d.ts +1 -0
  62. package/dist-server/service/invoice/invoice-service.js +5 -2
  63. package/dist-server/service/invoice/invoice-service.js.map +1 -1
  64. package/dist-server/service/invoice/invoice-type.d.ts +12 -0
  65. package/dist-server/service/invoice/invoice-type.js +37 -1
  66. package/dist-server/service/invoice/invoice-type.js.map +1 -1
  67. package/dist-server/tsconfig.tsbuildinfo +1 -1
  68. package/dist-shared/document-amounts.d.ts +56 -0
  69. package/dist-shared/document-amounts.js +134 -0
  70. package/dist-shared/document-amounts.js.map +1 -0
  71. package/dist-shared/document-money.d.ts +12 -0
  72. package/dist-shared/document-money.js +38 -0
  73. package/dist-shared/document-money.js.map +1 -0
  74. package/dist-shared/document-print.d.ts +37 -0
  75. package/dist-shared/document-print.js +87 -0
  76. package/dist-shared/document-print.js.map +1 -0
  77. package/dist-shared/document-start.d.ts +15 -0
  78. package/dist-shared/document-start.js +51 -0
  79. package/dist-shared/document-start.js.map +1 -0
  80. package/dist-shared/invoice-standing.d.ts +25 -0
  81. package/dist-shared/invoice-standing.js +51 -0
  82. package/dist-shared/invoice-standing.js.map +1 -0
  83. package/package.json +9 -7
  84. package/shared/document-amounts.ts +209 -0
  85. package/shared/document-money.ts +33 -0
  86. package/shared/document-print.ts +131 -0
  87. package/shared/document-start.ts +46 -0
  88. package/shared/invoice-standing.ts +49 -0
  89. package/translations/en.json +32 -6
  90. package/translations/es.json +22 -1
  91. package/translations/ja.json +22 -1
  92. package/translations/ko.json +32 -6
  93. package/translations/ms.json +22 -1
  94. package/translations/zh.json +22 -1
  95. package/tsconfig.shared.tsbuildinfo +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-preview.js","sourceRoot":"","sources":["../../client/document/document-preview.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,6BAA6B,CAAA;AACpC,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAE/D,OAA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C,uBAAuB,CAAC;;;oBAGhC,IAAI,CAAC,IAAI;kBACX,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAA2B,CAAC;;UAE7D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA,wBAAwB,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO;;KAExF,CAAA;IACH,CAAC;;AAxE+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;+CAA4B;AAC/C;IAAX,QAAQ,EAAE;;iDAA6C;AAEvC;IAAhB,KAAK,EAAE;;6CAAkB;AACT;IAAhB,KAAK,EAAE;;6CAAqB;AAzDlB,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CA8H3B;;AAED,iGAAiG;AACjG,MAAM,UAAU,mBAAmB,CAAC,MAA0B,EAAE,QAAmC,EAAE,KAAa;IAChH,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,QAAQ,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAA;IAC/E,OAAO,SAAS,CAAC,IAAI,CAAA,6BAA6B,MAAM,cAAc,GAAG,sBAAsB,EAAE;QAC/F,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,OAAO;QACb,KAAK;KACN,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { ButtonStyles, ScrollbarStyles } from '@operato/styles'\n\nimport { PRINT_LANGUAGES, printDocument, type PrintLanguage } from './document-print'\n\n/** The two forms the server makes a document in (`DocumentFileFormat`): the page to preview and print, and the PDF. */\nexport type DocumentFileFormat = 'HTML' | 'PDF'\n\n/** A file the server made - its name, media type and bytes in base64 (`DocumentFile`). */\nexport type DocumentFile = { fileName: string; mimeType: string; content: string }\n\n/** How a kind's editor asks the server for its document in a form and a language - the invoice's door, the quotation's. */\nexport type DocumentFileLoader = (format: DocumentFileFormat, language: PrintLanguage) => Promise<DocumentFile>\n\nconst bytesOf = (content: string) => Uint8Array.from(atob(content), char => char.charCodeAt(0))\n\n/** Hand a file the server made to the browser to save. */\nfunction saveDocumentFile({ fileName, mimeType, content }: DocumentFile) {\n const url = URL.createObjectURL(new Blob([bytesOf(content)], { type: mimeType }))\n const link = Object.assign(document.createElement('a'), { href: url, download: fileName })\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n}\n\n/**\n * A saved invoice or quotation as it goes out, before it does (ADR-0170 decision 10): the server's page of A4 in a\n * frame, the language of the print to change - the document's own first - and the PDF to download or the same page to\n * print, in that language. Every commercial document's editor opens it with its own loader.\n */\n@customElement('document-preview')\nexport class DocumentPreview extends localize(i18next)(LitElement) {\n static styles = [\n ButtonStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 0;\n background: var(--ui-bg, var(--md-sys-color-surface));\n }\n .bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-medium, 8px);\n padding: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n border-bottom: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted, var(--md-sys-color-on-surface-variant));\n }\n .bar .spacer {\n flex: 1;\n }\n ox-select {\n min-width: 120px;\n }\n /* The frame grows to its page and this box scrolls it - with the house scrollbar, not the frame's own. */\n .frame {\n position: relative;\n flex: 1;\n min-height: 0;\n overflow: auto;\n background: #e9edf1;\n }\n iframe {\n display: block;\n width: 100%;\n border: 0;\n overflow: hidden;\n }\n .loading {\n position: absolute;\n inset: 0;\n display: grid;\n place-items: center;\n background: rgba(233, 237, 241, 0.6);\n font-size: var(--ui-t-body, 13px);\n }\n `\n ]\n\n @property({ attribute: false }) loader!: DocumentFileLoader\n @property() language: PrintLanguage = PRINT_LANGUAGES[0]\n\n @state() private page = ''\n @state() private busy = false\n\n firstUpdated() {\n this.show()\n }\n\n private async show() {\n this.busy = true\n try {\n this.page = new TextDecoder().decode(bytesOf((await this.loader('HTML', this.language)).content))\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n\n private async download() {\n this.busy = true\n try {\n saveDocumentFile(await this.loader('PDF', this.language))\n } catch (error: any) {\n notify({ level: 'error', message: error?.graphQLErrors?.[0]?.message ?? error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n\n /** As tall as its page - read from its document, which is ours (same origin, no script). */\n private fit(frame: HTMLIFrameElement) {\n const height = frame.contentDocument?.documentElement?.scrollHeight\n if (height) frame.style.height = `${height}px`\n }\n\n render() {\n const word = (language: PrintLanguage) => (language === 'en' ? i18next.t('text.invoice-language-en') : i18next.t('text.invoice-language-ko'))\n return html`\n <div class=\"bar\">\n <span>${i18next.t('title.invoice-print-language')}</span>\n <ox-select\n .value=${this.language}\n aria-label=${i18next.t('title.invoice-print-language')}\n @change=${(e: CustomEvent) => {\n const next = PRINT_LANGUAGES.find(one => one === e.detail)\n if (!next || next === this.language) return\n this.language = next\n this.show()\n }}\n >\n <span slot=\"label\">${word(this.language)}</span>\n <ox-popup-list align-left nowrap>${PRINT_LANGUAGES.map(one => html`<div option value=${one}>${word(one)}</div>`)}</ox-popup-list>\n </ox-select>\n <span class=\"spacer\"></span>\n <button ?disabled=${this.busy || !this.page} @click=${() => printDocument(this.page)}><md-icon>print</md-icon>${i18next.t('button.invoice-print')}</button>\n <button raised ?disabled=${this.busy} @click=${() => this.download()}><md-icon>picture_as_pdf</md-icon>${i18next.t('button.invoice-download-pdf')}</button>\n </div>\n <div class=\"frame\">\n <!-- No script runs in the frame; an empty sandbox also kept the page from drawing in the app's browser. -->\n <iframe\n title=${i18next.t('title.invoice-preview')}\n sandbox=\"allow-same-origin\"\n scrolling=\"no\"\n .srcdoc=${this.page}\n @load=${(e: Event) => this.fit(e.target as HTMLIFrameElement)}\n ></iframe>\n ${this.busy ? html`<div class=\"loading\">${i18next.t('text.loading')}</div>` : nothing}\n </div>\n `\n }\n}\n\n/** Open the preview of a saved document, in its own language when the print has words for it. */\nexport function openDocumentPreview(loader: DocumentFileLoader, language: string | null | undefined, title: string) {\n const own = PRINT_LANGUAGES.find(one => one === language) ?? PRINT_LANGUAGES[0]\n return openPopup(html`<document-preview .loader=${loader} .language=${own}></document-preview>`, {\n backdrop: true,\n size: 'large',\n title\n })\n}\n"]}
@@ -1,16 +1,6 @@
1
- export type PrintedDocument = Record<string, any>;
1
+ export { PRINT_LANGUAGES, type PrintLanguage } from '@things-factory/invoice/dist-shared/document-print.js';
2
2
  /**
3
- * A commercial document as the buyer reads it, in the document's own language. `title` and `terms` are the kind's
4
- * words (「청구서」 and its due date, 「견적서」 and its last day); everything else is the shared head and lines.
5
- * Only escaped business data enters the page; the browser prints it or saves it as PDF.
3
+ * Print a page the server made (`shared/document-print.ts`) through a hidden frame - the same page the preview
4
+ * shows. The browser's dialog saves it as PDF too.
6
5
  */
7
- export declare function documentHtml(document: PrintedDocument, { title, terms, numberLabel }: {
8
- title: string;
9
- terms: {
10
- label: string;
11
- value?: string | null;
12
- }[];
13
- numberLabel?: string;
14
- }): string;
15
- /** Print through a hidden frame; the browser's dialog saves it as PDF too. */
16
6
  export declare function printDocument(html: string): void;
@@ -1,50 +1,8 @@
1
- import { i18next } from '@operato/i18n';
2
- import { currencyDigits } from './document-amount';
3
- const escape = (text) => String(text ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
1
+ export { PRINT_LANGUAGES } from '@things-factory/invoice/dist-shared/document-print.js';
4
2
  /**
5
- * A commercial document as the buyer reads it, in the document's own language. `title` and `terms` are the kind's
6
- * words (「청구서」 and its due date, 「견적서」 and its last day); everything else is the shared head and lines.
7
- * Only escaped business data enters the page; the browser prints it or saves it as PDF.
3
+ * Print a page the server made (`shared/document-print.ts`) through a hidden frame - the same page the preview
4
+ * shows. The browser's dialog saves it as PDF too.
8
5
  */
9
- export function documentHtml(document, { title, terms, numberLabel = 'field.invoice-number' }) {
10
- const lng = document.language === 'en' ? 'en' : 'ko';
11
- const t = (key) => escape(i18next.t(key, { lng }));
12
- const digits = currencyDigits(document.currency);
13
- const amount = (value) => escape(`${Number(value ?? 0).toLocaleString(lng, { minimumFractionDigits: digits, maximumFractionDigits: digits })}`);
14
- const kind = (taxKind) => taxKind === 'ZERO_RATED' ? t('text.invoice-tax-kind-zero-rated') : taxKind === 'EXEMPT' ? t('text.invoice-tax-kind-exempt') : t('text.invoice-tax-kind-taxable');
15
- const party = (label, name, address, number) => `<section><h2>${label}</h2><strong>${escape(name)}</strong><p class="text">${escape(address)}</p><p>${escape(number)}</p></section>`;
16
- return `<!doctype html><html lang="${lng}"><head><meta charset="utf-8"><title>${escape(document.number)}</title><style>
17
- @page{size:A4;margin:18mm}
18
- body{font:13px/1.5 system-ui,sans-serif;color:#000}
19
- h1{font-size:26px;margin:0}
20
- h2{font-size:13px;color:#555;margin:0 0 4px}
21
- header,.parties{display:flex;justify-content:space-between;gap:32px}
22
- .parties section{flex:1}
23
- table{width:100%;border-collapse:collapse;margin:24px 0}
24
- th,td{padding:8px;border-bottom:1px solid #999;text-align:right;font-variant-numeric:tabular-nums}
25
- th:first-child,td:first-child{text-align:left}
26
- .text{white-space:pre-wrap}
27
- .totals{width:50%;margin-left:auto}
28
- .grand td{font-weight:600;font-size:15px}
29
- </style></head><body>
30
- <header><h1>${escape(title)}</h1><div><p>${t(numberLabel)}: ${escape(document.number)}</p><p>${t('field.invoice-issue-date')}: ${escape(document.issueDate)}</p>${terms
31
- .map(one => `<p>${escape(one.label)}: ${escape(one.value)}</p>`)
32
- .join('')}</div></header>
33
- <div class="parties">${party(t('field.invoice-supplier-name'), document.supplierName, document.supplierAddress, document.supplierRegistrationNumber)}${party(t('field.invoice-buyer-name'), document.buyerName, document.buyerAddress, document.buyerRegistrationNumber)}</div>
34
- ${document.purchaseOrder ? `<p>${t('field.invoice-purchase-order')}: ${escape(document.purchaseOrder)}</p>` : ''}
35
- <table><thead><tr><th>${t('field.invoice-line-description')}</th><th>${t('field.invoice-quantity')}</th><th>${t('field.invoice-unit-price')}</th><th>${t('field.invoice-discount')}</th><th>${t('field.invoice-tax-kind')}</th><th>${t('field.invoice-supply-amount')}</th></tr></thead><tbody>${(document.items ?? [])
36
- .map((item) => `<tr><td>${escape(item.description)}</td><td>${escape(item.quantity)}</td><td>${amount(item.unitPrice)}</td><td>${amount(item.discount)}</td><td>${kind(item.taxKind)} ${escape(item.taxRate)}%</td><td>${amount(item.supplyAmount)}</td></tr>`)
37
- .join('')}</tbody></table>
38
- <table class="totals"><tbody>${(document.taxGroups ?? [])
39
- .map((group) => `<tr><td>${kind(group.taxKind)} ${escape(group.taxRate)}%</td><td>${amount(group.supplyAmount)}</td><td>${amount(group.taxAmount)}</td></tr>`)
40
- .join('')}<tr><td>${t('field.invoice-sum')}</td><td>${amount(document.supplyAmount)}</td><td>${amount(document.taxAmount)}</td></tr><tr class="grand"><td colspan="2">${t('field.invoice-total-amount')} (${escape(document.currency)})</td><td>${amount(document.totalAmount)}</td></tr></tbody></table>
41
- ${['paymentTerms', 'bankDetails', 'notes']
42
- .filter(key => document[key])
43
- .map(key => `<p class="text">${escape(document[key])}</p>`)
44
- .join('')}
45
- </body></html>`;
46
- }
47
- /** Print through a hidden frame; the browser's dialog saves it as PDF too. */
48
6
  export function printDocument(html) {
49
7
  const frame = window.document.createElement('iframe');
50
8
  frame.style.cssText = 'position:fixed;width:0;height:0;border:0;';
@@ -1 +1 @@
1
- {"version":3,"file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,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SAC5B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAmB,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SAC1D,IAAI,CAAC,EAAE,CAAC;iBACI,CAAA;AACjB,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACrD,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,2CAA2C,CAAA;IACjE,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE;QAClB,MAAM,IAAI,GAAG,KAAK,CAAC,aAAc,CAAA;QACjC,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACzE,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC,CAAA;IACD,KAAK,CAAC,MAAM,GAAG,IAAI,CAAA;IACnB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import { i18next } from '@operato/i18n'\n\nimport { currencyDigits } from './document-amount'\n\nconst escape = (text: unknown) => String(text ?? '').replace(/[&<>\"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' })[c]!)\n\nexport type PrintedDocument = Record<string, any>\n\n/**\n * A commercial document as the buyer reads it, in the document's own language. `title` and `terms` are the kind's\n * words (「청구서」 and its due date, 「견적서」 and its last day); everything else is the shared head and lines.\n * Only escaped business data enters the page; the browser prints it or saves it as PDF.\n */\nexport function documentHtml(\n document: PrintedDocument,\n { title, terms, numberLabel = 'field.invoice-number' }: { title: string; terms: { label: string; value?: string | null }[]; numberLabel?: string }\n) {\n const lng = document.language === 'en' ? 'en' : 'ko'\n const t = (key: string) => escape(i18next.t(key, { lng }))\n const digits = currencyDigits(document.currency)\n const amount = (value: number) => escape(`${Number(value ?? 0).toLocaleString(lng, { minimumFractionDigits: digits, maximumFractionDigits: digits })}`)\n const kind = (taxKind: string) =>\n taxKind === 'ZERO_RATED' ? t('text.invoice-tax-kind-zero-rated') : taxKind === 'EXEMPT' ? t('text.invoice-tax-kind-exempt') : t('text.invoice-tax-kind-taxable')\n const party = (label: string, name: string, address: string, number: string) =>\n `<section><h2>${label}</h2><strong>${escape(name)}</strong><p class=\"text\">${escape(address)}</p><p>${escape(number)}</p></section>`\n\n return `<!doctype html><html lang=\"${lng}\"><head><meta charset=\"utf-8\"><title>${escape(document.number)}</title><style>\n @page{size:A4;margin:18mm}\n body{font:13px/1.5 system-ui,sans-serif;color:#000}\n h1{font-size:26px;margin:0}\n h2{font-size:13px;color:#555;margin:0 0 4px}\n header,.parties{display:flex;justify-content:space-between;gap:32px}\n .parties section{flex:1}\n table{width:100%;border-collapse:collapse;margin:24px 0}\n th,td{padding:8px;border-bottom:1px solid #999;text-align:right;font-variant-numeric:tabular-nums}\n th:first-child,td:first-child{text-align:left}\n .text{white-space:pre-wrap}\n .totals{width:50%;margin-left:auto}\n .grand td{font-weight:600;font-size:15px}\n </style></head><body>\n <header><h1>${escape(title)}</h1><div><p>${t(numberLabel)}: ${escape(document.number)}</p><p>${t('field.invoice-issue-date')}: ${escape(document.issueDate)}</p>${terms\n .map(one => `<p>${escape(one.label)}: ${escape(one.value)}</p>`)\n .join('')}</div></header>\n <div class=\"parties\">${party(t('field.invoice-supplier-name'), document.supplierName, document.supplierAddress, document.supplierRegistrationNumber)}${party(\n t('field.invoice-buyer-name'),\n document.buyerName,\n document.buyerAddress,\n document.buyerRegistrationNumber\n )}</div>\n ${document.purchaseOrder ? `<p>${t('field.invoice-purchase-order')}: ${escape(document.purchaseOrder)}</p>` : ''}\n <table><thead><tr><th>${t('field.invoice-line-description')}</th><th>${t('field.invoice-quantity')}</th><th>${t('field.invoice-unit-price')}</th><th>${t(\n 'field.invoice-discount'\n )}</th><th>${t('field.invoice-tax-kind')}</th><th>${t('field.invoice-supply-amount')}</th></tr></thead><tbody>${(document.items ?? [])\n .map(\n (item: any) =>\n `<tr><td>${escape(item.description)}</td><td>${escape(item.quantity)}</td><td>${amount(item.unitPrice)}</td><td>${amount(item.discount)}</td><td>${kind(item.taxKind)} ${escape(\n item.taxRate\n )}%</td><td>${amount(item.supplyAmount)}</td></tr>`\n )\n .join('')}</tbody></table>\n <table class=\"totals\"><tbody>${(document.taxGroups ?? [])\n .map((group: any) => `<tr><td>${kind(group.taxKind)} ${escape(group.taxRate)}%</td><td>${amount(group.supplyAmount)}</td><td>${amount(group.taxAmount)}</td></tr>`)\n .join('')}<tr><td>${t('field.invoice-sum')}</td><td>${amount(document.supplyAmount)}</td><td>${amount(document.taxAmount)}</td></tr><tr class=\"grand\"><td colspan=\"2\">${t(\n 'field.invoice-total-amount'\n )} (${escape(document.currency)})</td><td>${amount(document.totalAmount)}</td></tr></tbody></table>\n ${['paymentTerms', 'bankDetails', 'notes']\n .filter(key => document[key])\n .map(key => `<p class=\"text\">${escape(document[key])}</p>`)\n .join('')}\n </body></html>`\n}\n\n/** Print through a hidden frame; the browser's dialog saves it as PDF too. */\nexport function printDocument(html: string) {\n const frame = window.document.createElement('iframe')\n frame.style.cssText = 'position:fixed;width:0;height:0;border:0;'\n frame.onload = () => {\n const view = frame.contentWindow!\n view.addEventListener('afterprint', () => frame.remove(), { once: true })\n view.focus()\n view.print()\n }\n frame.srcdoc = html\n window.document.body.append(frame)\n}\n"]}
1
+ {"version":3,"file":"document-print.js","sourceRoot":"","sources":["../../client/document/document-print.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,MAAM,uDAAuD,CAAA;AAE3G;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACrD,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,2CAA2C,CAAA;IACjE,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE;QAClB,MAAM,IAAI,GAAG,KAAK,CAAC,aAAc,CAAA;QACjC,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACzE,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC,CAAA;IACD,KAAK,CAAC,MAAM,GAAG,IAAI,CAAA;IACnB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["export { PRINT_LANGUAGES, type PrintLanguage } from '@things-factory/invoice/dist-shared/document-print.js'\n\n/**\n * Print a page the server made (`shared/document-print.ts`) through a hidden frame - the same page the preview\n * shows. The browser's dialog saves it as PDF too.\n */\nexport function printDocument(html: string) {\n const frame = window.document.createElement('iframe')\n frame.style.cssText = 'position:fixed;width:0;height:0;border:0;'\n frame.onload = () => {\n const view = frame.contentWindow!\n view.addEventListener('afterprint', () => frame.remove(), { once: true })\n view.focus()\n view.print()\n }\n frame.srcdoc = html\n window.document.body.append(frame)\n}\n"]}
@@ -1,6 +1,12 @@
1
1
  export { configureInvoiceLinkSection, configureInvoice360Query, type InvoiceLinkSection } from './invoice-attach.js';
2
2
  export { counterpartOf, invoiceStatusWord } from './entity360/invoice-360.js';
3
- export { currencyChoices, currencyDigits, documentAmount } from './document/document-amount.js';
3
+ export { currencyChoices, currencyDigits, documentAmount, documentNumber } from './document/document-amount.js';
4
4
  export { DocumentFormStyles, HEAD_FIELDS, renderDocumentHead, renderDocumentTotals, type DocumentValue } from './document/document-form.js';
5
- export { documentLinesConfig, linesOf } from './document/document-lines.js';
6
- export { documentHtml, printDocument } from './document/document-print.js';
5
+ export { documentLinesConfig, linesOf, onLineChange, reckonLines, settleLine } from './document/document-lines.js';
6
+ export { defaultTaxRate } from '@things-factory/invoice/dist-shared/document-amounts.js';
7
+ export { printDocument, PRINT_LANGUAGES, type PrintLanguage } from './document/document-print.js';
8
+ export { DocumentPreview, openDocumentPreview, type DocumentFile, type DocumentFileFormat, type DocumentFileLoader } from './document/document-preview.js';
9
+ export { DocumentPartySelect, partyOfName, type DocumentParty } from './document/document-party.js';
10
+ export { documentDefaults, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast, type DocumentDefaults } from './document/document-defaults.js';
11
+ export { daysAfter, nextInvoiceNumber, partyNamed, sameName } from '@things-factory/invoice/dist-shared/document-start.js';
12
+ export * from './viewparts/document-defaults-setting-let.js';
@@ -1,7 +1,13 @@
1
1
  export { configureInvoiceLinkSection, configureInvoice360Query } from './invoice-attach.js';
2
2
  export { counterpartOf, invoiceStatusWord } from './entity360/invoice-360.js';
3
- export { currencyChoices, currencyDigits, documentAmount } from './document/document-amount.js';
3
+ export { currencyChoices, currencyDigits, documentAmount, documentNumber } from './document/document-amount.js';
4
4
  export { DocumentFormStyles, HEAD_FIELDS, renderDocumentHead, renderDocumentTotals } from './document/document-form.js';
5
- export { documentLinesConfig, linesOf } from './document/document-lines.js';
6
- export { documentHtml, printDocument } from './document/document-print.js';
5
+ export { documentLinesConfig, linesOf, onLineChange, reckonLines, settleLine } from './document/document-lines.js';
6
+ export { defaultTaxRate } from '@things-factory/invoice/dist-shared/document-amounts.js';
7
+ export { printDocument, PRINT_LANGUAGES } from './document/document-print.js';
8
+ export { DocumentPreview, openDocumentPreview } from './document/document-preview.js';
9
+ export { DocumentPartySelect, partyOfName } from './document/document-party.js';
10
+ export { documentDefaults, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast } from './document/document-defaults.js';
11
+ export { daysAfter, nextInvoiceNumber, partyNamed, sameName } from '@things-factory/invoice/dist-shared/document-start.js';
12
+ export * from './viewparts/document-defaults-setting-let.js';
7
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAA2B,MAAM,qBAAqB,CAAA;AACpH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC/F,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAsB,MAAM,6BAA6B,CAAA;AAC3I,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA","sourcesContent":["export { configureInvoiceLinkSection, configureInvoice360Query, type InvoiceLinkSection } from './invoice-attach.js'\nexport { counterpartOf, invoiceStatusWord } from './entity360/invoice-360.js'\nexport { currencyChoices, currencyDigits, documentAmount } from './document/document-amount.js'\nexport { DocumentFormStyles, HEAD_FIELDS, renderDocumentHead, renderDocumentTotals, type DocumentValue } from './document/document-form.js'\nexport { documentLinesConfig, linesOf } from './document/document-lines.js'\nexport { documentHtml, printDocument } from './document/document-print.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAA2B,MAAM,qBAAqB,CAAA;AACpH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC/G,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAsB,MAAM,6BAA6B,CAAA;AAC3I,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAClH,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAsB,MAAM,8BAA8B,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAuE,MAAM,gCAAgC,CAAA;AAC1J,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAsB,MAAM,8BAA8B,CAAA;AACnG,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAyB,MAAM,iCAAiC,CAAA;AAC1I,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAA;AAC1H,cAAc,8CAA8C,CAAA","sourcesContent":["export { configureInvoiceLinkSection, configureInvoice360Query, type InvoiceLinkSection } from './invoice-attach.js'\nexport { counterpartOf, invoiceStatusWord } from './entity360/invoice-360.js'\nexport { currencyChoices, currencyDigits, documentAmount, documentNumber } from './document/document-amount.js'\nexport { DocumentFormStyles, HEAD_FIELDS, renderDocumentHead, renderDocumentTotals, type DocumentValue } from './document/document-form.js'\nexport { documentLinesConfig, linesOf, onLineChange, reckonLines, settleLine } from './document/document-lines.js'\nexport { defaultTaxRate } from '@things-factory/invoice/dist-shared/document-amounts.js'\nexport { printDocument, PRINT_LANGUAGES, type PrintLanguage } from './document/document-print.js'\nexport { DocumentPreview, openDocumentPreview, type DocumentFile, type DocumentFileFormat, type DocumentFileLoader } from './document/document-preview.js'\nexport { DocumentPartySelect, partyOfName, type DocumentParty } from './document/document-party.js'\nexport { documentDefaults, headFromDefaults, OUR_SIDE_FIELDS, oursFromLast, type DocumentDefaults } from './document/document-defaults.js'\nexport { daysAfter, nextInvoiceNumber, partyNamed, sameName } from '@things-factory/invoice/dist-shared/document-start.js'\nexport * from './viewparts/document-defaults-setting-let.js'\n"]}
@@ -2,12 +2,8 @@ import '@operato/data-grist/ox-grist.js';
2
2
  import '@operato/list-state/ox-page-state.js';
3
3
  import { PageView } from '@operato/shell';
4
4
  import { type DocumentValue } from '../document/document-form';
5
+ import { type DocumentDefaults } from '../document/document-defaults';
5
6
  import '../invoice-files';
6
- type Party = {
7
- id: string;
8
- name: string;
9
- businessNumber?: string | null;
10
- };
11
7
  declare const InvoiceEditor_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
12
8
  /**
13
9
  * 청구서 편집 — the head, the lines, the totals by tax kind and rate, and what an application links it to.
@@ -23,11 +19,15 @@ export declare class InvoiceEditor extends InvoiceEditor_base {
23
19
  error: unknown;
24
20
  busy: boolean;
25
21
  voidReason: string;
26
- /** The counterparty search: what was typed, and what it found when more than one. */
27
- partySearch: string;
28
- partiesFound: Party[];
29
22
  gristConfig: any;
23
+ /** The totals of the lines as typed - reckoned as the invoice will keep them, shown before it is saved. */
24
+ amounts: Partial<DocumentValue>;
25
+ /** The company's words a new invoice starts with, and the payment terms it offers (ADR-0170). */
26
+ defaults: DocumentDefaults | null;
27
+ /** The number a new invoice was offered - it follows the direction while the person leaves it. */
28
+ suggestedNumber: string;
30
29
  private grist?;
30
+ private get received();
31
31
  get editable(): boolean;
32
32
  get context(): {
33
33
  frame: string;
@@ -41,13 +41,34 @@ export declare class InvoiceEditor extends InvoiceEditor_base {
41
41
  private renderTerms;
42
42
  /**
43
43
  * Who the other party is among the domain's counterparties - the buyer of a sale, the supplier of a purchase. Found by
44
- * name or business number; choosing one writes its name and number onto the printed side, which stays editable.
44
+ * name or business number; choosing one writes its name and number onto the printed side, which stays editable. A
45
+ * saved invoice whose party is none of them says so under the picker (ADR-0170 decision 11).
45
46
  */
46
47
  private renderParty;
48
+ /**
49
+ * A party typed by name and not picked is the counterparty of that name when exactly one is - case and spaces aside;
50
+ * otherwise it stays unlinked and the editor says so.
51
+ */
52
+ private linkByName;
53
+ /**
54
+ * What a new invoice starts with, so a person writes only what is new: the number after the last sales invoice's, the
55
+ * due date the company's days after the issue, the company's own words (ADR-0170 decision 6), and what they leave
56
+ * blank of our side as the last sales invoice wrote it.
57
+ */
58
+ private prefill;
59
+ /** Days an invoice is due - the company's, or thirty. */
60
+ private get paymentDays();
47
61
  private chooseParty;
48
- private findParties;
49
62
  private renderVoid;
50
63
  private changeTaxBasis;
64
+ /** The discount of the whole invoice as typed, and the totals after it. */
65
+ private discount;
66
+ /**
67
+ * A change of the head; a new currency reckons the lines in its minor unit; the due date follows a moved issue date
68
+ * while it is the one offered. A new invoice's offered number is ours - a purchase carries its sender's, so it goes
69
+ * while the person leaves it, and comes back with a sale.
70
+ */
71
+ private edit;
51
72
  private configure;
52
73
  private load;
53
74
  private show;
@@ -55,10 +76,14 @@ export declare class InvoiceEditor extends InvoiceEditor_base {
55
76
  private run;
56
77
  private input;
57
78
  private save;
58
- /** Save what is on screen, then issue it — its amounts are fixed from here on. */
79
+ /** Asked first - to whom and how much, fixed after - then save what is on screen and issue it. */
59
80
  private issue;
60
81
  private void;
61
82
  private mutate;
62
- private print;
83
+ /**
84
+ * The saved invoice as it goes out (ADR-0170 decision 10) - the server's page in the language chosen there, the
85
+ * invoice's own first, to download as PDF or print. What is on screen and not saved is not in it.
86
+ */
87
+ private preview;
63
88
  }
64
89
  export {};