@things-factory/operato-wms 4.3.513 → 4.3.515

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/client/pages/constants/order.js +9 -1
  2. package/client/pages/inventory-check/cycle-count-report.js +2 -0
  3. package/client/pages/inventory-check/cycle-count-review.js +9 -1
  4. package/client/pages/inventory-check/inspecting-product.js +11 -13
  5. package/client/pages/order/arrival-notice/duplicate-arrival-notice.js +4 -1
  6. package/client/pages/order/release-order/b2b/b2b-order-list.js +71 -10
  7. package/client/pages/order/release-order/release-order-detail.js +266 -81
  8. package/client/pages/order/vas-order/popup/proceed-edit-vas-popup.js +549 -0
  9. package/client/pages/order/vas-order/popup/select-vas-popup.js +5 -1
  10. package/client/pages/order/vas-order/popup/vas-changes-popup.js +370 -0
  11. package/client/pages/report/order-vas-report.js +28 -5
  12. package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js +1 -1
  13. package/dist-server/graphql/resolvers/reports/non-loaded-inventory-report.js +4 -2
  14. package/dist-server/graphql/resolvers/reports/non-loaded-inventory-report.js.map +1 -1
  15. package/dist-server/graphql/resolvers/reports/vas-report.js +40 -20
  16. package/dist-server/graphql/resolvers/reports/vas-report.js.map +1 -1
  17. package/dist-server/graphql/types/reports/vas-report.js +1 -0
  18. package/dist-server/graphql/types/reports/vas-report.js.map +1 -1
  19. package/helps/release-note.md +4 -4
  20. package/package.json +5 -5
  21. package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +1 -1
  22. package/server/graphql/resolvers/reports/non-loaded-inventory-report.ts +5 -5
  23. package/server/graphql/resolvers/reports/vas-report.ts +44 -21
  24. package/server/graphql/types/reports/vas-report.ts +1 -0
  25. package/translations/en.json +25 -0
  26. package/translations/ko.json +25 -0
  27. package/translations/ms.json +25 -0
  28. package/translations/zh.json +25 -0
@@ -10,6 +10,8 @@ import '@things-factory/import-ui'
10
10
  import '../../components/select-product-popup'
11
11
  import '../../order/vas-order/popup/vas-target-product-popup'
12
12
  import '../../order/vas-order/popup/select-vas-popup'
13
+ import '../../order/vas-order/popup/proceed-edit-vas-popup'
14
+ import '../../order/vas-order/popup/vas-changes-popup'
13
15
 
14
16
  import gql from 'graphql-tag'
15
17
  import { css, html } from 'lit-element'
@@ -26,6 +28,7 @@ import { isMobileDevice } from '@things-factory/utils'
26
28
  import { fetchSettingRule } from '../../../fetch-setting-value'
27
29
  import {
28
30
  ORDER_STATUS,
31
+ ORDER_VAS_STATUS,
29
32
  PICKING_STANDARD,
30
33
  VAS_BATCH_AND_PRODUCT_TYPE,
31
34
  VAS_BATCH_NO_TYPE,
@@ -916,14 +919,28 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
916
919
  ...CommonButtonStyles.edit
917
920
  })
918
921
  }
919
- }
920
922
 
921
- if (this.isUserBelongsDomain && this._editVasStatus.indexOf(this._status) >= 0) {
922
- actions.push({
923
- title: i18next.t('button.edit_vas'),
924
- action: this.editVas.bind(this),
925
- ...CommonButtonStyles.edit
926
- })
923
+ if (this.vasData.records.some( vas => vas.status === ORDER_VAS_STATUS.PENDING_APPROVE.value )) {
924
+ actions.push({
925
+ title: i18next.t('button.vas_changes'),
926
+ action: this._openVasChangesPopup.bind(this),
927
+ ...CommonButtonStyles.inspect
928
+ })
929
+ } else if (this._editVasStatus.indexOf(this._status) >= 0) {
930
+ actions.push({
931
+ title: i18next.t('button.edit_vas'),
932
+ action: this.editVas.bind(this),
933
+ ...CommonButtonStyles.edit
934
+ })
935
+ }
936
+ } else {
937
+ if (this.vasData.records.some( vas => vas.status === ORDER_VAS_STATUS.PENDING_APPROVE.value )) {
938
+ actions.push({
939
+ title: i18next.t('button.inspect_changes'),
940
+ action: this._openApproveVasChangesPopup.bind(this),
941
+ ...CommonButtonStyles.inspect
942
+ })
943
+ }
927
944
  }
