@things-factory/operato-wms 4.3.287 → 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.
@@ -1106,6 +1106,8 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
1106
1106
  try {
1107
1107
  if (!record.qty && record.productId && record.productDetailId) {
1108
1108
  throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.qty') }))
1109
+ } else if (record.vasGristId === undefined) {
1110
+ throw new Error(i18next.t('text.empty_field_field', { field: i18next.t('field.sku') }))
1109
1111
  } else {
1110
1112
  this.openSelectVasPopup(record, rowIndex)
1111
1113
  }
@@ -2032,25 +2034,25 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2032
2034
  ? initialRecord.outputQty
2033
2035
  : (changeRecord.newUomValue = changeRecord.qty * newUomValue)
2034
2036
  : null
2035
- changeRecord.vasQty = changeRecord.qty
2037
+ // changeRecord.vasQty = changeRecord.qty
2036
2038
  changeRecord.outputQty = initialRecord.outputQty ? initialRecord.outputQty : null
2037
2039
  //
2038
- } else if (changedColumn === 'outputQty' || changedColumn === 'newUomValue') {
2039
- if (changeRecord.outputQty === undefined) throw new Error(i18next.t('text.there_is_no_selected_items'))
2040
- else if (
2041
- changeRecord.outputQty <= 0 ||
2042
- isNaN(changeRecord.outputQty) ||
2043
- (initialRecord.newProductId && initialRecord.productId && changeRecord.newUomValue <= 0)
2044
- ) {
2040
+ } else if (changedColumn === 'outputQty') {
2041
+ if (changeRecord.outputQty <= 0 || isNaN(changeRecord.outputQty)) {
2042
+ throw new Error(i18next.t('text.invalid_quantity_input'))
2043
+ } else if (initialRecord.outputQty == null) {
2044
+ const totalUomValue = changeRecord.outputQty * (changeRecord.newUomValue / changeRecord.qty)
2045
+ changeRecord.newUomValue = totalUomValue
2046
+ } else {
2047
+ const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / initialRecord.outputQty)
2048
+ changeRecord.newUomValue = totalUomValue
2049
+ }
2050
+ if (isNaN(changeRecord.newUomValue)) {
2051
+ changeRecord.newUomValue = null
2052
+ }
2053
+ } else if (changedColumn === 'newUomValue') {
2054
+ if (changeRecord.newUomValue <= 0 || isNaN(changeRecord.newUomValue)) {
2045
2055
  throw new Error(i18next.t('text.invalid_quantity_input'))
2046
- } else if (changedColumn === 'outputQty' && changeRecord.newProductId && changeRecord.newProductDetailId) {
2047
- if (initialRecord.outputQty == null) {
2048
- const totalUomValue = changeRecord.outputQty * (changeRecord.newUomValue / changeRecord.qty)
2049
- changeRecord.newUomValue = totalUomValue
2050
- } else {
2051
- const totalUomValue = changeRecord.outputQty * (initialRecord.newUomValue / initialRecord.outputQty)
2052
- changeRecord.newUomValue = totalUomValue
2053
- }
2054
2056
  }
2055
2057
  } else if (changedColumn === 'vasQty') {
2056
2058
  if (changeRecord.vasQty <= 0 || isNaN(changeRecord.vasQty)) {
@@ -2335,7 +2337,8 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2335
2337
  this._recallInput.checked = false
2336
2338
 
2337
2339
  // create order Vas
2338
- const orderVas = await this.createOrderVas(response.data.generateReleaseGood)
2340
+ await this.createVasOrder(response.data.generateReleaseGood)
2341
+ // await this.createOrderVas(response.data.generateReleaseGood)
2339
2342
 
2340
2343
  navigate(`release_order_detail/${response.data.generateReleaseGood.name}`)
2341
2344
  this._showToast({ message: i18next.t('text.release_order_created') })
@@ -2372,78 +2375,57 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
2372
2375
  }
2373
2376
  }
2374
2377
 
