@things-factory/sales-base 4.3.544 → 4.3.546

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.
@@ -1,12 +1,34 @@
1
+ import {
2
+ Arg,
3
+ Ctx,
4
+ Directive,
5
+ Mutation,
6
+ Resolver
7
+ } from 'type-graphql'
8
+ import { EntityManager } from 'typeorm'
9
+ import { v4 as uuidv4 } from 'uuid'
10
+
1
11
  import { User } from '@things-factory/auth-base'
12
+ import {
13
+ Product,
14
+ ProductDetail
15
+ } from '@things-factory/product-base'
2
16
  import { Domain } from '@things-factory/shell'
3
- import { Bizplace } from '@things-factory/biz-base'
4
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
5
- import { EntityManager } from 'typeorm'
6
- import { NewVas, VasPatch, OrderVasPatch, OrderVasItemPatch, ReleaseGood, OrderVas, OrderVasItem, NewOrderVas } from '../'
17
+
18
+ import {
19
+ NewVas,
20
+ OrderVas,
21
+ OrderVasItem,
22
+ OrderVasItemPatch,
23
+ OrderVasPatch,
24
+ ReleaseGood,
25
+ VasPatch
26
+ } from '../'
27
+ import {
28
+ ORDER_STATUS,
29
+ ORDER_VAS_STATUS
30
+ } from '../../constants'
7
31
  import { Vas } from './vas'
8
- import { v4 as uuidv4 } from 'uuid'
9
- import { ORDER_STATUS, ORDER_VAS_STATUS } from '../../constants'
10
32
 
11
33
  @Resolver(Vas)
12
34
  export class VasMutation {
@@ -424,6 +446,22 @@ async function _handleApprovedVas(tx, domain, user, releaseGood, approvedVas) {
424
446
  relations: ['product', 'productDetail', 'newProduct', 'newProductDetail', 'releaseGood', 'orderVasItems']
425
447
  })
426
448
 
449
+ const adjustedProduct: Product = await tx.getRepository(Product).findOne({
450
+ where: { id: orderVas.adjustedProductId }
451
+ })
452
+
453
+ const adjustedProductDetail: ProductDetail = await tx.getRepository(ProductDetail).findOne({
454
+ where: { id: orderVas.adjustedProductDetailId }
455
+ })
456
+
457
+ const adjustedNewProduct: Product = await tx.getRepository(Product).findOne({
458
+ where: { id: orderVas.adjustedNewProductId }
459
+ })
460
+
461
+ const adjustedNewProductDetail: ProductDetail = await tx.getRepository(ProductDetail).findOne({
462
+ where: { id: orderVas.adjustedNewProductDetailId }
463
+ })
464
+
427
465
  switch (ov.editType) {
428
466
  case ORDER_VAS_STATUS.NEW:
429
467
  await tx.getRepository(OrderVas).update(
@@ -453,15 +491,15 @@ async function _handleApprovedVas(tx, domain, user, releaseGood, approvedVas) {
453
491
  { id: ov.id },
454
492
  {
455
493
  batchId: orderVas.adjustedBatchId ? orderVas.adjustedBatchId : orderVas.batchId,
456
- product: orderVas.adjustedProduct ? orderVas.adjustedProduct : orderVas.product,
457
- productDetail: orderVas.adjustedProductDetail ? orderVas.adjustedProductDetail : orderVas.productDetail,
494
+ product: adjustedProduct ? adjustedProduct : orderVas.product,
495
+ productDetail: adjustedProductDetail ? adjustedProductDetail : orderVas.productDetail,
458
496
  uom: orderVas.adjustedUom ? orderVas.adjustedUom : orderVas.uom,
459
497
  uomValue: orderVas.adjustedNewUom ? orderVas.adjustedUomValue : orderVas.uomValue,
460
498
  packingType: orderVas.adjustedPackingType ? orderVas.adjustedPackingType : orderVas.packingType,
461
499
  qty: orderVas.adjustedQty ? orderVas.adjustedQty : orderVas.qty,
462
500
  outputQty: orderVas.adjustedOutputQty ? orderVas.adjustedOutputQty : orderVas.outputQty,
463
- newProduct: orderVas.adjustedNewProduct ? orderVas.adjustedNewProduct : orderVas.newProduct,
464
- newProductDetail: orderVas.adjustedNewProductDetail ? orderVas.adjustedNewProductDetail : orderVas.newProductDetail,
501
+ newProduct: adjustedNewProduct ? adjustedNewProduct : orderVas.newProduct,
502
+ newProductDetail: adjustedNewProductDetail ? adjustedNewProductDetail : orderVas.newProductDetail,
465
503
  newBatchId: orderVas.adjustedNewBatchId ? orderVas.adjustedNewBatchId : orderVas.newBatchId,
466
504
  newPackingType: orderVas.adjustedNewPackingType ? orderVas.adjustedNewPackingType : orderVas.newPackingType,
467
505
  newUom: orderVas.adjustedNewUom ? orderVas.adjustedNewUom : orderVas.newUom,