@things-factory/accounting 8.0.6 → 9.0.0-beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/dist-client/pages/accounting-category/accounting-category-tree-page.js +1 -1
  2. package/dist-client/pages/accounting-category/accounting-category-tree-page.js.map +1 -1
  3. package/dist-client/pages/bank/bank-importer.d.ts +23 -0
  4. package/dist-client/pages/bank/bank-importer.js +93 -0
  5. package/dist-client/pages/bank/bank-importer.js.map +1 -0
  6. package/dist-client/pages/bank/bank-list-page.d.ts +66 -0
  7. package/dist-client/pages/bank/bank-list-page.js +370 -0
  8. package/dist-client/pages/bank/bank-list-page.js.map +1 -0
  9. package/dist-client/pages/bank-account/bank-account-importer.d.ts +23 -0
  10. package/dist-client/pages/bank-account/bank-account-importer.js +93 -0
  11. package/dist-client/pages/bank-account/bank-account-importer.js.map +1 -0
  12. package/dist-client/pages/bank-account/bank-account-list-page.d.ts +66 -0
  13. package/dist-client/pages/bank-account/bank-account-list-page.js +370 -0
  14. package/dist-client/pages/bank-account/bank-account-list-page.js.map +1 -0
  15. package/dist-client/pages/financial-institution/financial-institution-importer.d.ts +23 -0
  16. package/dist-client/pages/financial-institution/financial-institution-importer.js +93 -0
  17. package/dist-client/pages/financial-institution/financial-institution-importer.js.map +1 -0
  18. package/dist-client/pages/financial-institution/financial-institution-list-page.d.ts +66 -0
  19. package/dist-client/pages/financial-institution/financial-institution-list-page.js +370 -0
  20. package/dist-client/pages/financial-institution/financial-institution-list-page.js.map +1 -0
  21. package/dist-client/tsconfig.tsbuildinfo +1 -1
  22. package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +5 -0
  23. package/dist-server/migrations/1725201567284-seed-country-codes.js +248 -0
  24. package/dist-server/migrations/1725201567284-seed-country-codes.js.map +1 -0
  25. package/dist-server/migrations/1725201667385-seed-financial-institutions.d.ts +5 -0
  26. package/dist-server/migrations/1725201667385-seed-financial-institutions.js +348 -0
  27. package/dist-server/migrations/1725201667385-seed-financial-institutions.js.map +1 -0
  28. package/dist-server/service/bank-account/bank-account-history.d.ts +34 -0
  29. package/dist-server/service/bank-account/bank-account-history.js +172 -0
  30. package/dist-server/service/bank-account/bank-account-history.js.map +1 -0
  31. package/dist-server/service/bank-account/bank-account-mutation.d.ts +10 -0
  32. package/dist-server/service/bank-account/bank-account-mutation.js +128 -0
  33. package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -0
  34. package/dist-server/service/bank-account/bank-account-query.d.ts +11 -0
  35. package/dist-server/service/bank-account/bank-account-query.js +79 -0
  36. package/dist-server/service/bank-account/bank-account-query.js.map +1 -0
  37. package/dist-server/service/bank-account/bank-account-type.d.ts +39 -0
  38. package/dist-server/service/bank-account/bank-account-type.js +153 -0
  39. package/dist-server/service/bank-account/bank-account-type.js.map +1 -0
  40. package/dist-server/service/bank-account/bank-account.d.ts +38 -0
  41. package/dist-server/service/bank-account/bank-account.js +164 -0
  42. package/dist-server/service/bank-account/bank-account.js.map +1 -0
  43. package/dist-server/service/bank-account/event-subscriber.d.ts +7 -0
  44. package/dist-server/service/bank-account/event-subscriber.js +21 -0
  45. package/dist-server/service/bank-account/event-subscriber.js.map +1 -0
  46. package/dist-server/service/bank-account/index.d.ts +7 -0
  47. package/dist-server/service/bank-account/index.js +12 -0
  48. package/dist-server/service/bank-account/index.js.map +1 -0
  49. package/dist-server/service/financial-institution/financial-institution-mutation.d.ts +10 -0
  50. package/dist-server/service/financial-institution/financial-institution-mutation.js +169 -0
  51. package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -0
  52. package/dist-server/service/financial-institution/financial-institution-query.d.ts +12 -0
  53. package/dist-server/service/financial-institution/financial-institution-query.js +97 -0
  54. package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -0
  55. package/dist-server/service/financial-institution/financial-institution-type.d.ts +32 -0
  56. package/dist-server/service/financial-institution/financial-institution-type.js +126 -0
  57. package/dist-server/service/financial-institution/financial-institution-type.js.map +1 -0
  58. package/dist-server/service/financial-institution/financial-institution.d.ts +34 -0
  59. package/dist-server/service/financial-institution/financial-institution.js +137 -0
  60. package/dist-server/service/financial-institution/financial-institution.js.map +1 -0
  61. package/dist-server/service/financial-institution/index.d.ts +6 -0
  62. package/dist-server/service/financial-institution/index.js +10 -0
  63. package/dist-server/service/financial-institution/index.js.map +1 -0
  64. package/dist-server/service/index.d.ts +3 -2
  65. package/dist-server/service/index.js +5 -0
  66. package/dist-server/service/index.js.map +1 -1
  67. package/dist-server/service/payment/index.d.ts +1 -2
  68. package/dist-server/service/payment/payment-history.d.ts +8 -1
  69. package/dist-server/service/payment/payment-history.js +41 -10
  70. package/dist-server/service/payment/payment-history.js.map +1 -1
  71. package/dist-server/service/payment/payment-type.d.ts +7 -1
  72. package/dist-server/service/payment/payment-type.js +24 -0
  73. package/dist-server/service/payment/payment-type.js.map +1 -1
  74. package/dist-server/service/payment/payment.d.ts +12 -0
  75. package/dist-server/service/payment/payment.js +36 -1
  76. package/dist-server/service/payment/payment.js.map +1 -1
  77. package/dist-server/tsconfig.tsbuildinfo +1 -1
  78. package/helps/accounting/bank-account.md +160 -0
  79. package/helps/accounting/bank.md +160 -0
  80. package/helps/accounting/financial-institution.md +160 -0
  81. package/package.json +7 -7
  82. package/client/activities/activity-book-edit.ts +0 -88
  83. package/client/activities/activity-book-view.ts +0 -88
  84. package/client/activities/activity-expense-edit.ts +0 -88
  85. package/client/activities/activity-expense-view.ts +0 -88
  86. package/client/bootstrap.ts +0 -10
  87. package/client/components/accounting-category-selector.ts +0 -136
  88. package/client/components/accounting-category-view.ts +0 -75
  89. package/client/grist-editors/grist-editor-accounting-category-object.ts +0 -83
  90. package/client/grist-editors/grist-renderer-accounting-category-object.ts +0 -13
  91. package/client/index.ts +0 -0
  92. package/client/pages/account/account-importer.ts +0 -97
  93. package/client/pages/account/account-list-page.ts +0 -364
  94. package/client/pages/accounting-category/accounting-category-importer.ts +0 -97
  95. package/client/pages/accounting-category/accounting-category-list-page.ts +0 -368
  96. package/client/pages/accounting-category/accounting-category-tree-page.ts +0 -338
  97. package/client/pages/accounting-document/accounting-document-importer.ts +0 -90
  98. package/client/pages/accounting-document/accounting-document-list-page.ts +0 -398
  99. package/client/pages/financial-statement/financial-statement-importer.ts +0 -97
  100. package/client/pages/financial-statement/financial-statement-list-page.ts +0 -338
  101. package/client/pages/fiscal-month/fiscal-month-importer.ts +0 -90
  102. package/client/pages/fiscal-month/fiscal-month-list-page.ts +0 -398
  103. package/client/pages/fiscal-quarter/fiscal-quarter-importer.ts +0 -90
  104. package/client/pages/fiscal-quarter/fiscal-quarter-list-page.ts +0 -398
  105. package/client/pages/fiscal-year/fiscal-year-importer.ts +0 -90
  106. package/client/pages/fiscal-year/fiscal-year-list-page.ts +0 -398
  107. package/client/pages/income-statement/income-statement-importer.ts +0 -97
  108. package/client/pages/income-statement/income-statement-list-page.ts +0 -338
  109. package/client/pages/payment/payment-importer.ts +0 -90
  110. package/client/pages/payment/payment-list-page.ts +0 -398
  111. package/client/pages/transaction/transaction-importer.ts +0 -97
  112. package/client/pages/transaction/transaction-list-page.ts +0 -338
  113. package/client/route.ts +0 -35
  114. package/client/tsconfig.json +0 -13
  115. package/client/types/accounting-category.ts +0 -23
  116. package/client/types/index.ts +0 -1
  117. package/server/activities/activity-book.ts +0 -172
  118. package/server/activities/activity-expense.ts +0 -149
  119. package/server/activities/index.ts +0 -18
  120. package/server/controllers/index.ts +0 -1
  121. package/server/controllers/summary-statements.ts +0 -166
  122. package/server/index.ts +0 -6
  123. package/server/middlewares/index.ts +0 -3
  124. package/server/migrations/1725200507196-seed-fiscal-entities.ts +0 -106
  125. package/server/migrations/1725201467183-seed-accounts.ts +0 -339
  126. package/server/migrations/index.ts +0 -9
  127. package/server/routes.ts +0 -26
  128. package/server/service/account/account-history.ts +0 -117
  129. package/server/service/account/account-mutation.ts +0 -140
  130. package/server/service/account/account-query.ts +0 -51
  131. package/server/service/account/account-type.ts +0 -44
  132. package/server/service/account/account.ts +0 -97
  133. package/server/service/account/event-subscriber.ts +0 -17
  134. package/server/service/account/index.ts +0 -9
  135. package/server/service/accounting-category/accounting-category-history.ts +0 -129
  136. package/server/service/accounting-category/accounting-category-mutation.ts +0 -148
  137. package/server/service/accounting-category/accounting-category-query.ts +0 -74
  138. package/server/service/accounting-category/accounting-category-type.ts +0 -48
  139. package/server/service/accounting-category/accounting-category.ts +0 -100
  140. package/server/service/accounting-category/event-subscriber.ts +0 -20
  141. package/server/service/accounting-category/index.ts +0 -9
  142. package/server/service/accounting-document/accounting-document-history.ts +0 -123
  143. package/server/service/accounting-document/accounting-document-mutation.ts +0 -137
  144. package/server/service/accounting-document/accounting-document-query.ts +0 -48
  145. package/server/service/accounting-document/accounting-document-type.ts +0 -52
  146. package/server/service/accounting-document/accounting-document.ts +0 -93
  147. package/server/service/accounting-document/event-subscriber.ts +0 -17
  148. package/server/service/accounting-document/index.ts +0 -9
  149. package/server/service/common-type.ts +0 -12
  150. package/server/service/financial-statement/event-subscriber.ts +0 -17
  151. package/server/service/financial-statement/financial-statement-history.ts +0 -129
  152. package/server/service/financial-statement/financial-statement-line-item.ts +0 -82
  153. package/server/service/financial-statement/financial-statement-mutation.ts +0 -148
  154. package/server/service/financial-statement/financial-statement-query.ts +0 -53
  155. package/server/service/financial-statement/financial-statement-type.ts +0 -51
  156. package/server/service/financial-statement/financial-statement.ts +0 -116
  157. package/server/service/financial-statement/index.ts +0 -10
  158. package/server/service/fiscal-month/fiscal-month-mutation.ts +0 -145
  159. package/server/service/fiscal-month/fiscal-month-query.ts +0 -58
  160. package/server/service/fiscal-month/fiscal-month-type.ts +0 -66
  161. package/server/service/fiscal-month/fiscal-month.ts +0 -84
  162. package/server/service/fiscal-month/index.ts +0 -7
  163. package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +0 -148
  164. package/server/service/fiscal-quarter/fiscal-quarter-query.ts +0 -60
  165. package/server/service/fiscal-quarter/fiscal-quarter-type.ts +0 -60
  166. package/server/service/fiscal-quarter/fiscal-quarter.ts +0 -80
  167. package/server/service/fiscal-quarter/index.ts +0 -7
  168. package/server/service/fiscal-year/fiscal-year-mutation.ts +0 -145
  169. package/server/service/fiscal-year/fiscal-year-query.ts +0 -53
  170. package/server/service/fiscal-year/fiscal-year-type.ts +0 -54
  171. package/server/service/fiscal-year/fiscal-year.ts +0 -76
  172. package/server/service/fiscal-year/index.ts +0 -7
  173. package/server/service/income-statement/event-subscriber.ts +0 -17
  174. package/server/service/income-statement/income-statement-history.ts +0 -133
  175. package/server/service/income-statement/income-statement-line-item.ts +0 -84
  176. package/server/service/income-statement/income-statement-mutation.ts +0 -147
  177. package/server/service/income-statement/income-statement-query.ts +0 -50
  178. package/server/service/income-statement/income-statement-type.ts +0 -51
  179. package/server/service/income-statement/income-statement.ts +0 -120
  180. package/server/service/income-statement/index.ts +0 -10
  181. package/server/service/index.ts +0 -108
  182. package/server/service/payment/event-subscriber.ts +0 -17
  183. package/server/service/payment/index.ts +0 -9
  184. package/server/service/payment/payment-history.ts +0 -132
  185. package/server/service/payment/payment-mutation.ts +0 -139
  186. package/server/service/payment/payment-query.ts +0 -50
  187. package/server/service/payment/payment-type.ts +0 -64
  188. package/server/service/payment/payment.ts +0 -123
  189. package/server/service/transaction/event-subscriber.ts +0 -17
  190. package/server/service/transaction/index.ts +0 -9
  191. package/server/service/transaction/transaction-history.ts +0 -161
  192. package/server/service/transaction/transaction-mutation.ts +0 -146
  193. package/server/service/transaction/transaction-query.ts +0 -50
  194. package/server/service/transaction/transaction-type.ts +0 -48
  195. package/server/service/transaction/transaction.ts +0 -230
  196. package/server/tsconfig.json +0 -10