928
945
 
929
946
  if (this._status === ORDER_STATUS.PENDING.value) {
@@ -1223,7 +1240,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1223
1240
  }
1224
1241
  if (column.name === 'newBatchId') {
1225
1242
  try {
1226
- if (!record.newProductId) {
1243
+ if (!record.newProduct?.id && !record.newProductId) {
1227
1244
  column.record.editable = false
1228
1245
  throw new Error(i18next.t('text.new_sku_empty'))
1229
1246
  } else {
@@ -1246,14 +1263,25 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1246
1263
  handlers: {
1247
1264
  click: (columns, data, column, record, rowIndex) => {
1248
1265
  if (this._editVasStatus.indexOf(this._status) >= 0) {
1249
- this.deletedVas.push({ ...record, cuFlag: '-' })
1266
+ if (record.id) {
1267
+ this.deletedVas.push({
1268
+ ...record,
1269
+ editType: ORDER_VAS_STATUS.REMOVED.value,
1270
+ cuFlag: 'M'
1271
+ })
1272
+ } else {
1273
+ this.deletedVas.push({
1274
+ ...record,
1275
+ itemEditType: ORDER_VAS_STATUS.REMOVED.value,
1276
+ cuFlag: 'M'
1277
+ })
1278
+ }
1250
1279
  this.vasData = {
1251
1280
  ...this.vasData,
1252
1281
  records: data.records.filter((rec, idx) =>
1253
1282
  record.productSKU ? rec.group !== record.group : idx !== rowIndex
1254
1283
  )
1255
1284
  }
1256
- const test = this.vasData
1257
1285
  }
1258
1286
  }
1259
1287
  }
@@ -1322,7 +1350,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1322
1350
  {
1323
1351
  type: 'string',
1324
1352
  name: 'newBatchId',
1325
- header: i18next.t('field.batch_no_(new_sku)'),
1353
+ header: i18next.t('field.batch_no_sku', { sku: 'New SKU' }),
1326
1354
  record: { editable: true },
1327
1355
  width: 150
1328
1356
  },
@@ -1335,7 +1363,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1335
1363
  {
1336
1364
  type: 'code',
1337
1365
  name: 'newPackingType',
1338
- header: i18next.t('field.packing_type_sku', { sku: 'N.SKU' }),
1366
+ header: i18next.t('field.packing_type_sku', { sku: 'New SKU' }),
1339
1367
  record: {
1340
1368
  editable: true,
1341
1369
  codeName: 'PACKING_TYPES'
@@ -1345,21 +1373,21 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1345
1373
  {
1346
1374
  type: 'code',
1347
1375
  name: 'newUom',
1348
- header: i18next.t('field.uom_sku', { sku: 'N.SKU' }),
1376
+ header: i18next.t('field.uom_sku', { sku: 'New SKU' }),
1349
1377
  record: { editable: true, codeName: 'UOM' },
1350
1378
  width: 80
1351
1379
  },
1352
1380
  {
1353
1381
  type: 'float',
1354
1382
  name: 'newUnitUomValue',
1355
- header: i18next.t('field.uom_value_sku', { sku: 'NEW SKU' }),
1383
+ header: i18next.t('field.uom_value_sku', { sku: 'New SKU' }),
1356
1384
  record: { editable: !this._strictProductSelection },
1357
1385
  width: 150
1358
1386
  },
1359
1387
  {
1360
1388
  type: 'float',
1361
1389
  name: 'newUomValue',
1362
- header: i18next.t('field.total_uom_value_sku', { sku: 'N.SKU' }),
1390
+ header: i18next.t('field.total_uom_value_sku', { sku: 'New SKU' }),
1363
1391
  record: { editable: !this._strictProductSelection, options: { min: 0 } },
1364
1392
  width: 150
1365
1393
  },
@@ -1524,8 +1552,10 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1524
1552
  id
1525
1553
  name
1526
1554
  createdAt
1555
+ editType
1527
1556
  orderVasItems {
1528
1557
  id
1558
+ itemEditType
1529
1559
  vas {
1530
1560
  id
1531
1561
  name
@@ -1534,25 +1564,45 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1534
1564
  }
1535
1565
  vasQty
1536
1566
  vasRemark
1567
+ adjustedVasQty
1568
+ adjustedVasRemark
1537
1569
  }
1538
1570
  batchId
1571
+ adjustedBatchId
1539
1572
  product {
1540
1573
  id
1541
1574
  name
1542
1575
  description
1543
1576
  sku
1544
1577
  }
1578
+ adjustedProduct {
1579
+ id
1580
+ name
1581
+ description
1582
+ sku
1583
+ }
1545
1584
  productDetail {
1546
1585
  id
1547
1586
  name
1548
1587
  uom
1549
1588
  }
1589
+ adjustedProductDetail {
1590
+ id
1591
+ name
1592
+ uom
1593
+ }
1550
1594
  newProduct {
1551
1595
  id
1552
1596
  name
1553
1597
  description
1554
1598
  sku
1555
1599
  }
1600
+ adjustedNewProduct {
1601
+ id
1602
+ name
1603
+ description
1604
+ sku
1605
+ }
1556
1606
  newProductDetail {
1557
1607
  id
1558
1608
  name
@@ -1560,16 +1610,32 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1560
1610
  uomValue
1561
1611
  uom
1562
1612
  }
1613
+ adjustedNewProductDetail {
1614
+ id
1615
+ name
1616
+ packingType
1617
+ uomValue
1618
+ uom
1619
+ }
1563
1620
  productName
1564
1621
  outputQty
1622
+ adjustedOutputQty
1565
1623
  packingType
1624
+ adjustedPackingType
1566
1625
  qty
1626
+ adjustedQty
1567
1627
  uom
1628
+ adjustedUom
1568
1629
  uomValue
1630
+ adjustedUomValue
1569
1631
  newBatchId
1632
+ adjustedNewBatchId
1570
1633
  newPackingType
1634
+ adjustedNewPackingType
1571
1635
  newUom
1636
+ adjustedNewUom
1572
1637
  newUomValue
1638
+ adjustedNewUomValue
1573
1639
  description
1574
1640
  remark
1575
1641
  status
@@ -1733,12 +1799,19 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1733
1799
  acc.push({
1734
1800
  ...orderVas,
1735
1801
  productSKU: orderVas.product?.sku,
1802
+ adjustedSku: orderVas.adjustedProduct?.sku,
1736
1803
  uom: orderVas.productDetail?.uom,
1804
+ adjustedUom: orderVas.adjustedProductDetail?.uom,
1737
1805
  newSku: orderVas.newProduct?.sku,
1806
+ adjustedNewSku: orderVas.adjustedNewProduct?.sku,
1738
1807
  newPackingType: orderVas?.newPackingType,
1808
+ adjustedNewPackingType: orderVas?.adjustedNewPackingType,
1739
1809
  newUnitUomValue: calUnitUomValue(orderVas?.newUomValue, orderVas?.outputQty).toFixed(2),
1810
+ adjustedNewUnitUomValue: calUnitUomValue(orderVas?.adjustedNewUomValue, orderVas?.adjustedOutputQty).toFixed(2),
1740
1811
  newUomValue: orderVas?.newUomValue,
1812
+ adjustedNewUomValue: orderVas?.adjustedNewUomValue,
1741
1813
  newUom: orderVas?.newUom,
1814
+ adjustedNewUom: orderVas?.adjustedNewUom,
1742
1815
  releaseQty: releaseQty
1743
1816
  })
1744
1817
 
@@ -1755,8 +1828,11 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1755
1828
  vasName: itm.vas.name,
1756
1829
  type: itm.vas.type
1757
1830
  },
1831
+ itemEditType: itm.itemEditType ? itm.itemEditType : orderVas.editType,
1758
1832
  vasQty: itm.vasQty,
1759
- vasRemark: itm.vasRemark
1833
+ vasRemark: itm.vasRemark,
1834
+ adjustedVasQty: itm.adjustedVasQty,
1835
+ adjustedVasRemark: itm.adjustedVasRemark
1760
1836
  }
1761
1837
  } else {
1762
1838
  acc.push({
@@ -1769,8 +1845,11 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1769
1845
  vasName: itm.vas.name,
1770
1846
  type: itm.vas.type
1771
1847
  },
1848
+ itemEditType: itm.itemEditType,
1772
1849
  vasQty: itm.vasQty,
1773
- vasRemark: itm.vasRemark
1850
+ vasRemark: itm.vasRemark,
1851
+ adjustedVasQty: itm.adjustedVasQty,
1852
+ adjustedVasRemark: itm.adjustedVasRemark
1774
1853
  })
1775
1854
  }
1776
1855
  })
