@things-factory/operato-wms 4.3.289 → 4.3.290

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.
@@ -926,11 +926,13 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
926
926
  ]
927
927
 
928
928
  if (cancelOrderStatus.indexOf(this._status) >= 0) {
929
- actions.push({
930
- title: i18next.t('button.cancel_order'),
931
- action: this._submitCancellationReleaseOrder.bind(this),
932
- ...CommonButtonStyles.cancel
933
- })
929
+ if (this.vasData?.records?.length > 0 && this._status !== 'LOADING') {
930
+ actions.push({
931
+ title: i18next.t('button.cancel_order'),
932
+ action: this._submitCancellationReleaseOrder.bind(this),
933
+ ...CommonButtonStyles.cancel
934
+ })
935
+ }
934
936
  }
935
937
 
936
938
  return {
@@ -1168,15 +1170,22 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1168
1170
  this._selectedVasRecordIdx = rowIndex
1169
1171
  if (this._editVasStatus.indexOf(this._status) >= 0) {
1170
1172
  if (column.name === 'productSKU') {
1171
- this._openTargetProductVasPopup(record)
1173
+ if (record.__dirty__ === '+' || record.product || record.productDetail) {
1174
+ this._openTargetProductVasPopup(record)
1175
+ }
1172
1176
  }
1173
1177
  if (column.name === 'newSku') {
1174
- this._openBulkProductSelectionForVas(this._selectBy, rowIndex, record)
1178
+ if (record.vas || record.product || record.productDetail) {
1179
+ this._openBulkProductSelectionForVas(this._selectBy, rowIndex, record)
1180
+ }
1175
1181
  }
1176
1182
  if (column.name === 'vas') {
1177
1183
  try {
1178
- if (!record.qty) {
1184
+ if (!record.qty && record.product) {
1179
1185
  throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.qty') }))
1186
+ }
1187
+ if (record.group === undefined) {
1188
+ throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.sku') }))
1180
1189
  } else {
1181
1190
  this._openSelectVasPopup(record, rowIndex)
1182
1191
  }
@@ -1459,6 +1468,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1459
1468
  id
1460
1469
  name
1461
1470
  description
1471
+ type
1462
1472
  }
1463
1473
  vasQty
1464
1474
  }
@@ -1491,7 +1501,11 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1491
1501
  outputQty
1492
1502
  packingType
1493
1503
  qty
1504
+ uom
1494
1505
  uomValue
1506
+ newPackingType
1507
+ newUom
1508
+ newUomValue
1495
1509
  description
1496
1510
  remark
1497
1511
  status
@@ -1640,9 +1654,9 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1640
1654
  productSKU: orderVas.product?.sku,
1641
1655
  uom: orderVas.productDetail?.uom,
1642
1656
  newSku: orderVas.newProduct?.sku,
1643
- newPackingType: orderVas.newProductDetail?.packingType,
1644
- newUomValue: orderVas.newProductDetail?.uomValue,
1645
- newUom: orderVas.newProductDetail?.uom,
1657
+ newPackingType: orderVas?.newPackingType,
1658
+ newUomValue: orderVas?.newUomValue,
1659
+ newUom: orderVas?.newUom,
1646
1660
  releaseQty: releaseQty
1647
1661
  })
1648
1662
 
@@ -1652,14 +1666,26 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1652
1666
  ...acc[acc.length - 1],
1653
1667
  orderVasItemId: itm.id,
1654
1668
  group: groupIdx,
1655
- vas: { id: itm.vas.id, name: `${itm.vas.name}(${itm.vas.description})` },
1669
+ vas: {
1670
+ id: itm.vas.id,
1671
+ name: itm.vas.name,
1672
+ description: itm.vas.description,
1673
+ vasName: itm.vas.name,
1674
+ type: itm.vas.type
1675
+ },
1656
1676
  vasQty: itm.vasQty
1657
1677
  }
1658
1678
  } else {
1659
1679
  acc.push({
1660
1680
  orderVasItemId: itm.id,
1661
1681
  group: groupIdx,
1662
- vas: { id: itm.vas.id, name: `${itm.vas.name}(${itm.vas.description})` },
1682
+ vas: {
1683
+ id: itm.vas.id,
1684
+ name: itm.vas.name,
1685
+ description: itm.vas.description,
1686
+ vasName: itm.vas.name,
1687
+ type: itm.vas.type
1688
+ },
1663
1689
  vasQty: itm.vasQty
1664
1690
  })
1665
1691
  }
