@things-factory/invoice 10.1.278 → 10.1.280
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/package.json +25 -9
- package/dist-client/bootstrap.js.map +0 -1
- package/dist-client/document/document-amount.js.map +0 -1
- package/dist-client/document/document-defaults.js.map +0 -1
- package/dist-client/document/document-form.js.map +0 -1
- package/dist-client/document/document-lines.js.map +0 -1
- package/dist-client/document/document-party.js.map +0 -1
- package/dist-client/document/document-preview.js.map +0 -1
- package/dist-client/document/document-print.js.map +0 -1
- package/dist-client/entity360/invoice-360.js.map +0 -1
- package/dist-client/index.js.map +0 -1
- package/dist-client/invoice-attach.js.map +0 -1
- package/dist-client/invoice-files.js.map +0 -1
- package/dist-client/invoice-preview.js.map +0 -1
- package/dist-client/pages/invoice-editor.js.map +0 -1
- package/dist-client/pages/invoice-list.js.map +0 -1
- package/dist-client/route.js.map +0 -1
- package/dist-client/tsconfig.tsbuildinfo +0 -1
- package/dist-client/viewparts/document-defaults-setting-let.js.map +0 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/role-tasks.js.map +0 -1
- package/dist-server/routes.js.map +0 -1
- package/dist-server/service/document-defaults/document-defaults-resolver.js.map +0 -1
- package/dist-server/service/document-defaults/document-defaults-rules.js.map +0 -1
- package/dist-server/service/document-defaults/index.js.map +0 -1
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/invoice/commercial-document.js.map +0 -1
- package/dist-server/service/invoice/index.js.map +0 -1
- package/dist-server/service/invoice/invoice-document-file.js.map +0 -1
- package/dist-server/service/invoice/invoice-files.js.map +0 -1
- package/dist-server/service/invoice/invoice-mutation.js.map +0 -1
- package/dist-server/service/invoice/invoice-query.js.map +0 -1
- package/dist-server/service/invoice/invoice-read.js.map +0 -1
- package/dist-server/service/invoice/invoice-remaining.js.map +0 -1
- package/dist-server/service/invoice/invoice-rules.js.map +0 -1
- package/dist-server/service/invoice/invoice-service.js.map +0 -1
- package/dist-server/service/invoice/invoice-status.js.map +0 -1
- package/dist-server/service/invoice/invoice-subject.js.map +0 -1
- package/dist-server/service/invoice/invoice-type.js.map +0 -1
- package/dist-server/service/invoice/invoice.js.map +0 -1
- package/dist-server/service/invoice-event/index.js.map +0 -1
- package/dist-server/service/invoice-event/invoice-event-query.js.map +0 -1
- package/dist-server/service/invoice-event/invoice-event.js.map +0 -1
- package/dist-server/service/invoice-item/index.js.map +0 -1
- package/dist-server/service/invoice-item/invoice-item-query.js.map +0 -1
- package/dist-server/service/invoice-item/invoice-item.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/dist-server/work-doors.js.map +0 -1
- package/dist-shared/currency-digits.js.map +0 -1
- package/dist-shared/document-amounts.js.map +0 -1
- package/dist-shared/document-money.js.map +0 -1
- package/dist-shared/document-print.js.map +0 -1
- package/dist-shared/document-start.js.map +0 -1
- package/dist-shared/invoice-standing.js.map +0 -1
- package/dist-shared/screen-money.js.map +0 -1
- package/shared/currency-digits.ts +0 -18
- package/shared/document-amounts.ts +0 -226
- package/shared/document-money.ts +0 -33
- package/shared/document-print.ts +0 -131
- package/shared/document-start.ts +0 -46
- package/shared/invoice-standing.ts +0 -87
- package/shared/screen-money.ts +0 -26
- package/tsconfig.shared.json +0 -18
- package/tsconfig.shared.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/invoice",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.280",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"README.md",
|
|
8
|
+
"dist-client",
|
|
9
|
+
"dist-server",
|
|
10
|
+
"dist-shared",
|
|
11
|
+
"things-factory.config.js",
|
|
12
|
+
"translations",
|
|
13
|
+
"!**/*.map",
|
|
14
|
+
"!**/*.test.*",
|
|
15
|
+
"!**/*.spec.*",
|
|
16
|
+
"!**/test/**",
|
|
17
|
+
"!**/tests/**",
|
|
18
|
+
"!**/__tests__/**",
|
|
19
|
+
"!**/*.tsbuildinfo",
|
|
20
|
+
"!**/.DS_Store"
|
|
21
|
+
],
|
|
6
22
|
"things-factory": true,
|
|
7
23
|
"license": "MIT",
|
|
8
24
|
"description": "Domestic and international commercial invoices, independent of tax invoices",
|
|
@@ -32,13 +48,13 @@
|
|
|
32
48
|
"@operato/shell": "^10.29.69",
|
|
33
49
|
"@operato/styles": "^10.29.1",
|
|
34
50
|
"@operato/utils": "^10.0.0",
|
|
35
|
-
"@things-factory/ai-assistant": "^10.1.
|
|
36
|
-
"@things-factory/attachment-base": "^10.1.
|
|
37
|
-
"@things-factory/auth-base": "^10.1.
|
|
38
|
-
"@things-factory/biz-base": "^10.1.
|
|
39
|
-
"@things-factory/pdf": "^10.1.
|
|
40
|
-
"@things-factory/setting-base": "^10.1.
|
|
41
|
-
"@things-factory/shell": "^10.1.
|
|
51
|
+
"@things-factory/ai-assistant": "^10.1.280",
|
|
52
|
+
"@things-factory/attachment-base": "^10.1.280",
|
|
53
|
+
"@things-factory/auth-base": "^10.1.280",
|
|
54
|
+
"@things-factory/biz-base": "^10.1.280",
|
|
55
|
+
"@things-factory/pdf": "^10.1.280",
|
|
56
|
+
"@things-factory/setting-base": "^10.1.280",
|
|
57
|
+
"@things-factory/shell": "^10.1.280",
|
|
42
58
|
"graphql-upload": "^15.0.2"
|
|
43
59
|
},
|
|
44
60
|
"publishConfig": {
|
|
@@ -51,5 +67,5 @@
|
|
|
51
67
|
"url": "git+https://github.com/hatiolab/things-factory.git",
|
|
52
68
|
"directory": "packages/invoice"
|
|
53
69
|
},
|
|
54
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "14ce4b7f5957272d63115af316a7dc1ab030e152"
|
|
55
71
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,mBAAmB,EAAE,CAAA;AACvB,CAAC","sourcesContent":["import { registerInvoiceKind } from './entity360/invoice-360.js'\n\nexport default function bootstrap() {\n registerInvoiceKind()\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-amount.js","sourceRoot":"","sources":["../../client/document/document-amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAA;AACvF,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,uDAAuD,CAAA;AAE9H,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgC,EAAE,QAAgB,EAAE,MAAc,OAAO,CAAC,QAAQ,IAAI,IAAI;IACvH,OAAO,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AACvC,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,cAAc,CAAC,KAAgC,EAAE,QAAgB,EAAE,MAAc,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,KAAK,GAAG,KAAK;IACtI,OAAO,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAC9C,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,GAAI,IAAY,CAAC,iBAAiB,CAAC,CAAC,CAAG,IAAY,CAAC,iBAAiB,CAAC,UAAU,CAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5G,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;IACjD,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import { i18next } from '@operato/i18n'\nimport { currencyDigits } from '@things-factory/invoice/dist-shared/currency-digits.js'\nimport { documentAmount as amountIn, documentNumber as numberIn } from '@things-factory/invoice/dist-shared/document-money.js'\n\nexport { currencyDigits }\n\n/**\n * An amount in its currency as the language writes money - `shared/document-money.ts`, in the screen's language\n * unless another is named.\n */\nexport function documentAmount(value: number | null | undefined, currency: string, lng: string = i18next.language || 'ko'): string {\n return amountIn(value, currency, lng)\n}\n\n/** A number without the currency (`shared/document-money.ts`), in the screen's language unless another is named. */\nexport function documentNumber(value: number | null | undefined, currency: string, lng: string = i18next.language || 'ko', exact = false): string {\n return numberIn(value, currency, lng, exact)\n}\n\n/** The currencies a document may be written in, most used first. */\nexport function currencyChoices(): string[] {\n const all = (Intl as any).supportedValuesOf ? ((Intl as any).supportedValuesOf('currency') as string[]) : []\n const first = ['KRW', 'USD', 'EUR', 'JPY', 'CNY']\n return [...first, ...all.filter(code => !first.includes(code))]\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-defaults.js","sourceRoot":"","sources":["../../client/document/document-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAe7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,8GAA8G,CAAA;AAEtJ;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAA;AAEvH,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC,8BAA8B,wBAAwB,MAAM,CAAC,CAAA;AAElG,sHAAsH;AACtH,MA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,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACrI,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\n/** The company's own words every new quotation and invoice starts with (ADR-0170) - as the Settings screen keeps them. */\nexport type DocumentDefaults = {\n supplierName: string\n supplierRegistrationNumber: string\n supplierAddress: string\n bankDetails: string\n paymentTerms: string[]\n notes: string\n validDays: number\n /** Days an invoice is due after its issue day. */\n paymentDays: number\n}\n\nexport const DOCUMENT_DEFAULTS_FIELDS = 'supplierName supplierRegistrationNumber supplierAddress bankDetails paymentTerms notes validDays paymentDays'\n\n/**\n * Whom the company's words are read for - a screen declares DOCUMENT_DEFAULTS with no variables until `hasPrivilege` of\n * this says yes, as a refusal would be shown to someone who never asked for it; an editor then starts empty.\n */\nexport const DOCUMENT_DEFAULTS_READER = { category: 'invoice-published', privilege: 'query', domainOwnerGranted: true }\n\n/** The company's words, as a QueryController reads them (ADR-0190). */\nexport const DOCUMENT_DEFAULTS = gql(`query { documentDefaults { ${DOCUMENT_DEFAULTS_FIELDS} } }`)\n\n/** A new sales document's head from the company's words - only the fields still blank, so a person's typing stays. */\nexport function headFromDefaults(form: Record<string, any>, defaults: DocumentDefaults | null): Record<string, any> {\n if (!defaults || form.direction === 'PURCHASE') return {}\n const words: Record<string, string> = {\n supplierName: defaults.supplierName,\n supplierRegistrationNumber: defaults.supplierRegistrationNumber,\n supplierAddress: defaults.supplierAddress,\n bankDetails: defaults.bankDetails,\n paymentTerms: defaults.paymentTerms[0] ?? '',\n notes: defaults.notes\n }\n return Object.fromEntries(Object.entries(words).filter(([key, value]) => value && !String(form[key] ?? '').trim()))\n}\n\n/** Our side of a sales document, as a person writes it once - our name, number and address, the account, the terms. */\nexport const OUR_SIDE_FIELDS = ['supplierName', 'supplierAddress', 'supplierRegistrationNumber', 'bankDetails', 'paymentTerms']\n\n/**\n * What `last` - the last sales document of the same kind - wrote of our side, for those fields still blank on `form`;\n * nothing for a purchase, whose supplier is the other party.\n */\nexport function oursFromLast(form: Record<string, any>, last: Record<string, any> | null | undefined): Record<string, any> {\n if (!last || form.direction === 'PURCHASE') return {}\n return Object.fromEntries(OUR_SIDE_FIELDS.filter(key => last[key] && !String(form[key] ?? '').trim()).map(key => [key, last[key]]))\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-form.js","sourceRoot":"","sources":["../../client/document/document-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAA;AAE7D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAWnE,+GAA+G;AAC/G,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,sBAAsB,EAAE;IACjD,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,0BAA0B,EAAE;IACxD,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,0BAA0B,EAAE;IAC3D,EAAE,IAAI,EAAE,4BAA4B,EAAE,KAAK,EAAE,yCAAyC,EAAE;IACxF,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,6BAA6B,EAAE,KAAK,EAAE,IAAI,EAAE;IAC9E,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,0BAA0B,EAAE;IACxD,EAAE,IAAI,EAAE,yBAAyB,EAAE,KAAK,EAAE,yCAAyC,EAAE;IACrF,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,6BAA6B,EAAE,KAAK,EAAE,IAAI,EAAE;IAC3E,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,8BAA8B,EAAE;IAChE,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,gCAAgC,EAAE;IACpE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,E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,CAAC","sourcesContent":["import { i18next } from '@operato/i18n'\nimport { css, html, nothing, type TemplateResult } from 'lit'\n\nimport { currencyChoices, documentAmount } from './document-amount'\n\n/*\n * The parts every commercial document editor draws — the head, the totals by tax kind and rate. Invoice and quotation\n * editors put them in their own sections; the quotation module imports them from here (ADR-0120 decision 1).\n */\n\nexport type DocumentValue = Record<string, any>\n\ntype HeadField = { name: string; label: string; wide?: boolean; prose?: boolean }\n\n/** The head fields in the order a person fills them: the document, each party as one group, then the terms. */\nexport const HEAD_FIELDS: HeadField[] = [\n { name: 'number', label: 'field.invoice-number' },\n { name: 'issueDate', label: 'field.invoice-issue-date' },\n { name: 'supplierName', label: 'field.invoice-party-name' },\n { name: 'supplierRegistrationNumber', label: 'field.invoice-party-registration-number' },\n { name: 'supplierAddress', label: 'field.invoice-party-address', prose: true },\n { name: 'buyerName', label: 'field.invoice-party-name' },\n { name: 'buyerRegistrationNumber', label: 'field.invoice-party-registration-number' },\n { name: 'buyerAddress', label: 'field.invoice-party-address', prose: true },\n { name: 'purchaseOrder', label: 'field.invoice-purchase-order' },\n { name: 'sourceReference', label: 'field.invoice-source-reference' },\n { name: 'paymentTerms', label: 'field.invoice-payment-terms', wide: true, prose: true },\n { name: 'bankDetails', label: 'field.invoice-bank-details', wide: true, prose: true },\n { name: 'notes', label: 'field.invoice-notes', wide: true, prose: true }\n]\n\nconst field = (name: string) => HEAD_FIELDS.find(one => one.name === name)!\n\nexport const DocumentFormStyles = css`\n /*\n * The lines' grid is as wide as its columns. With the grid styles the page is a flex item, and a flex item is at least\n * as wide as what it holds: the page grew past the window, the head spread into three cut-off columns and the\n * page scrolled sideways. The page and its sections may be narrower than the grid; the grid scrolls inside.\n */\n .page,\n .page-section,\n ox-grist {\n min-width: 0;\n }\n .form {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));\n gap: var(--spacing-large) var(--spacing-huge);\n }\n .form label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small);\n font-size: var(--ui-t-micro);\n color: var(--ui-muted);\n }\n .form .wide {\n grid-column: 1 / -1;\n }\n /* The two parties side by side, each its name, number and address together - not interleaved in one grid. */\n .parties {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));\n gap: var(--spacing-large) var(--spacing-huge);\n margin: var(--spacing-large) 0;\n }\n .parties fieldset {\n display: grid;\n gap: var(--spacing-large);\n margin: 0;\n padding: var(--spacing-large) var(--spacing-large) var(--spacing-large);\n border: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));\n border-radius: var(--ui-r, 10px);\n }\n .parties legend {\n padding: 0 var(--spacing-small);\n font-size: var(--ui-t-small, 11.5px);\n font-weight: 600;\n color: var(--ui-ink);\n }\n .form input,\n .form select,\n .form textarea {\n box-sizing: border-box;\n width: 100%;\n height: var(--form-element-height-medium);\n font-size: var(--ui-t-body);\n color: var(--ui-ink);\n }\n /* A searchable choice stands as the inputs beside it - the same box, not an underline. */\n .form ox-select {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n height: var(--form-element-height-medium);\n border: var(--input-field-border, 1px solid var(--md-sys-color-outline));\n border-radius: var(--input-field-border-radius, var(--md-sys-shape-corner-small, 4px));\n background: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n font-size: var(--ui-t-body);\n color: var(--ui-ink);\n }\n /* Whether the party is one of the counterparties - said quietly under the picker. */\n .form .quiet {\n font-size: var(--ui-t-micro);\n color: var(--ui-muted);\n }\n /* The payment terms the company offers, a click away above the field. */\n .form .terms {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-small);\n }\n .form .terms button[selected] {\n border-color: var(--md-sys-color-primary);\n color: var(--md-sys-color-primary);\n }\n .form textarea {\n height: auto;\n min-height: calc(var(--form-element-height-medium) * 2);\n }\n table.totals {\n width: 100%;\n border-collapse: collapse;\n font-variant-numeric: tabular-nums;\n }\n table.totals th,\n table.totals td {\n padding: var(--spacing-small) var(--spacing-medium);\n border-bottom: 1px solid var(--ui-line-soft);\n text-align: right;\n font-size: var(--ui-t-body);\n }\n table.totals th:first-child,\n table.totals td:first-child {\n text-align: left;\n }\n table.totals th {\n color: var(--ui-muted);\n font-weight: 400;\n }\n table.totals tfoot td {\n font-weight: 600;\n }\n /* The discount of the whole document, typed over the totals it lowers. */\n .discount {\n margin-bottom: var(--spacing-medium);\n }\n .discount input {\n max-width: 240px;\n text-align: right;\n }\n .discount .problem {\n color: var(--md-sys-color-error);\n }\n`\n\n/** The head of a document. `dates` holds the fields a kind adds — the due date, the last day of an offer. */\n/** `numberLabel` names the number as the kind does - 「청구서 번호」, 「견적 번호」. */\n/** `terms` are the payment terms the company offers (ADR-0170) - one click puts one in. */\n/**\n * `party` is the counterparty picker, drawn inside the group it fills - the buyer's of a sale, the supplier's of a\n * purchase (ADR-0170 decision 11).\n */\nexport function renderDocumentHead(\n value: DocumentValue,\n editable: boolean,\n change: (patch: DocumentValue) => void,\n dates: TemplateResult | typeof nothing = nothing,\n numberLabel = 'field.invoice-number',\n { terms = [], party: picker = nothing }: { terms?: string[]; party?: TemplateResult | typeof nothing } = {}\n) {\n const offered = (field: HeadField) =>\n field.name === 'paymentTerms' && editable && terms.length\n ? html`<span class=\"terms\">${terms.map(term => html`<button small ?selected=${value.paymentTerms === term} @click=${() => change({ paymentTerms: term })}>${term.split('\\n')[0]}</button>`)}</span>`\n : nothing\n const input = (field: HeadField) =>\n html`<label class=${field.wide ? 'wide' : ''}\n >${i18next.t(field.label)} ${offered(field)}\n ${field.prose\n ? html`<textarea .value=${value[field.name] ?? ''} ?disabled=${!editable} @input=${(e: any) => change({ [field.name]: e.target.value })}></textarea>`\n : html`<input\n type=${field.name === 'issueDate' ? 'date' : 'text'}\n .value=${value[field.name] ?? ''}\n ?disabled=${!editable}\n @input=${(e: any) => change({ [field.name]: e.target.value })}\n />`}</label\n >`\n\n const other = value.direction === 'PURCHASE' ? 'supplier' : 'buyer'\n const party = (side: 'supplier' | 'buyer', legend: string) =>\n html`<fieldset class=\"form\">\n <legend>${i18next.t(legend)}</legend>\n ${side === other ? picker : nothing} ${['Name', 'RegistrationNumber', 'Address'].map(part => input(field(`${side}${part}`)))}\n </fieldset>`\n\n return html`<div class=\"form\">\n ${input({ ...field('number'), label: numberLabel })} ${input(field('issueDate'))}\n <label\n >${i18next.t('field.invoice-direction')}\n <select .value=${value.direction} ?disabled=${!editable} @change=${(e: any) => change({ direction: e.target.value })}>\n <option value=\"SALES\" ?selected=${value.direction === 'SALES'}>${i18next.t('text.invoice-direction-sales')}</option>\n <option value=\"PURCHASE\" ?selected=${value.direction === 'PURCHASE'}>${i18next.t('text.invoice-direction-purchase')}</option>\n </select></label\n >\n <label\n >${i18next.t('field.invoice-currency')}\n <select ?disabled=${!editable} @change=${(e: any) => change({ currency: e.target.value })}>\n ${currencyChoices().map(code => html`<option value=${code} ?selected=${value.currency === code}>${code}</option>`)}\n </select></label\n >\n <label\n >${i18next.t('field.invoice-language')}\n <select ?disabled=${!editable} @change=${(e: any) => change({ language: e.target.value })}>\n <option value=\"ko\" ?selected=${value.language === 'ko'}>${i18next.t('text.invoice-language-ko')}</option>\n <option value=\"en\" ?selected=${value.language === 'en'}>${i18next.t('text.invoice-language-en')}</option>\n </select></label\n >\n ${dates}\n </div>\n <div class=\"parties\">${party('supplier', 'field.invoice-supplier-name')} ${party('buyer', 'field.invoice-buyer-name')}</div>\n <div class=\"form\">${['purchaseOrder', 'sourceReference', 'paymentTerms', 'bankDetails', 'notes'].map(name => input(field(name)))}</div>`\n}\n\n/**\n * Supply and tax of each tax kind and rate, then the document totals. With a discount of the whole document the lines'\n * supply and the discount come first, and each group's supply is the one after its part (ADR-0170 decision 8).\n * `discount` puts the discount's input over the table while a draft is written; `change` takes what is typed.\n */\nexport function renderDocumentTotals(value: DocumentValue, discount?: { value: unknown; editable: boolean; change: (value: string) => void }) {\n const currency = value.currency || 'KRW'\n const kind = (taxKind: string) =>\n taxKind === 'ZERO_RATED' ? i18next.t('text.tax-kind-zero-rated') : taxKind === 'EXEMPT' ? i18next.t('text.tax-kind-exempt') : i18next.t('text.tax-kind-taxable')\n const discounted = Number(value.discountAmount) > 0\n return html`${discount?.editable\n ? html`<div class=\"form discount\">\n <label\n >${i18next.t('field.invoice-document-discount')}\n <input type=\"number\" min=\"0\" .value=${String(discount.value ?? '')} @input=${(e: any) => discount.change(e.target.value)} />\n ${value.discountProblem ? html`<span class=\"problem\">${i18next.t('error.invoice-document-discount-invalid')}</span>` : nothing}\n </label>\n </div>`\n : nothing}\n <table class=\"totals\">\n <thead>\n <tr>\n <th>${i18next.t('field.invoice-tax-kind')}</th>\n <th>${i18next.t('field.invoice-tax-rate')}</th>\n <th>${i18next.t('field.invoice-supply-amount')}</th>\n <th>${i18next.t('field.invoice-tax-amount')}</th>\n </tr>\n </thead>\n <tbody>\n ${discounted\n ? html`<tr>\n <td colspan=\"2\">${i18next.t('field.invoice-line-sum')}</td>\n <td>${documentAmount(value.lineSupplyAmount, currency)}</td>\n <td></td>\n </tr>\n <tr>\n <td colspan=\"2\">${i18next.t('field.invoice-discount')}</td>\n <td>− ${documentAmount(value.discountAmount, currency)}</td>\n <td></td>\n </tr>`\n : nothing}\n ${(value.taxGroups ?? []).map(\n (group: any) =>\n html`<tr>\n <td>${kind(group.taxKind)}</td>\n <td>${group.taxRate}%</td>\n <td>${documentAmount(group.supplyAmount, currency)}</td>\n <td>${documentAmount(group.taxAmount, currency)}</td>\n </tr>`\n )}\n </tbody>\n <tfoot>\n <tr>\n <td colspan=\"2\">${i18next.t('field.invoice-sum')}</td>\n <td>${documentAmount(value.supplyAmount, currency)}</td>\n <td>${documentAmount(value.taxAmount, currency)}</td>\n </tr>\n <tr>\n <td colspan=\"3\">${i18next.t('field.invoice-total-amount')}</td>\n <td>${documentAmount(value.totalAmount, currency)}</td>\n </tr>\n </tfoot>\n </table>`\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-lines.js","sourceRoot":"","sources":["../../client/document/document-lines.ts"],"names":[],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O,EAAE,QAAQ,IAAI,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;IACrF,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAA;IACrG,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAmC,EAAE,KAAkB,EAAE,QAAgB,EAAE,QAAQ,GAAG,KAAK,EAAE,iBAA0B,CAAC;IACnJ,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IAC3D,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;IACtE,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { DataGrist } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\n\nimport { defaultTaxRate, documentAmounts, untouchedRow, type DocumentAmounts } from '@things-factory/invoice/dist-shared/document-amounts.js'\n\nimport { documentAmount, documentNumber } from './document-amount'\n\n/** The grid of a document's lines — typed or pasted like a spreadsheet while the document is a draft. */\nexport function documentLinesConfig({ editable, received, currency }: { editable: boolean; received?: boolean; currency: string }) {\n /* Prices and discounts read with thousands marks; the widths keep the supply in view at about 900px, the unit's column too. */\n const number = (name: string, header: string, width = 100) => ({\n type: 'float',\n name,\n header,\n width,\n record: { editable, align: 'right', renderer: (value: number) => documentNumber(value, currency) }\n })\n return {\n rows: { appendable: editable, selectable: { multiple: true }, accumulator: true },\n pagination: { infinite: true },\n emptyNote: { title: i18next.t('text.invoice-lines-empty') },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n ...(editable ? [{ type: 'gutter', gutterName: 'row-selector', multiple: true }] : []),\n { type: 'string', name: 'description', header: i18next.t('field.invoice-line-description'), width: 220, record: { editable } },\n number('quantity', i18next.t('field.invoice-quantity'), 60),\n { type: 'string', name: 'unit', header: i18next.t('field.invoice-unit'), width: 60, record: { editable, align: 'center' } },\n number('unitPrice', i18next.t('field.invoice-unit-price'), 110),\n number('discount', i18next.t('field.invoice-discount'), 80),\n {\n type: 'select',\n name: 'taxKind',\n header: i18next.t('field.invoice-tax-kind'),\n width: 70,\n record: {\n editable,\n options: [\n { value: 'TAXABLE', display: i18next.t('text.tax-kind-taxable') },\n { value: 'ZERO_RATED', display: i18next.t('text.tax-kind-zero-rated') },\n { value: 'EXEMPT', display: i18next.t('text.tax-kind-exempt') }\n ]\n }\n },\n number('taxRate', i18next.t('field.invoice-tax-rate-percent'), 56),\n ...(received ? [number('receivedTaxAmount', i18next.t('field.invoice-received-tax-amount'), 120)] : []),\n {\n type: 'float',\n name: 'supplyAmount',\n header: i18next.t('field.invoice-supply-amount'),\n width: 130,\n record: { editable: false, align: 'right', renderer: (value: number) => documentAmount(value, currency) },\n accumulator: 'sum'\n }\n ]\n }\n}\n\nconst blank = (value: unknown) => value === undefined || value === null || value === ''\n\n/** The rows of the grid that are lines of the document - deleted and untouched rows left out. */\nfunction lineRecords(grist: DataGrist | null | undefined): any[] {\n return ((grist?.dirtyData?.records ?? []) as any[]).filter(record => record.__dirty__ !== '-' && !untouchedRow(record))\n}\n\n/** The lines on the grid, as the save mutation takes them. */\nexport function linesOf(grist: DataGrist | null | undefined) {\n return lineRecords(grist)\n .map(record => ({\n description: String(record.description ?? '').trim(),\n quantity: Number(record.quantity ?? 1),\n unit: String(record.unit ?? '').trim() || null,\n unitPrice: Number(record.unitPrice ?? 0),\n discount: Number(record.discount ?? 0),\n taxKind: record.taxKind || 'TAXABLE',\n taxRate: Number(record.taxRate ?? 0),\n ...(record.receivedTaxAmount === undefined || record.receivedTaxAmount === null || record.receivedTaxAmount === ''\n ? {}\n : { receivedTaxAmount: Number(record.receivedTaxAmount) })\n }))\n}\n\n/**\n * What a line typed into is missing, filled - a quantity of one, no discount, taxable at the standard rate - and its\n * rate following its tax kind when the kind is what changed (taxable 10 %, zero-rated and exempt none). A select shows\n * its first option for an empty value, so 「과세」 looked chosen and choosing it changed nothing; the line now holds it.\n */\nexport function settleLine(record: any, changed?: string) {\n if (!record || record.__dirty__ === '-') return\n if (blank(record.quantity)) record.quantity = 1\n if (blank(record.discount)) record.discount = 0\n if (!record.taxKind) record.taxKind = 'TAXABLE'\n if (changed === 'taxKind' || blank(record.taxRate)) record.taxRate = defaultTaxRate(record.taxKind)\n}\n\n/**\n * The lines on the grid reckoned as the document will keep them (shared/document-amounts.ts): each row's supply is\n * written onto it for the grid to show, and the document's tax groups and totals - after `discountAmount`, the\n * discount of the whole document - are returned for the totals table.\n */\nexport function reckonLines(grist: DataGrist | null | undefined, currency: string, received = false, discountAmount: unknown = 0): DocumentAmounts {\n const records = lineRecords(grist)\n const amounts = documentAmounts(records, currency || 'KRW', received, discountAmount)\n records.forEach((record, index) => (record.supplyAmount = amounts.lines[index].supplyAmount ?? null))\n return amounts\n}\n\n/**\n * A change on the grid as an editor takes it: the changed line settled, every line reckoned, the grid redrawn with\n * the supplies. Returns the totals to show.\n */\nexport function onLineChange(grist: DataGrist | null | undefined, event: CustomEvent, currency: string, received = false, discountAmount: unknown = 0): DocumentAmounts {\n settleLine(event.detail?.after, event.detail?.column?.name)\n const amounts = reckonLines(grist, currency, received, discountAmount)\n grist?.refresh()\n return amounts\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,OAAO,EAAE,eAAe,EAAE,aAAa,EAAsB,MAAM,kBAAkB,CAAA;AAWrF,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/F,0DAA0D;AAC1D,SAAS,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAgB;I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S,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.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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,kBAAkB,CAAA;AAEzB,wEAAwE;AACxE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAwE,EAAE,EAAE,CACxG,CAAC,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;AAE/E,uHAAuH;AACvH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAwG,EAAE,EAAE,CAC1I,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,CAAC,cAAc,EAAE,IAAI,EAAE,aAAa,C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AC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;QAC/H,GAAG;YACH,CAAC,CAAC,IAAI,CAAA;oBACM,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;oBACjC,GAAG,CAAC,MAAM,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC;oBAC7C,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC;oBAC/B,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;oBAC/C,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC;oBACxC,GAAG,CAAC,YAAY;oBAChB,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC;oBACrC,GAAG,CAAC,SAAS;oBACb,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC;oBACrC,GAAG,CAAC,SAAS,IAAI,GAAG;oBACpB,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;oBACnC,GAAG,CAAC,OAAO,IAAI,GAAG;;cAExB,oBAAoB,CAAC,GAAG,CAAC,EAAE;YACjC,CAAC,CAAC,EAAE;4BACgB,CAAA;IAC1B,CAAC;;AA1C+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"]}
|
package/dist-client/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,WAAW,EAAsB,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAyB,MAAM,iCAAiC,CAAA;AACrK,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAA;AAC1H,OAAO,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAA;AACvF,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 { partyOfName, type DocumentParty } from './document/document-party.js'\nexport { DOCUMENT_DEFAULTS, DOCUMENT_DEFAULTS_READER, 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 { issuePeriodOf } from '@things-factory/invoice/dist-shared/invoice-standing.js'\nexport * from './viewparts/document-defaults-setting-let.js'\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-attach.js","sourceRoot":"","sources":["../client/invoice-attach.ts"],"names":[],"mappings":"AAcA,IAAI,WAA2C,CAAA;AAE/C,wHAAwH;AACxH,MAAM,UAAU,2BAA2B,CAAC,OAA2B;IACrE,WAAW,GAAG,OAAO,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,IAAI,iBAAiB,GAAG,SAAS,CAAA;AAEjC,oFAAoF;AACpF,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAC3F,iBAAiB,GAAG,KAAK,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,iBAAiB,CAAA;AAC1B,CAAC","sourcesContent":["import { type TemplateResult } from 'lit'\n\n/*\n * Where an application attaches its own work to an invoice — the same shape as tax-invoice's\n * configureTaxInvoice360Query (ADR-0120 decision 2). The invoice module knows no application words.\n */\n\nexport type InvoiceLinkSection = {\n /** The section's heading, already in the reader's words. */\n heading: () => string\n /** The section's body for one saved invoice; it reads and writes through the application's own API. */\n render: (invoice: { id: string; status: string; direction: string; currency: string; totalAmount: number }) => TemplateResult\n}\n\nlet linkSection: InvoiceLinkSection | undefined\n\n/** The 「links」 section of the invoice editor — Office ties an invoice to contract rounds, payments and tax invoices. */\nexport function configureInvoiceLinkSection(section: InvoiceLinkSection): void {\n linkSection = section\n}\n\nexport function invoiceLinkSection(): InvoiceLinkSection | undefined {\n return linkSection\n}\n\nlet invoiceQueryField = 'invoice'\n\n/** An application may read the 360's invoice through its own domain-scoped door. */\nexport function configureInvoice360Query(field: string): void {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(field)) throw new Error('Invalid invoice query field')\n invoiceQueryField = field\n}\n\nexport function invoice360Query(): string {\n return invoiceQueryField\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-files.js","sourceRoot":"","sources":["../client/invoice-files.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,0EAA0E;AAC1E,OAAO,qBAAqB,CAAA;AAC5B,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,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,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAA;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAIlD,2GAA2G;AAC3G,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAA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C,CAAC,eAAe,CAAC,EAAE;SAC5C,CAAC,CAAA;QACT,IAAI,IAAI;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IAEO,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAA0C;QACvF,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI;YAAE,OAAM;QACxC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACxJ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;IAC3B,CAAC;;AAhHW;IAAX,QAAQ,EAAE;;+CAAmB;AACrB;IAAR,KAAK,EAAE;;+CAAkB;AACjB;IAAR,KAAK,EAAE;;8CAAkB;AA9Ef,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA6LxB","sourcesContent":["import '@material/web/icon/icon.js'\n/* The tile is not a subpath of its own; the package root registers it. */\nimport '@operato/attachment'\nimport '@operato/input/ox-input-file.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { MutationController, QueryController, uploadContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\n\nimport { invoice360Query } from './invoice-attach'\n\ntype InvoiceFile = { id: string; name: string; mimetype?: string; fullpath: string }\n\n/** The phone's camera is offered where a finger taps - on a desktop the file button is the only way in. */\nconst touch = () => window.matchMedia('(pointer: coarse)').matches\n\n/**\n * The files an invoice keeps - the signed copy, the order, the delivery note. Each opens in its own tab. Whoever may\n * change invoices attaches (a photo taken on the spot, or any file) and takes one off; it is saved at once.\n */\n@customElement('invoice-files')\nexport class InvoiceFiles extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-medium, 8px);\n color: var(--ui-ink);\n }\n .tiles {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-medium, 8px);\n padding-top: 6px;\n }\n .tile {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 72px;\n gap: var(--spacing-tiny, 2px);\n }\n .tile a {\n display: block;\n width: 100%;\n aspect-ratio: 1;\n border-radius: var(--ui-r-small, 6px);\n border: 1px solid var(--ui-line);\n background: var(--ui-panel-2);\n overflow: hidden;\n }\n .tile ox-attachment-tile,\n .tile img {\n width: 100%;\n height: 100%;\n }\n .tile img {\n object-fit: cover;\n }\n .name {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .tile button {\n position: absolute;\n top: -6px;\n right: -6px;\n display: grid;\n place-items: center;\n width: 20px;\n height: 20px;\n padding: 0;\n border: 1px solid var(--ui-line);\n border-radius: 50%;\n background: var(--ui-panel);\n color: var(--ui-muted);\n cursor: pointer;\n }\n .tile button md-icon {\n --md-icon-size: 14px;\n }\n .pickers {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-small, 4px);\n }\n .none {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted);\n }\n `\n ]\n\n @property() invoiceId?: string\n @state() mayChange = false\n @state() progress?: number\n\n /* The files of the invoice named (ADR-0190). */\n private filesRead = new QueryController(\n this,\n gql(`query ($id: String!) { invoice: ${invoice360Query()}(id: $id) { id files { id name mimetype fullpath } } }`),\n { variables: () => (this.invoiceId ? { id: this.invoiceId } : undefined) }\n )\n\n /* Attaching or taking off reads the files again. */\n private changing = new MutationController(\n this,\n gql`\n mutation ($id: String!, $attach: [Upload!], $remove: [String!]) {\n changeInvoiceFiles(id: $id, attach: $attach, remove: $remove) {\n id\n }\n }\n `,\n { refetch: () => [this.filesRead] }\n )\n\n private get files(): InvoiceFile[] {\n return this.filesRead.data?.invoice?.files ?? []\n }\n\n private get busy() {\n return this.changing.pending\n }\n\n connectedCallback() {\n super.connectedCallback()\n hasPrivilege({ privilege: 'mutation', category: 'invoice', domainOwnerGranted: true }).then(may => (this.mayChange = !!may))\n }\n\n render() {\n const editable = this.mayChange && !this.busy\n return html`\n ${this.files.length\n ? html`<div class=\"tiles\">${this.files.map(one => this.tile(one, editable))}</div>`\n : html`<span class=\"none\">${i18next.t('text.invoice-files-none')}</span>`}\n ${this.mayChange\n ? html`<div class=\"pickers\">\n ${touch()\n ? html`<ox-input-file\n quiet\n hide-filelist\n accept=\"image/*\"\n capture=\"environment\"\n icon=\"photo_camera\"\n .label=${i18next.t('button.invoice-file-photo')}\n ?disabled=${!editable}\n .progress=${this.progress}\n @change=${(e: CustomEvent) => this.pick(e)}\n ></ox-input-file>`\n : nothing}\n <ox-input-file\n quiet\n hide-filelist\n multiple\n icon=\"attach_file\"\n .dropTarget=${this}\n .label=${i18next.t('button.invoice-file-attach')}\n ?disabled=${!editable}\n .progress=${touch() ? undefined : this.progress}\n @change=${(e: CustomEvent) => this.pick(e)}\n ></ox-input-file>\n </div>`\n : nothing}\n `\n }\n\n private tile(one: InvoiceFile, editable: boolean) {\n return html`<span class=\"tile\">\n <a href=${one.fullpath} target=\"_blank\" rel=\"noopener\" title=${one.name}\n >${one.mimetype?.startsWith('image/')\n ? html`<img src=${one.fullpath} alt=${one.name} />`\n : html`<ox-attachment-tile .src=${one.fullpath} .path=${one.name} .mimetype=${one.mimetype ?? ''}></ox-attachment-tile>`}</a\n >\n <span class=\"name\">${one.name}</span>\n ${this.mayChange\n ? html`<button type=\"button\" ?disabled=${!editable} title=${i18next.t('button.invoice-file-remove')} aria-label=${i18next.t('button.invoice-file-remove')} @click=${() => this.takeOff(one)}>\n <md-icon>close</md-icon>\n </button>`\n : nothing}\n </span>`\n }\n\n private async pick(e: CustomEvent) {\n const picked = [...((e.detail as File[]) ?? [])]\n /* The picker's own reset says `change` again, with nothing - that one is let go. */\n if (!picked.length) return\n ;(e.target as any).reset?.()\n await this.change({ attach: picked })\n }\n\n private async takeOff(one: InvoiceFile) {\n const sure = await OxPrompt.open({\n title: i18next.t('button.invoice-file-remove'),\n text: i18next.t('text.invoice-file-remove-confirm', { name: one.name }),\n confirmButton: { text: i18next.t('button.invoice-file-remove'), destructive: true } as any,\n cancelButton: { text: i18next.t('button.cancel') }\n } as any)\n if (sure) await this.change({ remove: [one.id] })\n }\n\n private async change({ attach = [], remove = [] }: { attach?: File[]; remove?: string[] }) {\n if (!this.invoiceId || this.busy) return\n await this.changing.run({ id: this.invoiceId, attach, remove }, { context: attach.length ? uploadContext(fraction => (this.progress = fraction)) : {} })\n this.progress = undefined\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-editor.js","sourceRoot":"","sources":["../../client/pages/invoice-editor.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AhB,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: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ClK,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAA;QACF,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM;YAAE,MAAM,QAAQ,CAAA;QAC3C,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;IACzF,CAAC;;AAxKQ;IAAR,KAAK,EAAE;;gDAAiB;AAEhB;IAAR,KAAK,EAAE;;2CAAuE;AACpD;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;0CAAA;AAtBjC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4LvB","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, nothing } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption, isFilterCondition } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { entity360Name, openEntity360Kind } from '@operato/layout'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { SELECTION_ROW_PICKER } from '@things-factory/ai-assistant/dist-client/index.js'\nimport { invoiceListFilters, overdue, totalsOf } from '@things-factory/invoice/dist-shared/invoice-standing.js'\n\nimport { documentAmount } from '../document/document-amount'\nimport { counterpartCell, counterpartOf, invoiceStatusWord } from '../entity360/invoice-360'\n\nconst today = () => new Date().toLocaleDateString('en-CA')\n\n/**\n * 청구서 — every invoice the domain sent or received. A click or a tap on the row opens the invoice's 360 to read; with\n * 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\n * (「AI와 작업」) as `invoice:<uuid>`, read by the invoice list's read (server invoice-read.ts). The headroom narrows it by\n * status, direction and issue period - the grid's own column filters, kept in the address with search, sort and page\n * (FOOTER-BUTTON-REVIEW G09); the totals of the rows shown stand over it (ADR-0170 decision 11).\n */\n@customElement('invoice-list')\nexport class InvoiceList extends localize(i18next)(PageView) {\n static styles = [\n WorkSurfacePageStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n ScrollbarStyles,\n css`\n .totals {\n font-size: var(--ui-t-small, 11.5px);\n color: var(--ui-muted, var(--md-sys-color-on-surface-variant));\n font-variant-numeric: tabular-nums;\n }\n .totals strong {\n color: var(--ui-ink, var(--md-sys-color-on-surface));\n font-weight: 600;\n }\n `\n ]\n\n @state() gristConfig: any\n /** The totals of the rows on the page, by direction and currency. */\n @state() totals: { direction: string; currency: string; amount: number }[] = []\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.invoice-list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n actions: [{ title: i18next.t('button.invoice-new'), icon: 'add', emphasis: { raised: true }, action: () => navigate('invoice-editor') }],\n exportable: { name: i18next.t('title.invoice-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n /* Changing it is apart from reading it: one picked row, 「수정」 on the bar over the list (the user, 2026-11-13). */\n private editAction = {\n title: i18next.t('button.edit'),\n icon: 'edit',\n single: true,\n action: () => {\n const row = this.grist.selected?.[0]\n if (row?.id) navigate(`invoice-editor?id=${row.id}`)\n }\n }\n\n render() {\n return html`${this.totals.length\n ? html`<div class=\"page-headroom totals\" aria-label=${i18next.t('text.invoice-totals-shown')}>\n ${i18next.t('text.invoice-totals-shown')}\n ${this.totals.map(\n one =>\n html`<span\n >${one.direction === 'PURCHASE' ? i18next.t('text.invoice-direction-purchase') : i18next.t('text.invoice-direction-sales')}\n <strong>${documentAmount(one.amount, one.currency)}</strong></span\n >`\n )}\n </div>`\n : nothing}<ox-assistant-selection-bar\n .gridOf=${() => this.grist}\n name=${i18next.t('title.invoice-list')}\n list=\"invoices\"\n axis=\"invoice\"\n .labelOf=${(row: any) => [row.number, counterpartOf(row)].filter(Boolean).join(' · ')}\n .actions=${[this.editAction]}\n ></ox-assistant-selection-bar>\n <ox-grist\n class=\"page-fill\"\n search-mode=\"term\"\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n ?url-params-sensitive=${this.active}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\"><ox-filters-form without-search></ox-filters-form></div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const open = (record: any) => record?.id && openEntity360Kind('invoice', record)\n const readonly = (type: string, name: string, header: string, width: number, extra: any = {}) => ({\n type,\n name,\n header,\n width,\n sortable: true,\n ...extra,\n record: { editable: false, ...extra.record }\n })\n /* The headroom's choices - a select of the column's values, the first one no condition. */\n const choices = (all: string, values: { value: string; display: string }[]) => ({ type: 'select', operator: 'eq', options: [{ value: '', display: i18next.t(all) }, ...values] })\n this.gristConfig = {\n /* The row's picker (a gutter) picks it for the bar; the rest of the row opens its 360 to read. */\n rows: {\n appendable: false,\n selectable: { multiple: true },\n handlers: { click: (_c: any, _d: any, column: any, record: any) => column?.type !== 'gutter' && open(record) }\n },\n pagination: { limit: 50, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.invoice-empty'), description: i18next.t('text.invoice-empty-description') },\n list: { fields: ['number', 'counterpart'], details: ['status', 'dueDate', 'totalAmount'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n SELECTION_ROW_PICKER,\n /* The number is the invoice's own name and opens its 360; the other party opens the counterparty's (ADR-0067 decision 1). */\n /* Narrow enough that the total stays in view on a laptop. */\n readonly('string', 'number', i18next.t('field.invoice-number'), 130, {\n record: { renderer: (value: string, _column: any, record: any) => (record?.id ? entity360Name({ __typename: 'Invoice', ...record }, value) : value) }\n }),\n readonly('string', 'counterpart', i18next.t('field.invoice-counterpart'), 170, {\n sortable: false,\n record: { renderer: (_value: any, _column: any, record: any) => counterpartCell(record) }\n }),\n readonly('string', 'status', i18next.t('field.invoice-status'), 110, {\n filter: choices('text.invoice-filter-all-statuses', [\n ...['DRAFT', 'ISSUED', 'VOID'].map(value => ({ value, display: invoiceStatusWord(value) })),\n { value: 'OVERDUE', display: i18next.t('text.invoice-overdue') }\n ]),\n record: {\n renderer: (value: string, _column: any, record: any) =>\n overdue(record ?? {}, today())\n ? html`${invoiceStatusWord(value)} · <span style=\"color:var(--md-sys-color-error)\">${i18next.t('text.invoice-overdue')}</span>`\n : invoiceStatusWord(value)\n }\n }),\n readonly('string', 'direction', i18next.t('field.invoice-direction'), 56, {\n filter: choices('text.invoice-filter-all-directions', [\n { value: 'SALES', display: i18next.t('text.invoice-direction-sales') },\n { value: 'PURCHASE', display: i18next.t('text.invoice-direction-purchase') }\n ]),\n record: { renderer: (value: string) => (value === 'PURCHASE' ? i18next.t('text.invoice-direction-purchase') : i18next.t('text.invoice-direction-sales')) }\n }),\n /* The issue date narrows by a period around today, read as the days between (invoiceListFilters). */\n readonly('string', 'issueDate', i18next.t('field.invoice-issue-date'), 92, {\n filter: choices(\n 'text.invoice-period-all',\n ['this-month', 'last-month', 'this-year', 'last-year'].map(value => ({ value, display: i18next.t(`text.invoice-period-${value}`) }))\n )\n }),\n readonly('string', 'dueDate', i18next.t('field.invoice-due-date'), 92),\n readonly('float', 'totalAmount', i18next.t('field.invoice-total-amount'), 140, {\n record: { align: 'right', renderer: (value: number, _column: any, record: any) => documentAmount(value, record?.currency || 'KRW') }\n })\n ],\n sorters: [{ name: 'issueDate', desc: true }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 50, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: invoices(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id\n number\n status\n direction\n currency\n counterpartyId\n supplierName\n buyerName\n issueDate\n dueDate\n totalAmount\n remainingAmount\n }\n total\n }\n }\n `,\n variables: { filters: invoiceListFilters(filters.filter(isFilterCondition), today()), pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n this.totals = totalsOf(response.data.responses.items)\n return { total: response.data.responses.total, records: response.data.responses.items }\n }\n}\n"]}
|
package/dist-client/route.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../client/route.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAY;IACxC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,cAAc;YACjB,MAAM,CAAC,sBAAsB,CAAC,CAAA;YAC9B,OAAO,IAAI,CAAA;QAEb,KAAK,gBAAgB;YACnB,MAAM,CAAC,wBAAwB,CAAC,CAAA;YAChC,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC","sourcesContent":["export default function route(page: string) {\n switch (page) {\n case 'invoice-list':\n import('./pages/invoice-list')\n return page\n\n case 'invoice-editor':\n import('./pages/invoice-editor')\n return page\n }\n}\n"]}
|