@@ -2226,7 +2305,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2226
2305
  sku: d.productSKU,
2227
2306
  maxQty: d.releaseQty,
2228
2307
  uomValue: d.releaseUomValue / d.releaseQty,
2229
- group: record.group ? record.group : ++group,
2308
+ group: record.id ? record.group : ++group,
2230
2309
  unitUomValue: d.unitUomValue,
2231
2310
  packingSize: d.packingSize,
2232
2311
  packingType: d.packingType,
@@ -2235,12 +2314,18 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2235
2314
  productSKU: d.productSKU,
2236
2315
  uom: d.uom,
2237
2316
  status: record.status,
2238
- cuFlag: 'M',
2239
- __dirty__: 'M',
2240
- __dirtyfields__: {
2241
- productSKU: { before: record.productSKU, after: d.productSKU }
2242
- // qty: { before: record.qty, after: d.qty }
2243
- }
2317
+ editType: record.id ? ORDER_VAS_STATUS.CHANGES.value : ORDER_VAS_STATUS.NEW.value,
2318
+ cuFlag: record.id ? 'M' : '+',
2319
+ __dirty__: record.id ? 'M' : '+',
2320
+ __dirtyfields__: record.__dirtyfields__
2321
+ ? {
2322
+ ...record.__dirtyfields__,
2323
+ productSKU: { before: record.productSKU, after: d.productSKU }
2324
+ }
2325
+ : {
2326
+ productSKU: { before: record.productSKU, after: d.productSKU }
2327
+ // qty: { before: record.qty, after: d.qty }
2328
+ }
2244
2329
 