@@ -2100,6 +2126,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2100
2126
  .targetList="${targetList}"
2101
2127
  .vasList="${this.vasData.records}"
2102
2128
  .record="${record}"
2129
+ .productSKU= "${record.productSKU}"
2103
2130
  @selected="${selected => {
2104
2131
  let group = this.vasGrist.data.records[this.vasGrist.data.records.length - 1]?.group
2105
2132
  ? this.vasGrist.data.records[this.vasGrist.data.records.length - 1]?.group
@@ -2108,6 +2135,7 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2108
2135
  const newRecords = selected.detail.map(d => {
2109
2136
  return {
2110
2137
  ...record,
2138
+ qty: undefined,
2111
2139
  batchId: d.batchId,
2112
2140
  id: record.id,
2113
2141
  sku: d.productSKU,
@@ -2189,8 +2217,8 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2189
2217
  cuFlag: 'M',
2190
2218
  __dirty__: 'M',
2191
2219
  __dirtyfields__:
2192
- record.__dirtyfields__ === {}
2193
- ? { ...record.__dirtyfields_, newSku: { before: record.newSku, after: e.detail.product.sku } }
2220
+ record.__dirtyfields__ !== {}
2221
+ ? { ...record.__dirtyfields__, newSku: { before: record.newSku, after: e.detail.product.sku } }
2194
2222
  : { newSku: { before: record.newSku, after: e.detail.product.sku } }
2195
2223
  }
2196
2224
  // for (let i = 0; i < e.detail.multipleProducts.length; i++) {
@@ -2236,73 +2264,106 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2236
2264
  openPopup(
2237
2265
  html`
2238
2266
  <select-vas-popup
2267
+ .bizplace="${this.partnerBizplaceId}"
2268
+ .currentSku="${this.vasGrist.dirtyData.records.find(
2269
+ data => data.group === record.group && data.product?.id && data.productDetail?.id
2270
+ )}"
2271
+ .currentSelectedVas="${this.vasGrist.dirtyData.records.reduce((acc, cur) => {
2272
+ if (cur.group === record.group && cur.vas) {
2273
+ return [
2274
+ ...acc,
2275
+ { id: cur.vas?.id, name: cur.vas?.vasName, description: cur.vas?.description, type: cur.vas?.type }
2276
+ ]
2277
+ } else {
2278
+ return acc
2279
+ }
2280
+ }, [])}"
2239
2281
  @selected="${e => {
2240
2282
  let newRecords = []
2283
+ let firstIndex = this.vasGrist.dirtyData.records.findIndex(oldData => oldData.group == record.group)
2284
+ let lastIndex = this.vasGrist.dirtyData.records.findLastIndex(oldData => oldData.group == record.group)
2285
+
2241
2286
  for (let i = 0; i < e.detail.length; i++) {
2242
- newRecords.push({ ...record, vas: e.detail[i] })
2243
- }
2244
- if (!record.vas) {
2245
- // if no VAS data, it will update the vas and add new rows
2246
- if (newRecords.length == 1) {
2247
- // update existing inventory data records
2248
- this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
2249
- ...this.vasGrist.dirtyData.records[rowIndex],
2250
- ...newRecords[0]
2287
+ if (i == 0) {
2288
+ newRecords.push({
2289
+ ...this.vasGrist.dirtyData.records[firstIndex],
2290
+ id: undefined,
2291
+ vas: {
2292
+ ...e.detail[i],
2293
+ name: e.detail[i].name,
2294
+ vasName: e.detail[i].name
2295
+ },
2296
+ vasQty: this.vasGrist.dirtyData.records[firstIndex].qty,
2297
+ cuFlag: '+',
2298
+ __dirty__: '+',
2299
+ __dirtyfields__:
2300
+ this.vasGrist.dirtyData.records[firstIndex].__dirtyfields__ === {}
2301
+ ? {
2302
+ ...this.vasGrist.dirtyData.records[firstIndex].__dirtyfields_,
2303
+ productSKU: {
2304
+ before: this.vasGrist.dirtyData.records[firstIndex].productSKU,
2305
+ after: e.detail[i].productSKU
2306
+ },
2307
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2308
+ vasQty: {
2309
+ before: 0,
2310
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2311
+ }
2312
+ }
2313
+ : {
2314
+ productSKU: {
2315
+ before: this.vasGrist.dirtyData.records[firstIndex].productSKU,
2316
+ after: e.detail[i].productSKU
2317
+ },
2318
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2319
+ vasQty: {
2320
+ before: 0,
2321
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2322
+ }
2323
+ }
2251
2324
  })
2252
- this.vasData = {
2253
- ...this.vasData,
2254
- records: [...this.vasGrist.dirtyData.records]
2255
- }
2256
2325
  } else {
2257
- // update existing inventory data records
2258
- this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
2259
- ...this.vasGrist.dirtyData.records[rowIndex],
2260
- ...newRecords[0]
2261
- })
2262
- this.vasData = {
2263
- ...this.vasData,
2264
- records: [...this.vasGrist.dirtyData.records]
2265
- }
2266
- // add new data
2267
- newRecords = newRecords.slice(1).map(nrecord => {
2268
- return {
2269
- group: record.group,
2270
- vasQty: nrecord.vasQty,
2271
- vas: nrecord.vas
2272
- }
2273
- })
2274
- this.vasData = {
2275
- ...this.vasData,
2276
- records: [...this.vasGrist.dirtyData.records, ...newRecords]
2277
- }
2278
- }
2279
- } else {
2280
- // if vas column is already there add new data ONLY
2281
- newRecords = newRecords.map(nrecord => {
2282
- if (this.vasData.records.find(v => v.group === nrecord.group && v.vas.id === nrecord.vas.id)) {
2283
- throw new Error(
2284
- this._showToast({
2285
- message: i18next.t('text.duplicated_value_field', { field: i18next.t('field.vas') })
2286
- })
2287
- )
2288
- }
2289
- return {
2290
- group: record.group,
2291
- vasQty: nrecord.vasQty,
2292
- vas: nrecord.vas,
2326
+ newRecords.push({
2327
+ group: this.vasGrist.dirtyData.records[firstIndex].group,
2328
+ vasQty: this.vasGrist.dirtyData.records[firstIndex].qty,
2329
+ vas: {
2330
+ ...e.detail[i],
2331
+ name: e.detail[i].name,
2332
+ vasName: e.detail[i].name
2333
+ },
2293
2334
  cuFlag: '+',
2294
2335
  __dirty__: '+',
2295
2336
  __dirtyfields__:
2296
- record.__dirtyfields__ === {}
2297
- ? { ...record.__dirtyfields_, vas: { before: record.vas, after: nrecord.vas } }
2298
- : { vas: { before: record.vas, after: nrecord.vas } }
2299
- }
2300
- })
2301
- this.vasData = {
2302
- ...this.vasData,
2303
- records: [...this.vasGrist.dirtyData.records, ...newRecords]
2337
+ this.vasGrist.dirtyData.records[firstIndex].__dirtyfields__ === {}
2338
+ ? {
2339
+ ...this.vasGrist.dirtyData.records[firstIndex].__dirtyfields_,
2340
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i].vas },
2341
+ vasQty: {
2342
+ before: 0,
2343
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2344
+ }
2345
+ }
2346
+ : {
2347
+ vas: { before: this.vasGrist.dirtyData.records[firstIndex].vas, after: e.detail[i] },
2348
+ vasQty: {
2349
+ before: 0,
2350
+ after: this.vasGrist.dirtyData.records[firstIndex].qty
2351
+ }
2352
+ }
2353
+ })
2304
2354
  }
2305
2355
  }
2356
+
2357
+ for (
2358
+ let i = firstIndex;
2359
+ i < this.vasGrist.dirtyData.records.filter(data => data.group === record.group).length + firstIndex;
2360
+ i++
2361
+ ) {
2362
+ this.deletedVas.push({ ...this.vasGrist.dirtyData.records[i], cuFlag: '-' })
2363
+ }
2364
+ this.vasGrist.dirtyData.records.splice(firstIndex, lastIndex - firstIndex + 1, ...newRecords)
2365
+ this.vasData.records = this.vasGrist.dirtyData.records
2366
+
2306
2367
  this.vasData = {
2307
2368
  ...this.vasData,
2308
2369
  records: this.sortByNameField(this.vasData.records, 'group', 'product')
@@ -2560,38 +2621,45 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2560
2621
  ? initialRecord.outputQty
2561
2622
  : (changeRecord.newUomValue = changeRecord.qty * newUomValue)
2562
2623
  : null
2563
- changeRecord.vasQty = changeRecord.qty
2564
2624
  changeRecord.outputQty = initialRecord.outputQty ? initialRecord.outputQty : null
2565
2625
  //
2566
- } else if (changedColumn === 'outputQty' || changedColumn === 'newUomValue') {
2567
- if (changeRecord.outputQty === undefined) throw new Error(i18next.t('text.there_is_no_selected_items'))
2568
- else if (
2569
- changeRecord.outputQty <= 0 ||
2570
- isNaN(changeRecord.outputQty) ||
2571
- (initialRecord.newProductId && initialRecord.productId && changeRecord.newUomValue <= 0)
2572
- ) {
2626
+ } else if (changedColumn === 'outputQty') {
2627
+ if (changeRecord.outputQty <= 0 || isNaN(changeRecord.outputQty)) {
2628
+ throw new Error(i18next.t('text.invalid_quantity_input'))
2629
+ } else if (initialRecord.outputQty == null) {
2630
+ const totalUomValue = changeRecord.outputQty * (changeRecord.newUomValue / changeRecord.qty)
2631
+ changeRecord.newUomValue = totalUomValue
2632
+ } else {
2633
+ const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / initialRecord.outputQty)
2634
+ changeRecord.newUomValue = totalUomValue
2635
+ }
2636
+ } else if (changedColumn === 'newUomValue') {
2637
+ if (isNaN(changeRecord.newUomValue) || changeRecord.newUomValue <= 0) {
2573
2638
  throw new Error(i18next.t('text.invalid_quantity_input'))
2574
- } else if (changedColumn === 'outputQty' && changeRecord.newProductId && changeRecord.newProductDetailId) {
2575
- if (initialRecord.outputQty == null) {
2576
- const totalUomValue = changeRecord.outputQty * (changeRecord.newUomValue / changeRecord.qty)
2577
- changeRecord.newUomValue = totalUomValue
2578
- } else {
2579
- const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / initialRecord.outputQty)
2580
- changeRecord.newUomValue = totalUomValue
2581
- }
2582
2639
  }
2583
2640
  } else if (changedColumn === 'vasQty') {
2584
2641
  if (changeRecord.vasQty <= 0 || isNaN(changeRecord.vasQty)) {
2585
2642
  throw new Error(i18next.t('text.invalid_quantity_input'))
2643
+ } else {
2644
+ this.vasGrist.dirtyData.records.splice(event.detail.row, 1, {
2645
+ ...this.vasGrist.dirtyData.records[event.detail.row],
2646
+ vasQty: event.detail.after.vasQty,
2647
+ cuFlag: this.vasGrist.dirtyData.records[event.detail.row].cuFlag,
2648
+ __dirty__: this.vasGrist.dirtyData.records[event.detail.row].__dirty__,
2649
+ __dirtyfields__: this.vasGrist.dirtyData.records[event.detail.row].__dirtyfields__
2650
+ ? {
2651
+ ...this.vasGrist.dirtyData.records[event.detail.row].__dirtyfields__,
2652
+ vasQty: { before: initialRecord.vasQty, after: changeRecord.vasQty }
2653
+ }
2654
+ : { vasQty: { before: initialRecord.vasQty, after: changeRecord.vasQty } }
2655
+ })
2656
+ return
2586
2657
  }
2587
2658
  } else if (changedColumn === 'outputQty') {
2588
2659
  if (changeRecord.outputQty <= 0 || isNaN(changeRecord.outputQty)) {
2589
2660
  throw new Error(i18next.t('text.invalid_quantity_input'))
2590
2661
  }
2591
2662
  }
2592
-
2593
- //
2594
- debugger
2595
2663
  } catch (e) {
2596
2664
  const beforeValue = event.detail.before && event.detail.before[event.detail.column.name]
2597
2665
  if (beforeValue) {
@@ -2989,23 +3057,10 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
2989
3057
  let orderVasItemPatch = []
2990
3058
  let vasStatus = this._releaseOrder.status === 'READY_TO_PICK' ? 'READY_TO_PROCESS' : 'PENDING_RECEIVE'
2991
3059
 
2992
- orderVasPatch = this.vasGrist.dirtyRecords.filter(
2993
- p =>
2994
- p.__dirtyfields__.qty ||
2995
- p.__dirtyfields__.outputQty ||
2996
- p.__dirtyfields__.productSKU ||
2997
- p.__dirtyfields__.newSku ||
2998
- p.__dirtyfields__.remark
2999
- )
3000
- orderVasItemPatch = orderVasItemPatch = this.vasGrist.dirtyRecords.filter(
3001
- p =>
3002
- p.__dirtyfields__.vasQty ||
3003
- (p.__dirtyfields__.vas &&
3004
- (!p.__dirtyfields__.qty ||
3005
- !p.__dirtyfields__.outputQty ||
3006
- !p.__dirtyfields__.productSKU ||
3007
- !p.__dirtyfields__.newSku))
3008
- )
3060
+ orderVasPatch = this.vasGrist.dirtyData.records.filter(p => p.product)
3061
+ // orderVasItemPatch = this.vasGrist.dirtyData.records.filter(
3062
+ // p => !orderVasPatch.find(ovp => ovp.group === p.group && ovp.cuFlag !== '+')
3063
+ // )
3009
3064
 
3010
3065
  // deleted Data
3011
3066
  orderVasPatch = orderVasPatch.concat(this.deletedVas.filter(del => del.id))
@@ -3032,18 +3087,23 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3032
3087
  newUom: ov.newUom,
3033
3088
  newUomValue: ov.newUomValue,
3034
3089
  outputQty: ov.outputQty ? ov.outputQty : ov.qty,
3035
- orderVasItemsPatch:
3036
- !ov.id && ov.cuFlag !== '-'
3037
- ? this.vasGrist.dirtyData.records.reduce((acc, cur) => {
3038
- if (cur.group === ov.group) {
3039
- return [...acc, { vas: { id: cur.vas.id, name: cur.vas.name }, vasQty: cur.vasQty, cuFlag: '+' }]
3040
- } else {
3041
- return acc
3042
- }
3043
- }, [])
3044
- : undefined,
3045
3090
  remark: ov.remark,
3046
- cuFlag: !ov.id ? '+' : ov.cuFlag ? ov.cuFlag : ov.__dirty__
3091
+ orderVasItemsPatch: this.vasGrist.dirtyData.records.reduce((acc, cur) => {
3092
+ if (cur.group === ov.group) {
3093
+ return [
3094
+ ...acc,
3095
+ {
3096
+ id: cur.orderVasItemId,
3097
+ vas: { id: cur.vas.id, name: cur.vas.name },
3098
+ vasQty: cur.vasQty,
3099
+ cuFlag: ov.cuFlag ? ov.cuFlag : 'M'
3100
+ }
3101
+ ]
3102
+ } else {
3103
+ return acc
3104
+ }
3105
+ }, []),
3106
+ cuFlag: !ov.id ? '+' : ov.cuFlag ? ov.cuFlag : ov.__dirty__ ? ov.__dirty__ : 'M'
3047
3107
  }
3048
3108
  })
3049
3109
 
@@ -3054,16 +3114,11 @@ class ReleaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
3054
3114
  vas: { id: ovi.vas.id, name: ovi.vas.name },
3055
3115
  orderVas: { id: this.vasData.records.find(vasData => ovi.group === vasData.group && vasData.id)?.id },
3056
3116
  vasQty: ovi.vasQty,
3057
- cuFlag: !ovi.orderVasItemId ? '+' : ovi.cuFlag ? ovi.cuFlag : ovi.__dirty__
3117
+ cuFlag: !ovi.orderVasItemId ? '+' : ovi.cuFlag ? ovi.cuFlag : ovi.__dirty__ ? ovi.__dirty__ : 'M'
3058
3118
  }
3059
3119
  })
3060
3120
  .filter(ovi => ovi.orderVas.id)
3061
3121
 
3062
- // delete ovi ; if ov ? (1)delete ovi based on ov , (2) delete wd based on ov and then (3) delete ov
3063
- // delete worksheet if no data anymore
3064
- // if (this.vasGrist.dirtyData.records.length) {
3065
- // debugger
3066
- // }
3067
3122
  const result = await CustomAlert({
3068
3123
  title: i18next.t('title.are_you_sure'),
3069
3124
  text: i18next.t('text.edit_vas'),