2375
- async createOrderVas(releaseGood) {
2376
- let patches = this.vasData.records
2377
- .filter(vas => vas.sku)
2378
- .map(ov => {
2379
- return {
2380
- bizplace: { id: this._bizplaceId },
2381
- cuFlag: '+',
2382
- name: ov.vasGristId,
2383
- newProduct: ov.newProductId,
2384
- newProductDetail: ov.newProductDetailId,
2385
- outputQty: ov.outputQty === null ? ov.qty : ov.outputQty,
2386
- packingType: ov.packingType,
2387
- productName: ov.productName,
2388
- qty: ov.qty,
2389
- releaseGood: releaseGood,
2390
- remark: ov.remark,
2391
- status: 'PENDING',
2392
- batchId: ov.batchId,
2393
- product: ov.product,
2394
- productDetail: this.selectByPalletInput.checked ? { id: ov.productDetailId } : ov.productDetail,
2395
- uom: ov.uom,
2396
- uomValue: ov.uomValue,
2397
- newPackingType: ov.newPackingType,
2398
- newUom: ov.newUom,
2399
- newUomValue: ov.newUomValue
2400
- }
2401
- })
2402
-
2403
- const response = await client.mutate({
2404
- mutation: gql`
2405
- mutation updateMultipleOrderVas($patches: [OrderVasPatch!]!) {
2406
- updateMultipleOrderVas(patches: $patches) {
2407
- id
2408
- name
2409
- }
2410
- }
2411
- `,
2412
- variables: { patches }
2413
- })
2414
-
2415
- await this.createOrderVasItem(response.data.updateMultipleOrderVas)
2416
- }
2417
-
2418
- async createOrderVasItem(orderVas) {
2419
- let patches = this.vasData.records.map(ovi => {
2420
- let ov = orderVas.filter(ov => ov.name == ovi.vasGristId).reduce(a => a)
2378
+ async createVasOrder(releaseGood) {
2379
+ let orderVasPatch = []
2380
+ orderVasPatch = this.vasGrist.dirtyData.records.filter(p => p.product)
2381
+ orderVasPatch = orderVasPatch.map(ov => {
2421
2382
  return {
2422
- cuFlag: '+',
2423
- name: `${ovi.vas.name}- ${ov.id}`,
2424
- orderVas: ov,
2425
- vas: {
2426
- id: ovi.vas.id,
2427
- name: ovi.vas.name,
2428
- description: ovi.vas.description
2429
- },
2430
- vasQty: ovi.vasQty
2383
+ bizplace: { id: this._bizplaceId },
2384
+ releaseGood: releaseGood,
2385
+ batchId: ov.batchId,
2386
+ qty: ov.qty,
2387
+ product: { id: ov.product.id, name: ov.product.name },
2388
+ name: `${ov.batchId} (${ov.sku})- ${new Date().toISOString()}`,
2389
+ productName: ov.productName,
2390
+ productDetail: ov.productDetail
2391
+ ? { id: ov.productDetail.id, name: ov.productDetail.name }
2392
+ : { id: ov.productDetailId },
2393
+ status: 'PENDING',
2394
+ packingType: ov.packingType,
2395
+ uom: ov.uom,
2396
+ uomValue: ov.uomValue,
2397
+ newProduct: ov.newProductId,
2398
+ newProductDetail: ov.newProductDetailId,
2399
+ newPackingType: ov.newPackingType,
2400
+ newUom: ov.newUom,
2401
+ newUomValue: ov.newUomValue,
2402
+ outputQty: ov.outputQty ? ov.outputQty : ov.qty,
2403
+ remark: ov.remark,
2404
+ orderVasItemsPatch: this.vasGrist.dirtyData.records.reduce((acc, cur) => {
2405
+ if (cur.vasGristId === ov.vasGristId) {
2406
+ return [...acc, { vas: { id: cur.vas.id, name: cur.vas.name }, vasQty: cur.vasQty, cuFlag: '+' }]
2407
+ } else {
2408
+ return acc
2409
+ }
2410
+ }, []),
2411
+ cuFlag: '+'
2431
2412
  }
2432
2413
  })
2433
2414
 
2434
2415
  const response = await client.mutate({
2435
2416
  mutation: gql`
2436
- mutation updateMultipleOrderVasItem($patches: [OrderVasItemPatch!]!) {
2437
- updateMultipleOrderVasItem(patches: $patches) {
2438
- id
2439
- name
2440
- }
2417
+ mutation editVas($orderVasPatch: [OrderVasPatch], $orderVasItemPatch: [OrderVasItemPatch], $orderNo: String) {
2418
+ editVas(orderVasPatch: $orderVasPatch, orderVasItemPatch: $orderVasItemPatch, orderNo: $orderNo)
2441
2419
  }
2442
2420
  `,
2443
- variables: { patches }
2421
+ variables: {
2422
+ orderVasPatch: orderVasPatch,
2423
+ orderNo: releaseGood.name
2424
+ }
2444
2425
  })
2445
2426
 
2446
- response
2427
+ if (!response.errors) {
2428
+ }
2447
2429
  }
2448
2430
 
2449
2431
  async _executeRelatedTrxs() {
@@ -3164,48 +3146,107 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
3164
3146
  .targetList="${targetList}"
3165
3147
  .vasList="${this.vasData.records}"
3166
3148
  .record="${record}"
3167
- @selected="${e => {
3168
- const newRecords = e.detail.map(d => {
3169
- return {
3170
- ...d,
3171
- sku: d.productSKU,
3172
- maxQty: d.releaseQty,
3173
- uomValue: d.releaseUomValue / d.releaseQty
3174
- }
3175
- })
3149
+ .productSKU="${record.productSKU}"
3150
+ @selected="${e =>
3151
+ // {
3152
+ // // let group = this.vasGrist.data.records[this.vasGrist.data.records.length - 1]?.group
3153
+ // // ? this.vasGrist.data.records[this.vasGrist.data.records.length - 1]?.group
3154
+ // // : 0
3155
+
3156
+ // const newRecords = e.detail.map(d => {
3157
+ // return {
3158
+ // ...record,
3159
+ // vasGristId: record?.vasGristId
3160
+ // ? record?.vasGristId
3161
+ // : `${record.batchId} (${record.sku})- ${new Date().toISOString()}`,
3162
+ // qty: undefined,
3163
+ // maxQty: d.releaseQty,
3164
+ // batchId: d.batchId,
3165
+ // sku: d.productSKU,
3166
+ // uomValue: d.releaseUomValue / d.releaseQty,
3167
+ // unitUomValue: d.unitUomValue,
3168
+ // packingSize: d.packingSize,
3169
+ // packingType: d.packingType,
3170
+ // productId: d.productId,
3171
+ // product: d.product,
3172
+ // productDetailId: d.productDetailId,
3173
+ // productDetail: d.productDetail,
3174
+ // productSKU: d.productSKU,
3175
+ // uom: d.uom,
3176
+ // releaseUomValue: d.releaseUomValue,
3177
+ // releaseQty: d.releaseQty
3178
+ // // group: ++group
3179
+ // }
3180
+ // })
3181
+
3182
+ // if (this.vasGrist.dirtyData.records.length !== this._selectedVasRecordIdx) {
3183
+ // // update existing vasData records
3184
+ // this.vasGrist.dirtyData.records.splice(this._selectedVasRecordIdx, 1, ...newRecords)
3185
+ // this.vasGrist.dirtyRecords.push(newRecords)
3186
+
3187
+ // this.vasData = {
3188
+ // ...this.vasData,
3189
+ // records: [...this.vasGrist.dirtyData.records]
3190
+ // }
3191
+ // } else {
3192
+ // this.vasData = {
3193
+ // ...this.vasData,
3194
+ // records: [...this.vasGrist.dirtyData.records, ...newRecords]
3195
+ // }
3196
+ // }
3197
+
3198
+ // // this.vasData = { ...this.vasData, records: this.sortByNameField(this.vasData.records, 'sku') }
3199
+ // // console.log(this.vasData)
3200
+ // }
3201
+ {
3202
+ let firstIndex = this.vasGrist.dirtyData.records.findIndex(
3203
+ oldData => oldData.vasGristId == record.vasGristId
3204
+ )
3205
+ let lastIndex = this.vasGrist.dirtyData.records.findLastIndex(
3206
+ oldData => oldData.vasGristId == record.vasGristId
3207
+ )
3208
+ const newRecords = e.detail.map(d => {
3209
+ return {
3210
+ ...d,
3211
+ ...record,
3212
+ sku: d.productSKU,
3213
+ maxQty: d.releaseQty,
3214
+ uomValue: d.releaseUomValue / d.releaseQty
3215
+ }
3216
+ })
3176
3217
 
3177
- if (this.vasGrist.dirtyData.records.length !== this._selectedVasRecordIdx) {
3178
- // update existing vasData records
3179
- this.vasGrist.dirtyData.records.splice(this._selectedVasRecordIdx, 1, ...newRecords)
3218
+ if (this.vasGrist.dirtyData.records.length !== this._selectedVasRecordIdx) {
3219
+ // update existing vasData records
3220
+ this.vasGrist.dirtyData.records.splice(firstIndex, 1, ...newRecords)
3180
3221
 
3222
+ this.vasData = {
3223
+ ...this.vasData,
3224
+ records: [...this.vasGrist.dirtyData.records]
3225
+ }
3226
+ } else {
3227
+ this.vasData = {
3228
+ ...this.vasData,
3229
+ records: [...this.vasGrist.dirtyData.records, ...newRecords]
3230
+ }
3231
+ }
3232
+ // assign Id
3181
3233
  this.vasData = {
3182
3234
  ...this.vasData,
3183
- records: [...this.vasGrist.dirtyData.records]
3235
+ records: this.vasData.records.map(record => {
3236
+ return {
3237
+ ...record,
3238
+ vasGristId: record.vasGristId
3239
+ ? record.vasGristId
3240
+ : `${record.batchId} (${record.sku})- ${new Date().toISOString()}`
3241
+ }
3242
+ })
3184
3243
  }
3185
- } else {
3244
+ // sorting
3186
3245
  this.vasData = {
3187
3246
  ...this.vasData,
3188
- records: [...this.vasGrist.dirtyData.records, ...newRecords]
3247
+ records: this.sortByNameField(this.vasData.records, 'vasGristId')
3189
3248
  }
3190
- }
3191
- // assign Id
3192
- this.vasData = {
3193
- ...this.vasData,
3194
- records: this.vasData.records.map(record => {
3195
- return {
3196
- ...record,
3197
- vasGristId: record.vasGristId
3198
- ? record.vasGristId
3199
- : `${record.batchId} (${record.sku})- ${new Date().toISOString()}`
3200
- }
3201
- })
3202
- }
3203
- // sorting
3204
- this.vasData = {
3205
- ...this.vasData,
3206
- records: this.sortByNameField(this.vasData.records, 'vasGristId')
3207
- }
3208
- }}"
3249
+ }}"
3209
3250
  ></vas-target-product-popup>
3210
3251
  `,
3211
3252
  {
@@ -3224,69 +3265,56 @@ class CreateReleaseOrder extends localize(i18next)(PageView) {
3224
3265
  openPopup(
3225
3266
  html`
3226
3267
  <select-vas-popup
3268
+ .bizplace="${this._bizplaceId}"
3269
+ .currentSku="${this.vasGrist.dirtyData.records.find(
3270
+ data => data.vasGristId === record.vasGristId && data.product
3271
+ )}"
3272
+ .currentSelectedVas="${this.vasGrist.dirtyData.records.reduce((acc, cur) => {
3273
+ if (cur.vasGristId === record.vasGristId && cur.vas) {
3274
+ return [
3275
+ ...acc,
3276
+ { id: cur.vas?.id, name: cur.vas?.name, description: cur.vas?.description, type: cur.vas?.type }
3277
+ ]
3278
+ } else {
3279
+ return acc
3280
+ }
3281
+ }, [])}"
3227
3282
  @selected="${e => {