2245
2330
  // group: ++group
2246
2331
  }
@@ -2297,9 +2382,15 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2297
2382
  newUomValue: e.detail.uomValue,
2298
2383
  newUnitUomValue: e.detail.uomValue,
2299
2384
  newProductDetailId: e.detail.productDetailId,
2385
+ editType: ORDER_VAS_STATUS.CHANGES.value,
2300
2386
  cuFlag: 'M',
2301
2387
  __dirty__: 'M',
2302
- __dirtyfields__: { newSku: { before: record.newSku, after: e.detail.product.sku } }
2388
+ __dirtyfields__: record.__dirtyfields__
2389
+ ? {
2390
+ ...record.__dirtyfields__,
2391
+ newSku: { before: record.newSku, after: e.detail.product.sku }
2392
+ }
2393
+ : { newSku: { before: record.newSku, after: e.detail.product.sku } }
2303
2394
  }
2304
2395
  // for (let i = 0; i < e.detail.multipleProducts.length; i++) {
2305
2396
  // newRecords.push(e.detail.multipleProducts[i])
@@ -2368,68 +2459,85 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2368
2459
  let lastIndex = this.vasGrist.dirtyData.records.findLastIndex(oldData => oldData.group == record.group)
2369
2460
 
2370
2461
  for (let i = 0; i < e.detail.length; i++) {
2371
- let a = oldRecords.find(vb => vb.vas?.id === e.detail[i].id)
2462
+ let a = oldRecords.find(vb => vb.vas?.id === e.detail[i].id && vb.group === this.vasGrist.dirtyData.records[firstIndex].group)
2372
2463
  if (i == 0) {
2373
2464
  newRecords.push({
2374
2465
  ...this.vasGrist.dirtyData.records[firstIndex],
2375
- id: undefined,
2466
+ id: a?.id ? a.id : this.vasGrist.dirtyData.records[firstIndex].id,
2376
2467
  vas: {
2377
2468
  ...e.detail[i],
2378
2469
  name: e.detail[i].name,
2379
2470
  vasName: e.detail[i].name
2380
2471
  },
2381
- vasQty: a?.vasQty ? a.vasQty : this.vasGrist.dirtyData.records[firstIndex].qty,
2472
+ orderVasItemId: a?.orderVasItemId ? a.orderVasItemId : undefined,
2473
+ vasQty: a?.vasQty,
2382
2474
  newBatchId: this.vasGrist.dirtyData.records[firstIndex].newBatchId,
2383
2475
  newProduct: this.vasGrist.dirtyData.records[firstIndex].newProduct,
2384
2476
  newProductDetail: this.vasGrist.dirtyData.records[firstIndex].newProductDetail,
2385
2477
  newSku: this.vasGrist.dirtyData.records[firstIndex].newSku,
2386
2478
  newUom: this.vasGrist.dirtyData.records[firstIndex].newUom,
2387
2479
  newUomValue: this.vasGrist.dirtyData.records[firstIndex].newUomValue,
2388
- vasRemark: a?.vasRemark ? a.vasRemark : '',
2389
- cuFlag: '+',
2390
- __dirty__: '+',
2391
- __dirtyfields__: {
2392
- productSKU: {
2393
- before: this.vasGrist.dirtyData.records[firstIndex].productSKU,
2394
- after: e.detail[i].productSKU
2395
- },
2396
- vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2397
- vasQty: {
2398
- before: 0,
2399
- after: this.vasGrist.dirtyData.records[firstIndex].qty
2480
+ vasRemark: a?.vasRemark,
2481
+ itemEditType: a?.orderVasItemId ? (a.itemEditType || (a.__dirty__ ? ORDER_VAS_STATUS.CHANGES.value : undefined)) : ORDER_VAS_STATUS.NEW.value,
2482
+ __dirty__: a?.orderVasItemId ? a.__dirty__ ? a.__dirty__ : undefined : '+',
2483
+ __dirtyfields__: a?.__dirtyfields__
2484
+ ? {
2485
+ ...a.__dirtyfields__,
2486
+ productSKU: {
2487
+ before: this.vasGrist.dirtyData.records[firstIndex].productSKU,
2488
+ after: e.detail[i].productSKU
2489
+ },
2490
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2491
+ vasQty: {
2492
+ before: 0,
2493
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2494
+ }
2495
+ }
2496
+ : {
2497
+ productSKU: {
2498
+ before: this.vasGrist.dirtyData.records[firstIndex].productSKU,
2499
+ after: e.detail[i].productSKU
2500
+ },
2501
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2502
+ vasQty: {
2503
+ before: 0,
2504
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2505
+ }
2400
2506
  }
2401
- }
2402
2507
  })
2403
2508
  } else {
2404
2509
  newRecords.push({
2405
2510
  group: this.vasGrist.dirtyData.records[firstIndex].group,
2406
- vasQty: this.vasGrist.dirtyData.records[firstIndex].qty,
2511
+ vasQty: a?.vasQty,
2407
2512
  vas: {
2408
2513
  ...e.detail[i],
2409
2514
  name: e.detail[i].name,
2410
2515
  vasName: e.detail[i].name
2411
2516
  },
2412
- vasRemark: a?.vasRemark ? a.vasRemark : '',
2413
- cuFlag: '+',
2414
- __dirty__: '+',
2415
- __dirtyfields__: {
2416
- vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2417
- vasQty: {
2418
- before: 0,
2419
- after: this.vasGrist.dirtyData.records[firstIndex].qty
2517
+ orderVasItemId: a?.orderVasItemId,
2518
+ vasRemark: a?.vasRemark,
2519
+ itemEditType: a?.orderVasItemId ? (a.itemEditType || (a.__dirty__ ? ORDER_VAS_STATUS.CHANGES.value : undefined)) : ORDER_VAS_STATUS.NEW.value,
2520
+ __dirty__: a?.orderVasItemId ? a.__dirty__ ? a.__dirty__ : undefined : '+',
2521
+ __dirtyfields__: a?.__dirtyfields__
2522
+ ? {
2523
+ ...a.__dirtyfields__,
2524
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2525
+ vasQty: {
2526
+ before: 0,
2527
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2528
+ }
2529
+ }
2530
+ : {
2531
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2532
+ vasQty: {
2533
+ before: 0,
2534
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2535
+ }
2420
2536
  }
2421
- }
2422
2537
  })
2423
2538
  }
2424
2539
  }
2425
2540
 
2426
- for (
2427
- let i = firstIndex;
2428
- i < this.vasGrist.dirtyData.records.filter(data => data.group === record.group).length + firstIndex;
2429
- i++
2430
- ) {
2431
- this.deletedVas.push({ ...this.vasGrist.dirtyData.records[i], cuFlag: '-' })
2432
- }
2433
2541
  this.vasGrist.dirtyData.records.splice(firstIndex, lastIndex - firstIndex + 1, ...newRecords)
2434
2542
  this.vasData.records = this.vasGrist.dirtyData.records
2435
2543
 
@@ -2438,6 +2546,22 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2438
2546
  records: this.sortByNameField(this.vasData.records, 'group', 'product')
2439
2547
  }
2440
2548
  }}"
