@things-factory/invoice 10.1.228 → 10.1.231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/entity360/invoice-360.js +1 -0
- package/dist-client/entity360/invoice-360.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/document-defaults-setting-let.d.ts +0 -6
- package/dist-client/viewparts/document-defaults-setting-let.js +5 -4
- package/dist-client/viewparts/document-defaults-setting-let.js.map +1 -1
- package/dist-server/index.js +2 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/document-defaults/document-defaults-resolver.d.ts +0 -3
- package/dist-server/service/document-defaults/document-defaults-resolver.js +13 -18
- package/dist-server/service/document-defaults/document-defaults-resolver.js.map +1 -1
- package/dist-server/service/document-defaults/document-defaults-rules.d.ts +0 -3
- package/dist-server/service/document-defaults/document-defaults-rules.js +4 -6
- package/dist-server/service/document-defaults/document-defaults-rules.js.map +1 -1
- package/dist-server/service/invoice/invoice-subject.d.ts +9 -0
- package/dist-server/service/invoice/invoice-subject.js +26 -0
- package/dist-server/service/invoice/invoice-subject.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -2,12 +2,6 @@ import '@material/web/button/outlined-button.js';
|
|
|
2
2
|
import '@things-factory/setting-base';
|
|
3
3
|
import { LitElement, nothing } from 'lit';
|
|
4
4
|
declare const DocumentDefaultsSettingLet_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
5
|
-
/**
|
|
6
|
-
* The company's own words for every new quotation and invoice (ADR-0170): our side, the account to pay into, the
|
|
7
|
-
* payment terms offered - one a line, the first a new document's - a standing note, how long an offer holds and how
|
|
8
|
-
* many days after its issue an invoice is due. Shown
|
|
9
|
-
* to whoever keeps the invoices; for anyone else the card stays empty.
|
|
10
|
-
*/
|
|
11
5
|
export declare class DocumentDefaultsSettingLet extends DocumentDefaultsSettingLet_base {
|
|
12
6
|
static styles: import("lit").CSSResult[];
|
|
13
7
|
private value?;
|
|
@@ -10,11 +10,13 @@ import { notify } from '@operato/layout';
|
|
|
10
10
|
import { hasPrivilege } from '@things-factory/auth-base/dist-client';
|
|
11
11
|
import { DOCUMENT_DEFAULTS_FIELDS, documentDefaults } from '../document/document-defaults';
|
|
12
12
|
/**
|
|
13
|
-
* The company's own words for every new quotation and invoice (ADR-0170):
|
|
13
|
+
* The company's own words for every new quotation and invoice (ADR-0170): the account to pay into, the
|
|
14
14
|
* payment terms offered - one a line, the first a new document's - a standing note, how long an offer holds and how
|
|
15
15
|
* many days after its issue an invoice is due. Shown
|
|
16
16
|
* to whoever keeps the invoices; for anyone else the card stays empty.
|
|
17
17
|
*/
|
|
18
|
+
/* Our name, number and address come with the defaults but are 「우리 회사」's, kept on its own card (ADR-0176). */
|
|
19
|
+
const inputOf = ({ supplierName, supplierRegistrationNumber, supplierAddress, ...defaults }) => defaults;
|
|
18
20
|
let DocumentDefaultsSettingLet = class DocumentDefaultsSettingLet extends localize(i18next)(LitElement) {
|
|
19
21
|
constructor() {
|
|
20
22
|
super(...arguments);
|
|
@@ -82,8 +84,7 @@ let DocumentDefaultsSettingLet = class DocumentDefaultsSettingLet extends locali
|
|
|
82
84
|
<setting-let>
|
|
83
85
|
<span slot="title">${i18next.t('title.invoice-document-defaults')}</span>
|
|
84
86
|
<div slot="content" content>
|
|
85
|
-
${
|
|
86
|
-
${prose('supplierAddress', 'field.invoice-party-address')} ${prose('bankDetails', 'field.invoice-bank-details')}
|
|
87
|
+
${prose('bankDetails', 'field.invoice-bank-details')}
|
|
87
88
|
<label class="wide"
|
|
88
89
|
>${i18next.t('field.invoice-payment-terms')} <small>${i18next.t('text.invoice-defaults-terms-hint')}</small>
|
|
89
90
|
<textarea .value=${value.paymentTerms.join('\n')} @input=${(e) => set({ paymentTerms: e.target.value.split('\n') })}></textarea>
|
|
@@ -109,7 +110,7 @@ let DocumentDefaultsSettingLet = class DocumentDefaultsSettingLet extends locali
|
|
|
109
110
|
try {
|
|
110
111
|
const response = await client.mutate({
|
|
111
112
|
mutation: gql(`mutation ($defaults: DocumentDefaultsInput!) { updateDocumentDefaults(defaults: $defaults) { ${DOCUMENT_DEFAULTS_FIELDS} } }`),
|
|
112
|
-
variables: { defaults: this.value }
|
|
113
|
+
variables: { defaults: inputOf(this.value) }
|
|
113
114
|
});
|
|
114
115
|
if (response.errors?.length)
|
|
115
116
|
throw response.errors[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-defaults-setting-let.js","sourceRoot":"","sources":["../../client/viewparts/document-defaults-setting-let.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,8BAA8B,CAAA;AAErC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAEpE,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAyB,MAAM,+BAA+B,CAAA;AAEjH;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"document-defaults-setting-let.js","sourceRoot":"","sources":["../../client/viewparts/document-defaults-setting-let.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,8BAA8B,CAAA;AAErC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa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QACtE,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;QACnB,CAAC;IACH,CAAC;;AA3DgB;IAAhB,KAAK,EAAE;;yDAAiC;AACxB;IAAhB,KAAK,EAAE;;wDAAqB;AAhDlB,0BAA0B;IADtC,aAAa,CAAC,+BAA+B,CAAC;GAClC,0BAA0B,CA2GtC","sourcesContent":["import '@material/web/button/outlined-button.js'\nimport '@things-factory/setting-base'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nimport { DOCUMENT_DEFAULTS_FIELDS, documentDefaults, type DocumentDefaults } from '../document/document-defaults'\n\n/**\n * The company's own words for every new quotation and invoice (ADR-0170): the account to pay into, the\n * payment terms offered - one a line, the first a new document's - a standing note, how long an offer holds and how\n * many days after its issue an invoice is due. Shown\n * to whoever keeps the invoices; for anyone else the card stays empty.\n */\n/* Our name, number and address come with the defaults but are 「우리 회사」's, kept on its own card (ADR-0176). */\nconst inputOf = ({ supplierName, supplierRegistrationNumber, supplierAddress, ...defaults }: DocumentDefaults) => defaults\n\n@customElement('document-defaults-setting-let')\nexport class DocumentDefaultsSettingLet extends localize(i18next)(LitElement) {\n static styles = [\n css`\n div[content] {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));\n gap: var(--spacing-medium, 8px) var(--spacing-large, 12px);\n }\n label {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small, 4px);\n font: var(--label-font);\n color: var(--md-sys-color-on-surface);\n text-transform: var(--label-text-transform);\n }\n label.wide {\n grid-column: 1 / -1;\n }\n small {\n color: var(--md-sys-color-on-surface-variant);\n text-transform: none;\n }\n input,\n textarea {\n box-sizing: border-box;\n width: 100%;\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n padding: var(--input-padding);\n font: var(--input-font);\n text-transform: none;\n }\n textarea {\n min-height: 64px;\n resize: vertical;\n }\n div[actions] {\n grid-column: 1 / -1;\n display: flex;\n justify-content: flex-end;\n }\n `\n ]\n\n @state() private value?: DocumentDefaults\n @state() private busy = false\n\n async connectedCallback() {\n super.connectedCallback()\n if (!(await hasPrivilege({ category: 'invoice', privilege: 'mutation', domainOwnerGranted: true }))) return\n this.value = (await documentDefaults()) ?? undefined\n }\n\n render() {\n const value = this.value\n if (!value) return nothing\n const set = (patch: Partial<DocumentDefaults>) => (this.value = { ...value, ...patch })\n const input = (name: keyof DocumentDefaults, label: string) =>\n html`<label>${i18next.t(label)}<input .value=${String(value[name] ?? '')} @input=${(e: any) => set({ [name]: e.target.value })} /></label>`\n const prose = (name: keyof DocumentDefaults, label: string) =>\n html`<label class=\"wide\">${i18next.t(label)}<textarea .value=${String(value[name] ?? '')} @input=${(e: any) => set({ [name]: e.target.value })}></textarea></label>`\n\n return html`\n <setting-let>\n <span slot=\"title\">${i18next.t('title.invoice-document-defaults')}</span>\n <div slot=\"content\" content>\n ${prose('bankDetails', 'field.invoice-bank-details')}\n <label class=\"wide\"\n >${i18next.t('field.invoice-payment-terms')} <small>${i18next.t('text.invoice-defaults-terms-hint')}</small>\n <textarea .value=${value.paymentTerms.join('\\n')} @input=${(e: any) => set({ paymentTerms: e.target.value.split('\\n') })}></textarea>\n </label>\n ${prose('notes', 'field.invoice-notes')}\n <label\n >${i18next.t('field.invoice-defaults-valid-days')}\n <input type=\"number\" min=\"1\" max=\"365\" .value=${String(value.validDays)} @input=${(e: any) => set({ validDays: Number(e.target.value) })}\n /></label>\n <label\n >${i18next.t('field.invoice-defaults-payment-days')}\n <input type=\"number\" min=\"0\" max=\"365\" .value=${String(value.paymentDays)} @input=${(e: any) => set({ paymentDays: Number(e.target.value) })}\n /></label>\n <div actions>\n <md-outlined-button ?disabled=${this.busy} @click=${() => this.save()}>${i18next.t('button.save')}</md-outlined-button>\n </div>\n </div>\n </setting-let>\n `\n }\n\n private async save() {\n this.busy = true\n try {\n const response = await client.mutate({\n mutation: gql(`mutation ($defaults: DocumentDefaultsInput!) { updateDocumentDefaults(defaults: $defaults) { ${DOCUMENT_DEFAULTS_FIELDS} } }`),\n variables: { defaults: inputOf(this.value!) }\n })\n if (response.errors?.length) throw response.errors[0]\n this.value = response.data.updateDocumentDefaults\n notify({ message: i18next.t('text.saved') })\n } catch (error: any) {\n notify({ level: 'error', message: error?.message ?? String(error) })\n } finally {\n this.busy = false\n }\n }\n}\n"]}
|
package/dist-server/index.js
CHANGED
|
@@ -6,7 +6,9 @@ tslib_1.__exportStar(require("./service"), exports);
|
|
|
6
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
7
|
const role_tasks_1 = require("./role-tasks");
|
|
8
8
|
const invoice_read_1 = require("./service/invoice/invoice-read");
|
|
9
|
+
const invoice_subject_1 = require("./service/invoice/invoice-subject");
|
|
9
10
|
for (const task of role_tasks_1.ROLE_TASKS)
|
|
10
11
|
(0, auth_base_1.registerRoleTask)(task);
|
|
11
12
|
(0, invoice_read_1.registerInvoiceReads)();
|
|
13
|
+
(0, invoice_subject_1.registerInvoiceSubject)();
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oBAAiB;AACjB,oDAAyB;AAEzB,yDAA4D;AAC5D,6CAAyC;AACzC,iEAAqE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oBAAiB;AACjB,oDAAyB;AAEzB,yDAA4D;AAC5D,6CAAyC;AACzC,iEAAqE;AACrE,uEAA0E;AAE1E,KAAK,MAAM,IAAI,IAAI,uBAAU;IAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAA;AACrD,IAAA,mCAAoB,GAAE,CAAA;AACtB,IAAA,wCAAsB,GAAE,CAAA","sourcesContent":["import './routes'\nexport * from './service'\n\nimport { registerRoleTask } from '@things-factory/auth-base'\nimport { ROLE_TASKS } from './role-tasks'\nimport { registerInvoiceReads } from './service/invoice/invoice-read'\nimport { registerInvoiceSubject } from './service/invoice/invoice-subject'\n\nfor (const task of ROLE_TASKS) registerRoleTask(task)\nregisterInvoiceReads()\nregisterInvoiceSubject()\n"]}
|
|
@@ -9,9 +9,6 @@ export declare class DocumentDefaults {
|
|
|
9
9
|
paymentDays: number;
|
|
10
10
|
}
|
|
11
11
|
export declare class DocumentDefaultsInput {
|
|
12
|
-
supplierName?: string;
|
|
13
|
-
supplierRegistrationNumber?: string;
|
|
14
|
-
supplierAddress?: string;
|
|
15
12
|
bankDetails?: string;
|
|
16
13
|
paymentTerms?: string[];
|
|
17
14
|
notes?: string;
|
|
@@ -4,21 +4,22 @@ exports.DocumentDefaultsResolver = exports.DocumentDefaultsInput = exports.Docum
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
7
8
|
const shell_1 = require("@things-factory/shell");
|
|
8
9
|
const document_defaults_rules_1 = require("./document-defaults-rules");
|
|
9
10
|
let DocumentDefaults = class DocumentDefaults {
|
|
10
11
|
};
|
|
11
12
|
exports.DocumentDefaults = DocumentDefaults;
|
|
12
13
|
tslib_1.__decorate([
|
|
13
|
-
(0, type_graphql_1.Field)({ description:
|
|
14
|
+
(0, type_graphql_1.Field)({ description: "Our name as a supplier - 「우리 회사」's (biz-base, ADR-0176)." }),
|
|
14
15
|
tslib_1.__metadata("design:type", String)
|
|
15
16
|
], DocumentDefaults.prototype, "supplierName", void 0);
|
|
16
17
|
tslib_1.__decorate([
|
|
17
|
-
(0, type_graphql_1.Field)({ description:
|
|
18
|
+
(0, type_graphql_1.Field)({ description: "Our business registration number - 「우리 회사」's." }),
|
|
18
19
|
tslib_1.__metadata("design:type", String)
|
|
19
20
|
], DocumentDefaults.prototype, "supplierRegistrationNumber", void 0);
|
|
20
21
|
tslib_1.__decorate([
|
|
21
|
-
(0, type_graphql_1.Field)({ description:
|
|
22
|
+
(0, type_graphql_1.Field)({ description: "Our address - 「우리 회사」's." }),
|
|
22
23
|
tslib_1.__metadata("design:type", String)
|
|
23
24
|
], DocumentDefaults.prototype, "supplierAddress", void 0);
|
|
24
25
|
tslib_1.__decorate([
|
|
@@ -47,18 +48,6 @@ exports.DocumentDefaults = DocumentDefaults = tslib_1.__decorate([
|
|
|
47
48
|
let DocumentDefaultsInput = class DocumentDefaultsInput {
|
|
48
49
|
};
|
|
49
50
|
exports.DocumentDefaultsInput = DocumentDefaultsInput;
|
|
50
|
-
tslib_1.__decorate([
|
|
51
|
-
(0, type_graphql_1.Field)({ nullable: true, description: 'Our name as a supplier.' }),
|
|
52
|
-
tslib_1.__metadata("design:type", String)
|
|
53
|
-
], DocumentDefaultsInput.prototype, "supplierName", void 0);
|
|
54
|
-
tslib_1.__decorate([
|
|
55
|
-
(0, type_graphql_1.Field)({ nullable: true, description: 'Our business registration number.' }),
|
|
56
|
-
tslib_1.__metadata("design:type", String)
|
|
57
|
-
], DocumentDefaultsInput.prototype, "supplierRegistrationNumber", void 0);
|
|
58
|
-
tslib_1.__decorate([
|
|
59
|
-
(0, type_graphql_1.Field)({ nullable: true, description: 'Our address.' }),
|
|
60
|
-
tslib_1.__metadata("design:type", String)
|
|
61
|
-
], DocumentDefaultsInput.prototype, "supplierAddress", void 0);
|
|
62
51
|
tslib_1.__decorate([
|
|
63
52
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The account to pay into, as printed.' }),
|
|
64
53
|
tslib_1.__metadata("design:type", String)
|
|
@@ -80,8 +69,13 @@ tslib_1.__decorate([
|
|
|
80
69
|
tslib_1.__metadata("design:type", Number)
|
|
81
70
|
], DocumentDefaultsInput.prototype, "paymentDays", void 0);
|
|
82
71
|
exports.DocumentDefaultsInput = DocumentDefaultsInput = tslib_1.__decorate([
|
|
83
|
-
(0, type_graphql_1.InputType)({ description: "The company's own words for new documents, whole - what is left out is emptied." })
|
|
72
|
+
(0, type_graphql_1.InputType)({ description: "The company's own words for new documents, whole - what is left out is emptied. Our name, number and address are kept as 「우리 회사」." })
|
|
84
73
|
], DocumentDefaultsInput);
|
|
74
|
+
/** Our side of a sales document - 「우리 회사」 as biz-base keeps it (ADR-0176 decision 4). */
|
|
75
|
+
async function ourSide(domain, manager) {
|
|
76
|
+
const company = await (0, biz_base_1.printedCompanyOf)(domain, { manager });
|
|
77
|
+
return { supplierName: company.name, supplierRegistrationNumber: company.brn, supplierAddress: company.address };
|
|
78
|
+
}
|
|
85
79
|
/** The attribute as this domain sees it - its own, else its closest ancestor's. */
|
|
86
80
|
async function storedValue(domain, manager) {
|
|
87
81
|
const ids = await (0, shell_1.getDomainIdsWithAncestors)(domain);
|
|
@@ -95,7 +89,8 @@ async function storedValue(domain, manager) {
|
|
|
95
89
|
let DocumentDefaultsResolver = class DocumentDefaultsResolver {
|
|
96
90
|
async documentDefaults(context) {
|
|
97
91
|
const { domain, tx } = context.state;
|
|
98
|
-
|
|
92
|
+
const manager = tx ?? (0, shell_1.getDataSource)().manager;
|
|
93
|
+
return { ...(await ourSide(domain, manager)), ...(0, document_defaults_rules_1.storedDocumentDefaults)(await storedValue(domain, manager)) };
|
|
99
94
|
}
|
|
100
95
|
async updateDocumentDefaults(defaults, context) {
|
|
101
96
|
const { domain, tx } = context.state;
|
|
@@ -107,7 +102,7 @@ let DocumentDefaultsResolver = class DocumentDefaultsResolver {
|
|
|
107
102
|
await repository.save({ ...own, value, active: true });
|
|
108
103
|
else
|
|
109
104
|
await repository.save({ domain, name: document_defaults_rules_1.DOCUMENT_DEFAULTS_ATTRIBUTE, value, active: true, description: 'Quotation and invoice defaults (ADR-0170) - set on the Settings screen' });
|
|
110
|
-
return kept;
|
|
105
|
+
return { ...(await ourSide(domain, tx)), ...kept };
|
|
111
106
|
}
|
|
112
107
|
};
|
|
113
108
|
exports.DocumentDefaultsResolver = DocumentDefaultsResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-defaults-resolver.js","sourceRoot":"","sources":["../../../server/service/document-defaults/document-defaults-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA+H;AAC/H,qCAA4B;AAE5B,iDAA6H;AAE7H,uEAAmH;AAG5G,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAS5B,CAAA;AATY,4CAAgB;
|
|
1
|
+
{"version":3,"file":"document-defaults-resolver.js","sourceRoot":"","sources":["../../../server/service/document-defaults/document-defaults-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA+H;AAC/H,qCAA4B;AAE5B,uDAA2D;AAC3D,iDAA6H;AAE7H,uEAAmH;AAG5G,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAS5B,CAAA;AATY,4CAAgB;AACyD;IAAnF,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,0DAA0D,EAAE,CAAC;;sDAAqB;AAC/B;IAAxE,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;;oEAAmC;AACvD;IAAnD,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;;yDAAwB;AACX;IAA/D,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;qDAAoB;AAC0D;IAA5I,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,iGAAiG,EAAE,CAAC;;sDAAuB;AACrG;IAA7D,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;;+CAAc;AACS;IAA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CAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,wEAAwE,EAAE,CAAC;IACnG,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAA;IAAmC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAA7B,qBAAqB;;sEAS3G;mCArBU,wBAAwB;IAFpC,IAAA,uBAAQ,GAAE;IACV,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,wBAAwB,CAsBpC","sourcesContent":["import { Arg, Ctx, Directive, Field, InputType, Int, Mutation, ObjectType, Query, Resolver, UseMiddleware } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { printedCompanyOf } from '@things-factory/biz-base'\nimport { dedupByClosestDomain, EnvVar, getDataSource, getDomainIdsWithAncestors, SpeakRefusals } from '@things-factory/shell'\n\nimport { DOCUMENT_DEFAULTS_ATTRIBUTE, documentDefaultsOf, storedDocumentDefaults } from './document-defaults-rules'\n\n@ObjectType({ description: \"The company's own words every new quotation and invoice starts with (ADR-0170).\" })\nexport class DocumentDefaults {\n @Field({ description: \"Our name as a supplier - 「우리 회사」's (biz-base, ADR-0176).\" }) supplierName: string\n @Field({ description: \"Our business registration number - 「우리 회사」's.\" }) supplierRegistrationNumber: string\n @Field({ description: \"Our address - 「우리 회사」's.\" }) supplierAddress: string\n @Field({ description: 'The account to pay into, as printed.' }) bankDetails: string\n @Field(type => [String], { description: 'The payment terms the company offers - the first is a new document\\'s, the others a click away.' }) paymentTerms: string[]\n @Field({ description: 'A note every new document carries.' }) notes: string\n @Field(type => Int, { description: 'Days a quotation holds after its issue day.' }) validDays: number\n @Field(type => Int, { description: 'Days an invoice is due after its issue day.' }) paymentDays: number\n}\n\n@InputType({ description: \"The company's own words for new documents, whole - what is left out is emptied. Our name, number and address are kept as 「우리 회사」.\" })\nexport class DocumentDefaultsInput {\n @Field({ nullable: true, description: 'The account to pay into, as printed.' }) bankDetails?: string\n @Field(type => [String], { nullable: true, description: 'The payment terms the company offers, in order.' }) paymentTerms?: string[]\n @Field({ nullable: true, description: 'A note every new document carries.' }) notes?: string\n @Field(type => Int, { nullable: true, description: 'Days a quotation holds after its issue day (1 to 365).' }) validDays?: number\n @Field(type => Int, { nullable: true, description: 'Days an invoice is due after its issue day (0 to 365).' }) paymentDays?: number\n}\n\n/** Our side of a sales document - 「우리 회사」 as biz-base keeps it (ADR-0176 decision 4). */\nasync function ourSide(domain: any, manager: any) {\n const company = await printedCompanyOf(domain, { manager })\n return { supplierName: company.name, supplierRegistrationNumber: company.brn, supplierAddress: company.address }\n}\n\n/** The attribute as this domain sees it - its own, else its closest ancestor's. */\nasync function storedValue(domain: any, manager: any): Promise<string | undefined> {\n const ids = await getDomainIdsWithAncestors(domain)\n const all: EnvVar[] = await manager.getRepository(EnvVar).find({ where: { domain: { id: In(ids) }, name: DOCUMENT_DEFAULTS_ATTRIBUTE, active: true } })\n return dedupByClosestDomain(all, ids, one => one.name)[0]?.value\n}\n\n/**\n * The company's words for new quotations and invoices (ADR-0170). Read by whoever writes either document\n * (`invoice-published`); changed by whoever keeps the invoices (`invoice:mutation`), on the Settings screen.\n */\n@Resolver()\n@UseMiddleware(SpeakRefusals)\nexport class DocumentDefaultsResolver {\n @Directive('@privilege(category: \"invoice-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => DocumentDefaults, { description: \"The company's own words every new quotation and invoice starts with.\" })\n async documentDefaults(@Ctx() context: ResolverContext): Promise<DocumentDefaults> {\n const { domain, tx } = context.state as any\n const manager = tx ?? getDataSource().manager\n return { ...(await ourSide(domain, manager)), ...storedDocumentDefaults(await storedValue(domain, manager)) }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"invoice\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => DocumentDefaults, { description: \"To set the company's own words for new quotations and invoices, whole.\" })\n async updateDocumentDefaults(@Arg('defaults', type => DocumentDefaultsInput) defaults: DocumentDefaultsInput, @Ctx() context: ResolverContext): Promise<DocumentDefaults> {\n const { domain, tx } = context.state as any\n const kept = documentDefaultsOf(defaults)\n const repository = tx.getRepository(EnvVar)\n const own = await repository.findOne({ where: { domain: { id: domain.id }, name: DOCUMENT_DEFAULTS_ATTRIBUTE } })\n const value = JSON.stringify(kept)\n if (own) await repository.save({ ...own, value, active: true })\n else await repository.save({ domain, name: DOCUMENT_DEFAULTS_ATTRIBUTE, value, active: true, description: 'Quotation and invoice defaults (ADR-0170) - set on the Settings screen' })\n return { ...(await ourSide(domain, tx)), ...kept }\n }\n}\n"]}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export interface DocumentDefaultsValue {
|
|
2
|
-
supplierName: string;
|
|
3
|
-
supplierRegistrationNumber: string;
|
|
4
|
-
supplierAddress: string;
|
|
5
2
|
bankDetails: string;
|
|
6
3
|
/** The payment terms the company offers, in the order they are offered - the first is a new document's. */
|
|
7
4
|
paymentTerms: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* The company's own words for every quotation and invoice it writes (ADR-0170):
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The company's own words for every quotation and invoice it writes (ADR-0170): the account to pay into, the payment
|
|
4
|
+
* terms it offers (several - one is picked per document), a standing note, and how long an offer holds. Pure - the
|
|
5
|
+
* resolver keeps them as one domain attribute. Our name, number and address are 「우리 회사」's, kept by biz-base
|
|
6
|
+
* (ADR-0176 decision 4) and read beside these.
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.DOCUMENT_DEFAULTS_ATTRIBUTE = exports.MAX_PAYMENT_TERMS = exports.DEFAULT_PAYMENT_DAYS = exports.DEFAULT_VALID_DAYS = void 0;
|
|
@@ -28,9 +29,6 @@ function documentDefaultsOf(input) {
|
|
|
28
29
|
const days = Math.round(Number(input?.validDays));
|
|
29
30
|
const payment = input?.paymentDays === null || input?.paymentDays === undefined || input?.paymentDays === '' ? NaN : Math.round(Number(input.paymentDays));
|
|
30
31
|
return {
|
|
31
|
-
supplierName: text(input?.supplierName),
|
|
32
|
-
supplierRegistrationNumber: text(input?.supplierRegistrationNumber),
|
|
33
|
-
supplierAddress: text(input?.supplierAddress),
|
|
34
32
|
bankDetails: text(input?.bankDetails),
|
|
35
33
|
paymentTerms: terms,
|
|
36
34
|
notes: text(input?.notes),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-defaults-rules.js","sourceRoot":"","sources":["../../../server/service/document-defaults/document-defaults-rules.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"document-defaults-rules.js","sourceRoot":"","sources":["../../../server/service/document-defaults/document-defaults-rules.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA0BH,gDAeC;AAGD,wDAMC;AArCY,QAAA,kBAAkB,GAAG,EAAE,CAAA;AACvB,QAAA,oBAAoB,GAAG,EAAE,CAAA;AACzB,QAAA,iBAAiB,GAAG,EAAE,CAAA;AAEnC,yCAAyC;AAC5B,QAAA,2BAA2B,GAAG,2BAA2B,CAAA;AAEtE,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAEhF;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,KAAU;IAC3C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC/E,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACtB,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KA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): the account to pay into, the payment\n * terms it offers (several - one is picked per document), a standing note, and how long an offer holds. Pure - the\n * resolver keeps them as one domain attribute. Our name, number and address are 「우리 회사」's, kept by biz-base\n * (ADR-0176 decision 4) and read beside these.\n */\n\nexport interface DocumentDefaultsValue {\n bankDetails: string\n /** The payment terms the company offers, in the order they are offered - the first is a new document's. */\n paymentTerms: string[]\n notes: string\n /** Days a quotation holds after its issue day. */\n validDays: number\n /** Days an invoice is due after its issue day - none means due on the day. */\n paymentDays: number\n}\n\nexport const DEFAULT_VALID_DAYS = 30\nexport const DEFAULT_PAYMENT_DAYS = 30\nexport const MAX_PAYMENT_TERMS = 10\n\n/** The attribute they are kept under. */\nexport const DOCUMENT_DEFAULTS_ATTRIBUTE = 'Invoice::documentDefaults'\n\nconst text = (value: unknown) => (typeof value === 'string' ? value.trim() : '')\n\n/**\n * What is kept: words trimmed, terms without blanks or repeats and at most ten, the days an offer holds a whole number\n * from 1 to 365 and the days an invoice is due one from 0 to 365.\n */\nexport function documentDefaultsOf(input: any): DocumentDefaultsValue {\n const terms: string[] = []\n for (const one of Array.isArray(input?.paymentTerms) ? input.paymentTerms : []) {\n const term = text(one)\n if (term && !terms.includes(term) && terms.length < MAX_PAYMENT_TERMS) terms.push(term)\n }\n const days = Math.round(Number(input?.validDays))\n const payment = input?.paymentDays === null || input?.paymentDays === undefined || input?.paymentDays === '' ? NaN : Math.round(Number(input.paymentDays))\n return {\n bankDetails: text(input?.bankDetails),\n paymentTerms: terms,\n notes: text(input?.notes),\n validDays: Number.isFinite(days) && days >= 1 && days <= 365 ? days : DEFAULT_VALID_DAYS,\n paymentDays: Number.isFinite(payment) && payment >= 0 && payment <= 365 ? payment : DEFAULT_PAYMENT_DAYS\n }\n}\n\n/** The kept attribute read back - nothing kept, or something unreadable, is the empty defaults. */\nexport function storedDocumentDefaults(value: string | null | undefined): DocumentDefaultsValue {\n try {\n return documentDefaultsOf(value ? JSON.parse(value) : {})\n } catch {\n return documentDefaultsOf({})\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The invoice whose 360 is open, named for the AI each turn (operato-application design/ai/screen-pattern.md §2-1).
|
|
3
|
+
*
|
|
4
|
+
* The 360 kind `invoice` anchors its conversation to `invoice:<uuid>`; the record is named only for someone the
|
|
5
|
+
* 360's own read (`Query.invoice`) lets through.
|
|
6
|
+
*/
|
|
7
|
+
import { type RecordSubject } from '@things-factory/ai-assistant';
|
|
8
|
+
export declare const INVOICE_SUBJECT: RecordSubject;
|
|
9
|
+
export declare function registerInvoiceSubject(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INVOICE_SUBJECT = void 0;
|
|
4
|
+
exports.registerInvoiceSubject = registerInvoiceSubject;
|
|
5
|
+
/**
|
|
6
|
+
* The invoice whose 360 is open, named for the AI each turn (operato-application design/ai/screen-pattern.md §2-1).
|
|
7
|
+
*
|
|
8
|
+
* The 360 kind `invoice` anchors its conversation to `invoice:<uuid>`; the record is named only for someone the
|
|
9
|
+
* 360's own read (`Query.invoice`) lets through.
|
|
10
|
+
*/
|
|
11
|
+
const ai_assistant_1 = require("@things-factory/ai-assistant");
|
|
12
|
+
const shell_1 = require("@things-factory/shell");
|
|
13
|
+
/** The other party as the 360 titles it: the supplier of a purchase, the buyer of a sale. */
|
|
14
|
+
const counterpartOf = (row) => (row.direction === 'PURCHASE' ? row.supplierName : row.buyerName) || '';
|
|
15
|
+
/* By entity name - the entity's decorators stay out of what a test of this has to load. */
|
|
16
|
+
exports.INVOICE_SUBJECT = {
|
|
17
|
+
axis: 'invoice',
|
|
18
|
+
noun: 'invoice',
|
|
19
|
+
door: 'Query.invoice',
|
|
20
|
+
read: (rowId, domainId) => (0, shell_1.getRepository)('Invoice').findOne({ where: { id: rowId, domain: { id: domainId } } }),
|
|
21
|
+
nameOf: row => [row.number, counterpartOf(row)].filter(Boolean).join(' ')
|
|
22
|
+
};
|
|
23
|
+
function registerInvoiceSubject() {
|
|
24
|
+
(0, ai_assistant_1.registerRecordSubject)(exports.INVOICE_SUBJECT);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=invoice-subject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-subject.js","sourceRoot":"","sources":["../../../server/service/invoice/invoice-subject.ts"],"names":[],"mappings":";;;AAqBA,wDAEC;AAvBD;;;;;GAKG;AACH,+DAAwF;AACxF,iDAAqD;AAErD,6FAA6F;AAC7F,MAAM,aAAa,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;AAE3G,2FAA2F;AAC9E,QAAA,eAAe,GAAkB;IAC5C,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAS,EAAE,CAAC;IACtH,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;CAC1E,CAAA;AAED,SAAgB,sBAAsB;IACpC,IAAA,oCAAqB,EAAC,uBAAe,CAAC,CAAA;AACxC,CAAC","sourcesContent":["/**\n * The invoice whose 360 is open, named for the AI each turn (operato-application design/ai/screen-pattern.md §2-1).\n *\n * The 360 kind `invoice` anchors its conversation to `invoice:<uuid>`; the record is named only for someone the\n * 360's own read (`Query.invoice`) lets through.\n */\nimport { registerRecordSubject, type RecordSubject } from '@things-factory/ai-assistant'\nimport { getRepository } from '@things-factory/shell'\n\n/** The other party as the 360 titles it: the supplier of a purchase, the buyer of a sale. */\nconst counterpartOf = (row: any) => (row.direction === 'PURCHASE' ? row.supplierName : row.buyerName) || ''\n\n/* By entity name - the entity's decorators stay out of what a test of this has to load. */\nexport const INVOICE_SUBJECT: RecordSubject = {\n axis: 'invoice',\n noun: 'invoice',\n door: 'Query.invoice',\n read: (rowId, domainId) => getRepository('Invoice').findOne({ where: { id: rowId, domain: { id: domainId } } as any }),\n nameOf: row => [row.number, counterpartOf(row)].filter(Boolean).join(' ')\n}\n\nexport function registerInvoiceSubject(): void {\n registerRecordSubject(INVOICE_SUBJECT)\n}\n"]}
|