@things-factory/operato-wms 4.3.300 → 4.3.301

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.
@@ -0,0 +1,490 @@
1
+ import '@things-factory/form-ui'
2
+ import '@things-factory/grist-ui'
3
+
4
+ import gql from 'graphql-tag'
5
+ import {
6
+ css,
7
+ html
8
+ } from 'lit-element'
9
+ import { connect } from 'pwa-helpers/connect-mixin'
10
+
11
+ import {
12
+ i18next,
13
+ localize
14
+ } from '@things-factory/i18n-base'
15
+ import {
16
+ client,
17
+ gqlContext,
18
+ PageView,
19
+ store
20
+ } from '@things-factory/shell'
21
+ import { isMobileDevice } from '@things-factory/utils'
22
+
23
+ class AnalysisPickingPackingReport extends connect(store)(localize(i18next)(PageView)) {
24
+ static get styles() {
25
+ return css`
26
+ :host {
27
+ display: flex;
28
+ flex-direction: column;
29
+ width: 100%;
30
+ }
31
+
32
+ data-grist {
33
+ overflow-y: auto;
34
+ flex: 1;
35
+ }
36
+ `
37
+ }
38
+
39
+ static get properties() {
40
+ return {
41
+ _searchFields: Object,
42
+ _config: Object,
43
+ _gristData: Object,
44
+ data: Object
45
+ }
46
+ }
47
+
48
+ get context() {
49
+ return {
50
+ title: i18next.t('title.analytics_report'),
51
+ exportable: {
52
+ name: i18next.t('title.analytics_report'),
53
+ data: this._exportableData.bind(this)
54
+ },
55
+ help: ''
56
+ }
57
+ }
58
+
59
+ get dataGrist() {
60
+ return this.shadowRoot.querySelector('data-grist')
61
+ }
62
+
63
+ get searchForm() {
64
+ return this.shadowRoot.querySelector('search-form')
65
+ }
66
+
67
+ get _bizplaceSelector() {
68
+ return this.searchForm.shadowRoot.querySelector('select[name=bizplace]')
69
+ }
70
+
71
+ get _fromDateInput() {
72
+ return this.searchForm.shadowRoot.querySelector('input[name=fromDate]')
73
+ }
74
+
75
+ get _toDateInput() {
76
+ return this.searchForm.shadowRoot.querySelector('input[name=toDate]')
77
+ }
78
+
79
+ render() {
80
+ return html`
81
+ <search-form id="search-form" .fields=${this._searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
82
+
83
+ <data-grist
84
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
85
+ .config=${this._config}
86
+ .fetchHandler="${this.fetchHandler.bind(this)}"
87
+ ></data-grist>
88
+ `
89
+ }
90
+
91
+ get searchFields() {
92
+ const sortingOptions = [
93
+ { name: i18next.t('label.desc'), value: 'desc' },
94
+ { name: i18next.t('label.asc'), value: 'asc' }
95
+ ]
96
+
97
+ const sortingTypes = [
98
+ { name: i18next.t('label.packing'), value: 'packing' },
99
+ { name: i18next.t('label.picking'), value: 'picking' }
100
+ ]
101
+
102
+ return [
103
+ {
104
+ label: i18next.t('field.company'),
105
+ name: 'bizplace',
106
+ type: 'select',
107
+ options: [
108
+ { value: '' },
109
+ ...this._partners
110
+ .map(partner => {
111
+ return {
112
+ name: `${partner.name} ${partner.description ? `(${partner.description})` : ''}`,
113
+ value: partner.id
114
+ }
115
+ })
116
+ .sort(this._compareValues('name', 'asc'))
117
+ ],
118
+ props: { searchOper: 'eq' }
119
+ },
120
+ {
121
+ label: i18next.t('field.from_date'),
122
+ name: 'fromDate',
123
+ type: 'date',
124
+ props: {
125
+ searchOper: 'eq',
126
+ max: new Date().toISOString().split('T')[0]
127
+ },
128
+ value: (() => {
129
+ let date = new Date()
130
+ date.setMonth(date.getMonth() - 1)
131
+ return date.toISOString().split('T')[0]
132
+ })(),
133
+ handlers: { change: this._modifyDateRange.bind(this) }
134
+ },
135
+ {
136
+ label: i18next.t('field.to_date'),
137
+ name: 'toDate',
138
+ type: 'date',
139
+ props: {
140
+ searchOper: 'eq',
141
+ min: (() => {
142
+ let date = new Date()
143
+ date.setMonth(date.getMonth() - 1)
144
+ return date.toISOString().split('T')[0]
145
+ })(),
146
+ max: new Date().toISOString().split('T')[0]
147
+ },
148
+ value: new Date().toISOString().split('T')[0],
149
+ handlers: { change: this._submit.bind(this) }
150
+ },
151
+ {
152
+ label: i18next.t('field.name'),
153
+ name: 'name',
154
+ type: 'string',
155
+ props: { searchOper: 'custom' }
156
+ },
157
+ {
158
+ label: i18next.t('field.rate'),
159
+ name: 'rate',
160
+ type: 'select',
161
+ options: sortingOptions,
162
+ props: { searchOper: 'eq' }
163
+ },
164
+ {
165
+ label: i18next.t('field.type'),
166
+ name: 'type',
167
+ type: 'select',
168
+ options: sortingTypes,
169
+ props: { searchOper: 'eq' }
170
+ }
171
+ ]
172
+ }
173
+
174
+ get reportConfig() {
175
+ const getTimeRangeHeader = hour => {
176
+ const now = new Date()
177
+ now.setHours(hour)
178
+ const next = new Date(now)
179
+ next.setHours(now.getHours() + 1)
180
+ return `${now.toLocaleString('en-US', { hour: 'numeric', hour12: true })} - ${next.toLocaleString('en-US', {
181
+ hour: 'numeric',
182
+ hour12: true
183
+ })}`
184
+ }
185
+
186
+ const timeRangeColumns = Array.from({ length: 12 }, (_, i) => {
187
+ const startHour = i + 7
188
+ const header = getTimeRangeHeader(startHour)
189
+ return {
190
+ type: 'string',
191
+ name: `${startHour}`,
192
+ header: header,
193
+ record: { editable: false, align: 'center' },
194
+ width: 120
195
+ }
196
+ })
197
+
198
+ let columns = [
199
+ { type: 'gutter', gutterName: 'sequence' },
200
+ {
201
+ type: 'string',
202
+ name: 'name',
203
+ header: i18next.t('field.name'),
204
+ width: 200
205
+ },
206
+ ...timeRangeColumns, // Using the time range columns array directly
207
+ {
208
+ type: 'float',
209
+ name: 'totalDaysWorked',
210
+ header: i18next.t('field.total_days_worked'),
211
+ width: 160
212
+ },
213
+ {
214
+ type: 'float',
215
+ name: 'totalPacks',
216
+ header: i18next.t('field.total_pack'),
217
+ width: 110,
218
+ align: 'center'
219
+ },
220
+ {
221
+ type: 'float',
222
+ name: 'totalHoursWorked',
223
+ header: i18next.t('field.total_hours_worked'),
224
+ width: 170
225
+ },
226
+ {
227
+ type: 'float',
228
+ name: 'packingRate',
229
+ header: i18next.t('field.packing_rate'),
230
+ width: 150
231
+ }
232
+ ]
233
+
234
+ let list = {
235
+ fields: [
236
+ 'name',
237
+ '7AM-8AM',
238
+ '8AM-9AM',
239
+ '9AM-10AM',
240
+ '10AM-11AM',
241
+ '11AM-12PM',
242
+ '12PM-1PM',
243
+ '1PM-2PM',
244
+ '2PM-3PM',
245
+ '3PM-4PM',
246
+ '4PM-5PM',
247
+ '5PM-6PM',
248
+ '6PM-7PM',
249
+ 'totalDaysWorked',
250
+ 'totalPacks',
251
+ 'totalHoursWorked',
252
+ 'packingRate'
253
+ ]
254
+ }
255
+
256
+ return {
257
+ columns: columns,
258
+ list,
259
+ pagination: { limit: 50, pages: [100, 200, 500, 1000] },
260
+ rows: {
261
+ selectable: false,
262
+ insertable: false,
263
+ appendable: false
264
+ }
265
+ }
266
+ }
267
+
268
+ async pageInitialized() {
269
+ this._gristData = { total: 0, records: [] }
270
+ const [_partnersReq] = await Promise.allSettled([this._fetchPartners()])
271
+
272
+ this._partners = _partnersReq.status == 'fulfilled' ? _partnersReq.value : []
273
+
274
+ this._searchFields = this.searchFields
275
+ this._config = this.reportConfig
276
+ }
277
+
278
+ async fetchHandler({ page, limit, sorters = [] }) {
279
+ try {
280
+ this._validate()
281
+ let filters = this.searchForm.queryFilters.map(filter => {
282
+ switch (filter.name) {
283
+ case 'fromDate':
284
+ let fromDt = new Date(filter.value)
285
+ fromDt.setHours(0)
286
+ filter.value = fromDt.toISOString()
287
+ break
288
+ case 'toDate':
289
+ let toDt = new Date(filter.value)
290
+ toDt.setHours(23, 59, 59)
291
+ filter.value = toDt.toISOString()
292
+ break
293
+ default:
294
+ break
295
+ }
296
+ return filter
297
+ })
298
+
299
+ const pagination = { page, limit }
300
+ const sortings = sorters
301
+
302
+ const response = await client.query({
303
+ query: gql`
304
+ query analysisPickingPackingReport($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
305
+ analysisPickingPackingReport(filters: $filters, pagination: $pagination, sortings: $sortings) {
306
+ items {
307
+ name
308
+ hourlyData
309
+ totalDaysWorked
310
+ totalPacks
311
+ totalHoursWorked
312
+ packingRate
313
+ }
314
+ total
315
+ }
316
+ }
317
+ `,
318
+ variables: { filters, pagination, sortings },
319
+ context: gqlContext()
320
+ })
321
+
322
+ const data = {
323
+ total: response.data.analysisPickingPackingReport.total,
324
+ records:
325
+ response.data.analysisPickingPackingReport.items.map(i=> {
326
+ let hourlyData = JSON.parse(i.hourlyData)
327
+ return {
328
+ ...i,
329
+ ...hourlyData
330
+ }
331
+ }) || []
332
+ }
333
+
334
+ this._gristData = {
335
+ ...data
336
+ }
337
+
338
+ return data
339
+ } catch (e) {
340
+ this._showToast(e)
341
+ }
342
+
343
+ }
344
+
345
+ async _fetchPartners() {
346
+ const filters = []
347
+ const response = await client.query({
348
+ query: gql`
349
+ query partnersBizplaces($filters: [Filter!]) {
350
+ partnersBizplaces(filters: $filters) {
351
+ items {
352
+ id
353
+ name
354
+ description
355
+ }
356
+ }
357
+ }
358
+ `,
359
+ variables: { filters }
360
+ })
361
+
362
+ if (!response.errors) {
363
+ return response.data.partnersBizplaces.items
364
+ }
365
+ }
366
+
367
+ _validate() {
368
+ if (!this.searchForm.shadowRoot.querySelector('form').checkValidity())
369
+ throw new Error(i18next.t('text.invalid_form_value'))
370
+ if (!this._bizplaceSelector.value) throw new Error(i18next.t('text.no_company_selected'))
371
+ if (!this._fromDateInput.value) throw new Error(i18next.t('text.from_date_is_empty'))
372
+ if (!this._toDateInput.value) throw new Error(i18next.t('text.to_date_is_empty'))
373
+ }
374
+
375
+ _compareValues(key, order = 'asc') {
376
+ return function innerSort(a, b) {
377
+ if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
378
+ return 0
379
+ }
380
+
381
+ const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key]
382
+ const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key]
383
+
384
+ let comparison = 0
385
+ if (varA > varB) {
386
+ comparison = 1
387
+ } else if (varA < varB) {
388
+ comparison = -1
389
+ }
390
+ return order === 'desc' ? comparison * -1 : comparison
391
+ }
392
+ }
393
+
394
+ _modifyDateRange(e) {
395
+ const fromDate = e.currentTarget.value
396
+
397
+ if (this._toDateInput.value < fromDate) this._toDateInput.value = fromDate
398
+
399
+ let min = new Date(fromDate).toISOString().split('T')[0]
400
+ this._toDateInput.min = min
401
+ this._submit()
402
+ }
403
+
404
+ _submit(e) {
405
+ this._config = { ...this.reportConfig }
406
+ this.searchForm.submit()
407
+ }
408
+
409
+ async _exportableData() {
410
+ try {
411
+ const getTimeRangeHeader = hour => {
412
+ const now = new Date();
413
+ now.setHours(hour);
414
+ const next = new Date(now);
415
+ next.setHours(now.getHours() + 1);
416
+ return `${now.toLocaleString('en-US', { hour: 'numeric', hour12: true })} - ${next.toLocaleString('en-US', {
417
+ hour: 'numeric',
418
+ hour12: true
419
+ })}`;
420
+ };
421
+
422
+ const timeRangeColumns = Array.from({ length: 12 }, (_, i) => {
423
+ const startHour = i + 7;
424
+ const header = getTimeRangeHeader(startHour);
425
+ const key = `${startHour}`;
426
+ return {
427
+ type: 'number',
428
+ name: `${startHour}`,
429
+ header: header,
430
+ key: key,
431
+ record: { editable: false, align: 'center' },
432
+ width: 20
433
+ };
434
+ });
435
+
436
+ const headerSetting = [
437
+ { header: i18next.t('field.name'), key: 'name', width: 30, type: 'string' },
438
+ ...timeRangeColumns,
439
+ { header: i18next.t('field.total_days_worked'), key: 'totalDaysWorked', width: 30, type: 'float' },
440
+ { header: i18next.t('field.total_pack'), key: 'totalPacks', width: 30, type: 'float' },
441
+ { header: i18next.t('field.total_hours_worked'), key: 'totalHoursWorked', width: 30, type: 'float' },
442
+ { header: i18next.t('field.packing_rate'), key: 'packingRate', width: 30, type: 'float' }
443
+ ];
444
+
445
+ let data = (await this.fetchHandler({ page: 1, limit: 9999999 })).records.map(itm => {
446
+ const hourlyData = JSON.parse(itm.hourlyData); // Parse the hourly data from JSON
447
+ const timeRangeData = Array.from({ length: 12 }, (_, i) => {
448
+ const startHour = i + 7;
449
+ const key = `${startHour}`;
450
+ const value = parseFloat(hourlyData[startHour.toString()]) || 0; // Convert to number
451
+ return {
452
+ [key]: value
453
+ };
454
+ }).reduce((obj, item) => ({ ...obj, ...item }), {});
455
+
456
+ return {
457
+ ...timeRangeData,
458
+ name: itm.name,
459
+ totalDaysWorked: itm.totalDaysWorked,
460
+ totalPacks: itm.totalPacks,
461
+ totalHoursWorked: itm.totalHoursWorked,
462
+ packingRate: itm.packingRate
463
+ };
464
+ });
465
+
466
+ var exportData = {
467
+ header: [...headerSetting],
468
+ data
469
+ };
470
+
471
+ return exportData;
472
+
473
+ } catch (e) {
474
+ this._showToast(e);
475
+ }
476
+ }
477
+
478
+ _showToast({ type, message }) {
479
+ document.dispatchEvent(
480
+ new CustomEvent('notify', {
481
+ detail: {
482
+ type,
483
+ message
484
+ }
485
+ })
486
+ )
487
+ }
488
+ }
489
+
490
+ window.customElements.define('analysis-picking-packing-report', AnalysisPickingPackingReport)
package/client/route.js CHANGED
@@ -497,6 +497,10 @@ export default function route(page) {
497
497
  import('./pages/report/vas-report')
498
498
  return page
499
499
 
500
+ case 'analysis_picking_packing_report':
501
+ import('./pages/report/analysis-picking-packing-report')
502
+ return page
503
+
500
504
  /**
501
505
  * Custom ELCCL Menus Section
502
506
  */
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analysisPickingPackingReport = void 0;
4
+ const biz_base_1 = require("@things-factory/biz-base");
5
+ const utils_1 = require("../../../utils");
6
+ exports.analysisPickingPackingReport = {
7
+ async analysisPickingPackingReport(_, params, context) {
8
+ try {
9
+ const { tx, domain } = context.state;
10
+ let bizplace = params.filters.find((data) => data.name === 'bizplace');
11
+ let fromDate = params.filters.find((data) => data.name == 'fromDate');
12
+ let toDate = params.filters.find((data) => data.name == 'toDate');
13
+ let name = params.filters.find((data) => data.name === 'name');
14
+ let rate = params.filters.find((data) => data.name === 'rate');
15
+ let type = params.filters.find((data) => data.name === 'type');
16
+ // throw error bizplace filter missing
17
+ if (!bizplace)
18
+ throw 'Invalid input';
19
+ let queryFilter = '';
20
+ if (name) {
21
+ let nameValue = name.value
22
+ .toLowerCase()
23
+ .split(',')
24
+ .map((prod) => {
25
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'";
26
+ })
27
+ .join(',');
28
+ queryFilter += `AND (
29
+ Lower(u.name) LIKE ANY(ARRAY[${nameValue}])
30
+ )`;
31
+ }
32
+ let sortingTypes = '';
33
+ if (type) {
34
+ let typeValue = type.value;
35
+ if (typeValue === 'packing' || typeValue === 'picking') {
36
+ sortingTypes = `AND ih.transaction_type = '${typeValue.toUpperCase()}'`;
37
+ }
38
+ }
39
+ let sortingOptions = '';
40
+ if (rate) {
41
+ let rateValue = rate.value;
42
+ if (rateValue === 'asc' || rateValue === 'desc') {
43
+ sortingOptions = `ORDER BY packing_rates."packingRate" ${rateValue.toUpperCase()}`;
44
+ }
45
+ }
46
+ if (bizplace) {
47
+ queryFilter += ` AND ih.bizplace_id = '${bizplace.value}'`;
48
+ }
49
+ const bizplaceObj = await tx.getRepository(biz_base_1.Bizplace).findOne({
50
+ id: bizplace.value
51
+ });
52
+ await (0, utils_1.rawProductsQuery)(tx, params, bizplaceObj);
53
+ const fromDateValue = new Date(fromDate.value);
54
+ const toDateValue = new Date(toDate.value);
55
+ // Check if the date objects are valid
56
+ if (isNaN(fromDateValue.getTime()) || isNaN(toDateValue.getTime())) {
57
+ throw new Error('Invalid date format. Please provide valid date values.');
58
+ }
59
+ const sqlQuery = `
60
+ WITH packing_rates AS (
61
+ SELECT
62
+ u.name,
63
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 7 THEN 1 ELSE 0 END) AS "7",
64
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 8 THEN 1 ELSE 0 END) AS "8",
65
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 9 THEN 1 ELSE 0 END) AS "9",
66
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 10 THEN 1 ELSE 0 END) AS "10",
67
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 11 THEN 1 ELSE 0 END) AS "11",
68
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 12 THEN 1 ELSE 0 END) AS "12",
69
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 13 THEN 1 ELSE 0 END) AS "13",
70
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 14 THEN 1 ELSE 0 END) AS "14",
71
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 15 THEN 1 ELSE 0 END) AS "15",
72
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 16 THEN 1 ELSE 0 END) AS "16",
73
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 17 THEN 1 ELSE 0 END) AS "17",
74
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 18 THEN 1 ELSE 0 END) AS "18",
75
+ COUNT(DISTINCT DATE(ih.created_at)) AS "totalDaysWorked",
76
+ COUNT(DISTINCT DATE_TRUNC('hour', (ih.created_at + INTERVAL '8 HOUR'))) AS "totalHoursWorked",
77
+ COUNT(*) AS "totalPacks",
78
+ ROUND(COUNT(*) / COUNT(DISTINCT DATE_TRUNC('hour', (ih.created_at + INTERVAL '8 HOUR')))) AS "packingRate"
79
+ FROM
80
+ inventory_histories ih
81
+ INNER JOIN
82
+ users u ON ih.creator_id = u.id
83
+ WHERE
84
+ ih.domain_id = $1
85
+ AND ih.created_at BETWEEN $2 AND $3
86
+ ${queryFilter}
87
+ ${sortingTypes}
88
+ GROUP BY
89
+ u.name
90
+ )
91
+ SELECT
92
+ "name",
93
+ "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
94
+ packing_rates."totalDaysWorked",
95
+ "totalPacks",
96
+ packing_rates."totalHoursWorked",
97
+ packing_rates."packingRate"
98
+ FROM
99
+ packing_rates
100
+ ${sortingOptions}
101
+ `;
102
+ const result = await tx.query(sqlQuery, [domain.id, fromDate.value, toDate.value]);
103
+ return {
104
+ items: result.map((data) => {
105
+ return Object.assign(Object.assign({}, data), { name: data.name, hourlyData: JSON.stringify({
106
+ 7: data["7"],
107
+ 8: data["8"],
108
+ 9: data["9"],
109
+ 10: data["10"],
110
+ 11: data["11"],
111
+ 12: data["12"],
112
+ 13: data["13"],
113
+ 14: data["14"],
114
+ 15: data["15"],
115
+ 16: data["16"],
116
+ 17: data["17"],
117
+ 18: data["18"],
118
+ }) });
119
+ }),
120
+ total: result.length
121
+ };
122
+ }
123
+ catch (error) {
124
+ throw error;
125
+ }
126
+ }
127
+ };
128
+ //# sourceMappingURL=analysis-picking-packing-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis-picking-packing-report.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/analysis-picking-packing-report.ts"],"names":[],"mappings":"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"}
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Query = void 0;
4
- const inbound_serial_number_report_1 = require("./inbound-serial-number-report");
5
- const outbound_serial_number_report_1 = require("./outbound-serial-number-report");
4
+ const analysis_picking_packing_report_1 = require("./analysis-picking-packing-report");
6
5
  const costing_report_1 = require("./costing-report");
7
6
  const inbound_order_details_report_1 = require("./inbound-order-details-report");
7
+ const inbound_serial_number_report_1 = require("./inbound-serial-number-report");
8
8
  const outbound_order_details_report_1 = require("./outbound-order-details-report");
9
+ const outbound_serial_number_report_1 = require("./outbound-serial-number-report");
9
10
  const product_label_report_1 = require("./product-label-report");
10
11
  const release_inventory_report_1 = require("./release-inventory-report");
11
12
  const tote_loading_qc_report_1 = require("./tote-loading-qc-report");
12
13
  const vas_report_1 = require("./vas-report");
13
- exports.Query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inbound_serial_number_report_1.inboundSerialNumberReport), outbound_serial_number_report_1.outboundSerialNumberReport), costing_report_1.costingReport), inbound_order_details_report_1.inboundOrderDetailsReport), outbound_order_details_report_1.outboundOrderDetailsReport), product_label_report_1.productLabelReport), release_inventory_report_1.releaseInventoryReport), tote_loading_qc_report_1.loadingQcReport), vas_report_1.orderVasReport), vas_report_1.vasReport);
14
+ exports.Query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inbound_serial_number_report_1.inboundSerialNumberReport), outbound_serial_number_report_1.outboundSerialNumberReport), costing_report_1.costingReport), inbound_order_details_report_1.inboundOrderDetailsReport), outbound_order_details_report_1.outboundOrderDetailsReport), product_label_report_1.productLabelReport), release_inventory_report_1.releaseInventoryReport), tote_loading_qc_report_1.loadingQcReport), vas_report_1.orderVasReport), vas_report_1.vasReport), analysis_picking_packing_report_1.analysisPickingPackingReport);
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0E;AAC1E,mFAA4E;AAE5E,qDAAgD;AAChD,iFAA0E;AAC1E,mFAA4E;AAC5E,iEAA2D;AAC3D,yEAAmE;AACnE,qEAA0D;AAC1D,6CAAwD;AAE3C,QAAA,KAAK,mJACb,wDAAyB,GACzB,0DAA0B,GAC1B,8BAAa,GACb,wDAAyB,GACzB,0DAA0B,GAC1B,yCAAkB,GAClB,iDAAsB,GACtB,wCAAe,GACf,2BAAc,GACd,sBAAS,EACb"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/reports/index.ts"],"names":[],"mappings":";;;AAAA,uFAAgF;AAChF,qDAAgD;AAChD,iFAA0E;AAC1E,iFAA0E;AAC1E,mFAA4E;AAC5E,mFAA4E;AAC5E,iEAA2D;AAC3D,yEAAmE;AACnE,qEAA0D;AAC1D,6CAAwD;AAE3C,QAAA,KAAK,iKACb,wDAAyB,GACzB,0DAA0B,GAC1B,8BAAa,GACb,wDAAyB,GACzB,0DAA0B,GAC1B,yCAAkB,GAClB,iDAAsB,GACtB,wCAAe,GACf,2BAAc,GACd,sBAAS,GACT,8DAA4B,EAChC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AnalysisPickingPackingReportList = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.AnalysisPickingPackingReportList = (0, graphql_tag_1.default) `
9
+ type AnalysisPickingPackingReportList {
10
+ items: [AnalysisPickingPackingReport]
11
+ total: Int
12
+ }
13
+ `;
14
+ //# sourceMappingURL=analysis-picking-packing-report-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis-picking-packing-report-list.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/analysis-picking-packing-report-list.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,gCAAgC,GAAG,IAAA,qBAAG,EAAA;;;;;CAKlD,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AnalysisPickingPackingReport = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.AnalysisPickingPackingReport = (0, graphql_tag_1.default) `
9
+ type AnalysisPickingPackingReport {
10
+ name: String
11
+ hourlyData: String
12
+ totalDaysWorked: Float
13
+ totalPacks: Float
14
+ totalHoursWorked: Float
15
+ packingRate: Float
16
+ }
17
+ `;
18
+ //# sourceMappingURL=analysis-picking-packing-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis-picking-packing-report.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/analysis-picking-packing-report.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,4BAA4B,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;CAS9C,CAAA"}
@@ -1,22 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Types = exports.Query = void 0;
4
- const inbound_serial_number_report_1 = require("./inbound-serial-number-report");
5
- const inbound_serial_number_report_list_1 = require("./inbound-serial-number-report-list");
6
- const outbound_serial_number_report_1 = require("./outbound-serial-number-report");
7
- const outbound_serial_number_report_list_1 = require("./outbound-serial-number-report-list");
4
+ const analysis_picking_packing_report_1 = require("./analysis-picking-packing-report");
5
+ const analysis_picking_packing_report_list_1 = require("./analysis-picking-packing-report-list");
6
+ const costing_report_1 = require("./costing-report");
7
+ const costing_report_list_1 = require("./costing-report-list");
8
8
  const inbound_order_details_report_1 = require("./inbound-order-details-report");
9
9
  const inbound_order_details_report_list_1 = require("./inbound-order-details-report-list");
10
+ const inbound_serial_number_report_1 = require("./inbound-serial-number-report");
11
+ const inbound_serial_number_report_list_1 = require("./inbound-serial-number-report-list");
12
+ const loading_qc_report_1 = require("./loading-qc-report");
13
+ const loading_qc_report_list_1 = require("./loading-qc-report-list");
10
14
  const outbound_order_details_report_1 = require("./outbound-order-details-report");
11
15
  const outbound_order_details_report_list_1 = require("./outbound-order-details-report-list");
16
+ const outbound_serial_number_report_1 = require("./outbound-serial-number-report");
17
+ const outbound_serial_number_report_list_1 = require("./outbound-serial-number-report-list");
12
18
  const product_label_report_1 = require("./product-label-report");
13
19
  const product_label_report_list_1 = require("./product-label-report-list");
14
- const costing_report_1 = require("./costing-report");
15
- const costing_report_list_1 = require("./costing-report-list");
16
20
  const release_inventory_report_1 = require("./release-inventory-report");
17
21
  const release_inventory_report_list_1 = require("./release-inventory-report-list");
18
- const loading_qc_report_1 = require("./loading-qc-report");
19
- const loading_qc_report_list_1 = require("./loading-qc-report-list");
20
22
  const vas_report_1 = require("./vas-report");
21
23
  const vas_report_list_1 = require("./vas-report-list");
22
24
  exports.Query = `
