@things-factory/sales-base 8.0.0-beta.9 → 8.0.0
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/server/constants/attachment-type.ts +9 -0
- package/server/constants/index.ts +7 -0
- package/server/constants/load-type.ts +4 -0
- package/server/constants/order.ts +203 -0
- package/server/constants/product-group-type.ts +4 -0
- package/server/constants/release-good.ts +9 -0
- package/server/constants/transfer-order-type.ts +6 -0
- package/server/constants/validation-error-code.ts +3 -0
- package/server/constants/vas-target-type.ts +25 -0
- package/server/controllers/ecommerce/ecommerce-controller.ts +122 -0
- package/server/controllers/ecommerce/index.ts +2 -0
- package/server/controllers/ecommerce/sellercraft-controller.ts +182 -0
- package/server/controllers/index.ts +2 -0
- package/server/controllers/order-controller.ts +296 -0
- package/server/errors/index.ts +1 -0
- package/server/errors/validation-error.ts +25 -0
- package/server/index.ts +5 -0
- package/server/migrations/index.ts +9 -0
- package/server/service/arrival-notice/arrival-notice-mutation.ts +1152 -0
- package/server/service/arrival-notice/arrival-notice-query.ts +549 -0
- package/server/service/arrival-notice/arrival-notice-types.ts +310 -0
- package/server/service/arrival-notice/arrival-notice.ts +202 -0
- package/server/service/arrival-notice/index.ts +9 -0
- package/server/service/claim/claim-mutation.ts +308 -0
- package/server/service/claim/claim-query.ts +122 -0
- package/server/service/claim/claim-types.ts +130 -0
- package/server/service/claim/claim.ts +140 -0
- package/server/service/claim/index.ts +9 -0
- package/server/service/claim-detail/claim-detail-mutation.ts +102 -0
- package/server/service/claim-detail/claim-detail-query.ts +55 -0
- package/server/service/claim-detail/claim-detail-types.ts +47 -0
- package/server/service/claim-detail/claim-detail.ts +69 -0
- package/server/service/claim-detail/index.ts +9 -0
- package/server/service/claim-order/claim-order-mutation.ts +101 -0
- package/server/service/claim-order/claim-order-query.ts +47 -0
- package/server/service/claim-order/claim-order-types.ts +35 -0
- package/server/service/claim-order/claim-order.ts +81 -0
- package/server/service/claim-order/index.ts +9 -0
- package/server/service/collection-order/collection-order-mutation.ts +245 -0
- package/server/service/collection-order/collection-order-query.ts +97 -0
- package/server/service/collection-order/collection-order-types.ts +165 -0
- package/server/service/collection-order/collection-order.ts +135 -0
- package/server/service/collection-order/index.ts +9 -0
- package/server/service/delivery-order/delivery-order-mutation.ts +967 -0
- package/server/service/delivery-order/delivery-order-query.ts +631 -0
- package/server/service/delivery-order/delivery-order-types.ts +268 -0
- package/server/service/delivery-order/delivery-order.ts +258 -0
- package/server/service/delivery-order/index.ts +9 -0
- package/server/service/draft-release-good/draft-release-good-mutation.ts +765 -0
- package/server/service/draft-release-good/draft-release-good-query.ts +354 -0
- package/server/service/draft-release-good/draft-release-good-type.ts +261 -0
- package/server/service/draft-release-good/draft-release-good.ts +284 -0
- package/server/service/draft-release-good/index.ts +9 -0
- package/server/service/goods-receival-note/goods-receival-note-mutation.ts +129 -0
- package/server/service/goods-receival-note/goods-receival-note-query.ts +280 -0
- package/server/service/goods-receival-note/goods-receival-note-types.ts +105 -0
- package/server/service/goods-receival-note/goods-receival-note.ts +127 -0
- package/server/service/goods-receival-note/index.ts +9 -0
- package/server/service/index.ts +238 -0
- package/server/service/inventory-check/index.ts +9 -0
- package/server/service/inventory-check/inventory-check-mutation.ts +149 -0
- package/server/service/inventory-check/inventory-check-query.ts +48 -0
- package/server/service/inventory-check/inventory-check-types.ts +48 -0
- package/server/service/inventory-check/inventory-check.ts +90 -0
- package/server/service/invoice/index.ts +9 -0
- package/server/service/invoice/invoice-mutation.ts +95 -0
- package/server/service/invoice/invoice-query.ts +53 -0
- package/server/service/invoice/invoice-types.ts +279 -0
- package/server/service/invoice/invoice.ts +230 -0
- package/server/service/invoice-product/index.ts +9 -0
- package/server/service/invoice-product/invoice-product-mutation.ts +54 -0
- package/server/service/invoice-product/invoice-product-query.ts +54 -0
- package/server/service/invoice-product/invoice-product-types.ts +84 -0
- package/server/service/invoice-product/invoice-product.ts +92 -0
- package/server/service/job-sheet/index.ts +9 -0
- package/server/service/job-sheet/job-sheet-mutation.ts +92 -0
- package/server/service/job-sheet/job-sheet-query.ts +112 -0
- package/server/service/job-sheet/job-sheet-types.ts +78 -0
- package/server/service/job-sheet/job-sheet.ts +102 -0
- package/server/service/manifest/index.ts +6 -0
- package/server/service/manifest/manifest-mutation.ts +190 -0
- package/server/service/manifest/manifest-query.ts +149 -0
- package/server/service/manifest/manifest-type.ts +84 -0
- package/server/service/manifest/manifest.ts +114 -0
- package/server/service/order-inventory/index.ts +9 -0
- package/server/service/order-inventory/order-inventory-mutation.ts +54 -0
- package/server/service/order-inventory/order-inventory-query.ts +722 -0
- package/server/service/order-inventory/order-inventory-types.ts +238 -0
- package/server/service/order-inventory/order-inventory.ts +401 -0
- package/server/service/order-product/index.ts +9 -0
- package/server/service/order-product/order-product-mutation.ts +48 -0
- package/server/service/order-product/order-product-query.ts +89 -0
- package/server/service/order-product/order-product-types.ts +335 -0
- package/server/service/order-product/order-product.ts +362 -0
- package/server/service/order-tote/index.ts +9 -0
- package/server/service/order-tote/order-tote-mutation.ts +31 -0
- package/server/service/order-tote/order-tote-query.ts +112 -0
- package/server/service/order-tote/order-tote-types.ts +47 -0
- package/server/service/order-tote/order-tote.ts +73 -0
- package/server/service/order-tote-item/index.ts +9 -0
- package/server/service/order-tote-item/order-tote-item-mutation.ts +31 -0
- package/server/service/order-tote-item/order-tote-item-query.ts +82 -0
- package/server/service/order-tote-item/order-tote-item-types.ts +56 -0
- package/server/service/order-tote-item/order-tote-item.ts +72 -0
- package/server/service/order-tote-seal/index.ts +9 -0
- package/server/service/order-tote-seal/order-tote-seal-mutation.ts +31 -0
- package/server/service/order-tote-seal/order-tote-seal-query.ts +59 -0
- package/server/service/order-tote-seal/order-tote-seal-types.ts +41 -0
- package/server/service/order-tote-seal/order-tote-seal.ts +46 -0
- package/server/service/order-vas/index.ts +9 -0
- package/server/service/order-vas/order-vas-mutation.ts +20 -0
- package/server/service/order-vas/order-vas-query.ts +72 -0
- package/server/service/order-vas/order-vas-types.ts +159 -0
- package/server/service/order-vas/order-vas.ts +207 -0
- package/server/service/others/index.ts +5 -0
- package/server/service/others/other-query.ts +563 -0
- package/server/service/others/other-types.ts +115 -0
- package/server/service/purchase-order/index.ts +9 -0
- package/server/service/purchase-order/purchase-order-mutation.ts +458 -0
- package/server/service/purchase-order/purchase-order-query.ts +90 -0
- package/server/service/purchase-order/purchase-order-types.ts +154 -0
- package/server/service/purchase-order/purchase-order.ts +172 -0
- package/server/service/purchase-order-other-charge/index.ts +9 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.ts +31 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge-query.ts +52 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge-types.ts +44 -0
- package/server/service/purchase-order-other-charge/purchase-order-other-charge.ts +68 -0
- package/server/service/release-good/index.ts +9 -0
- package/server/service/release-good/release-good-mutation.ts +1686 -0
- package/server/service/release-good/release-good-query.ts +980 -0
- package/server/service/release-good/release-good-types.ts +662 -0
- package/server/service/release-good/release-good.ts +490 -0
- package/server/service/retail-replenishment-order/index.ts +9 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order-mutation.ts +382 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order-query.ts +54 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order-types.ts +101 -0
- package/server/service/retail-replenishment-order/retail-replenishment-order.ts +115 -0
- package/server/service/return-order/index.ts +9 -0
- package/server/service/return-order/return-order-mutation.ts +516 -0
- package/server/service/return-order/return-order-query.ts +226 -0
- package/server/service/return-order/return-order-types.ts +196 -0
- package/server/service/return-order/return-order.ts +127 -0
- package/server/service/reverse-kitting-order/index.ts +9 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +500 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +197 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +173 -0
- package/server/service/reverse-kitting-order/reverse-kitting-order.ts +121 -0
- package/server/service/reverse-kitting-order-inventory/index.ts +9 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts +129 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.ts +52 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.ts +95 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +143 -0
- package/server/service/shipping-order/index.ts +9 -0
- package/server/service/shipping-order/shipping-order-mutation.ts +61 -0
- package/server/service/shipping-order/shipping-order-query.ts +61 -0
- package/server/service/shipping-order/shipping-order-types.ts +89 -0
- package/server/service/shipping-order/shipping-order.ts +129 -0
- package/server/service/transfer-order/index.ts +9 -0
- package/server/service/transfer-order/transfer-order-mutation.ts +309 -0
- package/server/service/transfer-order/transfer-order-query.ts +66 -0
- package/server/service/transfer-order/transfer-order-types.ts +97 -0
- package/server/service/transfer-order/transfer-order.ts +117 -0
- package/server/service/vas/index.ts +9 -0
- package/server/service/vas/vas-mutation.ts +106 -0
- package/server/service/vas/vas-query.ts +60 -0
- package/server/service/vas/vas-types.ts +71 -0
- package/server/service/vas/vas.ts +77 -0
- package/server/service/vas-order/index.ts +9 -0
- package/server/service/vas-order/vas-order-mutation.ts +259 -0
- package/server/service/vas-order/vas-order-query.ts +119 -0
- package/server/service/vas-order/vas-order-types.ts +49 -0
- package/server/service/vas-order/vas-order.ts +81 -0
- package/server/utils/datetime-util.ts +54 -0
- package/server/utils/index.ts +3 -0
- package/server/utils/inventory-util.ts +1155 -0
- package/server/utils/order-no-generator.ts +146 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/sales-base",
|
|
3
|
-
"version": "8.0.0
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/attachment-base": "^8.0.0
|
|
28
|
-
"@things-factory/auth-base": "^8.0.0
|
|
29
|
-
"@things-factory/biz-base": "^8.0.0
|
|
30
|
-
"@things-factory/code-base": "^8.0.0
|
|
31
|
-
"@things-factory/integration-sftp": "^8.0.0
|
|
32
|
-
"@things-factory/notification": "^8.0.0
|
|
33
|
-
"@things-factory/product-base": "^8.0.0
|
|
34
|
-
"@things-factory/setting-base": "^8.0.0
|
|
35
|
-
"@things-factory/shell": "^8.0.0
|
|
36
|
-
"@things-factory/transport-base": "^8.0.0
|
|
37
|
-
"@things-factory/warehouse-base": "^8.0.0
|
|
27
|
+
"@things-factory/attachment-base": "^8.0.0",
|
|
28
|
+
"@things-factory/auth-base": "^8.0.0",
|
|
29
|
+
"@things-factory/biz-base": "^8.0.0",
|
|
30
|
+
"@things-factory/code-base": "^8.0.0",
|
|
31
|
+
"@things-factory/integration-sftp": "^8.0.0",
|
|
32
|
+
"@things-factory/notification": "^8.0.0",
|
|
33
|
+
"@things-factory/product-base": "^8.0.0",
|
|
34
|
+
"@things-factory/setting-base": "^8.0.0",
|
|
35
|
+
"@things-factory/shell": "^8.0.0",
|
|
36
|
+
"@things-factory/transport-base": "^8.0.0",
|
|
37
|
+
"@things-factory/warehouse-base": "^8.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "07ef27d272dd9a067a9648ac7013748510556a18"
|
|
40
40
|
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
export const ORDER_STATUS = {
|
|
2
|
+
DRAFT: 'DRAFT',
|
|
3
|
+
PENDING: 'PENDING',
|
|
4
|
+
APPROVED: 'APPROVED',
|
|
5
|
+
EDITING: 'EDITING',
|
|
6
|
+
PENDING_RECEIVE: 'PENDING_RECEIVE',
|
|
7
|
+
PENDING_CANCEL: 'PENDING_CANCEL',
|
|
8
|
+
PENDING_APPROVAL: 'PENDING_APPROVAL',
|
|
9
|
+
PENDING_WORKSHEET: 'PENDING_WORKSHEET',
|
|
10
|
+
CANCELLED: 'CANCELLED',
|
|
11
|
+
INTRANSIT: 'INTRANSIT',
|
|
12
|
+
COLLECTING: 'COLLECTING',
|
|
13
|
+
DELIVERING: 'DELIVERING',
|
|
14
|
+
READY_TO_DISPATCH: 'READY_TO_DISPATCH',
|
|
15
|
+
READY_TO_EXECUTE: 'READY_TO_EXECUTE',
|
|
16
|
+
ARRIVED: 'ARRIVED',
|
|
17
|
+
READY_TO_UNLOAD: 'READY_TO_UNLOAD',
|
|
18
|
+
READY_TO_LOAD: 'READY_TO_LOAD',
|
|
19
|
+
READY_TO_PACK: 'READY_TO_PACK',
|
|
20
|
+
READY_TO_SORT: 'READY_TO_SORT',
|
|
21
|
+
READY_TO_PICK: 'READY_TO_PICK',
|
|
22
|
+
READY_TO_PUTAWAY: 'READY_TO_PUTAWAY',
|
|
23
|
+
PUTTING_AWAY: 'PUTTING_AWAY',
|
|
24
|
+
PACKING: 'PACKING',
|
|
25
|
+
PICKING: 'PICKING',
|
|
26
|
+
LOADING: 'LOADING',
|
|
27
|
+
PROCESSING: 'PROCESSING',
|
|
28
|
+
EXECUTING: 'EXECUTING',
|
|
29
|
+
PARTIAL_RETURN: 'PARTIAL_RETURN',
|
|
30
|
+
DONE: 'DONE',
|
|
31
|
+
PENDING_REVIEW: 'PENDING_REVIEW',
|
|
32
|
+
INPROCESS: 'INPROCESS',
|
|
33
|
+
SORTING: 'SORTING',
|
|
34
|
+
INSPECTING: 'INSPECTING',
|
|
35
|
+
REJECTED: 'REJECTED',
|
|
36
|
+
SHIPPING: 'SHIPPING',
|
|
37
|
+
RECEIVED: 'RECEIVED',
|
|
38
|
+
PARTIAL_RECEIVED: 'PARTIAL_RECEIVED'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const DISPATCHMENT_STATUS = {
|
|
42
|
+
READY_TO_DISPATCH: 'READY_TO_DISPATCH',
|
|
43
|
+
DISPATCHED: 'DISPATCHED'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const MANIFEST_STATUS = {
|
|
47
|
+
OPEN: 'OPEN',
|
|
48
|
+
CLOSED: 'CLOSED',
|
|
49
|
+
IN_QUEUE: 'IN_QUEUE'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const ORDER_INVENTORY_TYPE = {
|
|
53
|
+
RELEASE_OF_GOODS: 'RELEASE_OF_GOODS',
|
|
54
|
+
ARRIVAL_NOTICE: 'ARRIVAL_NOTICE',
|
|
55
|
+
DELIVERY: 'DELIVERY',
|
|
56
|
+
RETURN_ORDER: 'RETURN_ORDER'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const ORDER_PRODUCT_STATUS = {
|
|
60
|
+
ASSIGNED: 'ASSIGNED',
|
|
61
|
+
ADDED: 'ADDED',
|
|
62
|
+
EDITED: 'EDITED',
|
|
63
|
+
READY_TO_APPROVED: 'READY_TO_APPROVED',
|
|
64
|
+
APPROVED: 'APPROVED',
|
|
65
|
+
PENDING: 'PENDING',
|
|
66
|
+
PENDING_RECEIVE: 'PENDING_RECEIVE',
|
|
67
|
+
REJECTED: 'REJECTED',
|
|
68
|
+
INTRANSIT: 'INTRANSIT',
|
|
69
|
+
ARRIVED: 'ARRIVED',
|
|
70
|
+
READY_TO_COLLECT: 'READY_TO_COLLECT',
|
|
71
|
+
READY_TO_DELIVER: 'READY_TO_DELIVER',
|
|
72
|
+
READY_TO_UNLOAD: 'READY_TO_UNLOAD',
|
|
73
|
+
PENDING_APPROVAL: 'PENDING_APPROVAL',
|
|
74
|
+
PENDING_ASSIGN: 'PENDING_ASSIGN',
|
|
75
|
+
PENDING_WORKSHEET: 'PENDING_WORKSHEET',
|
|
76
|
+
READY_TO_PICK: 'READY_TO_PICK',
|
|
77
|
+
PICKING: 'PICKING',
|
|
78
|
+
UNLOADING: 'UNLOADING',
|
|
79
|
+
PARTIALLY_UNLOADED: 'PARTIALLY_UNLOADED',
|
|
80
|
+
UNLOADED: 'UNLOADED',
|
|
81
|
+
COLLECTED: 'COLLECTED',
|
|
82
|
+
DELIVERED: 'DELIVERED',
|
|
83
|
+
PUTTING_AWAY: 'PUTTING_AWAY',
|
|
84
|
+
STORED: 'STORED',
|
|
85
|
+
INSPECTED: 'INSPECTED',
|
|
86
|
+
TERMINATED: 'TERMINATED',
|
|
87
|
+
RECEIVED: 'RECEIVED',
|
|
88
|
+
NOT_RECEIVED: 'NOT_RECEIVED'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const ORDER_INVENTORY_STATUS = {
|
|
92
|
+
ASSIGNED: 'ASSIGNED',
|
|
93
|
+
ARRIVED: 'ARRIVED',
|
|
94
|
+
INTRANSIT: 'INTRANSIT',
|
|
95
|
+
PENDING: 'PENDING',
|
|
96
|
+
PENDING_RECEIVE: 'PENDING_RECEIVE',
|
|
97
|
+
PENDING_CANCEL: 'PENDING_CANCEL',
|
|
98
|
+
PENDING_WORKSHEET: 'PENDING_WORKSHEET',
|
|
99
|
+
PENDING_REVERSE: 'PENDING_REVERSE',
|
|
100
|
+
CANCELLED: 'CANCELLED',
|
|
101
|
+
PENDING_SPLIT: 'PENDING_SPLIT',
|
|
102
|
+
COMPLETE_SPLIT: 'COMPLETE_SPLIT',
|
|
103
|
+
READY_TO_DISPATCH: 'READY_TO_DISPATCH',
|
|
104
|
+
READY_TO_PICK: 'READY_TO_PICK',
|
|
105
|
+
READY_TO_PACK: 'READY_TO_PACK',
|
|
106
|
+
READY_TO_SORT: 'READY_TO_SORT',
|
|
107
|
+
SORTING: 'SORTING',
|
|
108
|
+
READY_TO_RETURN: 'READY_TO_RETURN',
|
|
109
|
+
PACKING: 'PACKING',
|
|
110
|
+
PICKING: 'PICKING',
|
|
111
|
+
LOADING: 'LOADING',
|
|
112
|
+
INSPECTING: 'INSPECTING',
|
|
113
|
+
INSPECTED: 'INSPECTED',
|
|
114
|
+
PICKED: 'PICKED',
|
|
115
|
+
PACKED: 'PACKED',
|
|
116
|
+
SORTED: 'SORTED',
|
|
117
|
+
LOADED: 'LOADED',
|
|
118
|
+
NOT_TALLY: 'NOT_TALLY',
|
|
119
|
+
RELOCATED: 'RELOCATED',
|
|
120
|
+
ADDED: 'ADDED',
|
|
121
|
+
MISSING: 'MISSING',
|
|
122
|
+
EXTRA: 'EXTRA',
|
|
123
|
+
REJECTED: 'REJECTED',
|
|
124
|
+
RELEASED: 'RELEASED',
|
|
125
|
+
REPLACED: 'REPLACED',
|
|
126
|
+
DELIVERING: 'DELIVERING',
|
|
127
|
+
RETURNING: 'RETURNING',
|
|
128
|
+
TERMINATED: 'TERMINATED',
|
|
129
|
+
DONE: 'DONE',
|
|
130
|
+
RECEIVED: 'RECEIVED',
|
|
131
|
+
NOT_RECEIVED: 'NOT_RECEIVED'
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const ORDER_VAS_STATUS = {
|
|
135
|
+
PENDING: 'PENDING',
|
|
136
|
+
PENDING_RECEIVE: 'PENDING_RECEIVE',
|
|
137
|
+
PENDING_CANCEL: 'PENDING_CANCEL',
|
|
138
|
+
CANCELLED: 'CANCELLED',
|
|
139
|
+
REJECTED: 'REJECTED',
|
|
140
|
+
INTRANSIT: 'INTRANSIT',
|
|
141
|
+
ARRIVED: 'ARRIVED',
|
|
142
|
+
READY_TO_PROCESS: 'READY_TO_PROCESS',
|
|
143
|
+
PROCESSING: 'PROCESSING',
|
|
144
|
+
COMPLETED: 'COMPLETED',
|
|
145
|
+
TERMINATED: 'TERMINATED'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const ORDER_TYPES = {
|
|
149
|
+
ARRIVAL_NOTICE: 'ARRIVAL_NOTICE',
|
|
150
|
+
SHIPPING: 'SHIPPING_ORDER',
|
|
151
|
+
DELIVERY: 'DELIVERY',
|
|
152
|
+
COLLECTION: 'COLLECTION',
|
|
153
|
+
RELEASE_OF_GOODS: 'RELEASE_OF_GOODS',
|
|
154
|
+
DRAFT_RELEASE_GOODS: 'DRAFT_RELEASE_GOODS',
|
|
155
|
+
VAS_ORDER: 'VAS_ORDER',
|
|
156
|
+
CYCLE_COUNT: 'CYCLE_COUNT',
|
|
157
|
+
STOCK_TAKE: 'STOCK_TAKE',
|
|
158
|
+
TRANSFER_ORDER: 'TRANSFER_ORDER'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const GRN_STATUS = {
|
|
162
|
+
READY_TO_SEND: 'READY_TO_SEND',
|
|
163
|
+
PENDING_RECEIVE: 'PENDING_RECEIVE',
|
|
164
|
+
SENT: 'SENT',
|
|
165
|
+
RECEIVED: 'RECEIVED'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const ORDER_NUMBER_SETTING_KEY = {
|
|
169
|
+
GAN_NUMBER_RULE: 'gan-number-rule',
|
|
170
|
+
PO_NUMBER_RULE: 'po-number-rule',
|
|
171
|
+
GRN_NUMBER_RULE: 'grn-number-rule',
|
|
172
|
+
RO_NUMBER_RULE: 'ro-number-rule',
|
|
173
|
+
DO_NUMBER_RULE: 'do-number-rule',
|
|
174
|
+
RR_NUMBER_RULE: 'rr-number-rule',
|
|
175
|
+
TO_NUMBER_RULE: 'to-number-rule',
|
|
176
|
+
DRO_NUMBER_RULE: 'dro-number-rule'
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export const ORDER_NUMBER_RULE_TYPE = {
|
|
180
|
+
GAN_NUMBER: 'gan_number',
|
|
181
|
+
PO_NUMBER: 'po_number',
|
|
182
|
+
GRN_NUMBER: 'grn_number',
|
|
183
|
+
RO_NUMBER: 'ro_number',
|
|
184
|
+
DO_NUMBER: 'do_number',
|
|
185
|
+
RR_NUMBER: 'rr_number',
|
|
186
|
+
TO_NUMBER: 'to_number',
|
|
187
|
+
DRO_NUMBER: 'dro_number'
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export const PURCHASE_ORDER_STATUS = {
|
|
191
|
+
DRAFT: 'DRAFT',
|
|
192
|
+
PENDING: 'PENDING',
|
|
193
|
+
APPROVED: 'APPROVED',
|
|
194
|
+
REJECTED: 'REJECTED',
|
|
195
|
+
COMPLETED: 'COMPLETED'
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const DRAFT_RELEASE_ORDER_STATUS = {
|
|
199
|
+
DRAFT: 'DRAFT',
|
|
200
|
+
INSUFFICIENT: 'INSUFFICIENT',
|
|
201
|
+
SUBMITTED: 'SUBMITTED',
|
|
202
|
+
CANCELLED: 'CANCELLED'
|
|
203
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const VAS_TARGET_TYPES = {
|
|
2
|
+
BATCH_NO_TYPE: 'BATCH_NO',
|
|
3
|
+
PRODUCT_TYPE: 'PRODUCT',
|
|
4
|
+
BATCH_AND_PRODUCT_TYPE: 'BATCH_AND_PRODUCT_TYPE',
|
|
5
|
+
ETC_TYPE: 'ETC'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const VAS_TYPES = {
|
|
9
|
+
MATERIALS: 'MATERIALS',
|
|
10
|
+
SERVICE: 'SERVICE'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const VAS = {
|
|
14
|
+
RELABELING: 'RELABELING',
|
|
15
|
+
REPACKING: 'REPACKING',
|
|
16
|
+
REPALLETIZING: 'REPALLETIZING',
|
|
17
|
+
UNPACKING: 'UNPACKING'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const VAS_OPERATION_GUIDES = {
|
|
21
|
+
VAS_RELABEL: 'vas-relabel',
|
|
22
|
+
VAS_REPACK: 'vas-repack',
|
|
23
|
+
VAS_REPALLETIZING: 'vas-repalletizing',
|
|
24
|
+
VAS_UNPACK: 'vas-unpack'
|
|
25
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { MarketplaceSetting, MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
|
|
2
|
+
import { MarketplaceProductVariation } from '@things-factory/marketplace-base'
|
|
3
|
+
import { Product } from '@things-factory/product-base'
|
|
4
|
+
import { Domain } from '@things-factory/shell'
|
|
5
|
+
import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
6
|
+
|
|
7
|
+
import { OrderController } from '../order-controller'
|
|
8
|
+
|
|
9
|
+
export class EcommerceController extends OrderController {
|
|
10
|
+
async updateProductVariationStock(
|
|
11
|
+
marketplaceStores: MarketplaceStore[],
|
|
12
|
+
productIds: string[],
|
|
13
|
+
companyDomain: Domain
|
|
14
|
+
): Promise<void> {
|
|
15
|
+
const inventoryProducts: any[] = await Promise.all(
|
|
16
|
+
productIds.map(async productId => {
|
|
17
|
+
const product: Product = await this.trxMgr.getRepository(Product).findOneBy({ id: productId })
|
|
18
|
+
let qb = await this.trxMgr.getRepository(Inventory).createQueryBuilder('inv')
|
|
19
|
+
qb.leftJoinAndSelect('inv.location', 'loc')
|
|
20
|
+
.andWhere('"inv"."domain_id" = :domainId')
|
|
21
|
+
.andWhere('"inv"."product_id" = :productId')
|
|
22
|
+
.andWhere('"inv"."status" != :status')
|
|
23
|
+
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
24
|
+
.setParameters({
|
|
25
|
+
domainId: this.domain.id,
|
|
26
|
+
productId: product.id,
|
|
27
|
+
status: INVENTORY_STATUS.TERMINATED,
|
|
28
|
+
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
let inventories: Inventory[] = await qb.getMany()
|
|
32
|
+
|
|
33
|
+
inventories = inventories.filter(
|
|
34
|
+
inventory =>
|
|
35
|
+
inventory?.location.type !== LOCATION_TYPE.QUARANTINE || inventory?.location.type !== LOCATION_TYPE.RESERVE
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
const inventoryQty: number = inventories.reduce((total, currentValue) => {
|
|
39
|
+
total += currentValue.qty
|
|
40
|
+
return total
|
|
41
|
+
}, 0)
|
|
42
|
+
|
|
43
|
+
const inventoryLockedQty: number = inventories.reduce((total, currentValue) => {
|
|
44
|
+
total += currentValue.lockedQty
|
|
45
|
+
return total
|
|
46
|
+
}, 0)
|
|
47
|
+
|
|
48
|
+
return { sku: product.sku, name: product.name, qty: inventoryQty - inventoryLockedQty }
|
|
49
|
+
})
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
for (var i = 0; i < marketplaceStores.length; i++) {
|
|
53
|
+
const marketplaceStore = marketplaceStores[i]
|
|
54
|
+
|
|
55
|
+
// get marketplace setting based on marketplace connection
|
|
56
|
+
const marketplaceSetting: MarketplaceSetting = await this.trxMgr.getRepository(MarketplaceSetting).findOne({
|
|
57
|
+
where: { marketplaceStore: { id: marketplaceStore.id }, category: 'stock_allocation' }
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
for (var j = 0; j < inventoryProducts.length; j++) {
|
|
61
|
+
const inventoryProduct = inventoryProducts[j]
|
|
62
|
+
const marketplaceProductVariations: MarketplaceProductVariation[] = await this.trxMgr
|
|
63
|
+
.getRepository(MarketplaceProductVariation)
|
|
64
|
+
.find({
|
|
65
|
+
where: { domain: { id: companyDomain.id }, sku: inventoryProduct.sku },
|
|
66
|
+
relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
let storeProductVariations: MarketplaceProductVariation[] = marketplaceProductVariations.filter(
|
|
70
|
+
productVariation => productVariation.marketplaceProduct.marketplaceStore.id === marketplaceStore.id
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
let percentageValue: number = 100
|
|
74
|
+
if (storeProductVariations) {
|
|
75
|
+
for (let k = 0; k < storeProductVariations.length; k++) {
|
|
76
|
+
let storeProductVariation: MarketplaceProductVariation = storeProductVariations[k]
|
|
77
|
+
if (marketplaceSetting) {
|
|
78
|
+
percentageValue = parseInt(marketplaceSetting.value)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let remainQty: number = Math.floor(
|
|
82
|
+
(inventoryProduct.qty - storeProductVariation.reserveQty) * (percentageValue / 100)
|
|
83
|
+
)
|
|
84
|
+
if (remainQty < 0) remainQty = 0
|
|
85
|
+
|
|
86
|
+
let productVariationLocationId = storeProductVariation?.locationId
|
|
87
|
+
let adjustQty: number = remainQty
|
|
88
|
+
|
|
89
|
+
if (marketplaceStore.platform === 'shopify') {
|
|
90
|
+
let locationIds: any[] = JSON.parse(productVariationLocationId)
|
|
91
|
+
adjustQty = adjustQty - storeProductVariation.qty
|
|
92
|
+
if (locationIds[0]?.location_id) productVariationLocationId = locationIds[0].location_id
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let validMarketplaceDistributors: any[] = []
|
|
96
|
+
if (marketplaceStore.marketplaceDistributors) {
|
|
97
|
+
validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(
|
|
98
|
+
distributor => distributor.status === 'ACTIVE'
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
|
|
103
|
+
{
|
|
104
|
+
itemId: storeProductVariation.marketplaceProduct.itemId,
|
|
105
|
+
variationId: storeProductVariation.variationId,
|
|
106
|
+
variationSku: storeProductVariation.variationSku,
|
|
107
|
+
qty: adjustQty,
|
|
108
|
+
locationId: productVariationLocationId,
|
|
109
|
+
inventoryItemId: storeProductVariation.inventoryItemId,
|
|
110
|
+
distributors: validMarketplaceDistributors
|
|
111
|
+
}
|
|
112
|
+
])
|
|
113
|
+
|
|
114
|
+
storeProductVariation.qty = remainQty
|
|
115
|
+
storeProductVariation.updater = this.user
|
|
116
|
+
await this.trxMgr.getRepository(MarketplaceProductVariation).save(storeProductVariation)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Bizplace } from '@things-factory/biz-base'
|
|
2
|
+
import { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'
|
|
3
|
+
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
4
|
+
import { Domain } from '@things-factory/shell'
|
|
5
|
+
import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
6
|
+
|
|
7
|
+
import { ORDER_PRODUCT_STATUS } from '../../constants'
|
|
8
|
+
import { OrderProduct } from '../../service/order-product/order-product'
|
|
9
|
+
import { ReleaseGood } from '../../service/release-good/release-good'
|
|
10
|
+
import { OrderController } from '../order-controller'
|
|
11
|
+
|
|
12
|
+
export class SellercraftController extends OrderController {
|
|
13
|
+
async packOrder(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<ReleaseGood> {
|
|
14
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
15
|
+
let disablePackOrder: boolean =
|
|
16
|
+
sellercraftSetting?.disablePackOrder && sellercraftSetting?.disablePackOrder == 1 ? true : false
|
|
17
|
+
|
|
18
|
+
if (!disablePackOrder) {
|
|
19
|
+
const orderProducts: OrderProduct[] = releaseGood.orderProducts
|
|
20
|
+
let sellercraftOPs: any[] = []
|
|
21
|
+
|
|
22
|
+
sellercraftOPs = orderProducts.map(orderProduct => {
|
|
23
|
+
const product: Product = orderProduct.product
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
sku: product.sku,
|
|
27
|
+
releaseQty: orderProduct.releaseQty,
|
|
28
|
+
uom: 'EA'
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const orderInformation: any = {
|
|
33
|
+
accountId: sellercraft.accountId,
|
|
34
|
+
orderId: releaseGood.refNo2,
|
|
35
|
+
sellercraftOPs
|
|
36
|
+
}
|
|
37
|
+
const packageId: string = await SellercraftAPI.packMarketplaceOrder(sellercraft, {
|
|
38
|
+
...orderInformation,
|
|
39
|
+
context: { state: { domain: this?.domain, user: this?.user } }
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
releaseGood.packageId = packageId
|
|
43
|
+
releaseGood.updater = this.user
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return releaseGood
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async updateSellercraftStock(sellercraft: Sellercraft, orderProducts: OrderProduct[], type: string): Promise<void> {
|
|
50
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
51
|
+
let disableUpdateStock: boolean =
|
|
52
|
+
sellercraftSetting?.disableUpdateStock && sellercraftSetting?.disableUpdateStock == 1 ? true : false
|
|
53
|
+
|
|
54
|
+
if (!disableUpdateStock) {
|
|
55
|
+
for (var i = 0; i < orderProducts.length; i++) {
|
|
56
|
+
const orderProduct: OrderProduct = orderProducts[i]
|
|
57
|
+
|
|
58
|
+
const product: Product = orderProduct.product
|
|
59
|
+
const pendingAssignOPs: OrderProduct[] = await this.trxMgr.getRepository(OrderProduct).find({
|
|
60
|
+
where: {
|
|
61
|
+
domain: { id: this.domain.id },
|
|
62
|
+
bizplace: orderProduct.bizplace,
|
|
63
|
+
product,
|
|
64
|
+
status: ORDER_PRODUCT_STATUS.PENDING_ASSIGN
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const productDetails: ProductDetail[] = product.productDetails
|
|
69
|
+
|
|
70
|
+
let totalUnassignReleaseQty: number = 0
|
|
71
|
+
if (pendingAssignOPs?.length) {
|
|
72
|
+
totalUnassignReleaseQty = pendingAssignOPs.reduce((total, currentValue) => {
|
|
73
|
+
total += currentValue.releaseQty
|
|
74
|
+
return total
|
|
75
|
+
}, 0)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let qb = await this.trxMgr.getRepository(Inventory).createQueryBuilder('inv')
|
|
79
|
+
qb.leftJoinAndSelect('inv.location', 'loc')
|
|
80
|
+
.andWhere('"inv"."domain_id" = :domainId')
|
|
81
|
+
.andWhere('"inv"."product_id" = :productId')
|
|
82
|
+
.andWhere('"inv"."bizplace_id" = :bizplaceId')
|
|
83
|
+
.andWhere('"inv"."status" = :status')
|
|
84
|
+
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
85
|
+
.setParameters({
|
|
86
|
+
domainId: this.domain.id,
|
|
87
|
+
productId: product.id,
|
|
88
|
+
bizplaceId: orderProduct.bizplace.id,
|
|
89
|
+
status: INVENTORY_STATUS.STORED,
|
|
90
|
+
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
let inventories: Inventory[] = await qb.getMany()
|
|
94
|
+
|
|
95
|
+
let defaultProductDetail: ProductDetail
|
|
96
|
+
const sellercraftInvs: any[] = await Promise.all(
|
|
97
|
+
inventories.map(async (inventory: Inventory) => {
|
|
98
|
+
const inventoryPackingType: string = inventory.packingType
|
|
99
|
+
defaultProductDetail = product.productDetails.find(productDetail => productDetail.isDefault)
|
|
100
|
+
|
|
101
|
+
let packingSize: number = 1
|
|
102
|
+
if (inventoryPackingType !== defaultProductDetail.packingType) {
|
|
103
|
+
const unmatchingProductDetail: ProductDetail = product.productDetails.find(
|
|
104
|
+
productDetail => productDetail.packingType === inventoryPackingType
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
packingSize = await this.getChildPackingSize(
|
|
108
|
+
productDetails,
|
|
109
|
+
defaultProductDetail,
|
|
110
|
+
unmatchingProductDetail
|
|
111
|
+
)
|
|
112
|
+
if (packingSize == 0) packingSize = 1
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return { totalQty: inventory.qty * packingSize, totalLockedQty: inventory.lockedQty * packingSize }
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
let inventoryTotalQty: number = sellercraftInvs.reduce((total, currentValue) => {
|
|
120
|
+
total += currentValue.totalQty
|
|
121
|
+
return total
|
|
122
|
+
}, 0)
|
|
123
|
+
|
|
124
|
+
let inventoryTotalLockedQty: number = sellercraftInvs.reduce((total, currentValue) => {
|
|
125
|
+
total += currentValue.totalLockedQty
|
|
126
|
+
return total
|
|
127
|
+
}, 0)
|
|
128
|
+
|
|
129
|
+
switch (type) {
|
|
130
|
+
case 'CONFIRM_ORDER':
|
|
131
|
+
inventoryTotalQty -= totalUnassignReleaseQty
|
|
132
|
+
break
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const sellercraftInv: any[] = [
|
|
136
|
+
{
|
|
137
|
+
sku: product.sku,
|
|
138
|
+
gtin: defaultProductDetail.gtin,
|
|
139
|
+
stock: {
|
|
140
|
+
quantity_total: inventoryTotalQty,
|
|
141
|
+
quantity_reserved: inventoryTotalLockedQty,
|
|
142
|
+
unit_of_measure: 'EA'
|
|
143
|
+
},
|
|
144
|
+
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
145
|
+
package_dimensions: {
|
|
146
|
+
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
147
|
+
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
148
|
+
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
await SellercraftAPI.updateProduct(sellercraft, {
|
|
154
|
+
context: { state: { domain: this?.domain, user: this?.user } },
|
|
155
|
+
accountId: sellercraft.accountId,
|
|
156
|
+
sellercraftInv
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async checkExistingReleaseGood(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<void> {
|
|
163
|
+
const { refNo, refNo2 } = releaseGood
|
|
164
|
+
|
|
165
|
+
const sellercraftDomain: Domain = await this.trxMgr.getRepository(Domain).findOne({
|
|
166
|
+
where: { id: sellercraft.domainId }
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const customerBizplace: Bizplace = await this.trxMgr.getRepository(Bizplace).findOne({
|
|
170
|
+
where: { domain: { id: sellercraftDomain.id } }
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const foundReleaseGood: ReleaseGood = await this.trxMgr.getRepository(ReleaseGood).findOne({
|
|
174
|
+
where: { bizplace: { id: customerBizplace.id }, refNo, refNo2 }
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
if (foundReleaseGood)
|
|
178
|
+
throw new Error(
|
|
179
|
+
'Existing release order found, kindly use update release order API if you tend to update the order information'
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
}
|