2549
+ @deleted="${e => {
2550
+ let oldRecord = this.vasGrist.dirtyData.records.filter(data => data.group === record.group && data.id === record.id)
2551
+ let oldOvi = oldRecord[0].orderVasItems
2552
+ for (const vas of e.detail) {
2553
+ let ovi = oldOvi?.find(data => data.vas.id === vas.id)
2554
+ if (ovi) {
2555
+ this.deletedVas.push({
2556
+ vas: vas,
2557
+ group: record.group,
2558
+ orderVasItemId: ovi.id,
2559
+ itemEditType: ORDER_VAS_STATUS.REMOVED.value,
2560
+ cuFlag: 'M'
2561
+ })
2562
+ }
2563
+ }
2564
+ }}"
2441
2565
  ></select-vas-popup>
2442
2566
  `,
2443
2567
  {
@@ -2644,8 +2768,8 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2644
2768
  const totalQtyVas = this.vasGrist.dirtyData.records.reduce(
2645
2769
  (total, vas) =>
2646
2770
  vas.qty &&
2647
- vas.productId === changeRecord.productId &&
2648
- vas.productDetailId === changeRecord.productDetailId &&
2771
+ vas.product.id === changeRecord.product?.id &&
2772
+ vas.productDetail.id === changeRecord.productDetail?.id &&
2649
2773
  vas.batchId === changeRecord.batchId
2650
2774
  ? total + vas.qty
2651
2775
  : total,
@@ -2654,8 +2778,8 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2654
2778
  const totalReleaseQty = this.inventoryData.records.reduce(
2655
2779
  (total, inv) =>
2656
2780
  inv.releaseQty &&
2657
- inv.productId === changeRecord.productId &&
2658
- inv.productDetailId === changeRecord.productDetailId &&
2781
+ inv.product.id === changeRecord.product?.id &&
2782
+ inv.productDetail.id === changeRecord.productDetail?.id &&
2659
2783
  inv.batchId === changeRecord.batchId
2660
2784
  ? total + inv.releaseQty
2661
2785
  : total,
@@ -3211,24 +3335,19 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3211
3335
  this._validateVas()
3212
3336
  let orderVasPatch = []
3213
3337
  let orderVasItemPatch = []
3214
- let vasStatus =
3215
- this._releaseOrder.status === 'READY_TO_PICK' || this._releaseOrder.status === 'PICKING'
3216
- ? 'READY_TO_PROCESS'
3217
- : 'PENDING_RECEIVE'
3218
3338
 
3219
3339
  orderVasPatch = this.vasGrist.dirtyData.records.filter(p => p.product)
3220
- // orderVasItemPatch = this.vasGrist.dirtyData.records.filter(
3221
- // p => !orderVasPatch.find(ovp => ovp.group === p.group && ovp.cuFlag !== '+')
3222
- // )
3340
+ orderVasItemPatch = this.vasGrist.dirtyData.records.filter(p => !p.id)
3223
3341
 
3224
3342
  // deleted Data
3225
3343
  orderVasPatch = orderVasPatch.concat(this.deletedVas.filter(del => del.id))
3226
3344
  orderVasItemPatch = orderVasItemPatch.concat(this.deletedVas.filter(del => !del.id && del.orderVasItemId))
3227
3345
 
3228
- orderVasPatch = orderVasPatch.map(ov => {
3346
+ orderVasPatch = orderVasPatch
3347
+ .map(ov => {
3229
3348
  return {
3230
3349
  id: ov?.id,
3231
- bizplace: !ov.id && ov.cuFlag !== '-' ? this._releaseOrder.bizplace : undefined,
3350
+ bizplace: this._releaseOrder.bizplace,
3232
3351
  releaseGood: !ov.id && ov.cuFlag !== '-' ? { id: this._releaseOrderId } : undefined,
3233
3352
  batchId: ov.batchId,
3234
3353
  qty: ov.qty,
@@ -3236,7 +3355,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3236
3355
  name: !ov.name ? `${ov.batchId} (${ov.sku})- ${new Date().toISOString()}` : undefined,
3237
3356
  productName: !ov.productName ? ov.product.name : undefined,
3238
3357
  productDetail: { id: ov.productDetail.id, name: ov.productDetail.name },
3239
- status: !ov.id && ov.cuFlag !== '-' ? vasStatus : undefined,
3358
+ status: ORDER_VAS_STATUS.PENDING_APPROVE.value,
3240
3359
  packingType: ov.packingType,
3241
3360
  uom: ov.uom,
3242
3361
  uomValue: ov.uomValue,
@@ -3252,32 +3371,37 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3252
3371
  return [
3253
3372
  ...acc,
3254
3373
  {
3255
- id: cur?.orderVasItemId,
3374
+ id: cur?.orderVasItemId ? cur.orderVasItemId : undefined,
3256
3375
  vas: { id: cur.vas.id, name: cur.vas.name },
3257
3376
  vasQty: cur.vasQty,
3258
3377
  vasRemark: cur?.vasRemark,
3259
- cuFlag: ov.cuFlag ? ov.cuFlag : 'M'
3378
+ cuFlag: cur.orderVasItemId ? (cur.cuFlag || (cur.__dirty__ ? 'M' : undefined)) : '+',
3379
+ itemEditType: cur?.orderVasItemId ? (cur.itemEditType || (cur.__dirty__ ? ORDER_VAS_STATUS.CHANGES.value : undefined)) : ORDER_VAS_STATUS.NEW.value,
3260
3380
  }
3261
3381
  ]
3262
3382
  } else {
3263
3383
  return acc
3264
3384
  }
3265
3385
  }, []),
3266
- cuFlag: !ov.id ? '+' : ov.cuFlag ? ov.cuFlag : ov.__dirty__ ? ov.__dirty__ : 'M'
3386
+ cuFlag: ov?.cuFlag,
3387
+ editType: ov?.editType
3267
3388
  }
3268
3389
  })
3269
3390
 
3391
+ orderVasPatch = this._determineOvFlags(orderVasPatch)
3392
+
3270
3393
  orderVasItemPatch = orderVasItemPatch
3271
3394
  .map(ovi => {
3272
3395
  return {
3273
- id: ovi.orderVasItemId,
3396
+ id: ovi.orderVasItemId ? ovi.orderVasItemId : undefined,
3274
3397
  vas: { id: ovi.vas.id, name: ovi.vas.name },
3275
- orderVas: { id: this.vasData.records.find(vasData => ovi.group === vasData.group && vasData.id)?.id },
3398
+ orderVas: { id: ovi.orderVas?.id ? ovi.orderVas.id : this.vasData.records.find(vasData => ovi.group === vasData.group && vasData.id)?.id },
3276
3399
  vasQty: ovi.vasQty,
3277
- cuFlag: !ovi.orderVasItemId ? '+' : ovi.cuFlag ? ovi.cuFlag : ovi.__dirty__ ? ovi.__dirty__ : 'M'
3400
+ cuFlag: ovi.orderVasItemId ? (ovi.cuFlag || (ovi.__dirty__ ? 'M' : undefined)) : '+',
3401
+ itemEditType: ovi.orderVasItemId ? (ovi.itemEditType || (ovi.__dirty__ ? ORDER_VAS_STATUS.CHANGES.value : undefined)) : ORDER_VAS_STATUS.NEW.value
3278
3402
  }
3279
3403
  })
3280
- .filter(ovi => ovi.orderVas.id)
3404
+ .filter(ovi => ovi.orderVas.id && !orderVasPatch.some(ovp => ovp.orderVasItemsPatch.some(item => item.id === ovi.id)))
3281
3405
 
3282
3406
  const result = await CustomAlert({
3283
3407
  title: i18next.t('title.are_you_sure'),
@@ -3302,13 +3426,26 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3302
3426
 
3303
3427
  if (!response.errors) {
3304
3428
  this._showToast({ message: i18next.t('text.vas_edited') })
3305
- this._fetchReleaseOrder()
3429
+ await this._fetchReleaseOrder()
3430
+ this.updateContext()
3306
3431
  }
3307
3432
  } catch (e) {
3308
3433
  this._showToast(e)
3309
3434
  }
3310
3435
  }
3311
3436
 
3437
+ _determineOvFlags(orderVas) {
3438
+ return orderVas.map(ov => {
3439
+ const isDirty = ov.__dirty__ || ov.orderVasItemsPatch.some(ovi => ovi.__dirty__)
3440
+ const hasChanges = ov.cuFlag || isDirty || ov.orderVasItemsPatch.some(ovi => ovi.cuFlag)
3441
+ return {
3442
+ ...ov,
3443
+ cuFlag: !ov.id ? '+' : hasChanges ? (ov.cuFlag || 'M') : undefined,
3444
+ editType: !ov.id ? ORDER_VAS_STATUS.NEW.value : hasChanges ? (ov.editType || ORDER_VAS_STATUS.CHANGES.value) : undefined
3445
+ }
3446
+ })
3447
+ }
3448
+
3312
3449
  _validateCountry(e) {
3313
3450
  if (e.target.value != 'MY') {
3314
3451
  this._selectedCountry = e.target.value
@@ -3326,11 +3463,14 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3326
3463
  }
3327
3464
 
3328
3465
  _validateVas() {
3466
+ if (this.deletedVas.length === 0 && !this.vasGrist.dirtyData.records.some( vas => vas.__dirty__ )) {
3467
+ throw new Error(i18next.t('text.no_changes_to_be_submitted'))
3468
+ }
3329
3469
  const roData = this.inventoryData.records
3330
3470
  roData.find(ro => {
3331
3471
  let newSku = []
3332
3472
  this.vasGrist.dirtyData.records.map(vas => {
3333
- if (vas.sku === ro.productSKU && vas.batchId === ro.batchId && vas.newSku) {
3473
+ if (vas.productSKU === ro.productSKU && vas.batchId === ro.batchId && vas.newSku) {
3334
3474
  newSku.push(vas)
3335
3475
  }
3336
3476
  })
@@ -3460,6 +3600,51 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3460
3600
 
3461
3601
  return items
3462
3602
  }
3603
+
3604
+ _openVasChangesPopup() {
3605
+ try {
3606
+ openPopup(
3607
+ html`
3608
+ <vas-changes-popup
3609
+ .releaseGoodNo="${this._releaseOrderNo}"
3610
+ .data="${this.vasData}"
3611
+ ></vas-changes-popup>
3612
+ `,
3613
+ {
3614
+ backdrop: true,
3615
+ size: 'large',
3616
+ title: i18next.t('title.view_vas_changes')
3617
+ }
3618
+ )
3619
+ } catch(e) {
3620
+ this._showToast(e)
3621
+ }
3622
+ }
3623
+
3624
+ _openApproveVasChangesPopup() {
3625
+ try {
3626
+ openPopup(
3627
+ html`
3628
+ <proceed-edit-vas-popup
3629
+ .releaseGoodNo="${this._releaseOrderNo}"
3630
+ .bizplace="${this.partnerBizplaceId}"
3631
+ .data="${this.vasData}"
3632
+ @completed="${e => {
3633
+ this._fetchReleaseOrder(this._releaseOrderNo)
3634
+ this.updateContext()
3635
+ }}"
3636
+ ></proceed-edit-vas-popup>
3637
+ `,
3638
+ {
3639
+ backdrop: true,
3640
+ size: 'large',
3641
+ title: i18next.t('title.proceed_edited_vas')
3642
+ }
3643
+ )
3644
+ } catch(e) {
3645
+ this._showToast(e)
3646
+ }
3647
+ }
3463
3648
  }
3464
3649
 
3465
3650
  window.customElements.define('release-order-detail', ReleaseOrderDetail)