3228
3283
  let newRecords = []
3284
+ let firstIndex = this.vasGrist.dirtyData.records.findIndex(
3285
+ oldData => oldData.vasGristId == record.vasGristId
3286
+ )
3287
+ let lastIndex = this.vasGrist.dirtyData.records.findLastIndex(
3288
+ oldData => oldData.vasGristId == record.vasGristId
3289
+ )
3290
+
3229
3291
  for (let i = 0; i < e.detail.length; i++) {
3230
- newRecords.push({ ...record, vas: e.detail[i] })
3231
- }
3232
- if (!record.vas) {
3233
- // if no VAS data, it will update the vas and add new rows
3234
- if (newRecords.length == 1) {
3235
- // update existing inventory data records
3236
- this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
3237
- ...this.vasGrist.dirtyData.records[rowIndex],
3238
- ...newRecords[0]
3292
+ if (i == 0) {
3293
+ newRecords.push({
3294
+ ...this.vasGrist.dirtyData.records[firstIndex],
3295
+ id: undefined,
3296
+ vas: {
3297
+ ...e.detail[i],
3298
+ name: e.detail[i].name,
3299
+ vasName: e.detail[i].name
3300
+ },
3301
+ vasQty: this.vasGrist.dirtyData.records[firstIndex].qty
3239
3302
  })
3240
- this.vasData = {
3241
- ...this.vasData,
3242
- records: [...this.vasGrist.dirtyData.records]
3243
- }
3244
3303
  } else {
3245
- // update existing inventory data records
3246
- this.vasGrist.dirtyData.records.splice(rowIndex, 1, {
3247
- ...this.vasGrist.dirtyData.records[rowIndex],
3248
- ...newRecords[0]
3249
- })
3250
- this.vasData = {
3251
- ...this.vasData,
3252
- records: [...this.vasGrist.dirtyData.records]
3253
- }
3254
- // add new data
3255
- newRecords = newRecords.slice(1).map(nrecord => {
3256
- return {
3257
- vasGristId: record.vasGristId,
3258
- vasQty: nrecord.vasQty,
3259
- vas: nrecord.vas
3304
+ newRecords.push({
3305
+ vasGristId: this.vasGrist.dirtyData.records[firstIndex].vasGristId,
3306
+ vasQty: this.vasGrist.dirtyData.records[firstIndex].qty,
3307
+ vas: {
3308
+ ...e.detail[i],
3309
+ name: e.detail[i].name,
3310
+ vasName: e.detail[i].name
3260
3311
  }
3261
3312
  })
3262
- this.vasData = {
3263
- ...this.vasData,
3264
- records: [...this.vasGrist.dirtyData.records, ...newRecords]
3265
- }
3266
- }
3267
- } else {
3268
- // if vas column is already there add new data ONLY
3269
- newRecords = newRecords.map(nrecord => {
3270
- if (
3271
- this.vasData.records.find(v => v.vasGristId === nrecord.vasGristId && v.vas.id === nrecord.vas.id)
3272
- ) {
3273
- throw new Error(
3274
- this._showToast({
3275
- message: i18next.t('text.duplicated_value_field', { field: i18next.t('field.vas') })
3276
- })
3277
- )
3278
- }
3279
- return {
3280
- vasGristId: record.vasGristId,
3281
- vasQty: nrecord.vasQty,
3282
- vas: nrecord.vas
3283
- }
3284
- })
3285
- this.vasData = {
3286
- ...this.vasData,
3287
- records: [...this.vasGrist.dirtyData.records, ...newRecords]
3288
3313
  }
3289
3314
  }
3315
+ this.vasGrist.dirtyData.records.splice(firstIndex, lastIndex - firstIndex + 1, ...newRecords)
3316
+ this.vasData.records = this.vasGrist.dirtyData.records
3317
+
3290
3318
  this.vasData = {
3291
3319
  ...this.vasData,
3292
3320
  records: this.sortByNameField(this.vasData.records, 'vasGristId')