@things-factory/operato-hub 6.1.83 → 6.1.85
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 +46 -46
- package/server/controllers/bizplace-initializer/codes.ts +0 -32
- package/server/controllers/bizplace-initializer/dataset/codes.ts +0 -398
- package/server/controllers/bizplace-initializer/dataset/groups.ts +0 -21
- package/server/controllers/bizplace-initializer/dataset/index.ts +0 -5
- package/server/controllers/bizplace-initializer/dataset/menus.ts +0 -500
- package/server/controllers/bizplace-initializer/dataset/roles-privileges.ts +0 -402
- package/server/controllers/bizplace-initializer/dataset/settings.ts +0 -91
- package/server/controllers/bizplace-initializer/generate-bizplace-domain-roles.ts +0 -29
- package/server/controllers/bizplace-initializer/generate-bizplace-domain.ts +0 -56
- package/server/controllers/bizplace-initializer/groups.ts +0 -19
- package/server/controllers/bizplace-initializer/index.ts +0 -5
- package/server/controllers/bizplace-initializer/menus.ts +0 -42
- package/server/controllers/bizplace-initializer/settings.ts +0 -20
- package/server/controllers/company-initializer/business-register.ts +0 -59
- package/server/controllers/company-initializer/codes.ts +0 -147
- package/server/controllers/company-initializer/generate-company-roles.ts +0 -119
- package/server/controllers/company-initializer/index.ts +0 -6
- package/server/controllers/company-initializer/menus.ts +0 -359
- package/server/controllers/company-initializer/settings.ts +0 -33
- package/server/controllers/company-initializer/transporter.ts +0 -20
- package/server/controllers/index.ts +0 -0
- package/server/controllers/invitation.ts +0 -132
- package/server/controllers/utils/make-invitation-token.ts +0 -5
- package/server/controllers/utils/save-invitation-token.ts +0 -9
- package/server/entities/index.ts +0 -0
- package/server/errors/index.ts +0 -1
- package/server/errors/validation-error.ts +0 -17
- package/server/graphql/index.ts +0 -7
- package/server/graphql/resolvers/generators/generate-bizplace.ts +0 -40
- package/server/graphql/resolvers/generators/generate-company.ts +0 -76
- package/server/graphql/resolvers/generators/index.ts +0 -9
- package/server/graphql/resolvers/generators/update-domain-extType.ts +0 -55
- package/server/graphql/resolvers/index.ts +0 -8
- package/server/graphql/resolvers/invitations/index.ts +0 -5
- package/server/graphql/resolvers/invitations/partner-invitation.ts +0 -62
- package/server/graphql/resolvers/oauth2/company-roles-by-scope.ts +0 -38
- package/server/graphql/resolvers/oauth2/index.ts +0 -5
- package/server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.ts +0 -180
- package/server/graphql/resolvers/synchronization/create-dat-shipments.ts +0 -64
- package/server/graphql/resolvers/synchronization/fetch-sync-invoices.ts +0 -52
- package/server/graphql/resolvers/synchronization/fetch-sync-products.ts +0 -99
- package/server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.ts +0 -75
- package/server/graphql/resolvers/synchronization/index.ts +0 -26
- package/server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.ts +0 -91
- package/server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.ts +0 -39
- package/server/graphql/resolvers/synchronization/sync-products-from-account.ts +0 -40
- package/server/graphql/resolvers/synchronization/sync-products-to-account.ts +0 -64
- package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +0 -176
- package/server/graphql/types/generators/generate-bizplace-input.ts +0 -11
- package/server/graphql/types/generators/generate-company-input.ts +0 -11
- package/server/graphql/types/generators/index.ts +0 -11
- package/server/graphql/types/generators/update-domain-type-input.ts +0 -8
- package/server/graphql/types/index.ts +0 -10
- package/server/graphql/types/invitations/index.ts +0 -5
- package/server/graphql/types/oauth2/company-role.ts +0 -8
- package/server/graphql/types/oauth2/index.ts +0 -7
- package/server/graphql/types/synchronization/index.ts +0 -33
- package/server/graphql/types/synchronization/sync-invoice-list.ts +0 -8
- package/server/graphql/types/synchronization/sync-invoice-set.ts +0 -38
- package/server/graphql/types/synchronization/sync-product-list.ts +0 -8
- package/server/graphql/types/synchronization/sync-product-set.ts +0 -8
- package/server/graphql/types/synchronization/sync-purchase-order-list.ts +0 -8
- package/server/graphql/types/synchronization/sync-purchase-order-set.ts +0 -28
- package/server/index.ts +0 -37
- package/server/middlewares/business-middleware.ts +0 -32
- package/server/middlewares/index.ts +0 -20
- package/server/middlewares/store-middleware.ts +0 -36
- package/server/middlewares/warehouse-middleware.ts +0 -36
- package/server/migrations/1597668478399-SeedBusinessDomain.ts +0 -34
- package/server/migrations/1597668478401-SeedBusinessRoles.ts +0 -377
- package/server/migrations/1608009991065-SeedUser.ts +0 -64
- package/server/migrations/index.ts +0 -9
- package/server/routers/api/index.ts +0 -3
- package/server/routers/api/restful-apis/unstable/add-contact-point.ts +0 -89
- package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +0 -198
- package/server/routers/api/restful-apis/unstable/add-inbound-order.ts +0 -246
- package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +0 -171
- package/server/routers/api/restful-apis/unstable/add-products.ts +0 -112
- package/server/routers/api/restful-apis/unstable/add-release-order.ts +0 -1061
- package/server/routers/api/restful-apis/unstable/add-sales-invoice.ts +0 -144
- package/server/routers/api/restful-apis/unstable/bizplace.ts +0 -45
- package/server/routers/api/restful-apis/unstable/cancel-marketplace-order.ts +0 -81
- package/server/routers/api/restful-apis/unstable/cancel-release-order.ts +0 -91
- package/server/routers/api/restful-apis/unstable/get-contact-point-list.ts +0 -110
- package/server/routers/api/restful-apis/unstable/get-delivery-order-detail.ts +0 -46
- package/server/routers/api/restful-apis/unstable/get-delivery-order-list.ts +0 -121
- package/server/routers/api/restful-apis/unstable/get-delivery-orders.ts +0 -178
- package/server/routers/api/restful-apis/unstable/get-goods-received-notes.ts +0 -134
- package/server/routers/api/restful-apis/unstable/get-inbound-order-detail.ts +0 -128
- package/server/routers/api/restful-apis/unstable/get-inbound-order-list.ts +0 -126
- package/server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.ts +0 -99
- package/server/routers/api/restful-apis/unstable/get-inventory-product-group.ts +0 -107
- package/server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.ts +0 -156
- package/server/routers/api/restful-apis/unstable/get-marketplace-store-list.ts +0 -81
- package/server/routers/api/restful-apis/unstable/get-onhand-inventories.ts +0 -125
- package/server/routers/api/restful-apis/unstable/get-partners.ts +0 -26
- package/server/routers/api/restful-apis/unstable/get-products.ts +0 -216
- package/server/routers/api/restful-apis/unstable/get-release-order-detail.ts +0 -138
- package/server/routers/api/restful-apis/unstable/get-release-order-list.ts +0 -199
- package/server/routers/api/restful-apis/unstable/get-warehouses.ts +0 -19
- package/server/routers/api/restful-apis/unstable/index.ts +0 -32
- package/server/routers/api/restful-apis/unstable/reject-inbound-order.ts +0 -46
- package/server/routers/api/restful-apis/unstable/set-marketplace-order-delivered.ts +0 -60
- package/server/routers/api/restful-apis/unstable/set-marketplace-order-failed-delivery.ts +0 -60
- package/server/routers/api/restful-apis/unstable/update-marketplace-order.ts +0 -111
- package/server/routers/api/restful-apis/unstable/update-marketplace-shipping-order.ts +0 -107
- package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +0 -94
- package/server/routers/api/restful-apis/v1/add-contact-point.ts +0 -77
- package/server/routers/api/restful-apis/v1/add-draft-release-order.ts +0 -196
- package/server/routers/api/restful-apis/v1/add-inbound-order.ts +0 -243
- package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +0 -172
- package/server/routers/api/restful-apis/v1/add-products.ts +0 -112
- package/server/routers/api/restful-apis/v1/add-release-order.ts +0 -967
- package/server/routers/api/restful-apis/v1/bizplace.ts +0 -45
- package/server/routers/api/restful-apis/v1/cancel-marketplace-order.ts +0 -81
- package/server/routers/api/restful-apis/v1/cancel-release-order.ts +0 -91
- package/server/routers/api/restful-apis/v1/get-contact-point-list.ts +0 -110
- package/server/routers/api/restful-apis/v1/get-delivery-order-detail.ts +0 -46
- package/server/routers/api/restful-apis/v1/get-delivery-order-list.ts +0 -121
- package/server/routers/api/restful-apis/v1/get-delivery-orders.ts +0 -178
- package/server/routers/api/restful-apis/v1/get-goods-received-notes.ts +0 -134
- package/server/routers/api/restful-apis/v1/get-inbound-order-detail.ts +0 -128
- package/server/routers/api/restful-apis/v1/get-inbound-order-list.ts +0 -126
- package/server/routers/api/restful-apis/v1/get-inventory-overall-product-group.ts +0 -99
- package/server/routers/api/restful-apis/v1/get-inventory-product-group.ts +0 -112
- package/server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.ts +0 -156
- package/server/routers/api/restful-apis/v1/get-marketplace-store-list.ts +0 -81
- package/server/routers/api/restful-apis/v1/get-onhand-inventories.ts +0 -125
- package/server/routers/api/restful-apis/v1/get-partners.ts +0 -26
- package/server/routers/api/restful-apis/v1/get-products.ts +0 -216
- package/server/routers/api/restful-apis/v1/get-release-order-detail.ts +0 -134
- package/server/routers/api/restful-apis/v1/get-release-order-list.ts +0 -198
- package/server/routers/api/restful-apis/v1/get-warehouses.ts +0 -19
- package/server/routers/api/restful-apis/v1/index.ts +0 -31
- package/server/routers/api/restful-apis/v1/reject-inbound-order.ts +0 -46
- package/server/routers/api/restful-apis/v1/set-marketplace-order-delivered.ts +0 -60
- package/server/routers/api/restful-apis/v1/set-marketplace-order-failed-delivery.ts +0 -60
- package/server/routers/api/restful-apis/v1/update-marketplace-order.ts +0 -111
- package/server/routers/api/restful-apis/v1/update-marketplace-shipping-order.ts +0 -104
- package/server/routers/api/restful-apis/v1/update-release-order-details.ts +0 -94
- package/server/routers/api/restful-apis/v2/add-contact-point.ts +0 -77
- package/server/routers/api/restful-apis/v2/add-draft-release-order.ts +0 -196
- package/server/routers/api/restful-apis/v2/add-inbound-order.ts +0 -243
- package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +0 -172
- package/server/routers/api/restful-apis/v2/add-products.ts +0 -112
- package/server/routers/api/restful-apis/v2/add-release-order.ts +0 -967
- package/server/routers/api/restful-apis/v2/bizplace.ts +0 -45
- package/server/routers/api/restful-apis/v2/cancel-marketplace-order.ts +0 -81
- package/server/routers/api/restful-apis/v2/cancel-release-order.ts +0 -91
- package/server/routers/api/restful-apis/v2/get-contact-point-list.ts +0 -110
- package/server/routers/api/restful-apis/v2/get-delivery-order-detail.ts +0 -46
- package/server/routers/api/restful-apis/v2/get-delivery-order-list.ts +0 -121
- package/server/routers/api/restful-apis/v2/get-delivery-orders.ts +0 -178
- package/server/routers/api/restful-apis/v2/get-goods-received-notes.ts +0 -134
- package/server/routers/api/restful-apis/v2/get-inbound-order-detail.ts +0 -128
- package/server/routers/api/restful-apis/v2/get-inbound-order-list.ts +0 -126
- package/server/routers/api/restful-apis/v2/get-inventory-overall-product-group.ts +0 -99
- package/server/routers/api/restful-apis/v2/get-inventory-product-group.ts +0 -112
- package/server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.ts +0 -156
- package/server/routers/api/restful-apis/v2/get-marketplace-store-list.ts +0 -81
- package/server/routers/api/restful-apis/v2/get-onhand-inventories.ts +0 -125
- package/server/routers/api/restful-apis/v2/get-partners.ts +0 -26
- package/server/routers/api/restful-apis/v2/get-products.ts +0 -216
- package/server/routers/api/restful-apis/v2/get-release-order-detail.ts +0 -134
- package/server/routers/api/restful-apis/v2/get-release-order-list.ts +0 -198
- package/server/routers/api/restful-apis/v2/get-warehouses.ts +0 -19
- package/server/routers/api/restful-apis/v2/index.ts +0 -31
- package/server/routers/api/restful-apis/v2/reject-inbound-order.ts +0 -46
- package/server/routers/api/restful-apis/v2/set-marketplace-order-delivered.ts +0 -60
- package/server/routers/api/restful-apis/v2/set-marketplace-order-failed-delivery.ts +0 -60
- package/server/routers/api/restful-apis/v2/update-marketplace-order.ts +0 -111
- package/server/routers/api/restful-apis/v2/update-marketplace-shipping-order.ts +0 -104
- package/server/routers/api/restful-apis/v2/update-release-order-details.ts +0 -94
- package/server/routers/auth-invitation-router.ts +0 -25
- package/server/routers/business/bizplace-register-router.ts +0 -31
- package/server/routers/business/business-register-router.ts +0 -32
- package/server/routers/business/index.ts +0 -3
- package/server/routers/business/path-base-business-router.ts +0 -15
- package/server/routes.ts +0 -28
- package/server/templates/account-unlock-email.ts +0 -64
- package/server/templates/invitation-email.ts +0 -65
- package/server/templates/reset-password-email.ts +0 -64
- package/server/templates/verification-email.ts +0 -65
- package/server/utils/build-map.ts +0 -18
- package/server/utils/get-warehouses.ts +0 -115
- package/server/utils/index.ts +0 -3
- package/server/utils/order-no-generator.ts +0 -8
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
import { EntityManager, getConnection } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
5
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
6
|
-
import { OrderInventory } from '@things-factory/sales-base'
|
|
7
|
-
|
|
8
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
9
|
-
import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
|
|
10
|
-
|
|
11
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-draft-release-order')
|
|
12
|
-
|
|
13
|
-
router.post(
|
|
14
|
-
'/unstable/warehouse/:warehouseId/add-draft-release-order',
|
|
15
|
-
businessMiddleware,
|
|
16
|
-
warehouseMiddleware,
|
|
17
|
-
async (context, next) => {
|
|
18
|
-
return await getConnection().transaction(async (tx: EntityManager) => {
|
|
19
|
-
const { client, domain, application } = context.state
|
|
20
|
-
const { warehouseId: customerBizplaceId } = context.params
|
|
21
|
-
const { t } = context
|
|
22
|
-
|
|
23
|
-
if (!customerBizplaceId) context.throw(404, t('error.warehouse id not found'))
|
|
24
|
-
|
|
25
|
-
let bodyReq = context.request.body
|
|
26
|
-
if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
|
|
27
|
-
context.throw(400, t('error.invalid body request format'))
|
|
28
|
-
}
|
|
29
|
-
debug('post:/add-draft-release-order request.body', bodyReq)
|
|
30
|
-
await checkMandatoryKey(context, bodyReq)
|
|
31
|
-
|
|
32
|
-
// get customer company's bizplace
|
|
33
|
-
const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
34
|
-
where: { id: customerBizplaceId }
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const orderInventories: OrderInventory[] = bodyReq.orderInventories
|
|
38
|
-
|
|
39
|
-
context.body = {
|
|
40
|
-
result: (
|
|
41
|
-
await client.mutate({
|
|
42
|
-
mutation: gql`
|
|
43
|
-
mutation upsertDraftReleaseGood(
|
|
44
|
-
$draftReleaseGood: DraftReleaseGoodPatch!
|
|
45
|
-
$orderProducts: [OrderProductPatch!]!
|
|
46
|
-
$files: [Upload!]
|
|
47
|
-
) {
|
|
48
|
-
upsertDraftReleaseGood(
|
|
49
|
-
draftReleaseGood: $draftReleaseGood
|
|
50
|
-
orderProducts: $orderProducts
|
|
51
|
-
files: $files
|
|
52
|
-
) {
|
|
53
|
-
id
|
|
54
|
-
name
|
|
55
|
-
refNo
|
|
56
|
-
refNo2
|
|
57
|
-
refNo3
|
|
58
|
-
status
|
|
59
|
-
truckNo
|
|
60
|
-
ownTransport
|
|
61
|
-
marketplaceOrderStatus
|
|
62
|
-
billingAddress
|
|
63
|
-
deliveryAddress1
|
|
64
|
-
deliveryAddress2
|
|
65
|
-
deliveryAddress3
|
|
66
|
-
deliveryAddress4
|
|
67
|
-
deliveryAddress5
|
|
68
|
-
attentionTo
|
|
69
|
-
attentionCompany
|
|
70
|
-
city
|
|
71
|
-
state
|
|
72
|
-
postalCode
|
|
73
|
-
country
|
|
74
|
-
phone1
|
|
75
|
-
phone2
|
|
76
|
-
email
|
|
77
|
-
type
|
|
78
|
-
exportOption
|
|
79
|
-
releaseDate
|
|
80
|
-
collectionOrderNo
|
|
81
|
-
bizplace {
|
|
82
|
-
name
|
|
83
|
-
}
|
|
84
|
-
orderProducts {
|
|
85
|
-
product {
|
|
86
|
-
sku
|
|
87
|
-
name
|
|
88
|
-
description
|
|
89
|
-
}
|
|
90
|
-
packingType
|
|
91
|
-
packingSize
|
|
92
|
-
releaseQty
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
`,
|
|
97
|
-
variables: {
|
|
98
|
-
draftReleaseGood: {
|
|
99
|
-
bizplace: {
|
|
100
|
-
id: customerBizplace.id
|
|
101
|
-
},
|
|
102
|
-
courierOption: bodyReq.courierOption,
|
|
103
|
-
collectionOrderNo: bodyReq.collectionOrderNo,
|
|
104
|
-
exportOption: bodyReq.exportOption,
|
|
105
|
-
ownTransport: bodyReq.ownTransport,
|
|
106
|
-
packingOption: bodyReq.packingOption,
|
|
107
|
-
refNo: bodyReq.refNo,
|
|
108
|
-
refNo2: bodyReq?.refNo2,
|
|
109
|
-
refNo3: bodyReq?.refNo3,
|
|
110
|
-
releaseDate: bodyReq.releaseDate,
|
|
111
|
-
type: bodyReq.type,
|
|
112
|
-
marketplaceOrderStatus: bodyReq?.marketplaceOrderStatus,
|
|
113
|
-
remark: bodyReq?.remark || null,
|
|
114
|
-
billingAddress: bodyReq?.billTo?.billingAddress || null,
|
|
115
|
-
deliveryAddress1: bodyReq?.deliverTo?.deliveryAddress1 || null,
|
|
116
|
-
deliveryAddress2: bodyReq?.deliverTo?.deliveryAddress2 || null,
|
|
117
|
-
deliveryAddress3: bodyReq?.deliverTo?.deliveryAddress3 || null,
|
|
118
|
-
deliveryAddress4: bodyReq?.deliverTo?.deliveryAddress4 || null,
|
|
119
|
-
deliveryAddress5: bodyReq?.deliverTo?.deliveryAddress5 || null,
|
|
120
|
-
attentionTo: bodyReq?.deliverTo?.attentionTo || null,
|
|
121
|
-
attentionCompany: bodyReq?.deliverTo?.attentionCompany || null,
|
|
122
|
-
city: bodyReq?.deliverTo?.city || null,
|
|
123
|
-
state: bodyReq?.deliverTo?.state || null,
|
|
124
|
-
postalCode: bodyReq?.deliverTo?.postalCode || null,
|
|
125
|
-
country: bodyReq?.deliverTo?.country || null,
|
|
126
|
-
phone1: bodyReq?.deliverTo?.phone1 || null,
|
|
127
|
-
phone2: bodyReq?.deliverTo?.phone2 || null,
|
|
128
|
-
email: bodyReq?.deliverTo?.email || null,
|
|
129
|
-
packageId: bodyReq?.packageId || null,
|
|
130
|
-
source: application?.type || null
|
|
131
|
-
},
|
|
132
|
-
orderProducts: orderInventories,
|
|
133
|
-
files: []
|
|
134
|
-
},
|
|
135
|
-
context: {
|
|
136
|
-
...context,
|
|
137
|
-
hasUpload: true,
|
|
138
|
-
state: {
|
|
139
|
-
...context.state,
|
|
140
|
-
customerBizplace,
|
|
141
|
-
domain,
|
|
142
|
-
type: 'api'
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} as any)
|
|
146
|
-
).data
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
export async function checkMandatoryKey(context, params) {
|
|
153
|
-
let noparams = ['releaseDate', 'exportOption'].filter(param => !(param in params))
|
|
154
|
-
|
|
155
|
-
if ('ownTransport' in params) {
|
|
156
|
-
if (params.ownTransport == true) {
|
|
157
|
-
if (!params.hasOwnProperty('collectionOrderNo')) {
|
|
158
|
-
noparams.push('collectionOrderNo')
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
noparams.push('ownTransport')
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if ('exportOption' in params) {
|
|
166
|
-
if (params.exportOption === true) {
|
|
167
|
-
if (
|
|
168
|
-
params.exportOption.filter(
|
|
169
|
-
record =>
|
|
170
|
-
!record.containerNo || !record.containerArrivalDate || !record.containerLeavingDate || !record.shipName
|
|
171
|
-
).length
|
|
172
|
-
) {
|
|
173
|
-
noparams.push('exportOption')
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if ('orderInventories' in params) {
|
|
179
|
-
params.orderInventories.forEach((param, key) => {
|
|
180
|
-
let noSubParams = []
|
|
181
|
-
|
|
182
|
-
if (!param?.releaseQty) noSubParams.push('releaseQty')
|
|
183
|
-
|
|
184
|
-
if (!param?.product) noSubParams.push('product')
|
|
185
|
-
|
|
186
|
-
if (noSubParams?.length)
|
|
187
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
|
|
188
|
-
})
|
|
189
|
-
} else {
|
|
190
|
-
noparams.push('orderInventories')
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (noparams?.length) {
|
|
194
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return params
|
|
198
|
-
}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
5
|
-
import { Bizplace, ContactPoint, getCompanyBizplace } from '@things-factory/biz-base'
|
|
6
|
-
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
7
|
-
import { getRepository } from '@things-factory/shell'
|
|
8
|
-
|
|
9
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
10
|
-
import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
|
|
11
|
-
|
|
12
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-inbound-order')
|
|
13
|
-
|
|
14
|
-
router.post(
|
|
15
|
-
'/unstable/warehouse/:warehouseId/add-inbound-order',
|
|
16
|
-
businessMiddleware,
|
|
17
|
-
warehouseMiddleware,
|
|
18
|
-
async (context, next) => {
|
|
19
|
-
const { client, domain, application } = context.state
|
|
20
|
-
const { warehouseId } = context.params
|
|
21
|
-
const { t } = context
|
|
22
|
-
const attachments = undefined
|
|
23
|
-
let bodyReq = context.request.body
|
|
24
|
-
|
|
25
|
-
if (!warehouseId) context.throw(404, t('error.warehouse id not found'))
|
|
26
|
-
|
|
27
|
-
if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
|
|
28
|
-
context.throw(400, t('error.invalid body request format'))
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await checkMandatoryKey(context, bodyReq)
|
|
32
|
-
debug('post:/add-inbound-order request.body', bodyReq)
|
|
33
|
-
|
|
34
|
-
// get customer company's bizplace
|
|
35
|
-
const custCompanyBizplace: Bizplace = await getCompanyBizplace(null, null, warehouseId)
|
|
36
|
-
const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({
|
|
37
|
-
where: { id: warehouseId }
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
//#1 to get all product list
|
|
41
|
-
const productDetails: ProductDetail[] = await getRepository(ProductDetail).find({
|
|
42
|
-
where: {
|
|
43
|
-
domain: { id: custCompanyBizplace.domain.id },
|
|
44
|
-
refCode: In(bodyReq.orderProducts.map(orderProduct => orderProduct.product.sku))
|
|
45
|
-
},
|
|
46
|
-
relations: ['product']
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
//#2 assign product id found to order product
|
|
50
|
-
let orderProducts: any[] = []
|
|
51
|
-
bodyReq.orderProducts.map(orderProduct => {
|
|
52
|
-
productDetails.forEach(productDetail => {
|
|
53
|
-
const product: Product = productDetail.product
|
|
54
|
-
const packingType: string = productDetail.packingType
|
|
55
|
-
const packingSize: number = productDetail.packingSize
|
|
56
|
-
|
|
57
|
-
if (orderProduct.product.sku === productDetail.refCode) {
|
|
58
|
-
orderProduct.product.id = product.id
|
|
59
|
-
|
|
60
|
-
if (packingType) {
|
|
61
|
-
orderProduct.packingType = packingType
|
|
62
|
-
orderProduct.packingSize = packingSize
|
|
63
|
-
orderProduct.uom = productDetail.uom
|
|
64
|
-
orderProduct.uomValue = productDetail.uomValue
|
|
65
|
-
orderProduct.totalUomValue = `${(productDetail.uomValue * orderProduct.packQty).toFixed(2)} ${
|
|
66
|
-
productDetail.uom
|
|
67
|
-
}`
|
|
68
|
-
} else {
|
|
69
|
-
productDetail = productDetails.find(productDetail => productDetail.isDefault)
|
|
70
|
-
|
|
71
|
-
orderProduct.packingType = productDetail.packingType
|
|
72
|
-
orderProduct.packingSize = productDetail.packingSize
|
|
73
|
-
orderProduct.uom = productDetail.uom
|
|
74
|
-
orderProduct.uomValue = productDetail.uomValue
|
|
75
|
-
orderProduct.totalUomValue = `${(productDetail.uomValue * orderProduct.packQty).toFixed(2)} ${
|
|
76
|
-
productDetail.uom
|
|
77
|
-
}`
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
if (orderProduct.product?.id) orderProducts.push({ ...orderProduct })
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
if (!orderProducts?.length) {
|
|
86
|
-
context.throw(404, t(`no matching product found`))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//#4 include supplier id if there's any
|
|
90
|
-
if (bodyReq?.supplier) {
|
|
91
|
-
const supplierInfo = bodyReq.supplier
|
|
92
|
-
const foundSupplier: ContactPoint = await getRepository(ContactPoint).findOne({
|
|
93
|
-
where: {
|
|
94
|
-
domain: { id: domain.id },
|
|
95
|
-
bizplace: warehouseId,
|
|
96
|
-
name: supplierInfo.name,
|
|
97
|
-
companyName: supplierInfo.companyName,
|
|
98
|
-
email: supplierInfo.email,
|
|
99
|
-
accountNo: supplierInfo.accountNo,
|
|
100
|
-
type: 'SUPPLIER'
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
if (foundSupplier) bodyReq.supplier = foundSupplier.id
|
|
105
|
-
else context.throw(404, t('error.supplier not found'))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
context.body = {
|
|
109
|
-
result: (
|
|
110
|
-
await client.mutate({
|
|
111
|
-
mutation: gql`
|
|
112
|
-
mutation addArrivalNotice($arrivalNotice: NewArrivalNotice!, $attachments: Upload) {
|
|
113
|
-
addArrivalNotice(arrivalNotice: $arrivalNotice, file: $attachments) {
|
|
114
|
-
name
|
|
115
|
-
refNo
|
|
116
|
-
etaDate
|
|
117
|
-
containerNo
|
|
118
|
-
ownTransport
|
|
119
|
-
crossDocking
|
|
120
|
-
releaseGood {
|
|
121
|
-
name
|
|
122
|
-
}
|
|
123
|
-
etaDate
|
|
124
|
-
looseItem
|
|
125
|
-
deliveryOrderNo
|
|
126
|
-
status
|
|
127
|
-
truckNo
|
|
128
|
-
refNo
|
|
129
|
-
importCargo
|
|
130
|
-
orderProducts {
|
|
131
|
-
batchId
|
|
132
|
-
product {
|
|
133
|
-
sku
|
|
134
|
-
name
|
|
135
|
-
description
|
|
136
|
-
packingType
|
|
137
|
-
type
|
|
138
|
-
}
|
|
139
|
-
packingType
|
|
140
|
-
uom
|
|
141
|
-
uomValue
|
|
142
|
-
packQty
|
|
143
|
-
totalUomValue
|
|
144
|
-
palletQty
|
|
145
|
-
}
|
|
146
|
-
orderVass {
|
|
147
|
-
vas {
|
|
148
|
-
name
|
|
149
|
-
operationGuide
|
|
150
|
-
operationGuideType
|
|
151
|
-
}
|
|
152
|
-
set
|
|
153
|
-
targetType
|
|
154
|
-
targetBatchId
|
|
155
|
-
targetProduct {
|
|
156
|
-
name
|
|
157
|
-
description
|
|
158
|
-
}
|
|
159
|
-
packingType
|
|
160
|
-
qty
|
|
161
|
-
uomValue
|
|
162
|
-
otherTarget
|
|
163
|
-
description
|
|
164
|
-
remark
|
|
165
|
-
operationGuide
|
|
166
|
-
}
|
|
167
|
-
supplier {
|
|
168
|
-
companyName
|
|
169
|
-
name
|
|
170
|
-
phone
|
|
171
|
-
email
|
|
172
|
-
address
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
`,
|
|
177
|
-
variables: {
|
|
178
|
-
arrivalNotice: { ...bodyReq, orderProducts, warehouseId, source: application?.type },
|
|
179
|
-
attachments
|
|
180
|
-
},
|
|
181
|
-
context: {
|
|
182
|
-
...context,
|
|
183
|
-
hasUpload: true,
|
|
184
|
-
state: {
|
|
185
|
-
...context.state,
|
|
186
|
-
bizplace: customerBizplace,
|
|
187
|
-
domain,
|
|
188
|
-
type: 'api'
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
} as any)
|
|
192
|
-
).data
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
export function checkMandatoryKey(context, params) {
|
|
198
|
-
let noparams = []
|
|
199
|
-
|
|
200
|
-
if ('container' in params) {
|
|
201
|
-
if (params.container === true) {
|
|
202
|
-
if (!params.hasOwnProperty('containerNo') || !params.hasOwnProperty('containerSize')) {
|
|
203
|
-
noparams.push('containerInfo')
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if ('orderProducts' in params) {
|
|
209
|
-
params.orderProducts.forEach((param, key) => {
|
|
210
|
-
let noSubParams = []
|
|
211
|
-
|
|
212
|
-
if (!param.batchId) noSubParams.push('batchId')
|
|
213
|
-
|
|
214
|
-
if (!param.packQty) noSubParams.push('packQty')
|
|
215
|
-
|
|
216
|
-
if (!param.product.sku) noSubParams.push('sku')
|
|
217
|
-
|
|
218
|
-
if (noSubParams?.length)
|
|
219
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
|
|
220
|
-
})
|
|
221
|
-
} else {
|
|
222
|
-
noparams.push('orderProducts')
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if ('etaDate' in params) {
|
|
226
|
-
const etaDate = new Date(params.etaDate)
|
|
227
|
-
|
|
228
|
-
if (isNaN(etaDate.getDate())) context.throw(400, context.t('error.eta date is invalid'))
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if ('supplier' in params) {
|
|
232
|
-
const supplierInfo = params.supplier
|
|
233
|
-
if (!supplierInfo?.name)
|
|
234
|
-
context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.name' }))
|
|
235
|
-
if (!supplierInfo?.companyName)
|
|
236
|
-
context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.companyName' }))
|
|
237
|
-
if (!supplierInfo?.email)
|
|
238
|
-
context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.email' }))
|
|
239
|
-
if (!supplierInfo?.accountNo)
|
|
240
|
-
context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.accountNo' }))
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (noparams.length > 0) {
|
|
244
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/** Customer list to inform when there are changes */
|
|
2
|
-
/** 1. Bridzia */
|
|
3
|
-
/** 2. Sweetmag */
|
|
4
|
-
|
|
5
|
-
import gql from 'graphql-tag'
|
|
6
|
-
import { EntityManager, getConnection } from 'typeorm'
|
|
7
|
-
|
|
8
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
9
|
-
import { createPayloadLog, PayloadType } from '@things-factory/integration-base'
|
|
10
|
-
import { MarketplaceOrder } from '@things-factory/marketplace-base'
|
|
11
|
-
|
|
12
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
13
|
-
import { storeMiddleware } from '../../../../middlewares/store-middleware'
|
|
14
|
-
|
|
15
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-marketplace-order')
|
|
16
|
-
const apiVersion = 'unstable'
|
|
17
|
-
|
|
18
|
-
router.post(
|
|
19
|
-
`/${apiVersion}/warehouse/:storeId/add-marketplace-order`,
|
|
20
|
-
businessMiddleware,
|
|
21
|
-
storeMiddleware,
|
|
22
|
-
async (context, next) => {
|
|
23
|
-
return await getConnection().transaction(async (tx: EntityManager) => {
|
|
24
|
-
const { client, marketplaceStore, domain } = context.state
|
|
25
|
-
const { t } = context
|
|
26
|
-
const bodyReq = context.request.body
|
|
27
|
-
|
|
28
|
-
if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
|
|
29
|
-
context.throw(400, t('error.invalid body request format'))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await checkMandatoryKey(context, bodyReq)
|
|
33
|
-
debug('post:/add-marketplace-order body request', bodyReq)
|
|
34
|
-
|
|
35
|
-
let existingMarketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
36
|
-
where: { name: bodyReq.name, domain: { id: domain.id }, marketplaceStore: { id: marketplaceStore.id } }
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
if (existingMarketplaceOrder) {
|
|
40
|
-
context.throw(400, `error.duplicate entry for order ${bodyReq.name}`)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
context.body = {
|
|
44
|
-
result: (
|
|
45
|
-
await client.mutate({
|
|
46
|
-
mutation: gql`
|
|
47
|
-
mutation generateMarketplaceOrder($marketplaceOrder: NewMarketplaceOrder!) {
|
|
48
|
-
generateMarketplaceOrder(marketplaceOrder: $marketplaceOrder) {
|
|
49
|
-
id
|
|
50
|
-
orderNo
|
|
51
|
-
currency
|
|
52
|
-
itemCount
|
|
53
|
-
totalAmount
|
|
54
|
-
paymentMethod
|
|
55
|
-
remark
|
|
56
|
-
giftOption
|
|
57
|
-
orderCreatedAt
|
|
58
|
-
orderUpdatedAt
|
|
59
|
-
marketplaceStore {
|
|
60
|
-
storeId
|
|
61
|
-
}
|
|
62
|
-
marketplaceOrderItems {
|
|
63
|
-
id
|
|
64
|
-
name
|
|
65
|
-
qty
|
|
66
|
-
cancelBy
|
|
67
|
-
returnStatus
|
|
68
|
-
paidPrice
|
|
69
|
-
packageId
|
|
70
|
-
invoiceNo
|
|
71
|
-
status
|
|
72
|
-
marketplaceOrderShippingItems {
|
|
73
|
-
marketplaceOrderShipping {
|
|
74
|
-
attentionTo
|
|
75
|
-
address1
|
|
76
|
-
address2
|
|
77
|
-
address3
|
|
78
|
-
address4
|
|
79
|
-
address5
|
|
80
|
-
state
|
|
81
|
-
city
|
|
82
|
-
postCode
|
|
83
|
-
country
|
|
84
|
-
phone1
|
|
85
|
-
phone2
|
|
86
|
-
email
|
|
87
|
-
orderType
|
|
88
|
-
freightType
|
|
89
|
-
parcelType
|
|
90
|
-
goodsType
|
|
91
|
-
deliveryMethod
|
|
92
|
-
totalWeight
|
|
93
|
-
totalVolume
|
|
94
|
-
transporter
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
marketplaceProductVariation {
|
|
98
|
-
id
|
|
99
|
-
sku
|
|
100
|
-
variationId
|
|
101
|
-
variationSku
|
|
102
|
-
channelSku
|
|
103
|
-
name
|
|
104
|
-
costPrice
|
|
105
|
-
sellPrice
|
|
106
|
-
marketplaceStatus
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`,
|
|
112
|
-
variables: { marketplaceOrder: bodyReq },
|
|
113
|
-
context: {
|
|
114
|
-
...context,
|
|
115
|
-
state: {
|
|
116
|
-
...context.state,
|
|
117
|
-
marketplaceStore,
|
|
118
|
-
domain,
|
|
119
|
-
type: 'api'
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} as any)
|
|
123
|
-
).data
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
createPayloadLog(
|
|
127
|
-
marketplaceStore.id,
|
|
128
|
-
`/${apiVersion}/warehouse/:storeId/add-marketplace-order`,
|
|
129
|
-
bodyReq,
|
|
130
|
-
context.body.result,
|
|
131
|
-
context,
|
|
132
|
-
PayloadType.INGESTION
|
|
133
|
-
)
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
export function checkMandatoryKey(context, params) {
|
|
139
|
-
let noparams = []
|
|
140
|
-
|
|
141
|
-
if (!params?.orderNo) {
|
|
142
|
-
noparams.push('orderNo')
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (!params?.status) {
|
|
146
|
-
noparams.push('status')
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (params.marketplaceOrderItems) {
|
|
150
|
-
params.marketplaceOrderItems.forEach(param => {
|
|
151
|
-
let noSubParams = []
|
|
152
|
-
|
|
153
|
-
if (!param?.qty) noSubParams.push('qty')
|
|
154
|
-
|
|
155
|
-
if (!param?.status) noSubParams.push('status')
|
|
156
|
-
|
|
157
|
-
if (!param?.marketplaceProductVariation) noSubParams.push('marketplaceProductVariation')
|
|
158
|
-
|
|
159
|
-
if (!param?.marketplaceProductVariation?.variationId) noSubParams.push('variationId')
|
|
160
|
-
|
|
161
|
-
if (noSubParams?.length)
|
|
162
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
|
|
163
|
-
})
|
|
164
|
-
} else {
|
|
165
|
-
noparams.push('marketplaceOrderItems')
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (noparams.length > 0) {
|
|
169
|
-
context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
|
|
170
|
-
}
|
|
171
|
-
}
|