@things-factory/sales-base 4.3.638 → 4.3.642
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/dist-server/service/arrival-notice/arrival-notice-mutation.js +33 -2
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +10 -3
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-types.js +2 -2
- package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order-mutation.js +3 -1
- package/dist-server/service/delivery-order/delivery-order-mutation.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order-query.js +11 -0
- package/dist-server/service/delivery-order/delivery-order-query.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order.js +5 -0
- package/dist-server/service/delivery-order/delivery-order.js.map +1 -1
- package/dist-server/service/inventory-check-item/inventory-check-item-types.js +48 -12
- package/dist-server/service/inventory-check-item/inventory-check-item-types.js.map +1 -1
- package/dist-server/service/inventory-check-item/inventory-check-item.js +56 -4
- package/dist-server/service/inventory-check-item/inventory-check-item.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +5 -1
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +12 -12
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +189 -13
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-package-item/order-package-item-types.js +14 -2
- package/dist-server/service/order-package-item/order-package-item-types.js.map +1 -1
- package/dist-server/service/order-package-item/order-package-item.js +28 -2
- package/dist-server/service/order-package-item/order-package-item.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +18 -18
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-product/order-product.js +104 -13
- package/dist-server/service/order-product/order-product.js.map +1 -1
- package/dist-server/service/order-tote-item/order-tote-item-types.js +2 -2
- package/dist-server/service/order-tote-item/order-tote-item-types.js.map +1 -1
- package/dist-server/service/order-tote-item/order-tote-item.js +15 -1
- package/dist-server/service/order-tote-item/order-tote-item.js.map +1 -1
- package/dist-server/service/others/other-query.js +4 -4
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +8 -4
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +108 -16
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +33 -18
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +1 -1
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +15 -0
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/utils/inventory-util.js +18 -14
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +8 -7
- package/server/service/arrival-notice/arrival-notice-mutation.ts +39 -2
- package/server/service/arrival-notice/arrival-notice-query.ts +40 -68
- package/server/service/arrival-notice/arrival-notice-types.ts +4 -4
- package/server/service/delivery-order/delivery-order-mutation.ts +25 -67
- package/server/service/delivery-order/delivery-order-query.ts +24 -29
- package/server/service/delivery-order/delivery-order.ts +5 -1
- package/server/service/inventory-check-item/inventory-check-item-types.ts +37 -10
- package/server/service/inventory-check-item/inventory-check-item.ts +52 -4
- package/server/service/order-inventory/order-inventory-query.ts +5 -0
- package/server/service/order-inventory/order-inventory-types.ts +12 -12
- package/server/service/order-inventory/order-inventory.ts +171 -13
- package/server/service/order-package-item/order-package-item-types.ts +12 -3
- package/server/service/order-package-item/order-package-item.ts +26 -2
- package/server/service/order-product/order-product-types.ts +18 -18
- package/server/service/order-product/order-product.ts +96 -12
- package/server/service/order-tote-item/order-tote-item-types.ts +3 -3
- package/server/service/order-tote-item/order-tote-item.ts +14 -1
- package/server/service/others/other-query.ts +8 -8
- package/server/service/others/other-types.ts +7 -4
- package/server/service/release-good/release-good-mutation.ts +148 -22
- package/server/service/release-good/release-good-query.ts +112 -129
- package/server/service/release-good/release-good-types.ts +1 -1
- package/server/service/release-good/release-good.ts +12 -0
- package/server/utils/inventory-util.ts +50 -60
|
@@ -1,62 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Args,
|
|
4
|
-
Ctx,
|
|
5
|
-
Directive,
|
|
6
|
-
FieldResolver,
|
|
7
|
-
Query,
|
|
8
|
-
Resolver,
|
|
9
|
-
Root
|
|
10
|
-
} from 'type-graphql'
|
|
11
|
-
import {
|
|
12
|
-
EntityManager,
|
|
13
|
-
getRepository,
|
|
14
|
-
In,
|
|
15
|
-
Repository,
|
|
16
|
-
SelectQueryBuilder
|
|
17
|
-
} from 'typeorm'
|
|
1
|
+
import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
+
import { EntityManager, getRepository, In, Repository, SelectQueryBuilder } from 'typeorm'
|
|
18
3
|
|
|
19
4
|
import { Attachment } from '@things-factory/attachment-base'
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
User
|
|
23
|
-
} from '@things-factory/auth-base'
|
|
24
|
-
import {
|
|
25
|
-
Bizplace,
|
|
26
|
-
getCompanyBizplace,
|
|
27
|
-
getMyBizplace,
|
|
28
|
-
getPermittedBizplaceIds
|
|
29
|
-
} from '@things-factory/biz-base'
|
|
5
|
+
import { checkUserBelongsDomain, User } from '@things-factory/auth-base'
|
|
6
|
+
import { Bizplace, getCompanyBizplace, getMyBizplace, getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
30
7
|
import { logger } from '@things-factory/env'
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
ListParam,
|
|
36
|
-
Pagination,
|
|
37
|
-
Sorting
|
|
38
|
-
} from '@things-factory/shell'
|
|
39
|
-
import {
|
|
40
|
-
Inventory,
|
|
41
|
-
LOCATION_TYPE
|
|
42
|
-
} from '@things-factory/warehouse-base'
|
|
43
|
-
|
|
44
|
-
import {
|
|
45
|
-
ATTACHMENT_TYPE,
|
|
46
|
-
ORDER_INVENTORY_STATUS,
|
|
47
|
-
ORDER_STATUS,
|
|
48
|
-
ORDER_VAS_STATUS
|
|
49
|
-
} from '../../constants'
|
|
8
|
+
import { buildQuery, Domain, Filter, ListParam, Pagination, Sorting } from '@things-factory/shell'
|
|
9
|
+
import { Inventory, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
10
|
+
|
|
11
|
+
import { ATTACHMENT_TYPE, ORDER_INVENTORY_STATUS, ORDER_STATUS, ORDER_VAS_STATUS } from '../../constants'
|
|
50
12
|
import { convertExcelDateToISO } from '../../utils/datetime-util'
|
|
51
13
|
import { OrderInventory } from '../order-inventory/order-inventory'
|
|
52
14
|
import { OrderPackage } from '../order-package/order-package'
|
|
53
15
|
import { ShippingOrder } from '../shipping-order/shipping-order'
|
|
54
16
|
import { ReleaseGood } from './release-good'
|
|
55
|
-
import {
|
|
56
|
-
NewReleaseGood,
|
|
57
|
-
ReleasableInventoryList,
|
|
58
|
-
ReleaseGoodList
|
|
59
|
-
} from './release-good-types'
|
|
17
|
+
import { NewReleaseGood, ReleasableInventoryList, ReleaseGoodList } from './release-good-types'
|
|
60
18
|
|
|
61
19
|
@Resolver(ReleaseGood)
|
|
62
20
|
export class ReleaseGoodQuery {
|
|
@@ -520,9 +478,9 @@ export class ReleaseGoodQuery {
|
|
|
520
478
|
params.filters.splice(fromDateParamIdx, 1)
|
|
521
479
|
|
|
522
480
|
params.filters.push({
|
|
523
|
-
name:
|
|
481
|
+
name: typeFilter == 'b2c' || isReleaseDateSearch.value ? 'releaseDate' : 'createdAt',
|
|
524
482
|
operator: 'gte',
|
|
525
|
-
value:
|
|
483
|
+
value: typeFilter == 'b2c' || isReleaseDateSearch.value ? releaseDateFrom : fromDateVal.toISOString(),
|
|
526
484
|
relation: false
|
|
527
485
|
})
|
|
528
486
|
}
|
|
@@ -534,15 +492,21 @@ export class ReleaseGoodQuery {
|
|
|
534
492
|
params.filters.splice(toDateParamIdx, 1)
|
|
535
493
|
|
|
536
494
|
params.filters.push({
|
|
537
|
-
name:
|
|
538
|
-
operator:
|
|
495
|
+
name: typeFilter == 'b2c' || isReleaseDateSearch.value ? 'releaseDate' : 'createdAt',
|
|
496
|
+
operator: typeFilter == 'b2c' || isReleaseDateSearch.value ? 'lte' : 'lt',
|
|
539
497
|
value:
|
|
540
|
-
|
|
498
|
+
typeFilter == 'b2c' || isReleaseDateSearch.value
|
|
499
|
+
? releaseDateTo
|
|
500
|
+
: new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
|
|
541
501
|
relation: false
|
|
542
502
|
})
|
|
543
503
|
}
|
|
544
504
|
|
|
545
|
-
if (!!isReleaseDateSearch)
|
|
505
|
+
if (!!isReleaseDateSearch)
|
|
506
|
+
params.filters.splice(
|
|
507
|
+
params.filters.findIndex(param => param.name == 'isReleaseDateSearch'),
|
|
508
|
+
1
|
|
509
|
+
)
|
|
546
510
|
|
|
547
511
|
if (noOfItemsFilter && noOfItemsFilter.value == 1) {
|
|
548
512
|
params.filters.find(param => param.name === 'noOfItems').operator = 'eq'
|
|
@@ -559,6 +523,7 @@ export class ReleaseGoodQuery {
|
|
|
559
523
|
qb.leftJoinAndSelect('rg.updater', 'updater')
|
|
560
524
|
qb.leftJoinAndSelect('rg.acceptedBy', 'acceptedBy')
|
|
561
525
|
qb.leftJoinAndSelect('rg.draftReleaseGood', 'draftReleaseGood')
|
|
526
|
+
qb.leftJoinAndSelect('rg.lastMileDelivery', 'lmd')
|
|
562
527
|
qb.leftJoinAndSelect('rg.deliverTo', 'deliverTo')
|
|
563
528
|
qb.leftJoinAndSelect('rg.orderVass', 'ov')
|
|
564
529
|
qb.leftJoin(
|
|
@@ -577,13 +542,9 @@ export class ReleaseGoodQuery {
|
|
|
577
542
|
|
|
578
543
|
if (hasVas) {
|
|
579
544
|
if (hasVas.value == true) {
|
|
580
|
-
qb.andWhere(
|
|
581
|
-
`ov.release_good_id notnull`
|
|
582
|
-
)
|
|
545
|
+
qb.andWhere(`ov.release_good_id notnull`)
|
|
583
546
|
} else if (hasVas.value == false && !vasStatusFilter) {
|
|
584
|
-
qb.andWhere(
|
|
585
|
-
`ov.release_good_id is null`
|
|
586
|
-
)
|
|
547
|
+
qb.andWhere(`ov.release_good_id is null`)
|
|
587
548
|
}
|
|
588
549
|
}
|
|
589
550
|
|
|
@@ -601,7 +562,8 @@ export class ReleaseGoodQuery {
|
|
|
601
562
|
release_goods rg2
|
|
602
563
|
LEFT JOIN order_vass ov2 on ov2.release_good_id = rg2.id
|
|
603
564
|
WHERE ov2.status = 'PENDING_APPROVE'
|
|
604
|
-
)`,
|
|
565
|
+
)`,
|
|
566
|
+
{ vasStatus: vasStatusFilter.value }
|
|
605
567
|
)
|
|
606
568
|
}
|
|
607
569
|
}
|
|
@@ -713,17 +675,26 @@ export class ReleaseGoodQuery {
|
|
|
713
675
|
newPlatformCode = 'Shopify'
|
|
714
676
|
}
|
|
715
677
|
}
|
|
678
|
+
|
|
679
|
+
if (
|
|
680
|
+
item.lastMileDelivery &&
|
|
681
|
+
item.lastMileDelivery.isTms &&
|
|
682
|
+
item.lastMileDelivery.platform === 'VERSA_FLEET'
|
|
683
|
+
) {
|
|
684
|
+
item.refNo2 = item.vehicleNo ? item.vehicleNo : item.refNo2
|
|
685
|
+
}
|
|
686
|
+
|
|
716
687
|
return {
|
|
717
688
|
...item,
|
|
718
689
|
platformCode: newPlatformCode ? newPlatformCode : item.platformCode,
|
|
719
690
|
transporter: orderPackages?.length
|
|
720
691
|
? [
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
692
|
+
...new Set(
|
|
693
|
+
orderPackages.map(op => {
|
|
694
|
+
return op.transporter
|
|
695
|
+
})
|
|
696
|
+
)
|
|
697
|
+
].join(', ')
|
|
727
698
|
: null,
|
|
728
699
|
orderRemark: item?.remark ? true : false
|
|
729
700
|
}
|
|
@@ -789,24 +760,27 @@ export class ReleaseGoodQuery {
|
|
|
789
760
|
${batchId ? `AND LOWER(${INV_ALIAS}.batch_id) LIKE '%${batchId.toLowerCase()}%'` : ''}
|
|
790
761
|
${packingType ? `AND LOWER(${INV_ALIAS}.packing_type) LIKE '%${packingType.toLowerCase()}%'` : ''}
|
|
791
762
|
${containerNo ? `AND LOWER(${GAN_ALIAS}.container_no) LIKE '%${containerNo.toLowerCase()}%'` : ''}
|
|
792
|
-
${
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
763
|
+
${
|
|
764
|
+
product?.length > 0 && product[0]
|
|
765
|
+
? `AND ${PROD_ALIAS}.id IN (${product.map((id: string) => `'${id}'`).join(', ')})`
|
|
766
|
+
: product[0] === null
|
|
767
|
+
? `AND ${PROD_ALIAS}.id isnull`
|
|
768
|
+
: ''
|
|
769
|
+
}
|
|
770
|
+
${
|
|
771
|
+
inventory?.length > 0
|
|
772
|
+
? `
|
|
773
|
+
AND (${INV_ALIAS}.batch_id, ${PROD_ALIAS}.id) ${
|
|
774
|
+
filters.find((filter: { name: string; operator: string; value: any }) => filter.name === 'inventory')
|
|
775
|
+
.operator
|
|
776
|
+
} (
|
|
803
777
|
${inventory
|
|
804
|
-
|
|
805
|
-
|
|
778
|
+
.map((inv: { batchId: string; productId: string }) => `('${inv.batchId}', '${inv.productId}')`)
|
|
779
|
+
.join(', ')}
|
|
806
780
|
)
|
|
807
781
|
`
|
|
808
|
-
|
|
809
|
-
|
|
782
|
+
: ''
|
|
783
|
+
}
|
|
810
784
|
`
|
|
811
785
|
|
|
812
786
|
// ${product?.length > 0 ? `AND ${PROD_ALIAS}.id IN (${product.map((id: string) => id ? `'${id}'` : null).join(', ')})` : ''}
|
|
@@ -996,7 +970,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
996
970
|
packing_type VARCHAR(50),
|
|
997
971
|
packing_size FLOAT,
|
|
998
972
|
uom VARCHAR(10),
|
|
999
|
-
release_qty
|
|
973
|
+
release_qty NUMERIC(15,3)
|
|
1000
974
|
);
|
|
1001
975
|
`
|
|
1002
976
|
)
|
|
@@ -1053,9 +1027,11 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
1053
1027
|
AND oi.uom = i.uom
|
|
1054
1028
|
AND oi.domain_id = $1
|
|
1055
1029
|
AND oi.bizplace_id = $2
|
|
1056
|
-
), 0) as "remain_uom_value"
|
|
1030
|
+
), 0) as "remain_uom_value",
|
|
1031
|
+
p.is_inventory_decimal
|
|
1057
1032
|
FROM inventories i
|
|
1058
|
-
|
|
1033
|
+
INNER JOIN locations l ON i.location_id = l.id
|
|
1034
|
+
LEFT JOIN products p ON i.product_id = p.id
|
|
1059
1035
|
INNER JOIN (
|
|
1060
1036
|
SELECT rrg.product_id, rrg.product_detail_id, rrg.sku, rrg.product_info, rrg.packing_type, rrg.packing_size, rrg.uom
|
|
1061
1037
|
FROM raw_release_goods rrg
|
|
@@ -1071,7 +1047,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
1071
1047
|
AND i.obsolete = false
|
|
1072
1048
|
AND i.transfer_qty <= 0
|
|
1073
1049
|
AND i.transfer_uom_value <= 0
|
|
1074
|
-
GROUP BY i.product_id, foo.product_detail_id, foo.sku, foo.product_info, i.packing_type, i.packing_size, i.uom
|
|
1050
|
+
GROUP BY i.product_id, foo.product_detail_id, foo.sku, foo.product_info, i.packing_type, i.packing_size, i.uom, p.is_inventory_decimal
|
|
1075
1051
|
${useDetailedQuery ? ', i.batch_id, i.carton_id, i.expiration_date' : ''}
|
|
1076
1052
|
ORDER BY foo.sku, remain_qty DESC
|
|
1077
1053
|
) SELECT * FROM inv WHERE remain_qty > 0
|
|
@@ -1082,7 +1058,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
1082
1058
|
await tx.query(`DROP TABLE raw_release_goods`)
|
|
1083
1059
|
|
|
1084
1060
|
availableItems = availableItems.map(item => {
|
|
1085
|
-
|
|
1061
|
+
const mappedItem = {
|
|
1086
1062
|
productId: item.product_id,
|
|
1087
1063
|
productDetailId: item.product_detail_id,
|
|
1088
1064
|
productInfo: item.product_info,
|
|
@@ -1094,8 +1070,10 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
1094
1070
|
remainUomValue: item.remain_uom_value,
|
|
1095
1071
|
batchId: item.batch_id ? item.batch_id : null,
|
|
1096
1072
|
cartonId: item.carton_id ? item.carton_id : null,
|
|
1097
|
-
expirationDate: item.expiration_date ? _getStdDateStr(new Date(item.expiration_date)) : null
|
|
1073
|
+
expirationDate: item.expiration_date ? _getStdDateStr(new Date(item.expiration_date)) : null,
|
|
1074
|
+
isInventoryDecimal: item.is_inventory_decimal === true
|
|
1098
1075
|
}
|
|
1076
|
+
return mappedItem
|
|
1099
1077
|
})
|
|
1100
1078
|
|
|
1101
1079
|
return _extractData(rawReleaseGoods, availableItems)
|
|
@@ -1146,22 +1124,25 @@ function _extractData(rawData, validatedData) {
|
|
|
1146
1124
|
// if sku is matched, assign qty and product id
|
|
1147
1125
|
if (idx >= 0) {
|
|
1148
1126
|
// assign qty to rawData as much as possible
|
|
1149
|
-
releaseUomValue =
|
|
1150
|
-
(Math.round((data[idx]?.remainUomValue / data[idx]?.remainQty) * 100) / 100) * raw.releaseQty
|
|
1127
|
+
releaseUomValue = (Math.round((data[idx]?.remainUomValue / data[idx]?.remainQty) * 1000) / 1000) * raw.releaseQty
|
|
1151
1128
|
|
|
1152
1129
|
raw.assignedQty =
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
:
|
|
1130
|
+
Math.round(
|
|
1131
|
+
(data[idx].remainQty >= raw.releaseQty
|
|
1132
|
+
? raw.releaseQty > 0
|
|
1133
|
+
? raw.releaseQty
|
|
1134
|
+
: 0
|
|
1135
|
+
: data[idx].remainQty) * 1000
|
|
1136
|
+
) / 1000
|
|
1158
1137
|
|
|
1159
1138
|
raw.assignedUomValue =
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
:
|
|
1139
|
+
Math.round(
|
|
1140
|
+
(data[idx].remainUomValue >= releaseUomValue
|
|
1141
|
+
? releaseUomValue > 0
|
|
1142
|
+
? releaseUomValue
|
|
1143
|
+
: 0
|
|
1144
|
+
: data[idx].remainUomValue) * 1000
|
|
1145
|
+
) / 1000
|
|
1165
1146
|
|
|
1166
1147
|
// deduct qty & uomValue from validateData
|
|
1167
1148
|
data[idx].remainQty -= raw.assignedQty
|
|
@@ -1173,67 +1154,69 @@ function _extractData(rawData, validatedData) {
|
|
|
1173
1154
|
raw.packingType = data[idx].packingType
|
|
1174
1155
|
raw.packingSize = data[idx].packingSize
|
|
1175
1156
|
raw.uom = data[idx].uom
|
|
1157
|
+
raw.isInventoryDecimal = data[idx].isInventoryDecimal === true
|
|
1176
1158
|
} else {
|
|
1177
1159
|
raw.assignedQty = 0
|
|
1178
1160
|
raw.assignedUomValue = 0
|
|
1179
1161
|
raw.productId = null
|
|
1180
1162
|
}
|
|
1181
1163
|
|
|
1182
|
-
|
|
1183
1164
|
const dateRegex = /^\d{4}-\d{2}-\d{2}$/
|
|
1184
1165
|
|
|
1185
1166
|
return {
|
|
1186
1167
|
...raw,
|
|
1187
1168
|
releaseUomValue,
|
|
1188
1169
|
errorMsg: (() => {
|
|
1189
|
-
const errors = []
|
|
1170
|
+
const errors = []
|
|
1190
1171
|
|
|
1191
|
-
if (errMsg){
|
|
1172
|
+
if (errMsg) {
|
|
1192
1173
|
errors.push(errMsg)
|
|
1193
1174
|
}
|
|
1194
1175
|
if (!raw.productId || !raw.productDetailId) {
|
|
1195
|
-
errors.push('inventory or product not found')
|
|
1176
|
+
errors.push('inventory or product not found')
|
|
1196
1177
|
}
|
|
1197
|
-
if (raw.releaseQty <= 0
|
|
1198
|
-
errors.push('invalid release qty')
|
|
1178
|
+
if (raw.releaseQty <= 0) {
|
|
1179
|
+
errors.push('invalid release qty')
|
|
1180
|
+
}
|
|
1181
|
+
if (raw.releaseQty % 1 !== 0 && raw.isInventoryDecimal !== true) {
|
|
1182
|
+
errors.push('decimal quantities are not allowed for this product')
|
|
1199
1183
|
}
|
|
1200
1184
|
if (raw.assignedQty < raw.releaseQty) {
|
|
1201
|
-
errors.push('insufficient stock')
|
|
1185
|
+
errors.push('insufficient stock')
|
|
1202
1186
|
}
|
|
1203
|
-
if(!dateRegex.test(raw.releaseDate)){
|
|
1187
|
+
if (!dateRegex.test(raw.releaseDate)) {
|
|
1204
1188
|
errors.push('invalid release date format. please use dd/mm/yyyy')
|
|
1205
1189
|
}
|
|
1206
1190
|
if (raw.releaseDate === '') {
|
|
1207
|
-
errors.push('release date is empty')
|
|
1191
|
+
errors.push('release date is empty')
|
|
1208
1192
|
}
|
|
1209
1193
|
if (raw.releaseDate < _getStdDateStr(new Date())) {
|
|
1210
|
-
errors.push('backdate is not allowed')
|
|
1194
|
+
errors.push('backdate is not allowed')
|
|
1211
1195
|
}
|
|
1212
1196
|
if (!raw.refNo || raw.refNo === '') {
|
|
1213
|
-
errors.push('ref no is empty')
|
|
1197
|
+
errors.push('ref no is empty')
|
|
1214
1198
|
}
|
|
1215
|
-
|
|
1216
|
-
if (!raw.attentionTo) errors.push('attention to is empty')
|
|
1217
|
-
if (!raw.postalCode) errors.push('postal code is empty')
|
|
1218
|
-
if (!raw.country) errors.push('country is empty')
|
|
1219
|
-
if (!raw.deliveryAddress1) errors.push('delivery address 1 is empty')
|
|
1220
|
-
if (!raw.city) errors.push('city is empty')
|
|
1221
|
-
if (!raw.phone1) errors.push('contact is empty')
|
|
1222
|
-
if (!raw.state) errors.push('state is empty')
|
|
1199
|
+
if (raw?.type === 'b2c') {
|
|
1200
|
+
if (!raw.attentionTo) errors.push('attention to is empty')
|
|
1201
|
+
if (!raw.postalCode) errors.push('postal code is empty')
|
|
1202
|
+
if (!raw.country) errors.push('country is empty')
|
|
1203
|
+
if (!raw.deliveryAddress1) errors.push('delivery address 1 is empty')
|
|
1204
|
+
if (!raw.city) errors.push('city is empty')
|
|
1205
|
+
if (!raw.phone1) errors.push('contact is empty')
|
|
1206
|
+
if (!raw.state) errors.push('state is empty')
|
|
1223
1207
|
if ((raw.codOption && !raw.paidAmount) || raw.paidAmount < 0 || raw.paidAmount == null) {
|
|
1224
|
-
errors.push('invalid paid amount')
|
|
1208
|
+
errors.push('invalid paid amount')
|
|
1225
1209
|
}
|
|
1226
|
-
if(raw?.expirationDate != null && !dateRegex.test(raw?.expirationDate)){
|
|
1210
|
+
if (raw?.expirationDate != null && !dateRegex.test(raw?.expirationDate)) {
|
|
1227
1211
|
errors.push('invalid expiration date format. please use dd/mm/yyyy')
|
|
1228
1212
|
}
|
|
1229
1213
|
if (raw.airwayBill && raw.lmdOption === true) {
|
|
1230
|
-
errors.push('kindly remove AWB as LMD is marked as true')
|
|
1214
|
+
errors.push('kindly remove AWB as LMD is marked as true')
|
|
1231
1215
|
}
|
|
1232
1216
|
}
|
|
1233
|
-
return errors.length > 0 ? errors.join(', ') : ''// Combine all errors into a single string
|
|
1234
|
-
})()
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1217
|
+
return errors.length > 0 ? errors.join(', ') : '' // Combine all errors into a single string
|
|
1218
|
+
})()
|
|
1219
|
+
}
|
|
1237
1220
|
})
|
|
1238
1221
|
}
|
|
1239
1222
|
|
|
@@ -99,7 +99,7 @@ export class InventoryInfos {
|
|
|
99
99
|
@Field(type => Float, { nullable: true })
|
|
100
100
|
packingSize?: number
|
|
101
101
|
|
|
102
|
-
@Field(type =>
|
|
102
|
+
@Field(type => Float, { nullable: false })
|
|
103
103
|
qty?: number
|
|
104
104
|
|
|
105
105
|
@Field(type => Float, { nullable: true })
|
|
@@ -368,6 +368,18 @@ export class ReleaseGood {
|
|
|
368
368
|
@Field({ nullable: true })
|
|
369
369
|
trackingNo: string
|
|
370
370
|
|
|
371
|
+
@Column({ nullable: true })
|
|
372
|
+
@Field({ nullable: true })
|
|
373
|
+
taskId: string
|
|
374
|
+
|
|
375
|
+
@Column({ nullable: true })
|
|
376
|
+
@Field({ nullable: true })
|
|
377
|
+
vehicleNo: string
|
|
378
|
+
|
|
379
|
+
@Column({ nullable: true })
|
|
380
|
+
@Field({ nullable: true })
|
|
381
|
+
driverName: string
|
|
382
|
+
|
|
371
383
|
@Column({ nullable: true })
|
|
372
384
|
@Field({ nullable: true })
|
|
373
385
|
airwayBill: string
|
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EntityManager,
|
|
3
|
-
Equal,
|
|
4
|
-
getRepository,
|
|
5
|
-
In,
|
|
6
|
-
Not,
|
|
7
|
-
Raw,
|
|
8
|
-
Repository,
|
|
9
|
-
SelectQueryBuilder
|
|
10
|
-
} from 'typeorm'
|
|
1
|
+
import { EntityManager, Equal, getRepository, In, Not, Raw, Repository, SelectQueryBuilder } from 'typeorm'
|
|
11
2
|
|
|
12
3
|
import { User } from '@things-factory/auth-base'
|
|
13
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ProductDetail
|
|
18
|
-
} from '@things-factory/product-base'
|
|
19
|
-
import {
|
|
20
|
-
PartnerSetting,
|
|
21
|
-
Setting
|
|
22
|
-
} from '@things-factory/setting-base'
|
|
23
|
-
import {
|
|
24
|
-
Domain,
|
|
25
|
-
ListParam
|
|
26
|
-
} from '@things-factory/shell'
|
|
5
|
+
import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
|
|
6
|
+
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
7
|
+
import { Domain, ListParam } from '@things-factory/shell'
|
|
27
8
|
import {
|
|
28
9
|
generateInventoryHistory,
|
|
29
10
|
Inventory,
|
|
@@ -303,6 +284,7 @@ export const InventoryUtil = {
|
|
|
303
284
|
COALESCE(p.sku, '') AS "productSKU",
|
|
304
285
|
COALESCE(p.brand, '') AS "productBrand",
|
|
305
286
|
p.id AS "productId",
|
|
287
|
+
p.is_inventory_decimal AS "isInventoryDecimal",
|
|
306
288
|
i.product_detail_id AS "productDetailId",
|
|
307
289
|
SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)) - SUM(COALESCE(pds.unassigned_qty, 0)) AS "remainQty",
|
|
308
290
|
SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - SUM(COALESCE(pds.unassigned_uom_value, 0)) AS "remainUomValue",
|
|
@@ -330,8 +312,9 @@ export const InventoryUtil = {
|
|
|
330
312
|
AND i.transfer_uom_value <= 0
|
|
331
313
|
AND i.lock_inventory is not true
|
|
332
314
|
AND CASE WHEN i.expiration_date IS NOT NULL AND p.min_outbound_shelf_life IS NOT NULL THEN CURRENT_DATE < i.expiration_date - p.min_outbound_shelf_life ELSE true END
|
|
333
|
-
${
|
|
334
|
-
|
|
315
|
+
${
|
|
316
|
+
cycleCountFilter
|
|
317
|
+
? `AND i.id NOT IN (
|
|
335
318
|
SELECT DISTINCT(ici.inventory_id) FROM worksheets w
|
|
336
319
|
INNER JOIN worksheet_details wd ON wd.worksheet_id = w.id
|
|
337
320
|
INNER JOIN inventory_check_items ici ON wd.target_inventory_check_item_id = ici.id
|
|
@@ -339,8 +322,9 @@ export const InventoryUtil = {
|
|
|
339
322
|
AND w.status != 'DONE'
|
|
340
323
|
AND w.bizplace_id IN (${bizplaceIds})
|
|
341
324
|
AND w.domain_id = '${domain.id}'
|
|
342
|
-
)`
|
|
343
|
-
|
|
325
|
+
)`
|
|
326
|
+
: `AND true`
|
|
327
|
+
}
|
|
344
328
|
${productWhereClause}
|
|
345
329
|
GROUP BY
|
|
346
330
|
i.product_detail_id,
|
|
@@ -361,6 +345,7 @@ export const InventoryUtil = {
|
|
|
361
345
|
pb.sku AS "productSKU",
|
|
362
346
|
'brand' AS "productBrand",
|
|
363
347
|
id AS "productId",
|
|
348
|
+
false AS "isInventoryDecimal",
|
|
364
349
|
pbs.product_detail_id AS "productDetailId",
|
|
365
350
|
MIN(FLOOR(pbs."availableQty")) AS "remainQty",
|
|
366
351
|
MIN(FLOOR(pbs."availableUomValue")) AS "remainUomValue",
|
|
@@ -430,7 +415,7 @@ export const InventoryUtil = {
|
|
|
430
415
|
} OFFSET $1 LIMIT $2`,
|
|
431
416
|
[(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
|
|
432
417
|
)
|
|
433
|
-
}
|
|
418
|
+
}
|
|
434
419
|
|
|
435
420
|
await trxMgr.query(`drop table temp_inventory_product_group`)
|
|
436
421
|
|
|
@@ -440,7 +425,12 @@ export const InventoryUtil = {
|
|
|
440
425
|
}
|
|
441
426
|
},
|
|
442
427
|
|
|
443
|
-
async bizplaceInventoryProductGroupImport(
|
|
428
|
+
async bizplaceInventoryProductGroupImport(
|
|
429
|
+
bizplaces: Bizplace[],
|
|
430
|
+
params: ListParam,
|
|
431
|
+
context: any,
|
|
432
|
+
trxMgr: EntityManager
|
|
433
|
+
) {
|
|
444
434
|
try {
|
|
445
435
|
let filters = params.filters
|
|
446
436
|
const { domain }: { domain: Domain } = context.state
|
|
@@ -463,12 +453,13 @@ export const InventoryUtil = {
|
|
|
463
453
|
COALESCE(p.sku, '') AS "productSKU",
|
|
464
454
|
COALESCE(p.brand, '') AS "productBrand",
|
|
465
455
|
p.id AS "productId",
|
|
456
|
+
p.is_inventory_decimal AS "isInventoryDecimal",
|
|
466
457
|
i.product_detail_id AS "productDetailId",
|
|
467
458
|
p.picking_strategy AS "pickingStrategy",
|
|
468
459
|
i.created_at AS "createdAt",
|
|
469
460
|
i.expiration_date AS "expirationDate",
|
|
470
461
|
i.manufacture_date AS "manufactureDate",
|
|
471
|
-
l2.name AS "
|
|
462
|
+
l2.name AS "name",
|
|
472
463
|
l2.zone AS "zone",
|
|
473
464
|
l2.row AS "row",
|
|
474
465
|
l2.column AS "column",
|
|
@@ -526,12 +517,13 @@ export const InventoryUtil = {
|
|
|
526
517
|
pb.sku AS "productSKU",
|
|
527
518
|
'brand' AS "productBrand",
|
|
528
519
|
id AS "productId",
|
|
520
|
+
false AS "isInventoryDecimal",
|
|
529
521
|
pbs.product_detail_id AS "productDetailId",
|
|
530
522
|
NULL AS "pickingStrategy",
|
|
531
523
|
NULL AS "createdAt",
|
|
532
524
|
NULL AS "expirationDate",
|
|
533
525
|
NULL AS "manufactureDate",
|
|
534
|
-
NULL AS "
|
|
526
|
+
NULL AS "name",
|
|
535
527
|
NULL AS "zone",
|
|
536
528
|
NULL AS "row",
|
|
537
529
|
NULL AS "column",
|
|
@@ -570,36 +562,37 @@ export const InventoryUtil = {
|
|
|
570
562
|
})
|
|
571
563
|
|
|
572
564
|
const getLocationSortingClause = (inventoryAssignmentSetting: any) => {
|
|
573
|
-
|
|
565
|
+
let locationSortingRules: Array<{ name: string; desc: boolean }> = []
|
|
574
566
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
567
|
+
if (inventoryAssignmentSetting) {
|
|
568
|
+
try {
|
|
569
|
+
let locationSetting = JSON.parse(inventoryAssignmentSetting.value)
|
|
570
|
+
for (const key in locationSetting) {
|
|
571
|
+
locationSortingRules.push({ name: key, desc: locationSetting[key] !== 'ASC' })
|
|
572
|
+
}
|
|
573
|
+
} catch (error) {
|
|
574
|
+
console.error('Invalid JSON in inventoryAssignmentSetting:', error)
|
|
580
575
|
}
|
|
581
|
-
} catch (error) {
|
|
582
|
-
console.error("Invalid JSON in inventoryAssignmentSetting:", error)
|
|
583
576
|
}
|
|
584
|
-
}
|
|
585
577
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
578
|
+
if (locationSortingRules.length) {
|
|
579
|
+
return locationSortingRules
|
|
580
|
+
.map(
|
|
581
|
+
rule => `
|
|
589
582
|
CASE
|
|
590
583
|
WHEN "pickingStrategy" = 'LOCATION' THEN "${rule.name}"
|
|
591
584
|
END ${rule.desc ? 'DESC' : 'ASC'}
|
|
592
|
-
`
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
return `
|
|
597
|
-
CASE
|
|
598
|
-
WHEN "pickingStrategy" = 'LOCATION' THEN "locationName"
|
|
599
|
-
END ASC
|
|
600
|
-
`
|
|
601
|
-
}
|
|
585
|
+
`
|
|
586
|
+
)
|
|
587
|
+
.join(',\n')
|
|
588
|
+
}
|
|
602
589
|
|
|
590
|
+
return `
|
|
591
|
+
CASE
|
|
592
|
+
WHEN "pickingStrategy" = 'LOCATION' THEN "name"
|
|
593
|
+
END ASC
|
|
594
|
+
`
|
|
595
|
+
}
|
|
603
596
|
|
|
604
597
|
await trxMgr.query(queryStrings, [domain.id])
|
|
605
598
|
|
|
@@ -608,7 +601,6 @@ export const InventoryUtil = {
|
|
|
608
601
|
let items: any[] = []
|
|
609
602
|
|
|
610
603
|
if (!params?.pagination) {
|
|
611
|
-
|
|
612
604
|
const orderByClause = `
|
|
613
605
|
ORDER BY
|
|
614
606
|
${getLocationSortingClause(inventoryAssignmentSetting)},
|
|
@@ -629,9 +621,7 @@ export const InventoryUtil = {
|
|
|
629
621
|
ELSE NULL
|
|
630
622
|
END ASC
|
|
631
623
|
`
|
|
632
|
-
items = await trxMgr.query(
|
|
633
|
-
`select * from temp_inventory_product_group ${orderByClause}`
|
|
634
|
-
)
|
|
624
|
+
items = await trxMgr.query(`select * from temp_inventory_product_group ${orderByClause}`)
|
|
635
625
|
}
|
|
636
626
|
|
|
637
627
|
await trxMgr.query(`drop table temp_inventory_product_group`)
|
|
@@ -807,7 +797,7 @@ export const InventoryUtil = {
|
|
|
807
797
|
)
|
|
808
798
|
|
|
809
799
|
resultQb.forEach(itm => {
|
|
810
|
-
if (itm.releaseQty > itm.availableQty) {
|
|
800
|
+
if (parseFloat(itm.releaseQty) > parseFloat(itm.availableQty)) {
|
|
811
801
|
throw new ValidationError({
|
|
812
802
|
...ValidationError.ERROR_CODES.RELEASE_QTY_OVER_LIMIT,
|
|
813
803
|
detail: { data: JSON.stringify(resultQb) }
|
|
@@ -1336,7 +1326,7 @@ export function _composeTargetInventories(
|
|
|
1336
1326
|
let orderInventory: OrderInventory = new OrderInventory()
|
|
1337
1327
|
|
|
1338
1328
|
if (inventory.remainQty > leftReleaseQty) {
|
|
1339
|
-
const uomValuePerQty: number = Math.round((inventory.remainUomValue / inventory.remainQty) *
|
|
1329
|
+
const uomValuePerQty: number = Math.round((inventory.remainUomValue / inventory.remainQty) * 1000) / 1000
|
|
1340
1330
|
|
|
1341
1331
|
compReleaseQty += leftReleaseQty
|
|
1342
1332
|
compReleaseUomValue += leftReleaseUomValue
|
|
@@ -1344,7 +1334,7 @@ export function _composeTargetInventories(
|
|
|
1344
1334
|
orderInventory = {
|
|
1345
1335
|
...orderInventory,
|
|
1346
1336
|
releaseQty: leftReleaseQty,
|
|
1347
|
-
releaseUomValue: Math.round(leftReleaseQty * uomValuePerQty *
|
|
1337
|
+
releaseUomValue: Math.round(leftReleaseQty * uomValuePerQty * 1000) / 1000
|
|
1348
1338
|
}
|
|
1349
1339
|
} else {
|
|
1350
1340
|
compReleaseQty += inventory.remainQty
|