@@ -30,6 +32,7 @@ exports.Query = `
30
32
  loadingQcReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): [LoadingQcReport] @transaction
31
33
  orderVasReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OrderVasReportList @transaction
32
34
  vasReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OrderVasReportList @transaction
35
+ analysisPickingPackingReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): AnalysisPickingPackingReportList @transaction
33
36
  `;
34
37
  exports.Types = [
35
38
  inbound_serial_number_report_1.InboundSerialNumberReport,
@@ -51,6 +54,8 @@ exports.Types = [
51
54
  vas_report_1.OrderVasReport,
52
55
  vas_report_list_1.OrderVasReportList,
53
56
  vas_report_1.VasReport,
54
- vas_report_list_1.VasReportList
57
+ vas_report_list_1.VasReportList,
58
+ analysis_picking_packing_report_1.AnalysisPickingPackingReport,
59
+ analysis_picking_packing_report_list_1.AnalysisPickingPackingReportList
55
60
  ];
56
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/index.ts"],"names":[],"mappings":";;;AAAA,iFAA0E;AAC1E,2FAAmF;AACnF,mFAA4E;AAC5E,6FAAqF;AAErF,iFAA0E;AAC1E,2FAAmF;AACnF,mFAA4E;AAC5E,6FAAqF;AACrF,iEAA2D;AAC3D,2EAAoE;AAEpE,qDAAgD;AAChD,+DAAyD;AACzD,yEAAmE;AACnE,mFAA4E;AAC5E,2DAAqD;AACrD,qEAA8D;AAE9D,6CAAwD;AACxD,uDAAqE;AAExD,QAAA,KAAK,GAAG;;;;;;;;;;;CAWpB,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,yCAAkB;IAClB,kDAAsB;IACtB,8BAAa;IACb,uCAAiB;IACjB,iDAAsB;IACtB,0DAA0B;IAC1B,mCAAe;IACf,4CAAmB;IACnB,2BAAc;IACd,oCAAkB;IAClB,sBAAS;IACT,+BAAa;CACd,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/reports/index.ts"],"names":[],"mappings":";;;AAAA,uFAAgF;AAChF,iGAAyF;AACzF,qDAAgD;AAChD,+DAAyD;AACzD,iFAA0E;AAC1E,2FAAmF;AACnF,iFAA0E;AAC1E,2FAAmF;AACnF,2DAAqD;AACrD,qEAA8D;AAC9D,mFAA4E;AAC5E,6FAAqF;AACrF,mFAA4E;AAC5E,6FAAqF;AACrF,iEAA2D;AAC3D,2EAAoE;AACpE,yEAAmE;AACnE,mFAA4E;AAC5E,6CAAwD;AACxD,uDAAqE;AAExD,QAAA,KAAK,GAAG;;;;;;;;;;;;CAYpB,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,wDAAyB;IACzB,iEAA6B;IAC7B,0DAA0B;IAC1B,mEAA8B;IAC9B,yCAAkB;IAClB,kDAAsB;IACtB,8BAAa;IACb,uCAAiB;IACjB,iDAAsB;IACtB,0DAA0B;IAC1B,mCAAe;IACf,4CAAmB;IACnB,2BAAc;IACd,oCAAkB;IAClB,sBAAS;IACT,+BAAa;IACb,8DAA4B;IAC5B,uEAAgC;CACjC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.300",
3
+ "version": "4.3.301",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -66,7 +66,7 @@
66
66
  "@things-factory/attachment-ui": "^4.3.281",
67
67
  "@things-factory/auth-ui": "^4.3.281",
68
68
  "@things-factory/barcode-ui": "^4.3.281",
69
- "@things-factory/biz-ui": "^4.3.281",
69
+ "@things-factory/biz-ui": "^4.3.301",
70
70
  "@things-factory/board-service": "^4.3.281",
71
71
  "@things-factory/board-ui": "^4.3.281",
72
72
  "@things-factory/code-ui": "^4.3.281",
@@ -89,9 +89,9 @@
89
89
  "@things-factory/pdf": "^4.3.281",
90
90
  "@things-factory/print-proxy-service": "^4.3.281",
91
91
  "@things-factory/print-ui": "^4.3.281",
92
- "@things-factory/product-base": "^4.3.291",
92
+ "@things-factory/product-base": "^4.3.301",
93
93
  "@things-factory/resource-ui": "^4.3.281",
94
- "@things-factory/sales-ui": "^4.3.300",
94
+ "@things-factory/sales-ui": "^4.3.301",
95
95
  "@things-factory/scene-data-transform": "^4.3.281",
96
96
  "@things-factory/scene-excel": "^4.3.281",
97
97
  "@things-factory/scene-firebase": "^4.3.281",
@@ -105,10 +105,10 @@
105
105
  "@things-factory/scene-visualizer": "^4.3.281",
106
106
  "@things-factory/setting-ui": "^4.3.281",
107
107
  "@things-factory/system-ui": "^4.3.281",
108
- "@things-factory/transport-base": "^4.3.281",
108
+ "@things-factory/transport-base": "^4.3.301",
109
109
  "@things-factory/tutorial-ui": "^4.3.281",
110
- "@things-factory/warehouse-base": "^4.3.300",
111
- "@things-factory/worksheet-base": "^4.3.300"
110
+ "@things-factory/warehouse-base": "^4.3.301",
111
+ "@things-factory/worksheet-base": "^4.3.301"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@things-factory/builder": "^4.3.281",
@@ -117,5 +117,5 @@
117
117
  "cypress-localstorage-commands": "^1.6.1",
118
118
  "eslint-plugin-cypress": "^2.12.1"
119
119
  },
