@things-factory/operato-wms 4.3.246 → 4.3.247
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/order/release-order/create-release-order.js +401 -116
- package/client/pages/order/vas-order/create-vas-order.js +1 -1
- package/client/pages/order/vas-order/popup/select-vas-popup.js +1 -1
- package/client/pages/outbound/loading-product.js +1 -1
- package/client/pages/outbound/worksheet-loading.js +14 -3
- package/client/pages/outbound/worksheet-picking.js +20 -5
- package/client/pages/report/vas-report.js +12 -11
- package/client/pages/vas/vas-execution-page.js +23 -11
- package/client/pages/vas/worksheet-ref-vas.js +28 -16
- package/dist-server/graphql/resolvers/reports/vas-report.js +19 -18
- package/dist-server/graphql/resolvers/reports/vas-report.js.map +1 -1
- package/package.json +4 -4
- package/server/graphql/resolvers/reports/vas-report.ts +19 -19
- package/translations/en.json +6 -2
- package/translations/ko.json +6 -2
- package/translations/ms.json +6 -2
- package/translations/zh.json +6 -2
|
@@ -69,10 +69,8 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
69
69
|
_productBundleName: String,
|
|
70
70
|
_selectedInventories: Array,
|
|
71
71
|
inventoryGristConfig: Object,
|
|
72
|
-
vasGristConfig: Object,
|
|
73
72
|
inventoryData: Object,
|
|
74
73
|
bundleData: Object,
|
|
75
|
-
vasData: Object,
|
|
76
74
|
crossDockingProducts: Array,
|
|
77
75
|
_releaseByBundleQty: Number,
|
|
78
76
|
_releaseByBundleUomValue: Number,
|
|
@@ -85,6 +83,11 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
85
83
|
// _vasExpanded: Boolean,
|
|
86
84
|
_selectedCP: String,
|
|
87
85
|
|
|
86
|
+
/* VAS related */
|
|
87
|
+
vasData: Object,
|
|
88
|
+
vasGristConfig: Object,
|
|
89
|
+
vasFormattedData: Object,
|
|
90
|
+
|
|
88
91
|
/* Shipping Form Field */
|
|
89
92
|
_contactPointId: String,
|
|
90
93
|
_contactPointName: String,
|
|
@@ -1096,15 +1099,15 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
1096
1099
|
click: (columns, data, column, record, rowIndex) => {
|
|
1097
1100
|
this._selectedVasRecord = record
|
|
1098
1101
|
this._selectedVasRecordIdx = rowIndex
|
|
1099
|
-
if (column.name === 'sku') {
|
|
1102
|
+
if (column.name === 'sku' && (record.__dirty__ === '+' || (record.vasGristId && record.productId))) {
|
|
1100
1103
|
this.openTargetproductVasPopup(record)
|
|
1101
1104
|
}
|
|
1102
1105
|
if (column.name === 'newSKU') {
|
|
1103
|
-
this._openBulkProductSelectionForVas(this._selectBy, rowIndex)
|
|
1106
|
+
this._openBulkProductSelectionForVas(this._selectBy, rowIndex, record)
|
|
1104
1107
|
}
|
|
1105
1108
|
if (column.name === 'vas') {
|
|
1106
1109
|
try {
|
|
1107
|
-
if (!record.qty) {
|
|
1110
|
+
if (!record.qty && record.productId && record.productDetailId) {
|
|
1108
1111
|
throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.qty') }))
|
|
1109
1112
|
} else {
|
|
1110
1113
|
this.openSelectVasPopup(record, rowIndex)
|
|
@@ -1389,6 +1392,28 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
1389
1392
|
if (record.isCrossDocking) throw new Error(i18next.t('text.cannot_delete_cross_docking_products'))
|
|
1390
1393
|
const newData = data.records.filter((_, idx) => idx !== rowIndex)
|
|
1391
1394
|
this.inventoryData = { ...this.inventoryData, records: newData }
|
|
1395
|
+
|
|
1396
|
+
if (this.vasData?.records.length > 0) {
|
|
1397
|
+
const vasGristId = this.vasData.records
|
|
1398
|
+
.filter(
|
|
1399
|
+
v =>
|
|
1400
|
+
v.productId === record.productId &&
|
|
1401
|
+
v.productDetailId === record.productDetailId &&
|
|
1402
|
+
v.batchId === record.batchId
|
|
1403
|
+
)
|
|
1404
|
+
.map(v => {
|
|
1405
|
+
return { vasGristId: v.vasGristId }
|
|
1406
|
+
})
|
|
1407
|
+
this.vasData = {
|
|
1408
|
+
...this.vasData,
|
|
1409
|
+
records: this.vasData.records.filter(v => {
|
|
1410
|
+
return !vasGristId.some(i => {
|
|
1411
|
+
return i.vasGristId === v.vasGristId
|
|
1412
|
+
})
|
|
1413
|
+
})
|
|
1414
|
+
}
|
|
1415
|
+
this.vasGrist.dirtyData.records = this.vasData.records
|
|
1416
|
+
}
|
|
1392
1417
|
this.inventoryGrist.dirtyData.records = newData
|
|
1393
1418
|
this._updateInventoryGristConfig()
|
|
1394
1419
|
} catch (e) {
|
|
@@ -1406,7 +1431,7 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
1406
1431
|
handlers: {
|
|
1407
1432
|
click: (columns, data, column, record, rowIndex) => {
|
|
1408
1433
|
this._selectBy = 'product'
|
|
1409
|
-
this._openBulkProductSelection(this._selectBy, rowIndex)
|
|
1434
|
+
this._openBulkProductSelection(this._selectBy, rowIndex, record)
|
|
1410
1435
|
}
|
|
1411
1436
|
},
|
|
1412
1437
|
width: 350
|
|
@@ -1505,12 +1530,53 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
1505
1530
|
handlers: {
|
|
1506
1531
|
click: (columns, data, column, record, rowIndex) => {
|
|
1507
1532
|
const newData = data.records.filter((_, idx) => idx !== rowIndex)
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1533
|
+
|
|
1534
|
+
if (this.vasData?.records.length > 0) {
|
|
1535
|
+
const invData = this.inventoryData
|
|
1536
|
+
const vasData = this.vasData
|
|
1537
|
+
const currentReleaseQty = this.inventoryData.records.reduce(
|
|
1538
|
+
(total, inv) =>
|
|
1539
|
+
inv.releaseQty &&
|
|
1540
|
+
inv.productId === record.productId &&
|
|
1541
|
+
inv.productDetailId === record.productDetailId &&
|
|
1542
|
+
inv.batchId === record.batchId
|
|
1543
|
+
? total + inv.releaseQty
|
|
1544
|
+
: total,
|
|
1545
|
+
0
|
|
1546
|
+
)
|
|
1547
|
+
let newReleaseQty = record.releaseQty ? currentReleaseQty - record.releaseQty : currentReleaseQty
|
|
1548
|
+
const vasDataQty = this.vasData.records.reduce(
|
|
1549
|
+
(total, vas) =>
|
|
1550
|
+
vas.qty &&
|
|
1551
|
+
vas.productId === record.productId &&
|
|
1552
|
+
vas.productDetailId === record.productDetailId &&
|
|
1553
|
+
vas.batchId === record.batchId
|
|
1554
|
+
? total + vas.qty
|
|
1555
|
+
: total,
|
|
1556
|
+
0
|
|
1557
|
+
)
|
|
1558
|
+
if (newReleaseQty < vasDataQty) {
|
|
1559
|
+
const vasGristId = this.vasData.records
|
|
1560
|
+
.filter(
|
|
1561
|
+
v =>
|
|
1562
|
+
v.productId === record.productId &&
|
|
1563
|
+
v.productDetailId === record.productDetailId &&
|
|
1564
|
+
v.batchId === record.batchId
|
|
1565
|
+
)
|
|
1566
|
+
.map(v => {
|
|
1567
|
+
return { vasGristId: v.vasGristId }
|
|
1568
|
+
})
|
|
1569
|
+
this.vasData = {
|
|
1570
|
+
...this.vasData,
|
|
1571
|
+
records: this.vasData.records.filter(v => {
|
|
1572
|
+
return !vasGristId.some(i => {
|
|
1573
|
+
return i.vasGristId === v.vasGristId
|
|
1574
|
+
})
|
|
1575
|
+
})
|
|
1576
|
+
}
|
|
1577
|
+
this.vasGrist.dirtyData.records = this.vasData.records
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1514
1580
|
this.inventoryData = { ...this.inventoryData, records: newData }
|
|
1515
1581
|
this.inventoryGrist.dirtyData.records = newData
|
|
1516
1582
|
this._updateInventoryGristConfig()
|
|
@@ -1799,10 +1865,72 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
1799
1865
|
}
|
|
1800
1866
|
}
|
|
1801
1867
|
|
|
1802
|
-
_onProductChangeHandler(event) {
|
|
1868
|
+
async _onProductChangeHandler(event) {
|
|
1803
1869
|
const changeRecord = event.detail.after
|
|
1804
1870
|
const changedColumn = event.detail.column.name
|
|
1805
1871
|
|
|
1872
|
+
if (
|
|
1873
|
+
(changedColumn == 'releaseQty' || changedColumn == 'releaseUom') &&
|
|
1874
|
+
(changeRecord.releaseQty < event.detail.before.releaseQty ||
|
|
1875
|
+
changeRecord.releaseUomValue < changeRecord.releaseUomValue)
|
|
1876
|
+
) {
|
|
1877
|
+
const newTotalQty = this.formatVasTargetproductData()
|
|
1878
|
+
.filter(
|
|
1879
|
+
v =>
|
|
1880
|
+
v.productId === event.detail.after.productId &&
|
|
1881
|
+
v.productDetailId === event.detail.after.productDetailId &&
|
|
1882
|
+
v.batchId === event.detail.after.batchId
|
|
1883
|
+
)
|
|
1884
|
+
.reduce(a => a).releaseQty
|
|
1885
|
+
|
|
1886
|
+
const vasTotalQTy = this.vasData.records
|
|
1887
|
+
.filter(
|
|
1888
|
+
v =>
|
|
1889
|
+
v.productId === event.detail.after.productId &&
|
|
1890
|
+
v.productDetailId === event.detail.after.productDetailId &&
|
|
1891
|
+
v.batchId === event.detail.after.batchId
|
|
1892
|
+
)
|
|
1893
|
+
.reduce((a, b) => a.qty + b.qty)
|
|
1894
|
+
|
|
1895
|
+
if (vasTotalQTy > newTotalQty) {
|
|
1896
|
+
const result = await CustomAlert({
|
|
1897
|
+
title: i18next.t('title.are_you_sure'),
|
|
1898
|
+
text: i18next.t(
|
|
1899
|
+
'text.sku_has_vas_releaseQty_less_than_qty_for_vas_changing_will_require_user_to_reenter_vas_information'
|
|
1900
|
+
),
|
|
1901
|
+
confirmButton: { text: i18next.t('button.confirm') },
|
|
1902
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
1903
|
+
})
|
|
1904
|
+
|
|
1905
|
+
if (!result.value) {
|
|
1906
|
+
this.inventoryGrist.dirtyData.records[event.detail.after.__seq__ - 1].releaseQty =
|
|
1907
|
+
event.detail.before.releaseQty
|
|
1908
|
+
this.inventoryData.records[event.detail.after.__seq__ - 1].releaseQty = event.detail.before.releaseQty
|
|
1909
|
+
return
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
const vasGristId = this.vasData.records
|
|
1913
|
+
.filter(
|
|
1914
|
+
v =>
|
|
1915
|
+
v.productId === changeRecord.productId &&
|
|
1916
|
+
v.productDetailId === changeRecord.productDetailId &&
|
|
1917
|
+
v.batchId === changeRecord.batchId
|
|
1918
|
+
)
|
|
1919
|
+
.map(v => {
|
|
1920
|
+
return { vasGristId: v.vasGristId }
|
|
1921
|
+
})
|
|
1922
|
+
this.vasData = {
|
|
1923
|
+
...this.vasData,
|
|
1924
|
+
records: this.vasData.records.filter(v => {
|
|
1925
|
+
return !vasGristId.some(i => {
|
|
1926
|
+
return i.vasGristId === v.vasGristId
|
|
1927
|
+
})
|
|
1928
|
+
})
|
|
1929
|
+
}
|
|
1930
|
+
this.vasGrist.dirtyData.records = this.vasData.records
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1806
1934
|
try {
|
|
1807
1935
|
if (changedColumn === 'releaseQty') {
|
|
1808
1936
|
if (changeRecord.isCrossDocking) {
|
|
@@ -1834,45 +1962,114 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
1834
1962
|
const initialRecord = event.detail.before
|
|
1835
1963
|
const changeRecord = event.detail.after
|
|
1836
1964
|
const changedColumn = event.detail.column.name
|
|
1837
|
-
|
|
1965
|
+
this.vasFormattedData = this.formatVasTargetproductData()
|
|
1966
|
+
const inventoryData = this.vasFormattedData.find(
|
|
1967
|
+
invData =>
|
|
1968
|
+
invData.productId === event.detail.after.productId &&
|
|
1969
|
+
invData.productDetailId === event.detail.after.productDetailId &&
|
|
1970
|
+
invData.batchId === event.detail.after.batchId
|
|
1971
|
+
)
|
|
1838
1972
|
|
|
1839
1973
|
try {
|
|
1974
|
+
// to map to the first row
|
|
1975
|
+
if (
|
|
1976
|
+
changedColumn === 'qty' ||
|
|
1977
|
+
changedColumn === 'newPackingType' ||
|
|
1978
|
+
changedColumn === 'newUom' ||
|
|
1979
|
+
changedColumn === 'newUomValue' ||
|
|
1980
|
+
changedColumn === 'outputQty' ||
|
|
1981
|
+
changedColumn === 'remark'
|
|
1982
|
+
)
|
|
1983
|
+
if (!changeRecord.productId && !changeRecord.productDetailId && !changeRecord.batchId) {
|
|
1984
|
+
delete event.detail.after[event.detail.column.name]
|
|
1985
|
+
const index = this.vasGrist.dirtyData.records.findIndex(
|
|
1986
|
+
d => d.vasGristId === changeRecord.vasGristId && d.productId && d.productDetailId && d.batchId
|
|
1987
|
+
)
|
|
1988
|
+
throw new Error(
|
|
1989
|
+
i18next.t('text.please_enter_value_on_row_row', {
|
|
1990
|
+
row: `[ ${index + 1} ] ${this.vasGrist.dirtyData.records[index].sku} (${
|
|
1991
|
+
this.vasGrist.dirtyData.records[index].batchId
|
|
1992
|
+
}) `
|
|
1993
|
+
})
|
|
1994
|
+
)
|
|
1995
|
+
}
|
|
1996
|
+
if (changeRecord.qty <= 0 || changeRecord.vasQty <= 0 || changeRecord.outputQty <= 0) {
|
|
1997
|
+
throw new Error(i18next.t('text.invalid_quantity_input'))
|
|
1998
|
+
}
|
|
1840
1999
|
if (changedColumn === 'qty') {
|
|
1841
2000
|
if (changeRecord.qty === undefined) throw new Error(i18next.t('text.there_is_no_selected_items'))
|
|
1842
2001
|
// total up the qty
|
|
1843
|
-
if (
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
changeRecord.
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2002
|
+
if (this._selectBy === 'pallet') {
|
|
2003
|
+
if (
|
|
2004
|
+
///
|
|
2005
|
+
this.vasData.records.reduce(
|
|
2006
|
+
(total, vas) =>
|
|
2007
|
+
vas.qty &&
|
|
2008
|
+
vas.productId === changeRecord.productId &&
|
|
2009
|
+
vas.productDetailId === changeRecord.productDetailId &&
|
|
2010
|
+
vas.batchId === changeRecord.batchId
|
|
2011
|
+
? total + vas.qty
|
|
2012
|
+
: total,
|
|
2013
|
+
0
|
|
2014
|
+
) > inventoryData.releaseQty
|
|
2015
|
+
|
|
2016
|
+
//
|
|
2017
|
+
) {
|
|
2018
|
+
throw new Error(i18next.t('text.qty_exceed_release_qty'))
|
|
2019
|
+
}
|
|
2020
|
+
} else if (this._selectBy === 'product') {
|
|
2021
|
+
if (changeRecord.qty > inventoryData.releaseQty) {
|
|
2022
|
+
throw new Error(i18next.t('text.qty_exceed_release_qty'))
|
|
2023
|
+
}
|
|
2024
|
+
if (
|
|
2025
|
+
this.vasData.records.reduce(
|
|
2026
|
+
(total, vas) =>
|
|
2027
|
+
vas.qty &&
|
|
2028
|
+
vas.productId === changeRecord.productId &&
|
|
2029
|
+
vas.productDetailId === changeRecord.productDetailId &&
|
|
2030
|
+
vas.batchId === changeRecord.batchId
|
|
2031
|
+
? total + vas.qty
|
|
2032
|
+
: total,
|
|
2033
|
+
0
|
|
2034
|
+
) > inventoryData.releaseQty
|
|
2035
|
+
) {
|
|
2036
|
+
throw new Error(i18next.t('text.qty_exceed_release_qty'))
|
|
2037
|
+
}
|
|
1866
2038
|
}
|
|
2039
|
+
//to change uom, vasQty
|
|
2040
|
+
let uomValue = initialRecord.releaseUomValue / initialRecord.releaseQty
|
|
2041
|
+
let newUomValue = initialRecord.newUomValue
|
|
2042
|
+
? initialRecord.qty
|
|
2043
|
+
? initialRecord.newUomValue / initialRecord.qty
|
|
2044
|
+
: initialRecord.newUomValue
|
|
2045
|
+
: null
|
|
2046
|
+
changeRecord.uomValue = uomValue * changeRecord.qty
|
|
2047
|
+
changeRecord.newUomValue
|
|
2048
|
+
? initialRecord.outputQty
|
|
2049
|
+
? initialRecord.outputQty
|
|
2050
|
+
: (changeRecord.newUomValue = changeRecord.qty * newUomValue)
|
|
2051
|
+
: null
|
|
2052
|
+
changeRecord.vasQty = changeRecord.qty
|
|
2053
|
+
changeRecord.outputQty = initialRecord.outputQty ? initialRecord.outputQty : null
|
|
2054
|
+
//
|
|
1867
2055
|
} else if (changedColumn === 'outputQty' || changedColumn === 'vasQty' || changedColumn === 'newUomValue') {
|
|
1868
2056
|
if (changeRecord.outputQty === undefined || changeRecord.vasQty === undefined)
|
|
1869
2057
|
throw new Error(i18next.t('text.there_is_no_selected_items'))
|
|
1870
|
-
if (
|
|
2058
|
+
else if (
|
|
1871
2059
|
changeRecord.outputQty <= 0 ||
|
|
2060
|
+
isNaN(changeRecord.outputQty) ||
|
|
1872
2061
|
changeRecord.vasQty <= 0 ||
|
|
1873
2062
|
(initialRecord.newProductId && initialRecord.productId && changeRecord.newUomValue <= 0)
|
|
1874
2063
|
) {
|
|
1875
2064
|
throw new Error(i18next.t('text.invalid_quantity_input'))
|
|
2065
|
+
} else if (changedColumn === 'outputQty' && changeRecord.newProductId && changeRecord.newProductDetailId) {
|
|
2066
|
+
if (initialRecord.outputQty == null) {
|
|
2067
|
+
const totalUomValue = changeRecord.outputQty * (changeRecord.newUomValue / changeRecord.qty)
|
|
2068
|
+
changeRecord.newUomValue = totalUomValue
|
|
2069
|
+
} else {
|
|
2070
|
+
const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / initialRecord.outputQty)
|
|
2071
|
+
changeRecord.newUomValue = totalUomValue
|
|
2072
|
+
}
|
|
1876
2073
|
}
|
|
1877
2074
|
}
|
|
1878
2075
|
this._updateVasTargets()
|
|
@@ -2373,7 +2570,7 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
2373
2570
|
if (!record.vas) throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.vas') }))
|
|
2374
2571
|
// allowing repacking to same SKU
|
|
2375
2572
|
// if (record.productSKU == record.newSKU)
|
|
2376
|
-
// throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.new_sku_same_as_original_sku') }))
|
|
2573
|
+
// throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.new_sku_same_as_original_sku') }))\
|
|
2377
2574
|
if (record.newSKU) {
|
|
2378
2575
|
if (!record.newPackingType) {
|
|
2379
2576
|
throw new Error(
|
|
@@ -2428,8 +2625,29 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
2428
2625
|
}
|
|
2429
2626
|
}
|
|
2430
2627
|
|
|
2431
|
-
_openBulkProductSelection(type, rowIndex) {
|
|
2628
|
+
async _openBulkProductSelection(type, rowIndex, record) {
|
|
2432
2629
|
if (this._bizplaceId) {
|
|
2630
|
+
{
|
|
2631
|
+
if (this.vasData.records.length > 0) {
|
|
2632
|
+
if (
|
|
2633
|
+
this.vasData.records.find(
|
|
2634
|
+
v =>
|
|
2635
|
+
v.productId === record?.productId &&
|
|
2636
|
+
v.productDetailId === record?.productDetailId &&
|
|
2637
|
+
v.batchId === record?.batchId
|
|
2638
|
+
)
|
|
2639
|
+
) {
|
|
2640
|
+
const result = await CustomAlert({
|
|
2641
|
+
title: i18next.t('title.are_you_sure'),
|
|
2642
|
+
text: i18next.t('text.sku_has_vas_changing_sku_will_need_user_to_reenter_vas_information'),
|
|
2643
|
+
confirmButton: { text: i18next.t('button.confirm') },
|
|
2644
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
2645
|
+
})
|
|
2646
|
+
|
|
2647
|
+
if (!result.value) return
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2433
2651
|
openPopup(
|
|
2434
2652
|
html`
|
|
2435
2653
|
<select-inventory-popup
|
|
@@ -2462,8 +2680,26 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
2462
2680
|
|
|
2463
2681
|
// if got this.vasData only, to prevent calling this function if this.vasData is unavailable
|
|
2464
2682
|
// delete vasData if product is changed in order tab
|
|
2465
|
-
if (this.vasData
|
|
2466
|
-
this.
|
|
2683
|
+
if (this.vasData?.records.length > 0) {
|
|
2684
|
+
const vasGristId = this.vasData.records
|
|
2685
|
+
.filter(
|
|
2686
|
+
v =>
|
|
2687
|
+
v.productId === record.productId &&
|
|
2688
|
+
v.productDetailId === record.productDetailId &&
|
|
2689
|
+
v.batchId === record.batchId
|
|
2690
|
+
)
|
|
2691
|
+
.map(v => {
|
|
2692
|
+
return { vasGristId: v.vasGristId }
|
|
2693
|
+
})
|
|
2694
|
+
this.vasData = {
|
|
2695
|
+
...this.vasData,
|
|
2696
|
+
records: this.vasData.records.filter(v => {
|
|
2697
|
+
return !vasGristId.some(i => {
|
|
2698
|
+
return i.vasGristId === v.vasGristId
|
|
2699
|
+
})
|
|
2700
|
+
})
|
|
2701
|
+
}
|
|
2702
|
+
this.vasGrist.dirtyData.records = this.vasData.records
|
|
2467
2703
|
}
|
|
2468
2704
|
}
|
|
2469
2705
|
}}"
|
|
@@ -2480,7 +2716,7 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
2480
2716
|
}
|
|
2481
2717
|
}
|
|
2482
2718
|
|
|
2483
|
-
_openBulkProductSelectionForVas(type, rowIndex) {
|
|
2719
|
+
_openBulkProductSelectionForVas(type, rowIndex, record) {
|
|
2484
2720
|
if (this._bizplaceId) {
|
|
2485
2721
|
openPopup(
|
|
2486
2722
|
html`
|
|
@@ -2503,15 +2739,19 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
2503
2739
|
// for (let i = 0; i < e.detail.multipleProducts.length; i++) {
|
|
2504
2740
|
// newRecords.push(e.detail.multipleProducts[i])
|
|
2505
2741
|
// }
|
|
2506
|
-
// update existing
|
|
2742
|
+
// update existing vas data records
|
|
2743
|
+
if (!record.productId) {
|
|
2744
|
+
rowIndex = this.vasGrist.dirtyData.records.findIndex(d => d.vasGristId === record.vasGristId)
|
|
2745
|
+
}
|
|
2507
2746
|
this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
|
|
2508
2747
|
...this.vasGrist.dirtyData.records[rowIndex],
|
|
2509
2748
|
...newRecords
|
|
2510
2749
|
})
|
|
2511
|
-
|
|
2512
2750
|
this.vasGrist.dirtyData.records.map(record => {
|
|
2513
2751
|
record.newSKU
|
|
2514
|
-
? record.
|
|
2752
|
+
? record.outputQty
|
|
2753
|
+
? (record.newUomValue = record.outputQty * record.newUomValue)
|
|
2754
|
+
: record.qty
|
|
2515
2755
|
? (record.newUomValue = record.qty * record.newUomValue)
|
|
2516
2756
|
: record.newUomValue
|
|
2517
2757
|
: (record.newUomValue = null)
|
|
@@ -2951,53 +3191,12 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
2951
3191
|
|
|
2952
3192
|
openTargetproductVasPopup(record) {
|
|
2953
3193
|
try {
|
|
3194
|
+
let targetList = this.formatVasTargetproductData()
|
|
2954
3195
|
this.checkInventoryValidity()
|
|
2955
3196
|
openPopup(
|
|
2956
3197
|
html`
|
|
2957
3198
|
<vas-target-product-popup
|
|
2958
|
-
.targetList="${
|
|
2959
|
-
.map(record => {
|
|
2960
|
-
const unitUomValue = record.releaseUomValue / record.releaseQty
|
|
2961
|
-
let packQty = record.releaseQty
|
|
2962
|
-
|
|
2963
|
-
if (this.vasData.records?.length) {
|
|
2964
|
-
const existVasData = this.vasData.records.filter(vasRecord => {
|
|
2965
|
-
const isSamePackingType = !!(record.packingType === vasRecord.packingType)
|
|
2966
|
-
switch (vasRecord.targetType) {
|
|
2967
|
-
case VAS_BATCH_AND_PRODUCT_TYPE:
|
|
2968
|
-
return (
|
|
2969
|
-
record.batchId === vasRecord.target.batchId &&
|
|
2970
|
-
record.product.id === vasRecord.target.productId &&
|
|
2971
|
-
isSamePackingType
|
|
2972
|
-
)
|
|
2973
|
-
case VAS_BATCH_NO_TYPE:
|
|
2974
|
-
return record.batchId === vasRecord.target && isSamePackingType
|
|
2975
|
-
case VAS_PRODUCT_TYPE:
|
|
2976
|
-
return record.product.id === vasRecord.target && isSamePackingType
|
|
2977
|
-
}
|
|
2978
|
-
})
|
|
2979
|
-
|
|
2980
|
-
if (existVasData?.length) {
|
|
2981
|
-
let assignedQty = 0
|
|
2982
|
-
|
|
2983
|
-
existVasData.forEach(dt => {
|
|
2984
|
-
assignedQty += dt.qty
|
|
2985
|
-
})
|
|
2986
|
-
|
|
2987
|
-
packQty -= assignedQty
|
|
2988
|
-
}
|
|
2989
|
-
}
|
|
2990
|
-
|
|
2991
|
-
delete record.__dirty__
|
|
2992
|
-
delete record.__dirtyfields__
|
|
2993
|
-
return {
|
|
2994
|
-
...record,
|
|
2995
|
-
packQty,
|
|
2996
|
-
unitUomValue,
|
|
2997
|
-
totalUomValue: record.releaseUomValue * packQty
|
|
2998
|
-
}
|
|
2999
|
-
})
|
|
3000
|
-
.filter(record => record.packQty > 0)}"
|
|
3199
|
+
.targetList="${targetList}"
|
|
3001
3200
|
.vasList="${this.vasData.records}"
|
|
3002
3201
|
.record="${record}"
|
|
3003
3202
|
@selected="${e => {
|
|
@@ -3030,7 +3229,9 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
3030
3229
|
records: this.vasData.records.map(record => {
|
|
3031
3230
|
return {
|
|
3032
3231
|
...record,
|
|
3033
|
-
vasGristId: record.vasGristId
|
|
3232
|
+
vasGristId: record.vasGristId
|
|
3233
|
+
? record.vasGristId
|
|
3234
|
+
: `${record.batchId} (${record.sku})- ${new Date().toISOString()}`
|
|
3034
3235
|
}
|
|
3035
3236
|
})
|
|
3036
3237
|
}
|
|
@@ -3063,28 +3264,53 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
3063
3264
|
for (let i = 0; i < e.detail.length; i++) {
|
|
3064
3265
|
newRecords.push({ ...record, vas: e.detail[i] })
|
|
3065
3266
|
}
|
|
3066
|
-
if (
|
|
3067
|
-
//
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3267
|
+
if (!record.vas) {
|
|
3268
|
+
// if no VAS data, it will update the vas and add new rows
|
|
3269
|
+
if (newRecords.length == 1) {
|
|
3270
|
+
// update existing inventory data records
|
|
3271
|
+
this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
|
|
3272
|
+
...this.vasGrist.dirtyData.records[rowIndex],
|
|
3273
|
+
...newRecords[0]
|
|
3274
|
+
})
|
|
3275
|
+
this.vasData = {
|
|
3276
|
+
...this.vasData,
|
|
3277
|
+
records: [...this.vasGrist.dirtyData.records]
|
|
3278
|
+
}
|
|
3279
|
+
} else {
|
|
3280
|
+
// update existing inventory data records
|
|
3281
|
+
this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
|
|
3282
|
+
...this.vasGrist.dirtyData.records[rowIndex],
|
|
3283
|
+
...newRecords[0]
|
|
3284
|
+
})
|
|
3285
|
+
this.vasData = {
|
|
3286
|
+
...this.vasData,
|
|
3287
|
+
records: [...this.vasGrist.dirtyData.records]
|
|
3288
|
+
}
|
|
3289
|
+
// add new data
|
|
3290
|
+
newRecords = newRecords.slice(1).map(nrecord => {
|
|
3291
|
+
return {
|
|
3292
|
+
vasGristId: record.vasGristId,
|
|
3293
|
+
vasQty: nrecord.vasQty,
|
|
3294
|
+
vas: nrecord.vas
|
|
3295
|
+
}
|
|
3296
|
+
})
|
|
3297
|
+
this.vasData = {
|
|
3298
|
+
...this.vasData,
|
|
3299
|
+
records: [...this.vasGrist.dirtyData.records, ...newRecords]
|
|
3300
|
+
}
|
|
3075
3301
|
}
|
|
3076
3302
|
} else {
|
|
3077
|
-
//
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3303
|
+
// if vas column is already there add new data ONLY
|
|
3304
|
+
newRecords = newRecords.map(nrecord => {
|
|
3305
|
+
if (
|
|
3306
|
+
this.vasData.records.find(v => v.vasGristId === nrecord.vasGristId && v.vas.id === nrecord.vas.id)
|
|
3307
|
+
) {
|
|
3308
|
+
throw new Error(
|
|
3309
|
+
this._showToast({
|
|
3310
|
+
message: i18next.t('text.duplicated_value_field', { field: i18next.t('field.vas') })
|
|
3311
|
+
})
|
|
3312
|
+
)
|
|
3313
|
+
}
|
|
3088
3314
|
return {
|
|
3089
3315
|
vasGristId: record.vasGristId,
|
|
3090
3316
|
vasQty: nrecord.vasQty,
|
|
@@ -3689,13 +3915,72 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
|
|
|
3689
3915
|
return items
|
|
3690
3916
|
}
|
|
3691
3917
|
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3918
|
+
formatVasTargetproductData() {
|
|
3919
|
+
let data = []
|
|
3920
|
+
data = this.inventoryGrist.dirtyData.records
|
|
3921
|
+
.map(record => {
|
|
3922
|
+
const unitUomValue = record.releaseUomValue / record.releaseQty
|
|
3923
|
+
let packQty = record.releaseQty
|
|
3924
|
+
|
|
3925
|
+
if (this.vasData.records?.length) {
|
|
3926
|
+
const existVasData = this.vasData.records.filter(vasRecord => {
|
|
3927
|
+
const isSamePackingType = !!(record.packingType === vasRecord.packingType)
|
|
3928
|
+
switch (vasRecord.targetType) {
|
|
3929
|
+
case VAS_BATCH_AND_PRODUCT_TYPE:
|
|
3930
|
+
return (
|
|
3931
|
+
record.batchId === vasRecord.target.batchId &&
|
|
3932
|
+
record.product.id === vasRecord.target.productId &&
|
|
3933
|
+
isSamePackingType
|
|
3934
|
+
)
|
|
3935
|
+
case VAS_BATCH_NO_TYPE:
|
|
3936
|
+
return record.batchId === vasRecord.target && isSamePackingType
|
|
3937
|
+
case VAS_PRODUCT_TYPE:
|
|
3938
|
+
return record.product.id === vasRecord.target && isSamePackingType
|
|
3939
|
+
}
|
|
3940
|
+
})
|
|
3941
|
+
|
|
3942
|
+
if (existVasData?.length) {
|
|
3943
|
+
let assignedQty = 0
|
|
3944
|
+
|
|
3945
|
+
existVasData.forEach(dt => {
|
|
3946
|
+
assignedQty += dt.qty
|
|
3947
|
+
})
|
|
3948
|
+
|
|
3949
|
+
packQty -= assignedQty
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
|
|
3953
|
+
delete record.__dirty__
|
|
3954
|
+
delete record.__dirtyfields__
|
|
3955
|
+
return {
|
|
3956
|
+
...record,
|
|
3957
|
+
packQty,
|
|
3958
|
+
unitUomValue,
|
|
3959
|
+
totalUomValue: record.releaseUomValue * packQty
|
|
3960
|
+
}
|
|
3697
3961
|
})
|
|
3698
|
-
|
|
3962
|
+
.filter(record => record.packQty > 0)
|
|
3963
|
+
|
|
3964
|
+
if (this._selectBy === 'product') {
|
|
3965
|
+
this.vasFormattedData = data
|
|
3966
|
+
} else if ((this._selectBy = 'pallet')) {
|
|
3967
|
+
// this is a function to group by product Id, productDetail Id and batchId and sum up qty and total uomvalue
|
|
3968
|
+
const groupBy = data =>
|
|
3969
|
+
Object.values(
|
|
3970
|
+
data.reduce((d, e) => {
|
|
3971
|
+
const key = e.productId + e.productDetailId + e.batchId
|
|
3972
|
+
d[key] = d[key] ? d[key] : { ...e, releaseQty: 0, releaseUomValue: 0 }
|
|
3973
|
+
d[key].releaseQty = d[key] ? d[key].releaseQty + e.releaseQty : e.releaseQty
|
|
3974
|
+
d[key].releaseUomValue = d[key].releaseUomValue
|
|
3975
|
+
? d[key].releaseUomValue + e.releaseUomValue
|
|
3976
|
+
: e.releaseUomValue
|
|
3977
|
+
return d
|
|
3978
|
+
}, {})
|
|
3979
|
+
)
|
|
3980
|
+
|
|
3981
|
+
this.vasFormattedData = groupBy(data)
|
|
3982
|
+
}
|
|
3983
|
+
return this.vasFormattedData
|
|
3699
3984
|
}
|
|
3700
3985
|
|
|
3701
3986
|
_showToast({ type, message }) {
|