@things-factory/tax-invoice 6.2.84

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 (151) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/bootstrap.ts +0 -0
  4. package/client/index.ts +0 -0
  5. package/client/pages/main.ts +25 -0
  6. package/client/pages/tax-audit-result/tax-audit-result-importer.ts +97 -0
  7. package/client/pages/tax-audit-result/tax-audit-result-list-page.ts +355 -0
  8. package/client/pages/tax-invoice/tax-invoice-detail-popup.ts +424 -0
  9. package/client/pages/tax-invoice/tax-invoice-list-page.ts +517 -0
  10. package/client/pages/tax-invoice-api/tax-invoice-api-page.ts +428 -0
  11. package/client/pages/tax-invoice-company/tax-invoice-company-importer.ts +175 -0
  12. package/client/pages/tax-invoice-company/tax-invoice-company-list-page.ts +496 -0
  13. package/client/route.ts +23 -0
  14. package/client/tsconfig.json +11 -0
  15. package/dist-client/bootstrap.d.ts +0 -0
  16. package/dist-client/bootstrap.js +2 -0
  17. package/dist-client/bootstrap.js.map +1 -0
  18. package/dist-client/index.d.ts +0 -0
  19. package/dist-client/index.js +2 -0
  20. package/dist-client/index.js.map +1 -0
  21. package/dist-client/pages/main.d.ts +1 -0
  22. package/dist-client/pages/main.js +27 -0
  23. package/dist-client/pages/main.js.map +1 -0
  24. package/dist-client/pages/tax-audit-result/tax-audit-result-importer.d.ts +22 -0
  25. package/dist-client/pages/tax-audit-result/tax-audit-result-importer.js +100 -0
  26. package/dist-client/pages/tax-audit-result/tax-audit-result-importer.js.map +1 -0
  27. package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.d.ts +62 -0
  28. package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.js +331 -0
  29. package/dist-client/pages/tax-audit-result/tax-audit-result-list-page.js.map +1 -0
  30. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.d.ts +14 -0
  31. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js +430 -0
  32. package/dist-client/pages/tax-invoice/tax-invoice-detail-popup.js.map +1 -0
  33. package/dist-client/pages/tax-invoice/tax-invoice-list-page.d.ts +70 -0
  34. package/dist-client/pages/tax-invoice/tax-invoice-list-page.js +500 -0
  35. package/dist-client/pages/tax-invoice/tax-invoice-list-page.js.map +1 -0
  36. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.d.ts +36 -0
  37. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js +419 -0
  38. package/dist-client/pages/tax-invoice-api/tax-invoice-api-page.js.map +1 -0
  39. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.d.ts +31 -0
  40. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js +182 -0
  41. package/dist-client/pages/tax-invoice-company/tax-invoice-company-importer.js.map +1 -0
  42. package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.d.ts +57 -0
  43. package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.js +477 -0
  44. package/dist-client/pages/tax-invoice-company/tax-invoice-company-list-page.js.map +1 -0
  45. package/dist-client/route.d.ts +1 -0
  46. package/dist-client/route.js +20 -0
  47. package/dist-client/route.js.map +1 -0
  48. package/dist-client/tsconfig.tsbuildinfo +1 -0
  49. package/dist-server/index.js +6 -0
  50. package/dist-server/index.js.map +1 -0
  51. package/dist-server/routes.js +25 -0
  52. package/dist-server/routes.js.map +1 -0
  53. package/dist-server/service/index.js +37 -0
  54. package/dist-server/service/index.js.map +1 -0
  55. package/dist-server/service/tax-audit-result/event-subscriber.js +21 -0
  56. package/dist-server/service/tax-audit-result/event-subscriber.js.map +1 -0
  57. package/dist-server/service/tax-audit-result/index.js +12 -0
  58. package/dist-server/service/tax-audit-result/index.js.map +1 -0
  59. package/dist-server/service/tax-audit-result/tax-audit-result-history.js +123 -0
  60. package/dist-server/service/tax-audit-result/tax-audit-result-history.js.map +1 -0
  61. package/dist-server/service/tax-audit-result/tax-audit-result-mutation.js +168 -0
  62. package/dist-server/service/tax-audit-result/tax-audit-result-mutation.js.map +1 -0
  63. package/dist-server/service/tax-audit-result/tax-audit-result-query.js +97 -0
  64. package/dist-server/service/tax-audit-result/tax-audit-result-query.js.map +1 -0
  65. package/dist-server/service/tax-audit-result/tax-audit-result-type.js +86 -0
  66. package/dist-server/service/tax-audit-result/tax-audit-result-type.js.map +1 -0
  67. package/dist-server/service/tax-audit-result/tax-audit-result.js +110 -0
  68. package/dist-server/service/tax-audit-result/tax-audit-result.js.map +1 -0
  69. package/dist-server/service/tax-invoice/index.js +9 -0
  70. package/dist-server/service/tax-invoice/index.js.map +1 -0
  71. package/dist-server/service/tax-invoice/tax-invoice-mutation.js +127 -0
  72. package/dist-server/service/tax-invoice/tax-invoice-mutation.js.map +1 -0
  73. package/dist-server/service/tax-invoice/tax-invoice-query.js +90 -0
  74. package/dist-server/service/tax-invoice/tax-invoice-query.js.map +1 -0
  75. package/dist-server/service/tax-invoice/tax-invoice-type.js +553 -0
  76. package/dist-server/service/tax-invoice/tax-invoice-type.js.map +1 -0
  77. package/dist-server/service/tax-invoice/tax-invoice.js +465 -0
  78. package/dist-server/service/tax-invoice/tax-invoice.js.map +1 -0
  79. package/dist-server/service/tax-invoice-api/index.js +9 -0
  80. package/dist-server/service/tax-invoice-api/index.js.map +1 -0
  81. package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js +64 -0
  82. package/dist-server/service/tax-invoice-api/tax-invoice-api-mutation.js.map +1 -0
  83. package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js +79 -0
  84. package/dist-server/service/tax-invoice-api/tax-invoice-api-query.js.map +1 -0
  85. package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js +103 -0
  86. package/dist-server/service/tax-invoice-api/tax-invoice-api-type.js.map +1 -0
  87. package/dist-server/service/tax-invoice-api/tax-invoice-api.js +163 -0
  88. package/dist-server/service/tax-invoice-api/tax-invoice-api.js.map +1 -0
  89. package/dist-server/service/tax-invoice-company/index.js +9 -0
  90. package/dist-server/service/tax-invoice-company/index.js.map +1 -0
  91. package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.js +80 -0
  92. package/dist-server/service/tax-invoice-company/tax-invoice-company-mutation.js.map +1 -0
  93. package/dist-server/service/tax-invoice-company/tax-invoice-company-query.js +89 -0
  94. package/dist-server/service/tax-invoice-company/tax-invoice-company-query.js.map +1 -0
  95. package/dist-server/service/tax-invoice-company/tax-invoice-company-type.js +100 -0
  96. package/dist-server/service/tax-invoice-company/tax-invoice-company-type.js.map +1 -0
  97. package/dist-server/service/tax-invoice-company/tax-invoice-company.js +166 -0
  98. package/dist-server/service/tax-invoice-company/tax-invoice-company.js.map +1 -0
  99. package/dist-server/service/tax-invoice-item/index.js +9 -0
  100. package/dist-server/service/tax-invoice-item/index.js.map +1 -0
  101. package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.js +127 -0
  102. package/dist-server/service/tax-invoice-item/tax-invoice-item-mutation.js.map +1 -0
  103. package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js +87 -0
  104. package/dist-server/service/tax-invoice-item/tax-invoice-item-query.js.map +1 -0
  105. package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js +121 -0
  106. package/dist-server/service/tax-invoice-item/tax-invoice-item-type.js.map +1 -0
  107. package/dist-server/service/tax-invoice-item/tax-invoice-item.js +115 -0
  108. package/dist-server/service/tax-invoice-item/tax-invoice-item.js.map +1 -0
  109. package/dist-server/tsconfig.tsbuildinfo +1 -0
  110. package/helps/tax-invoice/tax-audit-result.md +160 -0
  111. package/helps/tax-invoice/tax-invoice-api.md +160 -0
  112. package/helps/tax-invoice/tax-invoice-send.md +160 -0
  113. package/helps/tax-invoice/tax-invoice.md +160 -0
  114. package/package.json +37 -0
  115. package/server/index.ts +2 -0
  116. package/server/routes.ts +28 -0
  117. package/server/service/index.ts +36 -0
  118. package/server/service/tax-audit-result/event-subscriber.ts +17 -0
  119. package/server/service/tax-audit-result/index.ts +9 -0
  120. package/server/service/tax-audit-result/tax-audit-result-history.ts +110 -0
  121. package/server/service/tax-audit-result/tax-audit-result-mutation.ts +198 -0
  122. package/server/service/tax-audit-result/tax-audit-result-query.ts +62 -0
  123. package/server/service/tax-audit-result/tax-audit-result-type.ts +61 -0
  124. package/server/service/tax-audit-result/tax-audit-result.ts +95 -0
  125. package/server/service/tax-invoice/index.ts +6 -0
  126. package/server/service/tax-invoice/tax-invoice-mutation.ts +122 -0
  127. package/server/service/tax-invoice/tax-invoice-query.ts +54 -0
  128. package/server/service/tax-invoice/tax-invoice-type.ts +411 -0
  129. package/server/service/tax-invoice/tax-invoice.ts +389 -0
  130. package/server/service/tax-invoice-api/index.ts +6 -0
  131. package/server/service/tax-invoice-api/tax-invoice-api-mutation.ts +67 -0
  132. package/server/service/tax-invoice-api/tax-invoice-api-query.ts +48 -0
  133. package/server/service/tax-invoice-api/tax-invoice-api-type.ts +71 -0
  134. package/server/service/tax-invoice-api/tax-invoice-api.ts +137 -0
  135. package/server/service/tax-invoice-company/index.ts +6 -0
  136. package/server/service/tax-invoice-company/tax-invoice-company-mutation.ts +84 -0
  137. package/server/service/tax-invoice-company/tax-invoice-company-query.ts +53 -0
  138. package/server/service/tax-invoice-company/tax-invoice-company-type.ts +69 -0
  139. package/server/service/tax-invoice-company/tax-invoice-company.ts +142 -0
  140. package/server/service/tax-invoice-item/index.ts +6 -0
  141. package/server/service/tax-invoice-item/tax-invoice-item-mutation.ts +128 -0
  142. package/server/service/tax-invoice-item/tax-invoice-item-query.ts +57 -0
  143. package/server/service/tax-invoice-item/tax-invoice-item-type.ts +86 -0
  144. package/server/service/tax-invoice-item/tax-invoice-item.ts +85 -0
  145. package/server/tsconfig.json +10 -0
  146. package/things-factory.config.js +23 -0
  147. package/translations/en.json +1 -0
  148. package/translations/ja.json +1 -0
  149. package/translations/ko.json +71 -0
  150. package/translations/ms.json +1 -0
  151. package/translations/zh.json +1 -0