120
- "gitHead": "d8e36e58340db054cae228e4ea383e7e673a834f"
120
+ "gitHead": "649c7b97ee31690da25cca5afd11583eb2d8f605"
121
121
  }
@@ -0,0 +1,146 @@
1
+ import { EntityManager } from 'typeorm'
2
+
3
+ import { Bizplace } from '@things-factory/biz-base'
4
+ import {
5
+ Domain,
6
+ ListParam
7
+ } from '@things-factory/shell'
8
+
9
+ import { rawProductsQuery } from '../../../utils'
10
+
11
+ export const analysisPickingPackingReport = {
12
+ async analysisPickingPackingReport(_: any, params: ListParam, context: any) {
13
+ try {
14
+ const { tx, domain }: { tx: EntityManager; domain: Domain } = context.state
15
+ let bizplace = params.filters.find((data: { name: string }) => data.name === 'bizplace')
16
+ let fromDate = params.filters.find((data: { name: string }) => data.name == 'fromDate')
17
+ let toDate = params.filters.find((data: { name: string }) => data.name == 'toDate')
18
+ let name = params.filters.find((data: { name: string }) => data.name === 'name')
19
+ let rate = params.filters.find((data: { name: string }) => data.name === 'rate')
20
+ let type = params.filters.find((data: any) => data.name === 'type')
21
+
22
+ // throw error bizplace filter missing
23
+ if (!bizplace) throw 'Invalid input'
24
+
25
+ let queryFilter = ''
26
+ if (name) {
27
+ let nameValue = name.value
28
+ .toLowerCase()
29
+ .split(',')
30
+ .map((prod: string) => {
31
+ return "'%" + prod.trim().replace(/'/g, "''") + "%'"
32
+ })
33
+ .join(',')
34
+ queryFilter += `AND (
35
+ Lower(u.name) LIKE ANY(ARRAY[${nameValue}])
36
+ )`
37
+ }
38
+
39
+ let sortingTypes = ''
40
+ if(type){
41
+ let typeValue = type.value
42
+ if(typeValue === 'packing' || typeValue === 'picking'){
43
+ sortingTypes = `AND ih.transaction_type = '${typeValue.toUpperCase()}'`
44
+ }
45
+ }
46
+
47
+ let sortingOptions = ''
48
+ if(rate) {
49
+ let rateValue = rate.value
50
+ if (rateValue === 'asc' || rateValue === 'desc') {
51
+ sortingOptions = `ORDER BY packing_rates."packingRate" ${rateValue.toUpperCase()}`
52
+ }
53
+ }
54
+
55
+ if (bizplace) {
56
+ queryFilter += ` AND ih.bizplace_id = '${bizplace.value}'`
57
+ }
58
+
59
+ const bizplaceObj: Bizplace = await tx.getRepository(Bizplace).findOne({
60
+ id: bizplace.value
61
+ })
62
+
63
+ await rawProductsQuery(tx, params, bizplaceObj)
64
+
65
+ const fromDateValue = new Date(fromDate.value)
66
+ const toDateValue = new Date(toDate.value)
67
+
68
+ // Check if the date objects are valid
69
+ if (isNaN(fromDateValue.getTime()) || isNaN(toDateValue.getTime())) {
70
+ throw new Error('Invalid date format. Please provide valid date values.')
71
+ }
72
+
73
+ const sqlQuery = `
74
+ WITH packing_rates AS (
75
+ SELECT
76
+ u.name,
77
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 7 THEN 1 ELSE 0 END) AS "7",
78
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 8 THEN 1 ELSE 0 END) AS "8",
79
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 9 THEN 1 ELSE 0 END) AS "9",
80
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 10 THEN 1 ELSE 0 END) AS "10",
81
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 11 THEN 1 ELSE 0 END) AS "11",
82
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 12 THEN 1 ELSE 0 END) AS "12",
83
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 13 THEN 1 ELSE 0 END) AS "13",
84
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 14 THEN 1 ELSE 0 END) AS "14",
85
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 15 THEN 1 ELSE 0 END) AS "15",
86
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 16 THEN 1 ELSE 0 END) AS "16",
87
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 17 THEN 1 ELSE 0 END) AS "17",
88
+ SUM(CASE WHEN EXTRACT(HOUR FROM (ih.created_at + INTERVAL '8 HOUR')) = 18 THEN 1 ELSE 0 END) AS "18",
89
+ COUNT(DISTINCT DATE(ih.created_at)) AS "totalDaysWorked",
90
+ COUNT(DISTINCT DATE_TRUNC('hour', (ih.created_at + INTERVAL '8 HOUR'))) AS "totalHoursWorked",
91
+ COUNT(*) AS "totalPacks",
92
+ ROUND(COUNT(*) / COUNT(DISTINCT DATE_TRUNC('hour', (ih.created_at + INTERVAL '8 HOUR')))) AS "packingRate"
93
+ FROM
94
+ inventory_histories ih
95
+ INNER JOIN
96
+ users u ON ih.creator_id = u.id
97
+ WHERE
98
+ ih.domain_id = $1
99
+ AND ih.created_at BETWEEN $2 AND $3
100
+ ${queryFilter}
101
+ ${sortingTypes}
102
+ GROUP BY
103
+ u.name
104
+ )
105
+ SELECT
106
+ "name",
107
+ "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
108
+ packing_rates."totalDaysWorked",
109
+ "totalPacks",
110
+ packing_rates."totalHoursWorked",
111
+ packing_rates."packingRate"
112
+ FROM
113
+ packing_rates
114
+ ${sortingOptions}
115
+ `
116
+
117
+ const result = await tx.query(sqlQuery, [domain.id, fromDate.value, toDate.value])
118
+ return {
119
+ items: result.map((data: { [x: string]: any }) => {
120
+ return {
121
+ ...data,
122
+ name: data.name,
123
+ hourlyData: JSON.stringify({
124
+ 7: data["7"],
125
+ 8: data["8"],
126
+ 9: data["9"],
127
+ 10: data["10"],
128
+ 11: data["11"],
129
+ 12: data["12"],
130
+ 13: data["13"],
131
+ 14: data["14"],
132
+ 15: data["15"],
133
+ 16: data["16"],
134
+ 17: data["17"],
135
+ 18: data["18"],
136
+ })
137
+ }
138
+ }),
139
+ total: result.length
140
+ }
141
+
142
+ } catch (error) {
143
+ throw error
144
+ }
145
+ }
146
+ }
@@ -1,9 +1,9 @@
1
- import { inboundSerialNumberReport } from './inbound-serial-number-report'
2
- import { outboundSerialNumberReport } from './outbound-serial-number-report'
3
-
1
+ import { analysisPickingPackingReport } from './analysis-picking-packing-report'
4
2
  import { costingReport } from './costing-report'
5
3
  import { inboundOrderDetailsReport } from './inbound-order-details-report'
4
+ import { inboundSerialNumberReport } from './inbound-serial-number-report'
6
5
  import { outboundOrderDetailsReport } from './outbound-order-details-report'
6
+ import { outboundSerialNumberReport } from './outbound-serial-number-report'
7
7
  import { productLabelReport } from './product-label-report'
8
8
  import { releaseInventoryReport } from './release-inventory-report'
9
9
  import { loadingQcReport } from './tote-loading-qc-report'
@@ -19,5 +19,6 @@ export const Query = {
19
19
  ...releaseInventoryReport,
20
20
  ...loadingQcReport,
21
21
  ...orderVasReport,
22
- ...vasReport
22
+ ...vasReport,
23
+ ...analysisPickingPackingReport
23
24
  }
@@ -0,0 +1,8 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const AnalysisPickingPackingReportList = gql`
4
+ type AnalysisPickingPackingReportList {
5
+ items: [AnalysisPickingPackingReport]
6
+ total: Int
7
+ }
8
+ `
@@ -0,0 +1,12 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const AnalysisPickingPackingReport = gql`
4
+ type AnalysisPickingPackingReport {
5
+ name: String
6
+ hourlyData: String
7
+ totalDaysWorked: Float
8
+ totalPacks: Float
9
+ totalHoursWorked: Float
10
+ packingRate: Float
11
+ }
12
+ `
@@ -1,22 +1,21 @@
1
- import { InboundSerialNumberReport } from './inbound-serial-number-report'
2
- import { InboundSerialNumberReportList } from './inbound-serial-number-report-list'
3
- import { OutboundSerialNumberReport } from './outbound-serial-number-report'
4
- import { OutboundSerialNumberReportList } from './outbound-serial-number-report-list'
5
-
1
+ import { AnalysisPickingPackingReport } from './analysis-picking-packing-report'
2
+ import { AnalysisPickingPackingReportList } from './analysis-picking-packing-report-list'
3
+ import { CostingReport } from './costing-report'
4
+ import { CostingReportList } from './costing-report-list'
6
5
  import { InboundOrderDetailsReport } from './inbound-order-details-report'
7
6
  import { InboundOrderDetailsReportList } from './inbound-order-details-report-list'
7
+ import { InboundSerialNumberReport } from './inbound-serial-number-report'
8
+ import { InboundSerialNumberReportList } from './inbound-serial-number-report-list'
9
+ import { LoadingQcReport } from './loading-qc-report'
10
+ import { LoadingQcReportList } from './loading-qc-report-list'
8
11
  import { OutboundOrderDetailsReport } from './outbound-order-details-report'
9
12
  import { OutboundOrderDetailsReportList } from './outbound-order-details-report-list'
13
+ import { OutboundSerialNumberReport } from './outbound-serial-number-report'
14
+ import { OutboundSerialNumberReportList } from './outbound-serial-number-report-list'
10
15
  import { ProductLabelReport } from './product-label-report'
11
16
  import { ProductLabelReportList } from './product-label-report-list'
12
-
13
- import { CostingReport } from './costing-report'
14
- import { CostingReportList } from './costing-report-list'
15
17
  import { ReleaseInventoryReport } from './release-inventory-report'
16
18
  import { ReleaseInventoryReportList } from './release-inventory-report-list'
17
- import { LoadingQcReport } from './loading-qc-report'
18
- import { LoadingQcReportList } from './loading-qc-report-list'
19
-
20
19
  import { OrderVasReport, VasReport } from './vas-report'
21
20
  import { OrderVasReportList, VasReportList } from './vas-report-list'
22
21
 
@@ -31,6 +30,7 @@ export const Query = `
31
30
  loadingQcReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): [LoadingQcReport] @transaction
32
31
  orderVasReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OrderVasReportList @transaction
33
32
  vasReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): OrderVasReportList @transaction
33
+ analysisPickingPackingReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): AnalysisPickingPackingReportList @transaction
34
34
  `
35
35
 
36
36
  export const Types = [
@@ -53,5 +53,7 @@ export const Types = [
53
53
  OrderVasReport,
54
54
  OrderVasReportList,
55
55
  VasReport,
56
- VasReportList
56
+ VasReportList,
57
+ AnalysisPickingPackingReport,
58
+ AnalysisPickingPackingReportList
57
59
  ]
@@ -512,6 +512,10 @@ export default {
512
512
  tagname: 'vas-report',
513
513
  page: 'vas_report'
514
514
  },
515
+ {
516
+ tagname: 'analysis-picking-packing-report',
517
+ page: 'analysis_picking_packing_report'
518
+ },
515
519
 
516
520
  /**
517
521
  * Custom ELCCL Menus Section
@@ -443,6 +443,7 @@
443
443
  "field.packed_at": "packed at",
444
444
  "field.packed_by": "packed by",
445
445
  "field.packing_end": "packing end",
446
+ "field.packing_rate": "packing rate",
446
447
  "field.packing_size": "packing size",
447
448
  "field.packing_start": "packing start",
448
449
  "field.packing_type_sku": "packing type ({sku})",
@@ -496,6 +497,7 @@
496
497
  "field.quarantine_qty": "quarantine qty",
497
498
  "field.quarantine_stock_only": "quarantine stock only",
498
499
  "field.rank": "rank",
500
+ "field.rate": "rate",
499
501
  "field.ready": "completed",
500
502
  "field.reason_of_defective": "reason of defective",
501
503
  "field.recall": "recall",
@@ -616,7 +618,10 @@
616
618
  "field.to_date": "to date",
617
619
  "field.to": "to",
618
620
  "field.total_cost": "total cost",
621
+ "field.total_days_worked": "total days worked",
619
622
  "field.total_delivery": "total delivery",
623
+ "field.total_hours_worked": "total hours worked",
624
+ "field.total_pack": "total pack",
620
625
  "field.total_pack_qty": "total pack qty",
621
626
  "field.total_pallet": "total pallet",
622
627
  "field.total_price": "total price",
@@ -1699,6 +1704,7 @@
1699
1704
  "title.adjust_batch_id": "adjust batch no",
1700
1705
  "title.adjust_pallet_qty": "adjust pallet qty",
1701
1706
  "title.adjustment": "adjustment",
1707
+ "title.analytics_report": "analytics report",
1702
1708
  "title.approve_partnership": "approve partnership",
1703
1709
  "title.approve": "approve",
1704
1710
  "title.are_you_sure": "are you sure?",
@@ -442,6 +442,7 @@
442
442
  "field.packed_at": "[ko]packed at",
443
443
  "field.packed_by": "[ko]packed by",
444
444
  "field.packing_end": "[ko]packing end",
445
+ "field.packing_rate": "[ko] packing rate",
445
446
  "field.packing_start": "[ko]packing start",
446
447
  "field.packing_type": "포장 유형",
447
448
  "field.packing_uom_value": "포장 측량치",
@@ -619,6 +620,7 @@
619
620
  "field.to": "to",
620
621
  "field.total_cost": "[ko]total cost",
621
622
  "field.total_delivery": "총 운송건수",
623
+ "field.total_hours_worked": "[ko] total hours worked",
622
624
  "field.total_pack_qty": "전체 패킹 수량",
623
625
  "field.total_pallet": "[ko]total pallet",
624
626
  "field.total_price": "총 가격",
@@ -635,6 +637,7 @@
635
637
  "field.tote_box": "[ko] tote box",
636
638
  "field.tote_id": "[ko] tote id",
637
639
  "field.tote_no": "[ko] tote no",
640
+ "field.total_pack": "[ko] total pack",
638
641
  "field.tote": "[ko] tote",
639
642
  "field.tracking_no": "[ko] tracking no",
640
643
  "field.transaction_type": "트랜잭션 유형",
@@ -1727,6 +1730,7 @@
1727
1730
  "title.adjust_batch_id": "배치번호 조정",
1728
1731
  "title.adjust_pallet_qty": "파레트 수량 조정",
1729
1732
  "title.adjustment": "조정",
1733
+ "title.analytics_report": "[ko] analytics report",
1730
1734
  "title.approve_partnership": "파트너십 승인",
1731
1735
  "title.approve": "승인",
1732
1736
  "title.are_you_sure": "계속하시겠습니까?",
@@ -2148,6 +2152,8 @@
2148
2152
  "title.date_vas_summary_report": "[ko]{state.text} Vas Summary Report",
2149
2153
  "text.vas_order_created": "부가서비스주문 생성됨",
2150
2154
  "field.packing_type_sku": "[ko] packing type ({sku})",
2155
+ "field.rate": "[ko] rate",
2156
+ "field.total_days_worked": "[ko] total days worked",
2151
2157
  "field.uom_sku": "[ko] uom ({sku})",
2152
2158
  "field.uom_value_sku": "[ko] uom value ({sku})",
2153
2159
  "field.vas_qty": "[ko] vas qty",
@@ -425,6 +425,7 @@
425
425
  "field.packed_at": "[ms]packed at",
426
426
  "field.packed_by": "[ms]packed by",
427
427
  "field.packing_end": "[ms]packing end",
428
+ "field.packing_rate": "[ms] packing rate",
428
429
  "field.packing_start": "[ms]packing start",
429
430
  "field.packing_type": "jenis pek",
430
431
  "field.packing_uom_value": "packing uom value",
@@ -476,6 +477,7 @@
476
477
  "field.quarantine_qty": "[ms] quarantine qty",
477
478
  "field.quarantine_stock_only": "[ms] quarantine stock only",
478
479
  "field.rank": "kedudukan",
480
+ "field.rate": "[ms] rate",
479
481
  "field.ready": "siap",
480
482
  "field.reason_of_defective": "Reason of Defective",
481
483
  "field.recall": "recall",
@@ -597,7 +599,10 @@
597
599
  "field.to_date": "sehingga tarikh",
598
600
  "field.to": "pada",
599
601
  "field.total_cost": "[ms]total cost",
602
+ "field.total_days_worked": "[ms] total days worked",
600
603
  "field.total_delivery": "total delivery",
604
+ "field.total_hours_worked": "[ms] total hours worked",
605
+ "field.total_pack": "[ms] total pack",
601
606
  "field.total_pack_qty": "jumlah qty palet",
602
607
  "field.total_pallet": "[ms]total pallet",
603
608
  "field.total_price": "jumlah harga",
@@ -1642,6 +1647,7 @@
1642
1647
  "title.adjust_batch_id": "adjust batch no",
1643
1648
  "title.adjust_pallet_qty": "ubah suai kuantiti pallet",
1644
1649
  "title.adjustment": "kemaskini",
1650
+ "title.analytics_report": "[ms] analytics report",
1645
1651
  "title.approve_partnership": "permsngsian persetujuan",
1646
1652
  "title.approve": "lulus",
1647
1653
  "title.are_you_sure": "adakah anda pasti",
@@ -408,6 +408,7 @@
408
408
  "field.packed_at": "[zh]packed at",
409
409
  "field.packed_by": "[zh]packed by",
410
410
  "field.packing_end": "[zh]packing end",
411
+ "field.packing_rate": "[zh] packing rate",
411
412
  "field.packing_start": "[zh]packing start",
412
413
  "field.packing_type": "包装类型",
413
414
  "field.packing_uom_value": "packing uom value",
@@ -458,6 +459,7 @@
458
459
  "field.quarantine_qty": "[zh] quarantine qty",
459
460
  "field.quarantine_stock_only": "[zh] quarantine stock only",
460
461
  "field.rank": "列为",
462
+ "field.rate": "[zh] rate",
461
463
  "field.ready": "completed",
462
464
  "field.reason_of_defective": "[zh] Reason of Defective",
463
465
  "field.recall": "recall",
@@ -579,6 +581,9 @@
579
581
  "field.to": "to",
580
582
  "field.total_cost": "[zh]total cost",
581
583
  "field.total_delivery": "total delivery",
584
+ "field.total_days_worked": "total days worked",
585
+ "field.total_hours_worked": "[zh] total hours worked",
586
+ "field.total_pack": "total pack",
582
587
  "field.total_pack_qty": "total pack qty",
583
588
  "field.total_pallet": "[zh]total pallet",
584
589
  "field.total_price": "total price",
@@ -1608,6 +1613,7 @@
1608
1613
  "title.adjust_batch_id": "adjust batch no",
1609
1614
  "title.adjust_pallet_qty": "adjust pallet qty",
1610
1615
  "title.adjustment": "adjustment",
1616
+ "title.analytics_report": "[zh] analytics report",
1611
1617
  "title.approve_partnership": "approve partnership",
1612
1618
  "title.approve": "approve",
1613
1619
  "title.are_you_sure": "are you sure?",