@things-factory/operato-wms 4.2.0 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/inbound/unload-product.js +2 -2
- package/client/pages/inventory-check/inspecting-product.js +13 -7
- package/client/pages/order/release-order/release-extra-product-popup.js +15 -10
- package/client/pages/outbound/single-outbound-worksheet.js +15 -13
- package/client/pages/report/costing-report.js +453 -0
- package/client/pages/report/inbound-order-details-report.js +14 -0
- package/client/pages/report/outbound-order-details-report.js +12 -0
- package/client/route.js +4 -0
- package/dist-server/graphql/resolvers/reports/costing-report.js +172 -0
- package/dist-server/graphql/resolvers/reports/costing-report.js.map +1 -0
- package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js +2 -0
- package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/index.js +2 -1
- package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +10 -3
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/types/reports/costing-report-list.js +14 -0
- package/dist-server/graphql/types/reports/costing-report-list.js.map +1 -0
- package/dist-server/graphql/types/reports/costing-report.js +19 -0
- package/dist-server/graphql/types/reports/costing-report.js.map +1 -0
- package/dist-server/graphql/types/reports/inbound-order-details-report.js +1 -0
- package/dist-server/graphql/types/reports/inbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/types/reports/index.js +6 -1
- package/dist-server/graphql/types/reports/index.js.map +1 -1
- package/dist-server/graphql/types/reports/outbound-order-details-report.js +1 -0
- package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
- package/package.json +6 -6
- package/server/graphql/resolvers/reports/costing-report.ts +196 -0
- package/server/graphql/resolvers/reports/inbound-order-details-report.ts +2 -0
- package/server/graphql/resolvers/reports/index.ts +2 -0
- package/server/graphql/resolvers/reports/outbound-order-details-report.ts +10 -3
- package/server/graphql/types/reports/costing-report-list.ts +8 -0
- package/server/graphql/types/reports/costing-report.ts +13 -0
- package/server/graphql/types/reports/inbound-order-details-report.ts +1 -0
- package/server/graphql/types/reports/index.ts +7 -1
- package/server/graphql/types/reports/outbound-order-details-report.ts +1 -0
- package/things-factory.config.js +4 -0
- package/translations/en.json +3 -1
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -859,6 +859,7 @@ class UnloadProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
859
859
|
this._showToast(e)
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
+
|
|
862
863
|
async _scanProductUnload() {
|
|
863
864
|
if (this._scanning) return this._showToast({ message: i18next.t('text.previous_scan_is_executing') })
|
|
864
865
|
this._scanning = true
|
|
@@ -1010,9 +1011,8 @@ class UnloadProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1010
1011
|
}
|
|
1011
1012
|
} catch (e) {
|
|
1012
1013
|
this._showToast(e)
|
|
1013
|
-
} finally {
|
|
1014
|
-
this._scanning = false
|
|
1015
1014
|
}
|
|
1015
|
+
this._scanning = false
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
1018
|
async fetchProductDetail(gtin, productId) {
|
|
@@ -654,7 +654,7 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
654
654
|
this.locationData = { records: [] }
|
|
655
655
|
this.inventoryData = { records: [] }
|
|
656
656
|
|
|
657
|
-
const selectedWarehouseName = this.warehouseSelector.
|
|
657
|
+
const selectedWarehouseName = this.warehouseSelector?.value.trim()
|
|
658
658
|
const selectedZone = this.zoneSelector.value
|
|
659
659
|
this.selectedRow = this.rowSelector.value
|
|
660
660
|
this.selectedColumn = this.columnSelector.value
|
|
@@ -665,7 +665,7 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
665
665
|
this.zones = Array.from(
|
|
666
666
|
new Set(
|
|
667
667
|
this.formattedLocations
|
|
668
|
-
.filter(loc => loc.warehouse.name === selectedWarehouseName)
|
|
668
|
+
.filter(loc => loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName)
|
|
669
669
|
.map(loc => loc.zone)
|
|
670
670
|
.sort()
|
|
671
671
|
)
|
|
@@ -681,7 +681,10 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
681
681
|
rows = Array.from(
|
|
682
682
|
new Set(
|
|
683
683
|
this.formattedLocations
|
|
684
|
-
.filter(
|
|
684
|
+
.filter(
|
|
685
|
+
loc =>
|
|
686
|
+
loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName && loc.zone === selectedZone
|
|
687
|
+
)
|
|
685
688
|
.map(loc => loc.row)
|
|
686
689
|
.sort()
|
|
687
690
|
)
|
|
@@ -690,7 +693,10 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
690
693
|
columns = Array.from(
|
|
691
694
|
new Set(
|
|
692
695
|
this.formattedLocations
|
|
693
|
-
.filter(
|
|
696
|
+
.filter(
|
|
697
|
+
loc =>
|
|
698
|
+
loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName && loc.zone === selectedZone
|
|
699
|
+
)
|
|
694
700
|
.map(loc => loc.column)
|
|
695
701
|
.sort()
|
|
696
702
|
)
|
|
@@ -703,7 +709,7 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
703
709
|
this.formattedLocations
|
|
704
710
|
.filter(
|
|
705
711
|
loc =>
|
|
706
|
-
loc.warehouse.name === selectedWarehouseName &&
|
|
712
|
+
loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName &&
|
|
707
713
|
loc.zone === selectedZone &&
|
|
708
714
|
loc.row === this.selectedRow
|
|
709
715
|
)
|
|
@@ -719,7 +725,7 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
719
725
|
this.formattedLocations
|
|
720
726
|
.filter(
|
|
721
727
|
loc =>
|
|
722
|
-
loc.warehouse.name === selectedWarehouseName &&
|
|
728
|
+
loc.warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName &&
|
|
723
729
|
loc.zone === selectedZone &&
|
|
724
730
|
loc.column === this.selectedColumn
|
|
725
731
|
)
|
|
@@ -733,7 +739,7 @@ class InspectingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
733
739
|
if (selectedWarehouseName && selectedZone && (this.selectedRow || this.selectedColumn)) {
|
|
734
740
|
records = this.formattedLocations
|
|
735
741
|
.filter(({ warehouse, zone, row, column }) => {
|
|
736
|
-
if (warehouse.name === selectedWarehouseName && zone === selectedZone) {
|
|
742
|
+
if (warehouse.name.replace(/\s{2,}/g, ' ').trim() === selectedWarehouseName && zone === selectedZone) {
|
|
737
743
|
if (this.selectedRow && this.selectedColumn)
|
|
738
744
|
return row === this.selectedRow && column === this.selectedColumn
|
|
739
745
|
if (this.selectedRow) return row === this.selectedRow
|
|
@@ -609,7 +609,7 @@ export class ReleaseExtraProductPopup extends localize(i18next)(LitElement) {
|
|
|
609
609
|
|
|
610
610
|
if (afterValue >= 0) {
|
|
611
611
|
if (columnName == 'releaseUomValue' || columnName == 'releaseQty') {
|
|
612
|
-
if (originQty) {
|
|
612
|
+
if (originQty >= 0) {
|
|
613
613
|
if (originQty == 0 || originUom == 0) {
|
|
614
614
|
packageUom = originAddableUom / originAddableQty
|
|
615
615
|
} else {
|
|
@@ -643,6 +643,7 @@ export class ReleaseExtraProductPopup extends localize(i18next)(LitElement) {
|
|
|
643
643
|
|
|
644
644
|
return { releaseQty, roundedUom }
|
|
645
645
|
}
|
|
646
|
+
|
|
646
647
|
_onInventoryFieldChanged(e) {
|
|
647
648
|
let columnName = e.detail.column.name
|
|
648
649
|
let roundedUomValue = e.detail.record.roundedUomValue || 0
|
|
@@ -650,7 +651,7 @@ export class ReleaseExtraProductPopup extends localize(i18next)(LitElement) {
|
|
|
650
651
|
let packageUomValue = 0
|
|
651
652
|
|
|
652
653
|
try {
|
|
653
|
-
if (e.detail.after
|
|
654
|
+
if (Number.isNaN(e.detail.after)) {
|
|
654
655
|
throw new Error(i18next.t('text.invalid_form_value'))
|
|
655
656
|
}
|
|
656
657
|
} catch (e) {
|
|
@@ -707,15 +708,19 @@ export class ReleaseExtraProductPopup extends localize(i18next)(LitElement) {
|
|
|
707
708
|
var totalAvailableQty = 0
|
|
708
709
|
var totalAvailableUomValue = 0
|
|
709
710
|
|
|
710
|
-
if (gristType == 'existing') {
|
|
711
|
-
totalAvailableQty = beforeRecord.addableQty + beforeRecord.releaseQty
|
|
712
|
-
totalAvailableUomValue = beforeRecord.addableUomValue + beforeRecord.releaseUomValue
|
|
713
|
-
} else {
|
|
714
|
-
totalAvailableQty = changeRecord.remainQty
|
|
715
|
-
totalAvailableUomValue = changeRecord.remainUomValue
|
|
716
|
-
}
|
|
717
|
-
|
|
718
711
|
try {
|
|
712
|
+
if (Number.isNaN(changeRecord.releaseQty) || Number.isNaN(changeRecord.releaseUomValue)) {
|
|
713
|
+
throw new Error(i18next.t('text.invalid_form_value'))
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
if (gristType == 'existing') {
|
|
717
|
+
totalAvailableQty = beforeRecord.addableQty + beforeRecord.releaseQty
|
|
718
|
+
totalAvailableUomValue = beforeRecord.addableUomValue + beforeRecord.releaseUomValue
|
|
719
|
+
} else {
|
|
720
|
+
totalAvailableQty = changeRecord.remainQty
|
|
721
|
+
totalAvailableUomValue = changeRecord.remainUomValue
|
|
722
|
+
}
|
|
723
|
+
|
|
719
724
|
if (changedColumn === 'releaseQty') {
|
|
720
725
|
this._validateReleaseQty(changeRecord.releaseQty, changeRecord.remainQty, totalAvailableQty)
|
|
721
726
|
} else if (changedColumn === 'releaseUomValue') {
|
|
@@ -66,7 +66,13 @@ class SingleOutboundWorksheet extends localize(i18next)(PageView) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
get context() {
|
|
69
|
-
var actions = [
|
|
69
|
+
var actions = [
|
|
70
|
+
{
|
|
71
|
+
title: i18next.t('button.assign_picker'),
|
|
72
|
+
action: this._assignPicker.bind(this),
|
|
73
|
+
...CommonButtonStyles.activate
|
|
74
|
+
}
|
|
75
|
+
]
|
|
70
76
|
|
|
71
77
|
if (this._routeLabelSetting) {
|
|
72
78
|
actions.push({
|
|
@@ -78,19 +84,12 @@ class SingleOutboundWorksheet extends localize(i18next)(PageView) {
|
|
|
78
84
|
|
|
79
85
|
return {
|
|
80
86
|
title: i18next.t('title.outbound_worksheet'),
|
|
81
|
-
actions
|
|
82
|
-
{
|
|
83
|
-
title: i18next.t('button.assign_picker'),
|
|
84
|
-
action: this._assignPicker.bind(this),
|
|
85
|
-
...CommonButtonStyles.activate
|
|
86
|
-
}
|
|
87
|
-
],
|
|
87
|
+
actions,
|
|
88
88
|
exportable: {
|
|
89
89
|
name: i18next.t('title.outbound_worksheet'),
|
|
90
90
|
data: this._exportableData.bind(this)
|
|
91
91
|
},
|
|
92
|
-
help: 'operato-wms/outbound/single-outbound-worksheet'
|
|
93
|
-
actions
|
|
92
|
+
help: 'operato-wms/outbound/single-outbound-worksheet'
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
|
|
@@ -431,8 +430,11 @@ class SingleOutboundWorksheet extends localize(i18next)(PageView) {
|
|
|
431
430
|
})
|
|
432
431
|
|
|
433
432
|
if (!response.errors) {
|
|
434
|
-
let domain = response.data.worksheets.items[0]
|
|
435
|
-
|
|
433
|
+
let domain = response.data.worksheets.items[0]?.domain
|
|
434
|
+
|
|
435
|
+
if (domain)
|
|
436
|
+
this._routeLabelSetting = await fetchSettingRule('enable-print-route-label', domain.id)
|
|
437
|
+
|
|
436
438
|
this.updateContext()
|
|
437
439
|
return {
|
|
438
440
|
total: response.data.worksheets.total || 0,
|
|
@@ -487,7 +489,7 @@ class SingleOutboundWorksheet extends localize(i18next)(PageView) {
|
|
|
487
489
|
return item.status == 'DEACTIVATED'
|
|
488
490
|
})
|
|
489
491
|
|
|
490
|
-
if (selectedData.length <= 0) throw new Error('
|
|
492
|
+
if (selectedData.length <= 0) throw new Error(i18next.t('text.no_available_worksheet_selected'))
|
|
491
493
|
|
|
492
494
|
openPopup(
|
|
493
495
|
html`
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import '@things-factory/form-ui'
|
|
2
|
+
import '@things-factory/grist-ui'
|
|
3
|
+
import '../inventory/inventory-by-product-detail'
|
|
4
|
+
|
|
5
|
+
import gql from 'graphql-tag'
|
|
6
|
+
import { css, html } from 'lit-element'
|
|
7
|
+
import { connect } from 'pwa-helpers/connect-mixin'
|
|
8
|
+
|
|
9
|
+
import { getCodeByName } from '@things-factory/code-base'
|
|
10
|
+
import { i18next, localize } from '@things-factory/i18n-base'
|
|
11
|
+
import { client, gqlContext, PageView, store } from '@things-factory/shell'
|
|
12
|
+
import { flattenObject, isMobileDevice } from '@things-factory/utils'
|
|
13
|
+
|
|
14
|
+
class CostingReport extends connect(store)(localize(i18next)(PageView)) {
|
|
15
|
+
static get styles() {
|
|
16
|
+
return css`
|
|
17
|
+
:host {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
data-grist {
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
flex: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.summary {
|
|
29
|
+
background-color: var(--main-section-background-color);
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
overflow-y: auto;
|
|
33
|
+
align-items: flex-end;
|
|
34
|
+
padding: var(--data-list-item-padding);
|
|
35
|
+
display: grid;
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
color: #394e64;
|
|
38
|
+
grid-template-columns: repeat(2, 1fr);
|
|
39
|
+
grid-auto-rows: minmax(24px, auto);
|
|
40
|
+
}
|
|
41
|
+
`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static get properties() {
|
|
45
|
+
return {
|
|
46
|
+
_searchFields: Object,
|
|
47
|
+
_config: Object,
|
|
48
|
+
_partners: Object,
|
|
49
|
+
_gristData: Object,
|
|
50
|
+
data: Object
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get context() {
|
|
55
|
+
return {
|
|
56
|
+
title: 'Costing Report',
|
|
57
|
+
exportable: {
|
|
58
|
+
name: i18next.t('title.costing_report'),
|
|
59
|
+
data: this._exportableData.bind(this)
|
|
60
|
+
},
|
|
61
|
+
help: 'operato-wms/report/costing-report'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get dataGrist() {
|
|
66
|
+
return this.shadowRoot.querySelector('data-grist')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get searchForm() {
|
|
70
|
+
return this.shadowRoot.querySelector('search-form')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get _bizplaceSelector() {
|
|
74
|
+
return this.searchForm.shadowRoot.querySelector('select[name=bizplace]')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get _fromDateInput() {
|
|
78
|
+
return this.searchForm.shadowRoot.querySelector('input[name=fromDate]')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get _toDateInput() {
|
|
82
|
+
return this.searchForm.shadowRoot.querySelector('input[name=toDate]')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get searchFields() {
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
label: i18next.t('field.company'),
|
|
89
|
+
name: 'bizplace',
|
|
90
|
+
type: 'select',
|
|
91
|
+
options: [
|
|
92
|
+
{ value: '' },
|
|
93
|
+
...this._partners
|
|
94
|
+
.map(partner => {
|
|
95
|
+
return {
|
|
96
|
+
name: `${partner.name} ${partner.description ? `(${partner.description})` : ''}`,
|
|
97
|
+
value: partner.id
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.sort(this._compareValues('name', 'asc'))
|
|
101
|
+
],
|
|
102
|
+
props: { searchOper: 'eq' }
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
label: i18next.t('field.from_date'),
|
|
106
|
+
name: 'fromDate',
|
|
107
|
+
type: 'date',
|
|
108
|
+
props: {
|
|
109
|
+
searchOper: 'eq',
|
|
110
|
+
max: new Date().toISOString().split('T')[0]
|
|
111
|
+
},
|
|
112
|
+
value: (() => {
|
|
113
|
+
let date = new Date()
|
|
114
|
+
date.setMonth(date.getMonth() - 1)
|
|
115
|
+
return date.toISOString().split('T')[0]
|
|
116
|
+
})(),
|
|
117
|
+
handlers: { change: this._modifyDateRange.bind(this) }
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: i18next.t('field.to_date'),
|
|
121
|
+
name: 'toDate',
|
|
122
|
+
type: 'date',
|
|
123
|
+
props: {
|
|
124
|
+
searchOper: 'eq',
|
|
125
|
+
min: (() => {
|
|
126
|
+
let date = new Date()
|
|
127
|
+
date.setMonth(date.getMonth() - 1)
|
|
128
|
+
return date.toISOString().split('T')[0]
|
|
129
|
+
})(),
|
|
130
|
+
max: (() => {
|
|
131
|
+
var max = new Date()
|
|
132
|
+
max.setMonth(max.getMonth() + 1)
|
|
133
|
+
return max.toISOString().split('T')[0]
|
|
134
|
+
})()
|
|
135
|
+
},
|
|
136
|
+
value: new Date().toISOString().split('T')[0]
|
|
137
|
+
// handlers: { change: this._submit.bind(this) }
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get reportConfig() {
|
|
143
|
+
let columns = [
|
|
144
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
145
|
+
{
|
|
146
|
+
type: 'string',
|
|
147
|
+
name: 'bizplace|name',
|
|
148
|
+
header: i18next.t('field.company'),
|
|
149
|
+
width: 200
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
type: 'string',
|
|
153
|
+
name: 'product|sku',
|
|
154
|
+
header: i18next.t('field.sku'),
|
|
155
|
+
width: 150
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: 'string',
|
|
159
|
+
name: 'product|name',
|
|
160
|
+
header: i18next.t('field.product_name'),
|
|
161
|
+
width: 200
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'string',
|
|
165
|
+
name: 'product|description',
|
|
166
|
+
header: i18next.t('field.product_description'),
|
|
167
|
+
width: 300
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: 'string',
|
|
171
|
+
name: 'product|type',
|
|
172
|
+
header: i18next.t('field.product_type'),
|
|
173
|
+
width: 150
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: 'float',
|
|
177
|
+
name: 'qty',
|
|
178
|
+
header: i18next.t('field.qty'),
|
|
179
|
+
width: 120
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: 'float',
|
|
183
|
+
name: 'uomValue',
|
|
184
|
+
header: i18next.t('field.uom_value'),
|
|
185
|
+
width: 120
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
type: 'string',
|
|
189
|
+
name: 'uom',
|
|
190
|
+
header: i18next.t('field.uom'),
|
|
191
|
+
width: 100
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
type: 'string',
|
|
195
|
+
name: 'weightedAvgUnitCost',
|
|
196
|
+
header: 'Weighted Avg Unit Cost',
|
|
197
|
+
width: 100
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: 'string',
|
|
201
|
+
name: 'totalCost',
|
|
202
|
+
header: i18next.t('field.total_cost'),
|
|
203
|
+
width: 100
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
let list = {
|
|
207
|
+
fields: [
|
|
208
|
+
'bizplace|name',
|
|
209
|
+
'product|sku',
|
|
210
|
+
'product|name',
|
|
211
|
+
'product|description',
|
|
212
|
+
'product|type',
|
|
213
|
+
'qty',
|
|
214
|
+
'uomValue',
|
|
215
|
+
'uom',
|
|
216
|
+
'weightedAvgUnitCost',
|
|
217
|
+
'totalCost'
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
columns: columns,
|
|
223
|
+
list,
|
|
224
|
+
pagination: { limit: 100, pages: [100, 200, 500, 1000] },
|
|
225
|
+
rows: {
|
|
226
|
+
selectable: false,
|
|
227
|
+
insertable: false,
|
|
228
|
+
appendable: false
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
render() {
|
|
234
|
+
return html`
|
|
235
|
+
<search-form id="search-form" .fields=${this._searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
|
|
236
|
+
|
|
237
|
+
<data-grist
|
|
238
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
239
|
+
.config=${this._config}
|
|
240
|
+
.fetchHandler="${this.fetchHandler.bind(this)}"
|
|
241
|
+
></data-grist>
|
|
242
|
+
`
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async pageInitialized() {
|
|
246
|
+
this._gristData = { total: 0, records: [] }
|
|
247
|
+
this._products = []
|
|
248
|
+
|
|
249
|
+
const [_partnersReq] = await Promise.allSettled([this._fetchPartners()])
|
|
250
|
+
|
|
251
|
+
this._partners = _partnersReq.status == 'fulfilled' ? _partnersReq.value : []
|
|
252
|
+
|
|
253
|
+
this._searchFields = this.searchFields
|
|
254
|
+
this._config = this.reportConfig
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async pageUpdated(changes, lifecycle) {
|
|
258
|
+
if (this.active) {
|
|
259
|
+
this.dataGrist.fetch()
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async fetchHandler({ page, limit, sorters = [] }) {
|
|
264
|
+
try {
|
|
265
|
+
this._validate()
|
|
266
|
+
let filters = this.searchForm.queryFilters.map(filter => {
|
|
267
|
+
switch (filter.name) {
|
|
268
|
+
case 'fromDate':
|
|
269
|
+
let fromDt = new Date(filter.value)
|
|
270
|
+
fromDt.setHours(0)
|
|
271
|
+
filter.value = fromDt.toISOString()
|
|
272
|
+
break
|
|
273
|
+
case 'toDate':
|
|
274
|
+
let toDt = new Date(filter.value)
|
|
275
|
+
toDt.setHours(23, 59, 59)
|
|
276
|
+
filter.value = toDt.toISOString()
|
|
277
|
+
break
|
|
278
|
+
default:
|
|
279
|
+
break
|
|
280
|
+
}
|
|
281
|
+
return filter
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
const pagination = { page, limit }
|
|
285
|
+
const sortings = sorters
|
|
286
|
+
|
|
287
|
+
const response = await client.query({
|
|
288
|
+
query: gql`
|
|
289
|
+
query costingReport($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
290
|
+
costingReport(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
291
|
+
items {
|
|
292
|
+
bizplace {
|
|
293
|
+
name
|
|
294
|
+
description
|
|
295
|
+
}
|
|
296
|
+
product {
|
|
297
|
+
sku
|
|
298
|
+
name
|
|
299
|
+
description
|
|
300
|
+
type
|
|
301
|
+
}
|
|
302
|
+
qty
|
|
303
|
+
uomValue
|
|
304
|
+
uom
|
|
305
|
+
weightedAvgUnitCost
|
|
306
|
+
totalCost
|
|
307
|
+
}
|
|
308
|
+
total
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
`,
|
|
312
|
+
variables: { filters, pagination, sortings },
|
|
313
|
+
context: gqlContext()
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
const data = {
|
|
317
|
+
total: response.data.costingReport.total,
|
|
318
|
+
records:
|
|
319
|
+
response.data.costingReport.items.map(itm => {
|
|
320
|
+
itm = {
|
|
321
|
+
...itm,
|
|
322
|
+
weightedAvgUnitCost: parseFloat(itm.weightedAvgUnitCost ? itm.weightedAvgUnitCost : 0).toFixed(4),
|
|
323
|
+
totalCost: parseFloat(itm.totalCost ? itm.totalCost : 0).toFixed(4)
|
|
324
|
+
}
|
|
325
|
+
return flattenObject({ ...itm, bizplace: { name: `${itm.bizplace.name} ${itm.bizplace.description}` } })
|
|
326
|
+
}) || []
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
this._gristData = {
|
|
330
|
+
...data
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return data
|
|
334
|
+
} catch (e) {
|
|
335
|
+
this._showToast(e)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async _fetchPartners() {
|
|
340
|
+
const filters = []
|
|
341
|
+
const response = await client.query({
|
|
342
|
+
query: gql`
|
|
343
|
+
query partnersBizplaces($filters: [Filter!]) {
|
|
344
|
+
partnersBizplaces(filters: $filters) {
|
|
345
|
+
items {
|
|
346
|
+
id
|
|
347
|
+
name
|
|
348
|
+
description
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
`,
|
|
353
|
+
variables: { filters }
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
if (!response.errors) {
|
|
357
|
+
return response.data.partnersBizplaces.items
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
_validate() {
|
|
361
|
+
if (!this.searchForm.shadowRoot.querySelector('form').checkValidity())
|
|
362
|
+
throw new Error(i18next.t('text.invalid_form_value'))
|
|
363
|
+
if (!this._bizplaceSelector.value) throw new Error(i18next.t('text.no_company_selected'))
|
|
364
|
+
if (!this._fromDateInput.value) throw new Error(i18next.t('text.from_date_is_empty'))
|
|
365
|
+
if (!this._toDateInput.value) throw new Error(i18next.t('text.to_date_is_empty'))
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
_compareValues(key, order = 'asc') {
|
|
369
|
+
return function innerSort(a, b) {
|
|
370
|
+
if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
|
|
371
|
+
return 0
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key]
|
|
375
|
+
const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key]
|
|
376
|
+
|
|
377
|
+
let comparison = 0
|
|
378
|
+
if (varA > varB) {
|
|
379
|
+
comparison = 1
|
|
380
|
+
} else if (varA < varB) {
|
|
381
|
+
comparison = -1
|
|
382
|
+
}
|
|
383
|
+
return order === 'desc' ? comparison * -1 : comparison
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
_modifyDateRange(e) {
|
|
388
|
+
const fromDate = e.currentTarget.value
|
|
389
|
+
|
|
390
|
+
let min = new Date(fromDate)
|
|
391
|
+
let max = new Date(fromDate)
|
|
392
|
+
max.setMonth(max.getMonth() + 2)
|
|
393
|
+
|
|
394
|
+
min = min.toISOString().split('T')[0]
|
|
395
|
+
max = max.toISOString().split('T')[0]
|
|
396
|
+
|
|
397
|
+
if (this._toDateInput.value < fromDate) this._toDateInput.value = fromDate
|
|
398
|
+
|
|
399
|
+
if (this._toDateInput.value > max) this._toDateInput.value = max
|
|
400
|
+
|
|
401
|
+
this._toDateInput.max = max
|
|
402
|
+
this._toDateInput.min = min
|
|
403
|
+
this._submit()
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
_submit(e) {
|
|
407
|
+
this._config = { ...this.reportConfig }
|
|
408
|
+
this.searchForm.submit()
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
async _exportableData() {
|
|
412
|
+
try {
|
|
413
|
+
var headerSetting = [
|
|
414
|
+
{ header: i18next.t('field.company'), key: 'bizplace|name', width: 60, type: 'string' },
|
|
415
|
+
{ header: i18next.t('field.sku'), key: 'product|sku', width: 25, type: 'string' },
|
|
416
|
+
{ header: i18next.t('field.product_name'), key: 'product|name', width: 50, type: 'string' },
|
|
417
|
+
{ header: i18next.t('field.product_description'), key: 'product|description', width: 50, type: 'string' },
|
|
418
|
+
{ header: i18next.t('field.product_type'), key: 'product|type', width: 30, type: 'string' },
|
|
419
|
+
{ header: i18next.t('field.qty'), key: 'qty', width: 15, type: 'string' },
|
|
420
|
+
{ header: i18next.t('field.uom_value'), key: 'uomValue', width: 15, type: 'string' },
|
|
421
|
+
{ header: i18next.t('field.uom'), key: 'uom', width: 15, type: 'string' },
|
|
422
|
+
{ header: 'Weighted Avg Unit Cost', key: 'weightedAvgUnitCost', width: 15, type: 'string' },
|
|
423
|
+
{ header: i18next.t('field.total_cost'), key: 'totalCost', width: 15, type: 'string' }
|
|
424
|
+
]
|
|
425
|
+
|
|
426
|
+
var exportData = {
|
|
427
|
+
header: [...headerSetting],
|
|
428
|
+
data: (await this.fetchHandler({ page: 1, limit: 9999999 })).records.map(itm => {
|
|
429
|
+
return {
|
|
430
|
+
...itm
|
|
431
|
+
}
|
|
432
|
+
})
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return exportData
|
|
436
|
+
} catch (e) {
|
|
437
|
+
this._showToast(e)
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
_showToast({ type, message }) {
|
|
442
|
+
document.dispatchEvent(
|
|
443
|
+
new CustomEvent('notify', {
|
|
444
|
+
detail: {
|
|
445
|
+
type,
|
|
446
|
+
message
|
|
447
|
+
}
|
|
448
|
+
})
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
window.customElements.define('costing-report', CostingReport)
|
|
@@ -362,6 +362,12 @@ class InboundOrderDetailsReport extends connect(store)(localize(i18next)(PageVie
|
|
|
362
362
|
header: i18next.t('field.uom'),
|
|
363
363
|
width: 100
|
|
364
364
|
},
|
|
365
|
+
{
|
|
366
|
+
type: 'string',
|
|
367
|
+
name: 'unitCost',
|
|
368
|
+
header: i18next.t('field.unit_cost'),
|
|
369
|
+
width: 100
|
|
370
|
+
},
|
|
365
371
|
{
|
|
366
372
|
type: 'float',
|
|
367
373
|
name: 'unitVolume',
|
|
@@ -497,6 +503,7 @@ class InboundOrderDetailsReport extends connect(store)(localize(i18next)(PageVie
|
|
|
497
503
|
'qty',
|
|
498
504
|
'uomValue',
|
|
499
505
|
'uom',
|
|
506
|
+
'unitCost',
|
|
500
507
|
'unitVolume',
|
|
501
508
|
'totalVolume',
|
|
502
509
|
'unitNettWeight',
|
|
@@ -613,6 +620,7 @@ class InboundOrderDetailsReport extends connect(store)(localize(i18next)(PageVie
|
|
|
613
620
|
qty
|
|
614
621
|
uomValue
|
|
615
622
|
uom
|
|
623
|
+
unitCost
|
|
616
624
|
unitVolume
|
|
617
625
|
totalVolume
|
|
618
626
|
unitNettWeight
|
|
@@ -643,6 +651,11 @@ class InboundOrderDetailsReport extends connect(store)(localize(i18next)(PageVie
|
|
|
643
651
|
total: response.data.inboundOrderDetailsReport.total,
|
|
644
652
|
records:
|
|
645
653
|
response.data.inboundOrderDetailsReport.items.map(itm => {
|
|
654
|
+
itm = {
|
|
655
|
+
...itm,
|
|
656
|
+
unitCost: parseFloat(itm.unitCost ? itm.unitCost : 0).toFixed(2)
|
|
657
|
+
}
|
|
658
|
+
|
|
646
659
|
return flattenObject({ ...itm, bizplace: { name: `${itm.bizplace.name} ${itm.bizplace.description}` } })
|
|
647
660
|
}) || []
|
|
648
661
|
}
|
|
@@ -758,6 +771,7 @@ class InboundOrderDetailsReport extends connect(store)(localize(i18next)(PageVie
|
|
|
758
771
|
{ header: i18next.t('field.qty'), key: 'qty', width: 15, type: 'string' },
|
|
759
772
|
{ header: i18next.t('field.uom_value'), key: 'uomValue', width: 15, type: 'string' },
|
|
760
773
|
{ header: i18next.t('field.uom'), key: 'uom', width: 15, type: 'string' },
|
|
774
|
+
{ header: i18next.t('field.unit_cost'), key: 'unitCost', width: 15, type: 'string' },
|
|
761
775
|
{ header: i18next.t('field.unit_volume'), key: 'unitVolume', width: 15, type: 'string' },
|
|
762
776
|
{ header: i18next.t('field.total_volume'), key: 'totalVolume', width: 15, type: 'string' },
|
|
763
777
|
{ header: i18next.t('field.unit_nett_weight'), key: 'unitNettWeight', width: 15, type: 'string' },
|