@things-factory/asset 0.0.0-stage β†’ 10.1.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist-client/components/asset-documents.d.ts +22 -0
  2. package/dist-client/components/asset-documents.js +190 -0
  3. package/dist-client/components/asset-documents.js.map +1 -0
  4. package/dist-client/grid.d.ts +13 -0
  5. package/dist-client/grid.js +56 -0
  6. package/dist-client/grid.js.map +1 -0
  7. package/dist-client/index.d.ts +1 -0
  8. package/dist-client/index.js +2 -0
  9. package/dist-client/index.js.map +1 -0
  10. package/dist-client/pages/asset-list.d.ts +53 -0
  11. package/dist-client/pages/asset-list.js +171 -0
  12. package/dist-client/pages/asset-list.js.map +1 -0
  13. package/dist-client/pages/asset-reconciliation.d.ts +25 -0
  14. package/dist-client/pages/asset-reconciliation.js +165 -0
  15. package/dist-client/pages/asset-reconciliation.js.map +1 -0
  16. package/dist-client/pages/investee-page.d.ts +47 -0
  17. package/dist-client/pages/investee-page.js +322 -0
  18. package/dist-client/pages/investee-page.js.map +1 -0
  19. package/dist-client/pages/investment-list.d.ts +53 -0
  20. package/dist-client/pages/investment-list.js +131 -0
  21. package/dist-client/pages/investment-list.js.map +1 -0
  22. package/dist-client/route.d.ts +1 -0
  23. package/dist-client/route.js +18 -0
  24. package/dist-client/route.js.map +1 -0
  25. package/dist-client/tsconfig.tsbuildinfo +1 -0
  26. package/dist-client/words.d.ts +25 -0
  27. package/dist-client/words.js +23 -0
  28. package/dist-client/words.js.map +1 -0
  29. package/dist-server/attachment-reader.d.ts +3 -0
  30. package/dist-server/attachment-reader.js +20 -0
  31. package/dist-server/attachment-reader.js.map +1 -0
  32. package/dist-server/index.d.ts +1 -0
  33. package/dist-server/index.js +11 -0
  34. package/dist-server/index.js.map +1 -0
  35. package/dist-server/role-tasks.d.ts +2 -0
  36. package/dist-server/role-tasks.js +13 -0
  37. package/dist-server/role-tasks.js.map +1 -0
  38. package/dist-server/service/asset/asset-mutation.d.ts +5 -0
  39. package/dist-server/service/asset/asset-mutation.js +31 -0
  40. package/dist-server/service/asset/asset-mutation.js.map +1 -0
  41. package/dist-server/service/asset/asset-query.d.ts +19 -0
  42. package/dist-server/service/asset/asset-query.js +108 -0
  43. package/dist-server/service/asset/asset-query.js.map +1 -0
  44. package/dist-server/service/asset/asset-rules.d.ts +87 -0
  45. package/dist-server/service/asset/asset-rules.js +148 -0
  46. package/dist-server/service/asset/asset-rules.js.map +1 -0
  47. package/dist-server/service/asset/asset-service.d.ts +23 -0
  48. package/dist-server/service/asset/asset-service.js +84 -0
  49. package/dist-server/service/asset/asset-service.js.map +1 -0
  50. package/dist-server/service/asset/asset-type.d.ts +48 -0
  51. package/dist-server/service/asset/asset-type.js +182 -0
  52. package/dist-server/service/asset/asset-type.js.map +1 -0
  53. package/dist-server/service/asset/asset.d.ts +38 -0
  54. package/dist-server/service/asset/asset.js +159 -0
  55. package/dist-server/service/asset/asset.js.map +1 -0
  56. package/dist-server/service/asset/index.d.ts +6 -0
  57. package/dist-server/service/asset/index.js +10 -0
  58. package/dist-server/service/asset/index.js.map +1 -0
  59. package/dist-server/service/asset-document/asset-document-resolver.d.ts +32 -0
  60. package/dist-server/service/asset-document/asset-document-resolver.js +94 -0
  61. package/dist-server/service/asset-document/asset-document-resolver.js.map +1 -0
  62. package/dist-server/service/asset-document/asset-document-service.d.ts +34 -0
  63. package/dist-server/service/asset-document/asset-document-service.js +79 -0
  64. package/dist-server/service/asset-document/asset-document-service.js.map +1 -0
  65. package/dist-server/service/asset-document/index.d.ts +4 -0
  66. package/dist-server/service/asset-document/index.js +8 -0
  67. package/dist-server/service/asset-document/index.js.map +1 -0
  68. package/dist-server/service/checks.d.ts +12 -0
  69. package/dist-server/service/checks.js +27 -0
  70. package/dist-server/service/checks.js.map +1 -0
  71. package/dist-server/service/index.d.ts +18 -0
  72. package/dist-server/service/index.js +40 -0
  73. package/dist-server/service/index.js.map +1 -0
  74. package/dist-server/service/investment/index.d.ts +11 -0
  75. package/dist-server/service/investment/index.js +15 -0
  76. package/dist-server/service/investment/index.js.map +1 -0
  77. package/dist-server/service/investment/investee.d.ts +33 -0
  78. package/dist-server/service/investment/investee.js +135 -0
  79. package/dist-server/service/investment/investee.js.map +1 -0
  80. package/dist-server/service/investment/investment-board-seat.d.ts +25 -0
  81. package/dist-server/service/investment/investment-board-seat.js +98 -0
  82. package/dist-server/service/investment/investment-board-seat.js.map +1 -0
  83. package/dist-server/service/investment/investment-filing.d.ts +29 -0
  84. package/dist-server/service/investment/investment-filing.js +113 -0
  85. package/dist-server/service/investment/investment-filing.js.map +1 -0
  86. package/dist-server/service/investment/investment-holding.d.ts +31 -0
  87. package/dist-server/service/investment/investment-holding.js +127 -0
  88. package/dist-server/service/investment/investment-holding.js.map +1 -0
  89. package/dist-server/service/investment/investment-mutation.d.ts +15 -0
  90. package/dist-server/service/investment/investment-mutation.js +112 -0
  91. package/dist-server/service/investment/investment-mutation.js.map +1 -0
  92. package/dist-server/service/investment/investment-query.d.ts +33 -0
  93. package/dist-server/service/investment/investment-query.js +192 -0
  94. package/dist-server/service/investment/investment-query.js.map +1 -0
  95. package/dist-server/service/investment/investment-report.d.ts +37 -0
  96. package/dist-server/service/investment/investment-report.js +152 -0
  97. package/dist-server/service/investment/investment-report.js.map +1 -0
  98. package/dist-server/service/investment/investment-request.d.ts +31 -0
  99. package/dist-server/service/investment/investment-request.js +123 -0
  100. package/dist-server/service/investment/investment-request.js.map +1 -0
  101. package/dist-server/service/investment/investment-rules.d.ts +81 -0
  102. package/dist-server/service/investment/investment-rules.js +121 -0
  103. package/dist-server/service/investment/investment-rules.js.map +1 -0
  104. package/dist-server/service/investment/investment-service.d.ts +34 -0
  105. package/dist-server/service/investment/investment-service.js +280 -0
  106. package/dist-server/service/investment/investment-service.js.map +1 -0
  107. package/dist-server/service/investment/investment-type.d.ts +85 -0
  108. package/dist-server/service/investment/investment-type.js +324 -0
  109. package/dist-server/service/investment/investment-type.js.map +1 -0
  110. package/dist-server/service/patches.d.ts +24 -0
  111. package/dist-server/service/patches.js +63 -0
  112. package/dist-server/service/patches.js.map +1 -0
  113. package/dist-server/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +49 -4
  115. package/things-factory.config.js +11 -0
  116. package/translations/en.json +187 -0
  117. package/translations/es.json +187 -0
  118. package/translations/ja.json +187 -0
  119. package/translations/ko.json +187 -0
  120. package/translations/ms.json +187 -0
  121. package/translations/zh.json +187 -0
  122. package/README.md +0 -3