@@ -0,0 +1,23 @@
1
+ import '@material/web/icon/icon.js';
2
+ import '@operato/data-grist';
3
+ import { LitElement } from 'lit';
4
+ export declare class FinancialInstitutionImporter extends LitElement {
5
+ static styles: import("lit").CSSResult[];
6
+ financialInstitutions: any[];
7
+ columns: {
8
+ list: {
9
+ fields: string[];
10
+ };
11
+ pagination: {
12
+ infinite: boolean;
13
+ };
14
+ columns: {
15
+ type: string;
16
+ name: string;
17
+ header: string;
18
+ width: number;
19
+ }[];
20
+ };
21
+ render(): import("lit-html").TemplateResult<1>;
22
+ save(): Promise<void>;
23
+ }
@@ -0,0 +1,93 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import '@operato/data-grist';
4
+ import gql from 'graphql-tag';
5
+ import { css, html, LitElement } from 'lit';
6
+ import { property } from 'lit/decorators.js';
7
+ import { client } from '@operato/graphql';
8
+ import { i18next } from '@operato/i18n';
9
+ import { isMobileDevice } from '@operato/utils';
10
+ import { ButtonContainerStyles } from '@operato/styles';
11
+ export class FinancialInstitutionImporter extends LitElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.financialInstitutions = [];
15
+ this.columns = {
16
+ list: { fields: ['name', 'description'] },
17
+ pagination: { infinite: true },
18
+ columns: [
19
+ {
20
+ type: 'string',
21
+ name: 'name',
22
+ header: i18next.t('field.name'),
23
+ width: 150
24
+ },
25
+ {
26
+ type: 'string',
27
+ name: 'description',
28
+ header: i18next.t('field.description'),
29
+ width: 200
30
+ },
31
+ {
32
+ type: 'checkbox',
33
+ name: 'active',
34
+ header: i18next.t('field.active'),
35
+ width: 60
36
+ }
37
+ ]
38
+ };
39
+ }
40
+ render() {
41
+ return html `
42
+ <ox-grist
43
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
44
+ .config=${this.columns}
45
+ .data=${{
46
+ records: this.financialInstitutions
47
+ }}
48
+ ></ox-grist>
49
+
50
+ <div class="button-container">
51
+ <button @click="${this.save.bind(this)}"><md-icon>save</md-icon>${i18next.t('button.save')}</button>
52
+ </div>
53
+ `;
54
+ }
55
+ async save() {
56
+ var _a;
57
+ const response = await client.mutate({
58
+ mutation: gql `
59
+ mutation importFinancialInstitutions($financialInstitutions: [FinancialInstitutionPatch!]!) {
60
+ importFinancialInstitutions(financialInstitutions: $financialInstitutions)
61
+ }
62
+ `,
63
+ variables: { financialInstitutions: this.financialInstitutions }
64
+ });
65
+ if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length)
66
+ return;
67
+ this.dispatchEvent(new CustomEvent('imported'));
68
+ }
69
+ }
70
+ FinancialInstitutionImporter.styles = [
71
+ ButtonContainerStyles,
72
+ css `
73
+ :host {
74
+ display: flex;
75
+ flex-direction: column;
76
+
77
+ background-color: #fff;
78
+ }
79
+
80
+ ox-grist {
81
+ flex: 1;
82
+ }
83
+ `
84
+ ];
85
+ __decorate([
86
+ property({ type: Array }),
87
+ __metadata("design:type", Array)
88
+ ], FinancialInstitutionImporter.prototype, "financialInstitutions", void 0);
89
+ __decorate([
90
+ property({ type: Object }),
91
+ __metadata("design:type", Object)
92
+ ], FinancialInstitutionImporter.prototype, "columns", void 0);
93
+ //# sourceMappingURL=financial-institution-importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"financial-institution-importer.js","sourceRoot":"","sources":["../../../client/pages/financial-institution/financial-institution-importer.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,MAAM,OAAO,4BAA6B,SAAQ,UAAU;IAA5D;;QAiB6B,0BAAqB,GAAU,EAAE,CAAA;QAChC,YAAO,GAAG;YACpC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;YACzC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC9B,OAAO,EAAE;gBACP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C,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;2EAAkC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6DAuB1B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\nimport { ButtonContainerStyles } from '@operato/styles'\n\nexport class FinancialInstitutionImporter extends LitElement {\n static styles = [\n ButtonContainerStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n }\n\n ox-grist {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Array }) financialInstitutions: any[] = []\n @property({ type: Object }) columns = {\n list: { fields: ['name', 'description'] },\n pagination: { infinite: true },\n columns: [\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n header: i18next.t('field.active'),\n width: 60\n }\n ]\n }\n\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${\n { \n records: this.financialInstitutions \n }\n }\n ></ox-grist>\n\n <div class=\"button-container\">\n <button @click=\"${this.save.bind(this)}\"><md-icon>save</md-icon>${i18next.t('button.save')}</button>\n </div>\n `\n }\n\n async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importFinancialInstitutions($financialInstitutions: [FinancialInstitutionPatch!]!) {\n importFinancialInstitutions(financialInstitutions: $financialInstitutions)\n }\n `,\n variables: { financialInstitutions: this.financialInstitutions }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n\n"]}
@@ -0,0 +1,66 @@
1
+ import '@material/web/icon/icon.js';
2
+ import '@material/web/button/elevated-button.js';
3
+ import '@operato/data-grist/ox-grist.js';
4
+ import '@operato/data-grist/ox-filters-form.js';
5
+ import '@operato/data-grist/ox-record-creator.js';
6
+ import { PageView } from '@operato/shell';
7
+ import { FetchOption } from '@operato/data-grist';
8
+ import { FinancialInstitutionImporter } from './financial-institution-importer';
9
+ declare const FinancialInstitutionListPage_base: (new (...args: any[]) => {
10
+ _storeUnsubscribe: import("redux").Unsubscribe;
11
+ connectedCallback(): void;
12
+ disconnectedCallback(): void;
13
+ stateChanged(_state: unknown): void;
14
+ readonly isConnected: boolean;
15
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
16
+ export declare class FinancialInstitutionListPage extends FinancialInstitutionListPage_base {
17
+ static styles: import("lit").CSSResult[];
18
+ static get scopedElements(): {
19
+ 'financial-institution-importer': typeof FinancialInstitutionImporter;
20
+ };
21
+ gristConfig: any;
22
+ mode: 'CARD' | 'GRID' | 'LIST';
23
+ private grist;
24
+ get context(): {
25
+ title: string;
26
+ search: {
27
+ handler: (search: string) => void;
28
+ value: string;
29
+ };
30
+ filter: {
31
+ handler: () => void;
32
+ };
33
+ help: string;
34
+ actions: {
35
+ icon: string;
36
+ emphasis: {
37
+ raised: boolean;
38
+ outlined: boolean;
39
+ dense: boolean;
40
+ danger: boolean;
41
+ };
42
+ title: string;
43
+ action: () => Promise<void>;
44
+ }[];
45
+ exportable: {
46
+ name: string;
47
+ data: () => Promise<{}[]>;
48
+ };
49
+ importable: {
50
+ handler: (records: any) => Promise<void>;
51
+ };
52
+ };
53
+ render(): import("lit-html").TemplateResult<1>;
54
+ pageInitialized(lifecycle: any): Promise<void>;
55
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
56
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
57
+ total: any;
58
+ records: any;
59
+ }>;
60
+ _deleteFinancialInstitution(): Promise<void>;
61
+ _updateFinancialInstitution(): Promise<void>;
62
+ creationCallback(financialInstitution: any): Promise<boolean>;
63
+ exportHandler(): Promise<{}[]>;
64
+ importHandler(records: any): Promise<void>;
65
+ }
66
+ export {};
@@ -0,0 +1,370 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import '@material/web/button/elevated-button.js';
4
+ import '@operato/data-grist/ox-grist.js';
5
+ import '@operato/data-grist/ox-filters-form.js';
6
+ import '@operato/data-grist/ox-record-creator.js';
7
+ import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
8
+ import { PageView, store } from '@operato/shell';
9
+ import { css, html } from 'lit';
10
+ import { customElement, property, query } from 'lit/decorators.js';
11
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
12
+ import { DataGrist } from '@operato/data-grist';
13
+ import { client } from '@operato/graphql';
14
+ import { i18next, localize } from '@operato/i18n';
15
+ import { notify, openPopup } from '@operato/layout';
16
+ import { OxPrompt } from '@operato/popup';
17
+ import { isMobileDevice } from '@operato/utils';
18
+ import { connect } from 'pwa-helpers/connect-mixin';
19
+ import gql from 'graphql-tag';
20
+ import { FinancialInstitutionImporter } from './financial-institution-importer';
21
+ let FinancialInstitutionListPage = class FinancialInstitutionListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
25
+ }
26
+ static get scopedElements() {
27
+ return {
28
+ 'financial-institution-importer': FinancialInstitutionImporter
29
+ };
30
+ }
31
+ get context() {
32
+ return {
33
+ title: i18next.t('title.financial-institution list'),
34
+ search: {
35
+ handler: (search) => {
36
+ this.grist.searchText = search;
37
+ },
38
+ value: this.grist.searchText
39
+ },
40
+ filter: {
41
+ handler: () => {
42
+ this.grist.toggleHeadroom();
43
+ }
44
+ },
45
+ help: 'accounting/financial-institution',
46
+ actions: [
47
+ Object.assign({ title: i18next.t('button.save'), action: this._updateFinancialInstitution.bind(this) }, CommonButtonStyles.save),
48
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteFinancialInstitution.bind(this) }, CommonButtonStyles.delete)
49
+ ],
50
+ exportable: {
51
+ name: i18next.t('title.financial-institution list'),
52
+ data: this.exportHandler.bind(this)
53
+ },
54
+ importable: {
55
+ handler: this.importHandler.bind(this)
56
+ }
57
+ };
58
+ }
59
+ render() {
60
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
61
+ return html `
62
+ <ox-grist
63
+ .mode=${mode}
64
+ .config=${this.gristConfig}
65
+ .fetchHandler=${this.fetchHandler.bind(this)}
66
+ >
67
+ <div slot="headroom" class="header">
68
+ <div class="filters">
69
+ <ox-filters-form autofocus without-search></ox-filters-form>
70
+
71
+ <div id="modes">
72
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
73
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
74
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
75
+ </div>
76
+
77
+ <ox-record-creator id="add" .callback=${this.creationCallback.bind(this)}>
78
+ <button>
79
+ <md-icon>add</md-icon>
80
+ </button>
81
+ </ox-record-creator>
82
+
83
+ </div>
84
+ </div>
85
+ </ox-grist>
86
+ `;
87
+ }
88
+ async pageInitialized(lifecycle) {
89
+ this.gristConfig = {
90
+ list: {
91
+ fields: ['name', 'description'],
92
+ details: ['active', 'updatedAt']
93
+ },
94
+ columns: [
95
+ { type: 'gutter', gutterName: 'sequence' },
96
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
97
+ {
98
+ type: 'string',
99
+ name: 'name',
100
+ header: i18next.t('field.name'),
101
+ record: {
102
+ editable: true
103
+ },
104
+ filter: 'search',
105
+ sortable: true,
106
+ width: 150
107
+ },
108
+ {
109
+ type: 'string',
110
+ name: 'description',
111
+ header: i18next.t('field.description'),
112
+ record: {
113
+ editable: true
114
+ },
115
+ filter: 'search',
116
+ width: 200
117
+ },
118
+ {
119
+ type: 'checkbox',
120
+ name: 'active',
121
+ label: true,
122
+ header: i18next.t('field.active'),
123
+ record: {
124
+ editable: true
125
+ },
126
+ filter: true,
127
+ sortable: true,
128
+ width: 60
129
+ },
130
+ {
131
+ type: 'resource-object',
132
+ name: 'updater',
133
+ header: i18next.t('field.updater'),
134
+ record: {
135
+ editable: false
136
+ },
137
+ sortable: true,
138
+ width: 120
139
+ },
140
+ {
141
+ type: 'datetime',
142
+ name: 'updatedAt',
143
+ header: i18next.t('field.updated_at'),
144
+ record: {
145
+ editable: false
146
+ },
147
+ sortable: true,
148
+ width: 180
149
+ }
150
+ ],
151
+ rows: {
152
+ appendable: false,
153
+ selectable: {
154
+ multiple: true
155
+ }
156
+ },
157
+ sorters: [
158
+ {
159
+ name: 'name'
160
+ }
161
+ ]
162
+ };
163
+ }
164
+ async pageUpdated(changes, lifecycle) {
165
+ if (this.active) {
166
+ // do something here when this page just became as active
167
+ }
168
+ }
169
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
170
+ const response = await client.query({
171
+ query: gql `
172
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
173
+ responses: financialInstitutions(filters: $filters, pagination: $pagination, sortings: $sortings) {
174
+ items {
175
+ id
176
+ name
177
+ description
178
+ active
179
+ updater {
180
+ id
181
+ name
182
+ }
183
+ updatedAt
184
+ }
185
+ total
186
+ }
187
+ }
188
+ `,
189
+ variables: {
190
+ filters,
191
+ pagination: { page, limit },
192
+ sortings
193
+ }
194
+ });
195
+ return {
196
+ total: response.data.responses.total || 0,
197
+ records: response.data.responses.items || []
198
+ };
199
+ }
200
+ async _deleteFinancialInstitution() {
201
+ if (await OxPrompt.open({
202
+ title: i18next.t('text.are_you_sure'),
203
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
204
+ confirmButton: { text: i18next.t('button.confirm') },
205
+ cancelButton: { text: i18next.t('button.cancel') }
206
+ })) {
207
+ const ids = this.grist.selected.map(record => record.id);
208
+ if (ids && ids.length > 0) {
209
+ const response = await client.mutate({
210
+ mutation: gql `
211
+ mutation ($ids: [String!]!) {
212
+ deleteFinancialInstitutions(ids: $ids)
213
+ }
214
+ `,
215
+ variables: {
216
+ ids
217
+ }
218
+ });
219
+ if (!response.errors) {
220
+ this.grist.fetch();
221
+ notify({
222
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
223
+ });
224
+ }
225
+ }
226
+ }
227
+ }
228
+ async _updateFinancialInstitution() {
229
+ let patches = this.grist.dirtyRecords;
230
+ if (patches && patches.length) {
231
+ patches = patches.map(patch => {
232
+ let patchField = patch.id ? { id: patch.id } : {};
233
+ const dirtyFields = patch.__dirtyfields__;
234
+ for (let key in dirtyFields) {
235
+ patchField[key] = dirtyFields[key].after;
236
+ }
237
+ patchField.cuFlag = patch.__dirty__;
238
+ return patchField;
239
+ });
240
+ const response = await client.mutate({
241
+ mutation: gql `
242
+ mutation ($patches: [FinancialInstitutionPatch!]!) {
243
+ updateMultipleFinancialInstitution(patches: $patches) {
244
+ name
245
+ }
246
+ }
247
+ `,
248
+ variables: {
249
+ patches
250
+ }
251
+ });
252
+ if (!response.errors) {
253
+ this.grist.fetch();
254
+ }
255
+ }
256
+ }
257
+ async creationCallback(financialInstitution) {
258
+ try {
259
+ const response = await client.query({
260
+ query: gql `
261
+ mutation ($financialInstitution: NewFinancialInstitution!) {
262
+ createFinancialInstitution(financialInstitution: $financialInstitution) {
263
+ id
264
+ }
265
+ }
266
+ `,
267
+ variables: {
268
+ financialInstitution
269
+ },
270
+ context: {
271
+ hasUpload: true
272
+ }
273
+ });
274
+ if (!response.errors) {
275
+ this.grist.fetch();
276
+ document.dispatchEvent(new CustomEvent('notify', {
277
+ detail: {
278
+ message: i18next.t('text.data_created_successfully')
279
+ }
280
+ }));
281
+ }
282
+ return true;
283
+ }
284
+ catch (ex) {
285
+ console.error(ex);
286
+ document.dispatchEvent(new CustomEvent('notify', {
287
+ detail: {
288
+ type: 'error',
289
+ message: i18next.t('text.error')
290
+ }
291
+ }));
292
+ return false;
293
+ }
294
+ }
295
+ async exportHandler() {
296
+ const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
297
+ const targetFieldSet = new Set([
298
+ 'id',
299
+ 'name',
300
+ 'description',
301
+ 'active'
302
+ ]);
303
+ return exportTargets.map(financialInstitution => {
304
+ let tempObj = {};
305
+ for (const field of targetFieldSet) {
306
+ tempObj[field] = financialInstitution[field];
307
+ }
308
+ return tempObj;
309
+ });
310
+ }
311
+ async importHandler(records) {
312
+ const popup = openPopup(html `
313
+ <financial-institution-importer
314
+ .financialInstitutions=${records}
315
+ @imported=${() => {
316
+ history.back();
317
+ this.grist.fetch();
318
+ }}
319
+ ></financial-institution-importer>
320
+ `, {
321
+ backdrop: true,
322
+ size: 'large',
323
+ title: i18next.t('title.import financial-institution')
324
+ });
325
+ popup.onclosed = () => {
326
+ this.grist.fetch();
327
+ };
328
+ }
329
+ };
330
+ FinancialInstitutionListPage.styles = [
331
+ ScrollbarStyles,
332
+ CommonGristStyles,
333
+ CommonHeaderStyles,
334
+ css `
335
+ :host {
336
+ display: flex;
337
+
338
+ width: 100%;
339
+
340
+ --grid-record-emphasized-background-color: #8B0000;
341
+ --grid-record-emphasized-color: #FF6B6B;
342
+ }
343
+
344
+ ox-grist {
345
+ overflow-y: auto;
346
+ flex: 1;
347
+ }
348
+
349
+ ox-filters-form {
350
+ flex: 1;
351
+ }
352
+ `
353
+ ];
354
+ __decorate([
355
+ property({ type: Object }),
356
+ __metadata("design:type", Object)
357
+ ], FinancialInstitutionListPage.prototype, "gristConfig", void 0);
358
+ __decorate([
359
+ property({ type: String }),
360
+ __metadata("design:type", String)
361
+ ], FinancialInstitutionListPage.prototype, "mode", void 0);
362
+ __decorate([
363
+ query('ox-grist'),
364
+ __metadata("design:type", DataGrist)
365
+ ], FinancialInstitutionListPage.prototype, "grist", void 0);
366
+ FinancialInstitutionListPage = __decorate([
367
+ customElement('financial-institution-list-page')
368
+ ], FinancialInstitutionListPage);
369
+ export { FinancialInstitutionListPage };
370
+ //# sourceMappingURL=financial-institution-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"financial-institution-list-page.js","sourceRoot":"","sources":["../../../client/pages/financial-institution/financial-institution-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,iCAAiC,CAAA;AACxC,OAAO,wCAAwC,CAAA;AAC/C,OAAO,0CAA0C,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5G,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAW,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAA;AA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BAAiB,SAAS;2DAAA;AApCjC,4BAA4B;IADxC,aAAa,CAAC,iCAAiC,CAAC;GACpC,4BAA4B,CAoXxC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/data-grist/ox-filters-form.js'\nimport '@operato/data-grist/ox-record-creator.js'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup, OxPrompt } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { FinancialInstitutionImporter } from './financial-institution-importer'\n\n@customElement('financial-institution-list-page')\nexport class FinancialInstitutionListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8B0000;\n --grid-record-emphasized-color: #FF6B6B;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form {\n flex: 1;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'financial-institution-importer': FinancialInstitutionImporter\n }\n }\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.financial-institution 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 help: 'accounting/financial-institution',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateFinancialInstitution.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteFinancialInstitution.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.financial-institution list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist\n .mode=${mode}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus without-search></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n\n <ox-record-creator id=\"add\" .callback=${this.creationCallback.bind(this)}>\n <button>\n <md-icon>add</md-icon>\n </button>\n </ox-record-creator>\n\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n appendable: false,\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: financialInstitutions(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\n updater {\n id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deleteFinancialInstitution() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteFinancialInstitutions(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updateFinancialInstitution() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [FinancialInstitutionPatch!]!) {\n updateMultipleFinancialInstitution(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n async creationCallback(financialInstitution) {\n try {\n const response = await client.query({\n query: gql`\n mutation ($financialInstitution: NewFinancialInstitution!) {\n createFinancialInstitution(financialInstitution: $financialInstitution) {\n id\n }\n }\n `,\n variables: {\n financialInstitution\n },\n context: {\n hasUpload: true\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n message: i18next.t('text.data_created_successfully')\n }\n })\n )\n }\n\n return true\n } catch (ex) {\n console.error(ex)\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n type: 'error',\n message: i18next.t('text.error')\n }\n })\n )\n return false\n }\n }\n\n async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set([\n 'id',\n 'name',\n 'description',\n 'active'\n ])\n\n return exportTargets.map(financialInstitution => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = financialInstitution[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <financial-institution-importer\n .financialInstitutions=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></financial-institution-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import financial-institution')\n }\n )\n \n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n\n"]}