@@ -0,0 +1,428 @@
1
+ import '@operato/data-grist'
2
+
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
4
+ import { PageView } from '@operato/shell'
5
+ import { css, html } from 'lit'
6
+ import { customElement, property, query } from 'lit/decorators.js'
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
8
+ import { DataGrist, FetchOption } from '@operato/data-grist'
9
+ import { client } from '@operato/graphql'
10
+ import { i18next, localize } from '@operato/i18n'
11
+ import { notify } from '@operato/layout'
12
+ import { OxPrompt } from '@operato/popup'
13
+ import { isMobileDevice } from '@operato/utils'
14
+ import gql from 'graphql-tag'
15
+
16
+ @customElement('tax-invoice-api-page')
17
+ export class TaxInvoiceApiPage extends localize(i18next)(ScopedElementsMixin(PageView)) {
18
+ static styles = [
19
+ ScrollbarStyles,
20
+ CommonGristStyles,
21
+ css`
22
+ :host {
23
+ display: flex;
24
+
25
+ width: 100%;
26
+
27
+ --grid-record-emphasized-background-color: red;
28
+ --grid-record-emphasized-color: yellow;
29
+ }
30
+ `
31
+ ]
32
+
33
+ @property({ type: Object }) gristConfig: any
34
+ @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
35
+
36
+ @query('ox-grist') private grist!: DataGrist
37
+
38
+ get context() {
39
+ return {
40
+ title: i18next.t('title.tax invoice api'),
41
+ help: 'tax-invoice-api/tax-invoice-api',
42
+ actions: [
43
+ {
44
+ title: i18next.t('button.save'),
45
+ action: this._updateTaxInvoiceApi.bind(this),
46
+ ...CommonButtonStyles.save
47
+ },
48
+ {
49
+ title: i18next.t('button.delete'),
50
+ action: this._deleteTaxInvoiceApi.bind(this),
51
+ ...CommonButtonStyles.delete
52
+ }
53
+ ]
54
+ }
55
+ }
56
+
57
+ render() {
58
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
59
+
60
+ return html`
61
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
62
+ <div slot="headroom">
63
+ <div id="filters">
64
+ <ox-filters-form autofocus></ox-filters-form>
65
+ </div>
66
+ </div>
67
+ </ox-grist>
68
+ `
69
+ }
70
+
71
+ async pageInitialized(lifecycle: any) {
72
+ this.gristConfig = {
73
+ list: {
74
+ fields: ['name', 'description'],
75
+ details: ['name', 'updatedAt']
76
+ },
77
+ columns: [
78
+ { type: 'gutter', gutterName: 'sequence' },
79
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
80
+ {
81
+ type: 'string',
82
+ name: 'name',
83
+ header: i18next.t('field.name'),
84
+ record: {
85
+ editable: true,
86
+ classifier: () => ({ emphasized: ['#D1E8FF', '#000'] })
87
+ },
88
+ filter: 'search',
89
+ sortable: true,
90
+ width: 150
91
+ },
92
+ {
93
+ type: 'string',
94
+ name: 'description',
95
+ header: i18next.t('field.description'),
96
+ record: {
97
+ editable: true
98
+ },
99
+ filter: 'search',
100
+ width: 200
101
+ },
102
+ {
103
+ type: 'string',
104
+ name: 'apiKey',
105
+ header: i18next.t('field.api key'),
106
+ record: {
107
+ editable: true
108
+ },
109
+ width: 150
110
+ },
111
+ {
112
+ type: 'string',
113
+ name: 'apiAccountId',
114
+ header: i18next.t('field.api account id'),
115
+ record: {
116
+ editable: true
117
+ },
118
+ width: 150
119
+ },
120
+ {
121
+ type: 'password',
122
+ name: 'apiAccountPassword',
123
+ header: i18next.t('field.api account password'),
124
+ record: {
125
+ editable: true
126
+ },
127
+ width: 150
128
+ },
129
+ {
130
+ type: 'string',
131
+ name: 'businessRegistrationNumber',
132
+ header: i18next.t('field.business registration number'),
133
+ record: {
134
+ editable: true
135
+ },
136
+ width: 150
137
+ },
138
+ {
139
+ type: 'string',
140
+ name: 'branchIdentification',
141
+ header: i18next.t('field.branch identification'),
142
+ record: {
143
+ editable: true
144
+ },
145
+ width: 150
146
+ },
147
+ {
148
+ type: 'string',
149
+ name: 'businessName',
150
+ header: i18next.t('field.business name'),
151
+ record: {
152
+ editable: true
153
+ },
154
+ width: 150
155
+ },
156
+ {
157
+ type: 'string',
158
+ name: 'representativeName',
159
+ header: i18next.t('field.representative name'),
160
+ record: {
161
+ editable: true
162
+ },
163
+ width: 150
164
+ },
165
+ {
166
+ type: 'string',
167
+ name: 'address',
168
+ header: i18next.t('field.address'),
169
+ record: {
170
+ editable: true
171
+ },
172
+ width: 200
173
+ },
174
+ {
175
+ type: 'string',
176
+ name: 'businessType',
177
+ header: i18next.t('field.business type'),
178
+ record: {
179
+ editable: true
180
+ },
181
+ width: 100
182
+ },
183
+ {
184
+ type: 'string',
185
+ name: 'industryType',
186
+ header: i18next.t('field.industry type'),
187
+ record: {
188
+ editable: true
189
+ },
190
+ width: 100
191
+ },
192
+ {
193
+ type: 'string',
194
+ name: 'department',
195
+ header: i18next.t('field.department'),
196
+ record: {
197
+ editable: true
198
+ },
199
+ width: 150
200
+ },
201
+ {
202
+ type: 'string',
203
+ name: 'contactName',
204
+ header: i18next.t('field.contact name'),
205
+ record: {
206
+ editable: true
207
+ },
208
+ width: 150
209
+ },
210
+ {
211
+ type: 'string',
212
+ name: 'contactPhone',
213
+ header: i18next.t('field.contact phone'),
214
+ record: {
215
+ editable: true
216
+ },
217
+ width: 150
218
+ },
219
+ {
220
+ type: 'string',
221
+ name: 'contactEmail',
222
+ header: i18next.t('field.contact email'),
223
+ record: {
224
+ editable: true
225
+ },
226
+ width: 150
227
+ },
228
+ {
229
+ type: 'string',
230
+ name: 'contactCellPhone',
231
+ header: i18next.t('field.contact cell phone'),
232
+ record: {
233
+ editable: true
234
+ },
235
+ width: 150
236
+ },
237
+ {
238
+ type: 'attributes',
239
+ name: 'attributes',
240
+ header: i18next.t('field.attributes'),
241
+ record: {
242
+ editable: true,
243
+ options: async () => {
244
+ return {
245
+ objectified: true,
246
+ attributeSet: await this.getAttributeSetForDomain()
247
+ }
248
+ }
249
+ },
250
+ width: 150
251
+ },
252
+ {
253
+ type: 'resource-object',
254
+ name: 'updater',
255
+ header: i18next.t('field.updater'),
256
+ record: {
257
+ editable: false
258
+ },
259
+ width: 120
260
+ },
261
+ {
262
+ type: 'datetime',
263
+ name: 'updatedAt',
264
+ header: i18next.t('field.updated_at'),
265
+ record: {
266
+ editable: false
267
+ },
268
+ width: 180
269
+ }
270
+ ],
271
+ rows: {
272
+ selectable: {
273
+ multiple: true
274
+ }
275
+ },
276
+ sorters: [
277
+ {
278
+ name: 'name'
279
+ }
280
+ ]
281
+ }
282
+ }
283
+
284
+ async pageUpdated(changes: any, lifecycle: any) {
285
+ if (this.active) {
286
+ this.grist.fetch()
287
+ }
288
+ }
289
+
290
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
291
+ const response = await client.query({
292
+ query: gql`
293
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
294
+ responses: taxInvoiceApis(filters: $filters, pagination: $pagination, sortings: $sortings) {
295
+ items {
296
+ id
297
+ name
298
+ description
299
+ apiKey
300
+ apiAccountId
301
+ apiAccountPassword
302
+ businessRegistrationNumber
303
+ branchIdentification
304
+ businessName
305
+ representativeName
306
+ address
307
+ businessType
308
+ industryType
309
+ department
310
+ contactName
311
+ contactPhone
312
+ contactEmail
313
+ contactCellPhone
314
+ updater {
315
+ id
316
+ name
317
+ }
318
+ updatedAt
319
+ }
320
+ total
321
+ }
322
+ }
323
+ `,
324
+ variables: {
325
+ filters,
326
+ pagination: { page, limit },
327
+ sortings
328
+ }
329
+ })
330
+
331
+ return {
332
+ total: response.data.responses.total || 0,
333
+ records: response.data.responses.items || []
334
+ }
335
+ }
336
+
337
+ async _deleteTaxInvoiceApi() {
338
+ if (
339
+ await OxPrompt.open({
340
+ title: i18next.t('text.are_you_sure'),
341
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
342
+ confirmButton: { text: i18next.t('button.confirm') },
343
+ cancelButton: { text: i18next.t('button.cancel') }
344
+ })
345
+ ) {
346
+ const ids = this.grist.selected.map(record => record.id)
347
+ if (ids && ids.length > 0) {
348
+ const response = await client.mutate({
349
+ mutation: gql`
350
+ mutation ($ids: [String!]!) {
351
+ deleteTaxInvoiceApis(ids: $ids)
352
+ }
353
+ `,
354
+ variables: {
355
+ ids
356
+ }
357
+ })
358
+
359
+ if (!response.errors) {
360
+ this.grist.fetch()
361
+ notify({
362
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
363
+ })
364
+ }
365
+ }
366
+ }
367
+ }
368
+
369
+ async _updateTaxInvoiceApi() {
370
+ let patches = this.grist.dirtyRecords
371
+ if (patches && patches.length) {
372
+ patches = patches.map(patch => {
373
+ let patchField: any = patch.id ? { id: patch.id } : {}
374
+ const dirtyFields = patch.__dirtyfields__
375
+ for (let key in dirtyFields) {
376
+ patchField[key] = key === 'type' ? Number(dirtyFields[key].after) : dirtyFields[key].after
377
+ }
378
+ patchField.cuFlag = patch.__dirty__
379
+
380
+ return patchField
381
+ })
382
+
383
+ const response = await client.mutate({
384
+ mutation: gql`
385
+ mutation ($patches: [TaxInvoiceApiPatch!]!) {
386
+ updateMultipleTaxInvoiceApis(patches: $patches) {
387
+ name
388
+ }
389
+ }
390
+ `,
391
+ variables: {
392
+ patches
393
+ }
394
+ })
395
+
396
+ if (!response.errors) {
397
+ this.grist.fetch()
398
+ notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.save') }) })
399
+ } else {
400
+ notify({ message: i18next.t('error.fail-save'), level: 'error' })
401
+ }
402
+ }
403
+ }
404
+
405
+ async getAttributeSetForDomain() {
406
+ const response = await client.query({
407
+ query: gql`
408
+ query {
409
+ attributeSet: attributeSetByEntity(entity: "Domain") {
410
+ entity
411
+ description
412
+ items {
413
+ name
414
+ description
415
+ tag
416
+ type
417
+ active
418
+ hidden
419
+ options
420
+ }
421
+ }
422
+ }
423
+ `
424
+ })
425
+
426
+ return response.data?.attributeSet || {}
427
+ }
428
+ }
@@ -0,0 +1,175 @@
1
+ import '@operato/data-grist'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement } from 'lit'
5
+ import { property } from 'lit/decorators.js'
6
+
7
+ import { client } from '@operato/graphql'
8
+ import { i18next } from '@operato/i18n'
9
+ import { isMobileDevice } from '@operato/utils'
10
+ import { COMPANY_TYPE_LABEL } from './tax-invoice-company-list-page'
11
+
12
+ export class TaxInvoiceCompanyImporter extends LitElement {
13
+ static styles = [
14
+ css`
15
+ :host {
16
+ display: flex;
17
+ flex-direction: column;
18
+
19
+ background-color: #fff;
20
+ }
21
+
22
+ ox-grist {
23
+ flex: 1;
24
+ }
25
+
26
+ .button-container {
27
+ display: flex;
28
+ margin-left: auto;
29
+ padding: var(--padding-default);
30
+ }
31
+
32
+ mwc-button {
33
+ margin-left: var(--margin-default);
34
+ }
35
+ `
36
+ ]
37
+
38
+ @property({ type: Array }) taxInvoiceCompanies: any[] = []
39
+ @property({ type: Object }) columns = {
40
+ list: { fields: ['name', 'description'] },
41
+ pagination: { infinite: true },
42
+ columns: [
43
+ {
44
+ type: 'string',
45
+ name: 'name',
46
+ header: i18next.t('field.name'),
47
+ width: 150
48
+ },
49
+ {
50
+ type: 'string',
51
+ name: 'description',
52
+ header: i18next.t('field.description'),
53
+ width: 200
54
+ },
55
+ {
56
+ type: 'select',
57
+ name: 'type',
58
+ header: i18next.t('field.type'),
59
+ record: {
60
+ renderer: value => COMPANY_TYPE_LABEL[value]
61
+ },
62
+ width: 100
63
+ },
64
+ {
65
+ type: 'string',
66
+ name: 'businessRegistrationNumber',
67
+ header: i18next.t('field.business registration number'),
68
+ width: 150
69
+ },
70
+ {
71
+ type: 'string',
72
+ name: 'branchIdentification',
73
+ header: i18next.t('field.branch identification'),
74
+ width: 150
75
+ },
76
+ {
77
+ type: 'string',
78
+ name: 'businessName',
79
+ header: i18next.t('field.business name'),
80
+ width: 150
81
+ },
82
+ {
83
+ type: 'string',
84
+ name: 'representativeName',
85
+ header: i18next.t('field.representative name'),
86
+ width: 150
87
+ },
88
+ {
89
+ type: 'string',
90
+ name: 'address',
91
+ header: i18next.t('field.address'),
92
+ width: 200
93
+ },
94
+ {
95
+ type: 'string',
96
+ name: 'businessType',
97
+ header: i18next.t('field.business type'),
98
+ width: 100
99
+ },
100
+ {
101
+ type: 'string',
102
+ name: 'industryType',
103
+ header: i18next.t('field.industry type'),
104
+ width: 100
105
+ },
106
+ {
107
+ type: 'string',
108
+ name: 'department',
109
+ header: i18next.t('field.department'),
110
+ width: 150
111
+ },
112
+ {
113
+ type: 'string',
114
+ name: 'contactName',
115
+ header: i18next.t('field.contact name'),
116
+ width: 150
117
+ },
118
+ {
119
+ type: 'string',
120
+ name: 'contactPhone',
121
+ header: i18next.t('field.contact phone'),
122
+ width: 150
123
+ },
124
+ {
125
+ type: 'string',
126
+ name: 'contactEmail',
127
+ header: i18next.t('field.contact email'),
128
+ width: 150
129
+ },
130
+ {
131
+ type: 'string',
132
+ name: 'contactCellPhone',
133
+ header: i18next.t('field.contact cell phone'),
134
+ width: 150
135
+ },
136
+ {
137
+ type: 'attributes',
138
+ name: 'attributes',
139
+ header: i18next.t('field.attributes'),
140
+ width: 150
141
+ }
142
+ ]
143
+ }
144
+
145
+ render() {
146
+ return html`
147
+ <ox-grist
148
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
149
+ .config=${this.columns}
150
+ .data=${{
151
+ records: this.taxInvoiceCompanies
152
+ }}
153
+ ></ox-grist>
154
+
155
+ <div class="button-container">
156
+ <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
157
+ </div>
158
+ `
159
+ }
160
+
161
+ async save() {
162
+ const response = await client.mutate({
163
+ mutation: gql`
164
+ mutation importTaxInvoiceCompanies($taxInvoiceCompanies: [TaxInvoiceCompanyPatch!]!) {
165
+ importTaxInvoiceCompanies(taxInvoiceCompanies: $taxInvoiceCompanies)
166
+ }
167
+ `,
168
+ variables: { taxInvoiceCompanies: this.taxInvoiceCompanies }
169
+ })
170
+
171
+ if (response.errors?.length) return
172
+
173
+ this.dispatchEvent(new CustomEvent('imported'))
174
+ }
175
+ }