@@ -0,0 +1,22 @@
1
+ import '@operato/input/ox-input-file.js';
2
+ import { LitElement } from 'lit';
3
+ /**
4
+ * The papers of one row of the register - a contract, a certificate, a report, a signed copy (ADR-0175). Picked files
5
+ * are attached at once; taking one off keeps the file (the server moves it aside).
6
+ */
7
+ export declare class AssetDocuments extends LitElement {
8
+ static styles: import("lit").CSSResult;
9
+ owner: string;
10
+ ownerId: string;
11
+ rows: any[];
12
+ busy: boolean;
13
+ progress?: number;
14
+ failure: string;
15
+ /** Open a row's papers in a popup; `changed` runs when files were attached or taken off. */
16
+ static open(owner: string, ownerId: string, title: string, changed?: () => void): import("@operato/layout").PopupHandle<unknown>;
17
+ connectedCallback(): void;
18
+ private read;
19
+ private upload;
20
+ private takeOff;
21
+ render(): import("lit-html").TemplateResult<1>;
22
+ }
@@ -0,0 +1,190 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/input/ox-input-file.js';
3
+ import gql from 'graphql-tag';
4
+ import { css, html, LitElement, nothing } from 'lit';
5
+ import { customElement, property, state } from 'lit/decorators.js';
6
+ import { client, uploadContext } from '@operato/graphql';
7
+ import { i18next } from '@operato/i18n';
8
+ import { openPopup } from '@operato/layout';
9
+ import { OxPrompt } from '@operato/popup/ox-prompt.js';
10
+ import { failureOf } from '../grid.js';
11
+ /**
12
+ * The papers of one row of the register - a contract, a certificate, a report, a signed copy (ADR-0175). Picked files
13
+ * are attached at once; taking one off keeps the file (the server moves it aside).
14
+ */
15
+ let AssetDocuments = class AssetDocuments extends LitElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.owner = '';
19
+ this.ownerId = '';
20
+ this.rows = [];
21
+ this.busy = false;
22
+ this.failure = '';
23
+ }
24
+ static { this.styles = css `
25
+ :host {
26
+ display: flex;
27
+ flex-direction: column;
28
+ gap: var(--spacing-medium, 8px);
29
+ padding: var(--spacing-large, 12px);
30
+ min-height: 200px;
31
+ }
32
+ table {
33
+ width: 100%;
34
+ border-collapse: collapse;
35
+ font-size: var(--ui-t-body, 14px);
36
+ }
37
+ td {
38
+ padding: 6px 4px;
39
+ border-bottom: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
40
+ }
41
+ td.num {
42
+ text-align: right;
43
+ white-space: nowrap;
44
+ color: var(--md-sys-color-on-surface-variant);
45
+ }
46
+ .none {
47
+ color: var(--md-sys-color-on-surface-variant);
48
+ }
49
+ .failure {
50
+ color: var(--md-sys-color-error);
51
+ }
52
+ button[quiet] {
53
+ border: none;
54
+ background: none;
55
+ color: var(--md-sys-color-error);
56
+ font: inherit;
57
+ cursor: pointer;
58
+ }
59
+ `; }
60
+ /** Open a row's papers in a popup; `changed` runs when files were attached or taken off. */
61
+ static open(owner, ownerId, title, changed) {
62
+ const popup = openPopup(html `<asset-documents .owner=${owner} .ownerId=${ownerId}></asset-documents>`, { backdrop: true, size: 'medium', title });
63
+ popup.onclosed = () => changed?.();
64
+ return popup;
65
+ }
66
+ connectedCallback() {
67
+ super.connectedCallback();
68
+ this.read();
69
+ }
70
+ async read() {
71
+ if (!this.owner || !this.ownerId)
72
+ return;
73
+ try {
74
+ const response = await client.query({
75
+ query: gql `
76
+ query ($owner: AssetDocumentOwner!, $id: String!) {
77
+ assetDocuments(owner: $owner, id: $id) { id name size fullpath createdAt creator }
78
+ }
79
+ `,
80
+ variables: { owner: this.owner, id: this.ownerId },
81
+ fetchPolicy: 'network-only'
82
+ });
83
+ if (response.errors?.length)
84
+ throw response;
85
+ this.rows = response.data.assetDocuments;
86
+ }
87
+ catch (error) {
88
+ this.failure = failureOf(error);
89
+ }
90
+ }
91
+ async upload(files) {
92
+ if (!files.length || this.busy)
93
+ return;
94
+ this.busy = true;
95
+ this.failure = '';
96
+ try {
97
+ const response = await client.mutate({
98
+ mutation: gql `
99
+ mutation ($owner: AssetDocumentOwner!, $id: String!, $files: [Upload!]!) {
100
+ attachAssetDocuments(owner: $owner, id: $id, files: $files) { id }
101
+ }
102
+ `,
103
+ variables: { owner: this.owner, id: this.ownerId, files },
104
+ context: uploadContext((fraction) => (this.progress = fraction))
105
+ });
106
+ if (response.errors?.length)
107
+ throw response;
108
+ await this.read();
109
+ }
110
+ catch (error) {
111
+ this.failure = failureOf(error);
112
+ }
113
+ finally {
114
+ this.busy = false;
115
+ this.progress = undefined;
116
+ this.renderRoot.querySelector('ox-input-file')?.reset();
117
+ }
118
+ }
119
+ async takeOff(one) {
120
+ const confirmed = await OxPrompt.open({
121
+ title: i18next.t('button.asset-document-remove'),
122
+ text: i18next.t('text.asset-document-remove-confirm', { name: one.name }),
123
+ confirmButton: { text: i18next.t('button.asset-document-remove') },
124
+ cancelButton: { text: i18next.t('button.cancel') }
125
+ });
126
+ if (!confirmed)
127
+ return;
128
+ try {
129
+ const response = await client.mutate({ mutation: gql `mutation ($id: String!) { removeAssetDocument(id: $id) }`, variables: { id: one.id } });
130
+ if (response.errors?.length)
131
+ throw response;
132
+ await this.read();
133
+ }
134
+ catch (error) {
135
+ this.failure = failureOf(error);
136
+ }
137
+ }
138
+ render() {
139
+ const size = (bytes) => (bytes ? (bytes >= 1048576 ? `${(bytes / 1048576).toFixed(1)}MB` : `${Math.max(1, Math.round(bytes / 1024))}KB`) : '');
140
+ return html `
141
+ <ox-input-file
142
+ multiple
143
+ .label=${i18next.t('button.asset-document-attach')}
144
+ .progress=${this.progress}
145
+ ?disabled=${this.busy && this.progress === undefined}
146
+ @change=${(e) => this.upload([...(e.detail ?? [])])}
147
+ ></ox-input-file>
148
+ ${this.rows.length
149
+ ? html `<table>
150
+ ${this.rows.map(one => html `<tr>
151
+ <td><a href=${one.fullpath} target="_blank" rel="noopener">${one.name}</a></td>
152
+ <td class="num">${size(one.size)}</td>
153
+ <td class="num">${one.createdAt ? new Date(one.createdAt).toLocaleDateString() : ''}${one.creator ? ` Β· ${one.creator}` : ''}</td>
154
+ <td class="num"><button quiet ?disabled=${this.busy} @click=${() => this.takeOff(one)}>${i18next.t('button.asset-document-remove')}</button></td>
155
+ </tr>`)}
156
+ </table>`
157
+ : html `<div class="none">${i18next.t('text.asset-documents-none')}</div>`}
158
+ ${this.failure ? html `<div class="failure" role="alert">${this.failure}</div>` : nothing}
159
+ `;
160
+ }
161
+ };
162
+ __decorate([
163
+ property(),
164
+ __metadata("design:type", Object)
165
+ ], AssetDocuments.prototype, "owner", void 0);
166
+ __decorate([
167
+ property(),
168
+ __metadata("design:type", Object)
169
+ ], AssetDocuments.prototype, "ownerId", void 0);
170
+ __decorate([
171
+ state(),
172
+ __metadata("design:type", Array)
173
+ ], AssetDocuments.prototype, "rows", void 0);
174
+ __decorate([
175
+ state(),
176
+ __metadata("design:type", Object)
177
+ ], AssetDocuments.prototype, "busy", void 0);
178
+ __decorate([
179
+ state(),
180
+ __metadata("design:type", Number)
181
+ ], AssetDocuments.prototype, "progress", void 0);
182
+ __decorate([
183
+ state(),
184
+ __metadata("design:type", Object)
185
+ ], AssetDocuments.prototype, "failure", void 0);
186
+ AssetDocuments = __decorate([
187
+ customElement('asset-documents')
188
+ ], AssetDocuments);
189
+ export { AssetDocuments };
190
+ //# sourceMappingURL=asset-documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-documents.js","sourceRoot":"","sources":["../../client/components/asset-documents.ts"],"names":[],"mappings":";AAAA,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,aA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AC,CAAC,2BAA2B,CAAC,QAAQ;QACzE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,qCAAqC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,OAAO;KACzF,CAAA;IACH,CAAC;;AAxGW;IAAX,QAAQ,EAAE;;6CAAW;AACV;IAAX,QAAQ,EAAE;;+CAAa;AACf;IAAR,KAAK,EAAE;;4CAAiB;AAChB;IAAR,KAAK,EAAE;;4CAAa;AACZ;IAAR,KAAK,EAAE;;gDAAkB;AACjB;IAAR,KAAK,EAAE;;+CAAa;AA3CV,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CA+I1B","sourcesContent":["import '@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 { client, uploadContext } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { failureOf } from '../grid.js'\n\n/**\n * The papers of one row of the register - a contract, a certificate, a report, a signed copy (ADR-0175). Picked files\n * are attached at once; taking one off keeps the file (the server moves it aside).\n */\n@customElement('asset-documents')\nexport class AssetDocuments extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-medium, 8px);\n padding: var(--spacing-large, 12px);\n min-height: 200px;\n }\n table {\n width: 100%;\n border-collapse: collapse;\n font-size: var(--ui-t-body, 14px);\n }\n td {\n padding: 6px 4px;\n border-bottom: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));\n }\n td.num {\n text-align: right;\n white-space: nowrap;\n color: var(--md-sys-color-on-surface-variant);\n }\n .none {\n color: var(--md-sys-color-on-surface-variant);\n }\n .failure {\n color: var(--md-sys-color-error);\n }\n button[quiet] {\n border: none;\n background: none;\n color: var(--md-sys-color-error);\n font: inherit;\n cursor: pointer;\n }\n `\n\n @property() owner = ''\n @property() ownerId = ''\n @state() rows: any[] = []\n @state() busy = false\n @state() progress?: number\n @state() failure = ''\n\n /** Open a row's papers in a popup; `changed` runs when files were attached or taken off. */\n static open(owner: string, ownerId: string, title: string, changed?: () => void) {\n const popup = openPopup(html`<asset-documents .owner=${owner} .ownerId=${ownerId}></asset-documents>`, { backdrop: true, size: 'medium', title })\n popup.onclosed = () => changed?.()\n return popup\n }\n\n connectedCallback() {\n super.connectedCallback()\n this.read()\n }\n\n private async read() {\n if (!this.owner || !this.ownerId) return\n try {\n const response = await client.query({\n query: gql`\n query ($owner: AssetDocumentOwner!, $id: String!) {\n assetDocuments(owner: $owner, id: $id) { id name size fullpath createdAt creator }\n }\n `,\n variables: { owner: this.owner, id: this.ownerId },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n this.rows = response.data.assetDocuments\n } catch (error) {\n this.failure = failureOf(error)\n }\n }\n\n private async upload(files: File[]) {\n if (!files.length || this.busy) return\n this.busy = true\n this.failure = ''\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation ($owner: AssetDocumentOwner!, $id: String!, $files: [Upload!]!) {\n attachAssetDocuments(owner: $owner, id: $id, files: $files) { id }\n }\n `,\n variables: { owner: this.owner, id: this.ownerId, files },\n context: uploadContext((fraction: number) => (this.progress = fraction))\n })\n if ((response as any).errors?.length) throw response\n await this.read()\n } catch (error) {\n this.failure = failureOf(error)\n } finally {\n this.busy = false\n this.progress = undefined\n ;(this.renderRoot.querySelector('ox-input-file') as any)?.reset()\n }\n }\n\n private async takeOff(one: any) {\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.asset-document-remove'),\n text: i18next.t('text.asset-document-remove-confirm', { name: one.name }),\n confirmButton: { text: i18next.t('button.asset-document-remove') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n try {\n const response = await client.mutate({ mutation: gql`mutation ($id: String!) { removeAssetDocument(id: $id) }`, variables: { id: one.id } })\n if ((response as any).errors?.length) throw response\n await this.read()\n } catch (error) {\n this.failure = failureOf(error)\n }\n }\n\n render() {\n const size = (bytes?: number) => (bytes ? (bytes >= 1048576 ? `${(bytes / 1048576).toFixed(1)}MB` : `${Math.max(1, Math.round(bytes / 1024))}KB`) : '')\n return html`\n <ox-input-file\n multiple\n .label=${i18next.t('button.asset-document-attach')}\n .progress=${this.progress}\n ?disabled=${this.busy && this.progress === undefined}\n @change=${(e: CustomEvent) => this.upload([...(e.detail ?? [])])}\n ></ox-input-file>\n ${this.rows.length\n ? html`<table>\n ${this.rows.map(\n one => html`<tr>\n <td><a href=${one.fullpath} target=\"_blank\" rel=\"noopener\">${one.name}</a></td>\n <td class=\"num\">${size(one.size)}</td>\n <td class=\"num\">${one.createdAt ? new Date(one.createdAt).toLocaleDateString() : ''}${one.creator ? ` Β· ${one.creator}` : ''}</td>\n <td class=\"num\"><button quiet ?disabled=${this.busy} @click=${() => this.takeOff(one)}>${i18next.t('button.asset-document-remove')}</button></td>\n </tr>`\n )}\n </table>`\n : html`<div class=\"none\">${i18next.t('text.asset-documents-none')}</div>`}\n ${this.failure ? html`<div class=\"failure\" role=\"alert\">${this.failure}</div>` : nothing}\n `\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { DataGrist } from '@operato/data-grist';
2
+ /** What a failed call says, in the server's words. */
3
+ export declare const failureOf: (error: any) => any;
4
+ /** The grid's new, changed and deleted rows as patches - all fields of a new row, the changed ones otherwise. */
5
+ export declare function patchesOf(grist: DataGrist, fields: string[]): {
6
+ cuFlag: any;
7
+ id?: any;
8
+ }[];
9
+ /**
10
+ * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a
11
+ * refusal keeps nothing. True when saved.
12
+ */
13
+ export declare function saveGrid(grist: DataGrist, fields: string[], mutation: string, type: string, extra?: Record<string, any>, deleting?: boolean): Promise<boolean>;
@@ -0,0 +1,56 @@
1
+ import gql from 'graphql-tag';
2
+ import { client } from '@operato/graphql';
3
+ import { i18next } from '@operato/i18n';
4
+ import { notify } from '@operato/layout';
5
+ import { OxPrompt } from '@operato/popup/ox-prompt.js';
6
+ /** What a failed call says, in the server's words. */
7
+ export const failureOf = (error) => error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error);
8
+ /** The grid's new, changed and deleted rows as patches - all fields of a new row, the changed ones otherwise. */
9
+ export function patchesOf(grist, fields) {
10
+ return grist.dirtyRecords.map((record) => {
11
+ const changed = record.__dirty__ === '+' ? fields.filter(field => record[field] !== undefined) : Object.keys(record.__dirtyfields__ ?? {}).filter(field => fields.includes(field));
12
+ return { ...(record.id ? { id: record.id } : {}), cuFlag: record.__dirty__, ...Object.fromEntries(changed.map(field => [field, record[field] === '' ? null : record[field]])) };
13
+ });
14
+ }
15
+ /**
16
+ * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a
17
+ * refusal keeps nothing. True when saved.
18
+ */
19
+ export async function saveGrid(grist, fields, mutation, type, extra = {}, deleting = false) {
20
+ const patches = deleting
21
+ ? grist.selected.filter((record) => record.id).map((record) => ({ id: record.id, cuFlag: '-' }))
22
+ : patchesOf(grist, fields);
23
+ if (!patches.length)
24
+ return false;
25
+ if (deleting) {
26
+ const confirmed = await OxPrompt.open({
27
+ title: i18next.t('button.delete'),
28
+ text: i18next.t('text.asset-delete-confirm', { count: patches.length }),
29
+ confirmButton: { text: i18next.t('button.delete'), destructive: true },
30
+ cancelButton: { text: i18next.t('button.cancel') }
31
+ });
32
+ if (!confirmed)
33
+ return false;
34
+ }
35
+ const args = Object.keys(extra).map(name => `$${name}: String!`);
36
+ const passes = Object.keys(extra).map(name => `${name}: $${name}`);
37
+ try {
38
+ const response = await client.mutate({
39
+ mutation: gql `
40
+ mutation (${[...args, `$patches: [${type}!]!`].join(', ')}) {
41
+ ${mutation}(${[...passes, 'patches: $patches'].join(', ')}) { id }
42
+ }
43
+ `,
44
+ variables: { ...extra, patches }
45
+ });
46
+ if (response.errors?.length)
47
+ throw response;
48
+ notify({ level: 'info', message: i18next.t('text.asset-saved') });
49
+ return true;
50
+ }
51
+ catch (error) {
52
+ notify({ level: 'error', message: failureOf(error) });
53
+ return false;
54
+ }
55
+ }
56
+ //# sourceMappingURL=grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.js","sourceRoot":"","sources":["../client/grid.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;AAE7I,iHAAiH;AACjH,MAAM,UAAU,SAAS,CAAC,KAAgB,EAAE,MAAgB;IAC1D,OAAO,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE;QAC5C,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;QAClL,OAAO,EAAE,GAA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AK,CAAA;IACd,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n/** What a failed call says, in the server's words. */\nexport const failureOf = (error: any) => error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n\n/** The grid's new, changed and deleted rows as patches - all fields of a new row, the changed ones otherwise. */\nexport function patchesOf(grist: DataGrist, fields: string[]) {\n return grist.dirtyRecords.map((record: any) => {\n const changed = record.__dirty__ === '+' ? fields.filter(field => record[field] !== undefined) : Object.keys(record.__dirtyfields__ ?? {}).filter(field => fields.includes(field))\n return { ...(record.id ? { id: record.id } : {}), cuFlag: record.__dirty__, ...Object.fromEntries(changed.map(field => [field, record[field] === '' ? null : record[field]])) }\n })\n}\n\n/**\n * Save a grid: its rows with the deleted ones marked, through the module's `updateMultiple<Type>` - one transaction, so a\n * refusal keeps nothing. True when saved.\n */\nexport async function saveGrid(grist: DataGrist, fields: string[], mutation: string, type: string, extra: Record<string, any> = {}, deleting = false): Promise<boolean> {\n const patches = deleting\n ? grist.selected.filter((record: any) => record.id).map((record: any) => ({ id: record.id, cuFlag: '-' }))\n : patchesOf(grist, fields)\n if (!patches.length) return false\n if (deleting) {\n const confirmed = await OxPrompt.open({\n title: i18next.t('button.delete'),\n text: i18next.t('text.asset-delete-confirm', { count: patches.length }),\n confirmButton: { text: i18next.t('button.delete'), destructive: true },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return false\n }\n const args = Object.keys(extra).map(name => `$${name}: String!`)\n const passes = Object.keys(extra).map(name => `${name}: $${name}`)\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation (${[...args, `$patches: [${type}!]!`].join(', ')}) {\n ${mutation}(${[...passes, 'patches: $patches'].join(', ')}) { id }\n }\n `,\n variables: { ...extra, patches }\n })\n if ((response as any).errors?.length) throw response\n notify({ level: 'info', message: i18next.t('text.asset-saved') })\n return true\n } catch (error) {\n notify({ level: 'error', message: failureOf(error) })\n return false\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export { AssetDocuments } from './components/asset-documents.js';
@@ -0,0 +1,2 @@
1
+ export { AssetDocuments } from './components/asset-documents.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA","sourcesContent":["export { AssetDocuments } from './components/asset-documents.js'\n"]}
@@ -0,0 +1,53 @@
1
+ import '@operato/data-grist/ox-grist.js';
2
+ import '@operato/data-grist/ox-filters-form.js';
3
+ import '../components/asset-documents.js';
4
+ import { FetchOption } from '@operato/data-grist';
5
+ import { PageView } from '@operato/shell';
6
+ declare const AssetList_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
7
+ /**
8
+ * μžμ‚° λŒ€μž₯ β€” the domain's tangible and intangible assets (ADR-0175 decisions 3-4), typed like a spreadsheet and saved
9
+ * together. This year's depreciation, its accumulated amount and the book value are computed from each row. The papers of
10
+ * a row open from its count.
11
+ */
12
+ export declare class AssetList extends AssetList_base {
13
+ static styles: import("lit").CSSResult[];
14
+ gristConfig: any;
15
+ private grist;
16
+ get context(): {
17
+ title: string;
18
+ search: {
19
+ handler: (search: string) => string;
20
+ value: string;
21
+ };
22
+ filter: {
23
+ handler: () => void;
24
+ };
25
+ actions: ({
26
+ title: string;
27
+ icon: string;
28
+ action: () => void;
29
+ } | {
30
+ icon: string;
31
+ emphasis: {
32
+ raised: boolean;
33
+ outlined: boolean;
34
+ dense: boolean;
35
+ danger: boolean;
36
+ };
37
+ title: string;
38
+ action: () => Promise<void>;
39
+ })[];
40
+ exportable: {
41
+ name: string;
42
+ data: () => any[];
43
+ };
44
+ };
45
+ render(): import("lit-html").TemplateResult<1>;
46
+ pageInitialized(): Promise<void>;
47
+ fetchHandler({ page, limit, sortings, filters, search }: FetchOption): Promise<{
48
+ total: any;
49
+ records: any;
50
+ }>;
51
+ private save;
52
+ }
53
+ export {};
@@ -0,0 +1,171 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist/ox-grist.js';
3
+ import '@operato/data-grist/ox-filters-form.js';
4
+ import '../components/asset-documents.js';
5
+ import gql from 'graphql-tag';
6
+ import { html } from 'lit';
7
+ import { customElement, query, state } from 'lit/decorators.js';
8
+ import { DataGrist } from '@operato/data-grist';
9
+ import { client } from '@operato/graphql';
10
+ import { i18next, localize } from '@operato/i18n';
11
+ import { navigate, PageView } from '@operato/shell';
12
+ import { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
13
+ import { isMobileDevice } from '@operato/utils';
14
+ import { AssetDocuments } from '../components/asset-documents.js';
15
+ import { saveGrid } from '../grid.js';
16
+ import { amountText, ASSET_KINDS, ASSET_STATUSES, DEPRECIATION_METHODS, fieldWord, filterOptionsOf, optionsOf } from '../words.js';
17
+ const FIELDS = [
18
+ 'name',
19
+ 'kind',
20
+ 'statementCode',
21
+ 'acquiredOn',
22
+ 'cost',
23
+ 'residualValue',
24
+ 'method',
25
+ 'usefulLifeYears',
26
+ 'declineRate',
27
+ 'depreciationStartOn',
28
+ 'status',
29
+ 'disposedOn',
30
+ 'location',
31
+ 'keeper',
32
+ 'source',
33
+ 'project',
34
+ 'description'
35
+ ];
36
+ /**
37
+ * μžμ‚° λŒ€μž₯ β€” the domain's tangible and intangible assets (ADR-0175 decisions 3-4), typed like a spreadsheet and saved
38
+ * together. This year's depreciation, its accumulated amount and the book value are computed from each row. The papers of
39
+ * a row open from its count.
40
+ */
41
+ let AssetList = class AssetList extends localize(i18next)(PageView) {
42
+ static { this.styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]; }
43
+ get context() {
44
+ return {
45
+ title: i18next.t('title.asset-list'),
46
+ search: { handler: (search) => (this.grist.searchText = search), value: this.grist?.searchText || '' },
47
+ filter: { handler: () => this.grist.toggleHeadroom() },
48
+ actions: [
49
+ { title: i18next.t('button.asset-reconciliation'), icon: 'balance', action: () => navigate('asset-reconciliation') },
50
+ { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ kind: 'MACHINERY', status: 'IN_USE', method: 'STRAIGHT_LINE', cost: 0, residualValue: 0 }) },
51
+ { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },
52
+ { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }
53
+ ],
54
+ exportable: { name: i18next.t('title.asset-list'), data: () => this.grist.exportRecords() }
55
+ };
56
+ }
57
+ render() {
58
+ return html `<ox-grist class="page-fill" search-mode="term" .mode=${isMobileDevice() ? 'CARD' : 'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
59
+ <div slot="headroom" class="header">
60
+ <div class="filters"><ox-filters-form without-search autofocus></ox-filters-form></div>
61
+ </div>
62
+ </ox-grist>`;
63
+ }
64
+ async pageInitialized() {
65
+ const year = new Date().getFullYear();
66
+ const editable = { editable: true };
67
+ const text = (name, width, extra = {}) => ({ type: 'string', name, header: fieldWord('asset', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } });
68
+ const day = (name, extra = {}) => text(name, 100, { record: { align: 'center', ...extra.record }, ...extra });
69
+ const money = (name, extra = {}) => ({ type: 'float', name, header: fieldWord('asset', name), width: 120, sortable: true, ...extra, record: { ...editable, align: 'right', renderer: (value) => amountText(value), ...extra.record } });
70
+ const computed = (name) => ({ type: 'float', name, header: fieldWord('asset', name, { year }), width: 120, record: { align: 'right', renderer: (value) => amountText(value) } });
71
+ this.gristConfig = {
72
+ rows: { appendable: true, selectable: { multiple: true } },
73
+ pagination: { limit: 100, pages: [50, 100, 500] },
74
+ emptyNote: { title: i18next.t('text.asset-empty'), description: i18next.t('text.asset-empty-description') },
75
+ list: { fields: ['name', 'kind'], details: ['acquiredOn', 'cost', 'bookValue'] },
76
+ columns: [
77
+ { type: 'gutter', gutterName: 'sequence' },
78
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
79
+ text('name', 180, { record: { mandatory: true } }),
80
+ {
81
+ type: 'select',
82
+ name: 'kind',
83
+ header: fieldWord('asset', 'kind'),
84
+ width: 100,
85
+ sortable: true,
86
+ record: { ...editable, mandatory: true, options: optionsOf('asset-kind', ASSET_KINDS) },
87
+ filter: { type: 'select', operator: 'eq', options: filterOptionsOf('asset-kind', ASSET_KINDS) }
88
+ },
89
+ day('acquiredOn', { record: { mandatory: true } }),
90
+ money('cost'),
91
+ money('residualValue', { hidden: true }),
92
+ { type: 'select', name: 'method', header: fieldWord('asset', 'method'), width: 90, record: { ...editable, options: optionsOf('depreciation-method', DEPRECIATION_METHODS) } },
93
+ { type: 'float', name: 'usefulLifeYears', header: fieldWord('asset', 'usefulLifeYears'), width: 70, record: { ...editable, align: 'right' } },
94
+ { type: 'float', name: 'declineRate', header: fieldWord('asset', 'declineRate'), width: 70, hidden: true, record: { ...editable, align: 'right' } },
95
+ day('depreciationStartOn', { hidden: true }),
96
+ computed('expense'),
97
+ computed('accumulated'),
98
+ computed('bookValue'),
99
+ {
100
+ type: 'select',
101
+ name: 'status',
102
+ header: fieldWord('asset', 'status'),
103
+ width: 80,
104
+ sortable: true,
105
+ record: { ...editable, options: optionsOf('asset-status', ASSET_STATUSES) },
106
+ filter: { type: 'select', operator: 'eq', options: filterOptionsOf('asset-status', ASSET_STATUSES) }
107
+ },
108
+ day('disposedOn'),
109
+ text('statementCode', 70, { record: { align: 'center' } }),
110
+ text('location', 120),
111
+ text('keeper', 90),
112
+ text('source', 180),
113
+ text('project', 140, { hidden: true }),
114
+ {
115
+ type: 'number',
116
+ name: 'documents',
117
+ header: fieldWord('asset', 'documents'),
118
+ width: 60,
119
+ record: {
120
+ align: 'center',
121
+ renderer: (value, _c, record) => (record?.id ? (value ? `πŸ“Ž ${value}` : 'οΌ‹') : '')
122
+ },
123
+ handlers: { click: (_c, _d, _col, record) => record?.id && AssetDocuments.open('Asset', record.id, record.name, () => this.grist.fetch()) }
124
+ },
125
+ text('description', 200)
126
+ ],
127
+ sorters: [{ name: 'acquiredOn', desc: true }]
128
+ };
129
+ }
130
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }) {
131
+ const response = await client.query({
132
+ query: gql `
133
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {
134
+ responses: assets(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {
135
+ items {
136
+ id name kind statementCode acquiredOn cost residualValue method usefulLifeYears declineRate depreciationStartOn
137
+ status disposedOn location keeper source project description documents
138
+ year { expense accumulated bookValue }
139
+ }
140
+ total
141
+ }
142
+ }
143
+ `,
144
+ variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },
145
+ fetchPolicy: 'network-only'
146
+ });
147
+ if (response.errors?.length)
148
+ throw response;
149
+ return {
150
+ total: response.data.responses.total,
151
+ records: response.data.responses.items.map(({ year, ...one }) => ({ ...one, ...year }))
152
+ };
153
+ }
154
+ async save(deleting = false) {
155
+ if (await saveGrid(this.grist, FIELDS, 'updateMultipleAsset', 'AssetPatch', {}, deleting))
156
+ this.grist.fetch();
157
+ }
158
+ };
159
+ __decorate([
160
+ state(),
161
+ __metadata("design:type", Object)
162
+ ], AssetList.prototype, "gristConfig", void 0);
163
+ __decorate([
164
+ query('ox-grist'),
165
+ __metadata("design:type", DataGrist)
166
+ ], AssetList.prototype, "grist", void 0);
167
+ AssetList = __decorate([
168
+ customElement('asset-list')
169
+ ], AssetList);
170
+ export { AssetList };
171
+ //# sourceMappingURL=asset-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-list.js","sourceRoot":"","sources":["../../client/pages/asset-list.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACx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M;YAAE,MAAM,QAAQ,CAAA;QAC3C,OAAO;YACL,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;YACpC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,EAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;SAC7F,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK;QACjC,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,CAAC;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC/G,CAAC;;AAvHQ;IAAR,KAAK,EAAE;;8CAAiB;AACE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;wCAAA;AAJjC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA2HrB","sourcesContent":["import '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\nimport '../components/asset-documents.js'\n\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { AssetDocuments } from '../components/asset-documents.js'\nimport { saveGrid } from '../grid.js'\nimport { amountText, ASSET_KINDS, ASSET_STATUSES, DEPRECIATION_METHODS, fieldWord, filterOptionsOf, optionsOf } from '../words.js'\n\nconst FIELDS = [\n 'name',\n 'kind',\n 'statementCode',\n 'acquiredOn',\n 'cost',\n 'residualValue',\n 'method',\n 'usefulLifeYears',\n 'declineRate',\n 'depreciationStartOn',\n 'status',\n 'disposedOn',\n 'location',\n 'keeper',\n 'source',\n 'project',\n 'description'\n]\n\n/**\n * μžμ‚° λŒ€μž₯ β€” the domain's tangible and intangible assets (ADR-0175 decisions 3-4), typed like a spreadsheet and saved\n * together. This year's depreciation, its accumulated amount and the book value are computed from each row. The papers of\n * a row open from its count.\n */\n@customElement('asset-list')\nexport class AssetList extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, CommonGristStyles, CommonHeaderStyles, ScrollbarStyles]\n\n @state() gristConfig: any\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.asset-list'),\n search: { handler: (search: string) => (this.grist.searchText = search), value: this.grist?.searchText || '' },\n filter: { handler: () => this.grist.toggleHeadroom() },\n actions: [\n { title: i18next.t('button.asset-reconciliation'), icon: 'balance', action: () => navigate('asset-reconciliation') },\n { title: i18next.t('button.add'), icon: 'add', action: () => this.grist.addRecordToTop({ kind: 'MACHINERY', status: 'IN_USE', method: 'STRAIGHT_LINE', cost: 0, residualValue: 0 }) },\n { title: i18next.t('button.delete'), action: () => this.save(true), ...CommonButtonStyles.delete },\n { title: i18next.t('button.save'), action: () => this.save(), ...CommonButtonStyles.save }\n ],\n exportable: { name: i18next.t('title.asset-list'), data: () => this.grist.exportRecords() }\n }\n }\n\n render() {\n return html`<ox-grist class=\"page-fill\" search-mode=\"term\" .mode=${isMobileDevice() ? 'CARD' : 'GRID'} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\"><ox-filters-form without-search autofocus></ox-filters-form></div>\n </div>\n </ox-grist>`\n }\n\n async pageInitialized() {\n const year = new Date().getFullYear()\n const editable = { editable: true }\n const text = (name: string, width: number, extra: any = {}) => ({ type: 'string', name, header: fieldWord('asset', name), width, sortable: true, ...extra, record: { ...editable, ...extra.record } })\n const day = (name: string, extra: any = {}) => text(name, 100, { record: { align: 'center', ...extra.record }, ...extra })\n const money = (name: string, extra: any = {}) => ({ type: 'float', name, header: fieldWord('asset', name), width: 120, sortable: true, ...extra, record: { ...editable, align: 'right', renderer: (value: number) => amountText(value), ...extra.record } })\n const computed = (name: string) => ({ type: 'float', name, header: fieldWord('asset', name, { year }), width: 120, record: { align: 'right', renderer: (value: number) => amountText(value) } })\n this.gristConfig = {\n rows: { appendable: true, selectable: { multiple: true } },\n pagination: { limit: 100, pages: [50, 100, 500] },\n emptyNote: { title: i18next.t('text.asset-empty'), description: i18next.t('text.asset-empty-description') },\n list: { fields: ['name', 'kind'], details: ['acquiredOn', 'cost', 'bookValue'] },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n text('name', 180, { record: { mandatory: true } }),\n {\n type: 'select',\n name: 'kind',\n header: fieldWord('asset', 'kind'),\n width: 100,\n sortable: true,\n record: { ...editable, mandatory: true, options: optionsOf('asset-kind', ASSET_KINDS) },\n filter: { type: 'select', operator: 'eq', options: filterOptionsOf('asset-kind', ASSET_KINDS) }\n },\n day('acquiredOn', { record: { mandatory: true } }),\n money('cost'),\n money('residualValue', { hidden: true }),\n { type: 'select', name: 'method', header: fieldWord('asset', 'method'), width: 90, record: { ...editable, options: optionsOf('depreciation-method', DEPRECIATION_METHODS) } },\n { type: 'float', name: 'usefulLifeYears', header: fieldWord('asset', 'usefulLifeYears'), width: 70, record: { ...editable, align: 'right' } },\n { type: 'float', name: 'declineRate', header: fieldWord('asset', 'declineRate'), width: 70, hidden: true, record: { ...editable, align: 'right' } },\n day('depreciationStartOn', { hidden: true }),\n computed('expense'),\n computed('accumulated'),\n computed('bookValue'),\n {\n type: 'select',\n name: 'status',\n header: fieldWord('asset', 'status'),\n width: 80,\n sortable: true,\n record: { ...editable, options: optionsOf('asset-status', ASSET_STATUSES) },\n filter: { type: 'select', operator: 'eq', options: filterOptionsOf('asset-status', ASSET_STATUSES) }\n },\n day('disposedOn'),\n text('statementCode', 70, { record: { align: 'center' } }),\n text('location', 120),\n text('keeper', 90),\n text('source', 180),\n text('project', 140, { hidden: true }),\n {\n type: 'number',\n name: 'documents',\n header: fieldWord('asset', 'documents'),\n width: 60,\n record: {\n align: 'center',\n renderer: (value: number, _c: any, record: any) => (record?.id ? (value ? `πŸ“Ž ${value}` : 'οΌ‹') : '')\n },\n handlers: { click: (_c: any, _d: any, _col: any, record: any) => record?.id && AssetDocuments.open('Asset', record.id, record.name, () => this.grist.fetch()) }\n },\n text('description', 200)\n ],\n sorters: [{ name: 'acquiredOn', desc: true }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [], search }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $search: String) {\n responses: assets(filters: $filters, pagination: $pagination, sortings: $sortings, search: $search) {\n items {\n id name kind statementCode acquiredOn cost residualValue method usefulLifeYears declineRate depreciationStartOn\n status disposedOn location keeper source project description documents\n year { expense accumulated bookValue }\n }\n total\n }\n }\n `,\n variables: { filters, pagination: { page, limit }, sortings, search: search?.trim() || undefined },\n fetchPolicy: 'network-only'\n })\n if (response.errors?.length) throw response\n return {\n total: response.data.responses.total,\n records: response.data.responses.items.map(({ year, ...one }: any) => ({ ...one, ...year }))\n }\n }\n\n private async save(deleting = false) {\n if (await saveGrid(this.grist, FIELDS, 'updateMultipleAsset', 'AssetPatch', {}, deleting)) this.grist.fetch()\n }\n}\n\n"]}
@@ -0,0 +1,25 @@
1
+ import '@operato/input/ox-select.js';
2
+ import '@operato/popup/ox-popup-list.js';
3
+ import { PageView } from '@operato/shell';
4
+ declare const AssetReconciliationPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
5
+ /**
6
+ * μ‹ κ³  μž¬λ¬΄μ œν‘œμ™€ 맞좀 β€” the register beside the filed balance sheet of a year, line by line (ADR-0175 decision 5): cost
7
+ * and accumulated depreciation as the register computes them and as the books carry them. Nothing is changed here; a
8
+ * difference is for the accountant to explain.
9
+ */
10
+ export declare class AssetReconciliationPage extends AssetReconciliationPage_base {
11
+ static styles: import("lit").CSSResult[];
12
+ fiscalYear: number;
13
+ answer?: {
14
+ filed: boolean;
15
+ rows: any[];
16
+ };
17
+ failure: string;
18
+ get context(): {
19
+ title: string;
20
+ };
21
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
22
+ private read;
23
+ render(): import("lit-html").TemplateResult<1>;
24
+ }
25
+ export {};