@things-factory/operato-mms 4.3.671 → 4.3.675
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/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/entities/index.js +5 -0
- package/dist-server/entities/index.js.map +1 -0
- package/dist-server/graphql/index.js +33 -0
- package/dist-server/graphql/index.js.map +1 -0
- package/dist-server/graphql/resolvers/index.js +32 -0
- package/dist-server/graphql/resolvers/index.js.map +1 -0
- package/dist-server/graphql/resolvers/interface-with-hub/add-release-order.js +242 -0
- package/dist-server/graphql/resolvers/interface-with-hub/add-release-order.js.map +1 -0
- package/dist-server/graphql/resolvers/interface-with-hub/auto-add-release-order.js +218 -0
- package/dist-server/graphql/resolvers/interface-with-hub/auto-add-release-order.js.map +1 -0
- package/dist-server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.js +159 -0
- package/dist-server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.js.map +1 -0
- package/dist-server/graphql/resolvers/interface-with-hub/generate-replenishment-order.js +27 -0
- package/dist-server/graphql/resolvers/interface-with-hub/generate-replenishment-order.js.map +1 -0
- package/dist-server/graphql/resolvers/interface-with-hub/index.js +12 -0
- package/dist-server/graphql/resolvers/interface-with-hub/index.js.map +1 -0
- package/dist-server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.js +157 -0
- package/dist-server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.js.map +1 -0
- package/dist-server/graphql/resolvers/shipping-provider/index.js +6 -0
- package/dist-server/graphql/resolvers/shipping-provider/index.js.map +1 -0
- package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js +32 -0
- package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js.map +1 -0
- package/dist-server/graphql/resolvers/warehouse-product/auto-link-warehouse-marketplace-product-variations.js +63 -0
- package/dist-server/graphql/resolvers/warehouse-product/auto-link-warehouse-marketplace-product-variations.js.map +1 -0
- package/dist-server/graphql/resolvers/warehouse-product/index.js +6 -0
- package/dist-server/graphql/resolvers/warehouse-product/index.js.map +1 -0
- package/dist-server/graphql/types/index.js +33 -0
- package/dist-server/graphql/types/index.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/index.js +29 -0
- package/dist-server/graphql/types/interface-with-hub/index.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/new-stock-replenishment.js +34 -0
- package/dist-server/graphql/types/interface-with-hub/new-stock-replenishment.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/replenishment-order-product.js +50 -0
- package/dist-server/graphql/types/interface-with-hub/replenishment-order-product.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/stock-replenishment-list.js +16 -0
- package/dist-server/graphql/types/interface-with-hub/stock-replenishment-list.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/stock-replenishment.js +47 -0
- package/dist-server/graphql/types/interface-with-hub/stock-replenishment.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/warehouse-inventory.js +17 -0
- package/dist-server/graphql/types/interface-with-hub/warehouse-inventory.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/warehouse-marketplace-product-list.js +14 -0
- package/dist-server/graphql/types/interface-with-hub/warehouse-marketplace-product-list.js.map +1 -0
- package/dist-server/graphql/types/interface-with-hub/warehouse-marketplace-product.js +20 -0
- package/dist-server/graphql/types/interface-with-hub/warehouse-marketplace-product.js.map +1 -0
- package/dist-server/graphql/types/shipping-provider/index.js +10 -0
- package/dist-server/graphql/types/shipping-provider/index.js.map +1 -0
- package/dist-server/graphql/types/shipping-provider/shipping-provider-list.js +13 -0
- package/dist-server/graphql/types/shipping-provider/shipping-provider-list.js.map +1 -0
- package/dist-server/graphql/types/shipping-provider/shipping-provider.js +13 -0
- package/dist-server/graphql/types/shipping-provider/shipping-provider.js.map +1 -0
- package/dist-server/graphql/types/warehouse-product/index.js +11 -0
- package/dist-server/graphql/types/warehouse-product/index.js.map +1 -0
- package/dist-server/graphql/types/warehouse-product/warehouse-product.js +12 -0
- package/dist-server/graphql/types/warehouse-product/warehouse-product.js.map +1 -0
- package/dist-server/index.js +34 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/middlewares/index.js +4 -0
- package/dist-server/middlewares/index.js.map +1 -0
- package/dist-server/migrations/1599732967233-SeedCommonCode.js +52 -0
- package/dist-server/migrations/1599732967233-SeedCommonCode.js.map +1 -0
- package/dist-server/migrations/1608009991075-SeedUser.js +51 -0
- package/dist-server/migrations/1608009991075-SeedUser.js.map +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routers/etrax-router.js +155 -0
- package/dist-server/routers/etrax-router.js.map +1 -0
- package/dist-server/routers/shopify-pos-public-router.js +109 -0
- package/dist-server/routers/shopify-pos-public-router.js.map +1 -0
- package/dist-server/routes.js +11 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/util/interface-helper.js +53 -0
- package/dist-server/util/interface-helper.js.map +1 -0
- package/dist-server/util/no-generator.js +14 -0
- package/dist-server/util/no-generator.js.map +1 -0
- package/package.json +33 -33
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.etraxRouter = void 0;
|
|
7
|
+
const koa_router_1 = __importDefault(require("koa-router"));
|
|
8
|
+
const typeorm_1 = require("typeorm");
|
|
9
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
10
|
+
const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
|
|
11
|
+
const integration_lmd_1 = require("@things-factory/integration-lmd");
|
|
12
|
+
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
|
13
|
+
const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
14
|
+
const shell_1 = require("@things-factory/shell");
|
|
15
|
+
const debug = require('debug')('things-factory:jest.config');
|
|
16
|
+
exports.etraxRouter = new koa_router_1.default();
|
|
17
|
+
exports.etraxRouter.post(`/lmd/etrax/status_update`, async (context, next) => {
|
|
18
|
+
const repo = (0, typeorm_1.getRepository)(integration_lmd_1.LastMileDelivery);
|
|
19
|
+
const requestBody = context.request.body;
|
|
20
|
+
debug('etrax_status_update/context: ', context);
|
|
21
|
+
const bodyToken = requestBody.Token;
|
|
22
|
+
const bodyTimestamp = requestBody.TimeStamp;
|
|
23
|
+
const bodySourceID = requestBody.SourceID;
|
|
24
|
+
const extOrderNo = requestBody.ExtOrderNo;
|
|
25
|
+
const trackingNo = requestBody.TrackingNo;
|
|
26
|
+
const status = requestBody.Status;
|
|
27
|
+
const awbUrl = requestBody.AWBurl;
|
|
28
|
+
const customerCode = bodySourceID;
|
|
29
|
+
const lmd = await repo.findOne({
|
|
30
|
+
where: { clientName: customerCode, platform: 'eTrax' }
|
|
31
|
+
});
|
|
32
|
+
debug(lmd);
|
|
33
|
+
const secretKey = lmd.secretKey;
|
|
34
|
+
if (customerCode === '' || secretKey === '') {
|
|
35
|
+
//Cant find the correct record
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const etrax = new integration_lmd_1.Etrax(customerCode);
|
|
39
|
+
debug('RequestBody: ', requestBody);
|
|
40
|
+
//Validate Token
|
|
41
|
+
const validate = await etrax.validateToken(bodyToken, 'UPDATE_STATUS', bodyTimestamp);
|
|
42
|
+
debug('IsAuthenticated: ', validate);
|
|
43
|
+
if (!validate) {
|
|
44
|
+
//Return unauthorized
|
|
45
|
+
const resp = {
|
|
46
|
+
Status: 'ERROR',
|
|
47
|
+
Code: 302,
|
|
48
|
+
Message: 'Validate failed',
|
|
49
|
+
OrderNo: extOrderNo,
|
|
50
|
+
ExtOrderNo: extOrderNo,
|
|
51
|
+
TrackingNo: trackingNo
|
|
52
|
+
};
|
|
53
|
+
context.type = 'application/json';
|
|
54
|
+
context.body = JSON.stringify(resp);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
//TAS - Transporter Assignment Success
|
|
58
|
+
if (status === 'TAS') {
|
|
59
|
+
//Update DB if Validate Success
|
|
60
|
+
const orderRepo = (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceOrder);
|
|
61
|
+
const orderShippingRepo = (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceOrderShipping);
|
|
62
|
+
let order = await orderRepo.findOne({
|
|
63
|
+
where: { orderNo: extOrderNo },
|
|
64
|
+
relations: [
|
|
65
|
+
'domain',
|
|
66
|
+
'marketplaceStore',
|
|
67
|
+
'marketplaceOrderItems',
|
|
68
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
69
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping',
|
|
70
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping.fulfillmentCenter',
|
|
71
|
+
'marketplaceOrderItems.marketplaceProductVariation',
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
let orderItems = order.marketplaceOrderItems;
|
|
75
|
+
const marketplaceStore = order.marketplaceStore;
|
|
76
|
+
const marketplaceTransporter = await (0, typeorm_1.getRepository)(integration_marketplace_1.MarketplaceTransporter).findOne({
|
|
77
|
+
where: { marketplaceStore },
|
|
78
|
+
relations: ['pickupTransporter']
|
|
79
|
+
});
|
|
80
|
+
for (const orderItem of orderItems) {
|
|
81
|
+
if (orderItem.marketplaceOrderShippingItems[0].marketplaceOrderShipping !== null) {
|
|
82
|
+
const orderShippingItems = orderItem.marketplaceOrderShippingItems;
|
|
83
|
+
const orderShipping = orderShippingItems[0].marketplaceOrderShipping;
|
|
84
|
+
const fulfillmentCenter = orderShipping === null || orderShipping === void 0 ? void 0 : orderShipping.fulfillmentCenter;
|
|
85
|
+
const currentDate = new Date();
|
|
86
|
+
const centerId = fulfillmentCenter.centerId;
|
|
87
|
+
const warehouseDomain = await (0, typeorm_1.getRepository)(shell_1.Domain).findOne({ where: { subdomain: centerId } });
|
|
88
|
+
const customerBizplaces = await (0, biz_base_1.getCustomerBizplaces)(warehouseDomain);
|
|
89
|
+
const customerBizplaceId = customerBizplaces.find(customerBizplace => customerBizplace.company.domain.id == (order === null || order === void 0 ? void 0 : order.domain.id)).id;
|
|
90
|
+
let patch = {
|
|
91
|
+
id: orderShipping.releaseOrderId,
|
|
92
|
+
trackingNo: trackingNo,
|
|
93
|
+
transporter: marketplaceTransporter === null || marketplaceTransporter === void 0 ? void 0 : marketplaceTransporter.pickupTransporter.name
|
|
94
|
+
};
|
|
95
|
+
integration_fulfillment_1.FulfillmentAPI.updateReleaseGoodDetails(fulfillmentCenter, {
|
|
96
|
+
customerBizplaceId,
|
|
97
|
+
releaseOrder: Object.assign({}, patch),
|
|
98
|
+
shippingOrder: null
|
|
99
|
+
});
|
|
100
|
+
await orderShippingRepo.update({ id: orderShipping.id }, { trackingNo: trackingNo, airwayBill: awbUrl, updatedAt: currentDate, transporter: (marketplaceTransporter === null || marketplaceTransporter === void 0 ? void 0 : marketplaceTransporter.pickupTransporter.name) || orderShipping.transporter });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// to-do update tracking no to every marketplaces
|
|
104
|
+
if (marketplaceStore.platform === 'woocommerce' || marketplaceStore.platform === 'shopify') {
|
|
105
|
+
const note = 'http://ets.sntglobal.com/?mod=tracking&action=index&orders=' + trackingNo;
|
|
106
|
+
let orderInfo = await (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceOrder).findOne({
|
|
107
|
+
where: {
|
|
108
|
+
name: order.name
|
|
109
|
+
},
|
|
110
|
+
relations: ['marketplaceOrderItems', 'marketplaceOrderItems.marketplaceProductVariation']
|
|
111
|
+
});
|
|
112
|
+
const result = await integration_marketplace_1.StoreAPI.setStoreOrderStatusReadyToShip(marketplaceStore, {
|
|
113
|
+
orderId: order.name,
|
|
114
|
+
trackingUrl: note,
|
|
115
|
+
trackingNo,
|
|
116
|
+
order: orderInfo,
|
|
117
|
+
note,
|
|
118
|
+
transporter: marketplaceTransporter === null || marketplaceTransporter === void 0 ? void 0 : marketplaceTransporter.pickupTransporter.name
|
|
119
|
+
});
|
|
120
|
+
if (marketplaceStore.platform === 'woocommerce') {
|
|
121
|
+
await integration_marketplace_1.StoreAPI.updateOrderStatus(marketplaceStore, {
|
|
122
|
+
orderId: order.name,
|
|
123
|
+
status: 'DELIVERED'
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const updatedOrder = await integration_marketplace_1.StoreAPI.getStoreOrder(marketplaceStore, { orderId: order.name });
|
|
129
|
+
order.status = updatedOrder.status;
|
|
130
|
+
order.orderUpdatedAt = updatedOrder.orderUpdatedAt;
|
|
131
|
+
order.trackingNo = updatedOrder.trackingNo;
|
|
132
|
+
order.shippingProvider = updatedOrder.shippingProvider;
|
|
133
|
+
await (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceOrder).save(order);
|
|
134
|
+
for (let idx = 0; idx < order.marketplaceOrderItems.length; idx++) {
|
|
135
|
+
let matchItem = updatedOrder.orderItems.find(i => i.variationId == order.marketplaceOrderItems[idx].marketplaceProductVariation.variationId);
|
|
136
|
+
if (matchItem) {
|
|
137
|
+
let targetMarketplaceOrderItem = Object.assign(Object.assign({}, order.marketplaceOrderItems[idx]), { shippingProvider: matchItem.shippingProvider, trackingCode: matchItem.trackingNo, status: matchItem.status });
|
|
138
|
+
await (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceOrderItem).save(targetMarketplaceOrderItem);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (e) { }
|
|
143
|
+
const resp = {
|
|
144
|
+
Status: 'SUCCESS',
|
|
145
|
+
Code: 200,
|
|
146
|
+
Message: 'Updated',
|
|
147
|
+
OrderNo: order.orderNo,
|
|
148
|
+
ExtOrderNo: extOrderNo,
|
|
149
|
+
TrackingNo: trackingNo
|
|
150
|
+
};
|
|
151
|
+
context.type = 'application/json';
|
|
152
|
+
context.body = JSON.stringify(resp);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
//# sourceMappingURL=etrax-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"etrax-router.js","sourceRoot":"","sources":["../../server/routers/etrax-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,qCAAuC;AAEvC,uDAAyE;AACzE,qFAA2F;AAC3F,qEAAyE;AACzE,qFAA4G;AAC5G,uEAKyC;AACzC,iDAA8C;AAE9C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAA;AAC/C,QAAA,WAAW,GAAG,IAAI,oBAAM,EAAE,CAAA;AAEvC,mBAAW,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACnE,MAAM,IAAI,GAAG,IAAA,uBAAa,EAAC,kCAAgB,CAAC,CAAA;IAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IACxC,KAAK,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAA;IAE/C,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAA;IACnC,MAAM,aAAa,GAAG,WAAW,CAAC,SAAS,CAAA;IAC3C,MAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAA;IACzC,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAA;IACzC,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAA;IACzC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAA;IACjC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAA;IAEjC,MAAM,YAAY,GAAG,YAAY,CAAA;IACjC,MAAM,GAAG,GAAqB,MAAM,IAAI,CAAC,OAAO,CAAC;QAC/C,KA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MAAM,EAAE,SAAS,CAAC,MAAM,GACzB,CAAA;oBAED,MAAM,IAAA,uBAAa,EAAC,uCAAoB,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;iBAC3E;aACF;SACF;QAAC,OAAM,CAAC,EAAE,GAAE;QAEb,MAAM,IAAI,GAAG;YACX,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,UAAU,EAAE,UAAU;YACtB,UAAU,EAAE,UAAU;SACvB,CAAA;QACD,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAA;QACjC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;KACpC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.shopifyPosPublicRouter = void 0;
|
|
7
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
8
|
+
const env_1 = require("@things-factory/env");
|
|
9
|
+
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
|
10
|
+
const marketplace_base_1 = require("@things-factory/marketplace-base");
|
|
11
|
+
const product_base_1 = require("@things-factory/product-base");
|
|
12
|
+
const warehouse_base_1 = require("@things-factory/warehouse-base");
|
|
13
|
+
const koa_router_1 = __importDefault(require("koa-router"));
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const shopifyConfig = env_1.config.get('marketplaceIntegrationShopify', {});
|
|
16
|
+
const { apiKey, apiSecret } = shopifyConfig;
|
|
17
|
+
exports.shopifyPosPublicRouter = new koa_router_1.default();
|
|
18
|
+
exports.shopifyPosPublicRouter.post('/webhook-shopify/orders/create', async (context, next) => {
|
|
19
|
+
const { request, t } = context;
|
|
20
|
+
const hmac = request.get('x-shopify-hmac-sha256');
|
|
21
|
+
const shopDomain = request.get('x-shopify-shop-domain');
|
|
22
|
+
const shop = shopDomain.replace('.myshopify.com', '');
|
|
23
|
+
const shopify = new integration_marketplace_1.Shopify({ apiKey, apiSecret, shop });
|
|
24
|
+
const marketplaceStore = await (0, typeorm_1.getRepository)(integration_marketplace_1.MarketplaceStore).findOne({
|
|
25
|
+
where: { storeId: shop, status: 'ACTIVE' },
|
|
26
|
+
relations: ['domain']
|
|
27
|
+
});
|
|
28
|
+
if (!marketplaceStore) {
|
|
29
|
+
context.status = 404;
|
|
30
|
+
context.body = t('error.unable to find store account');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const webhookKey = marketplaceStore.webhookKey;
|
|
34
|
+
const verifyMerchant = shopify.verifyWebhook(request, hmac, webhookKey);
|
|
35
|
+
if (!verifyMerchant) {
|
|
36
|
+
context.status = 404;
|
|
37
|
+
context.body = t('error.unable to verify webhook origin');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const data = request.body;
|
|
41
|
+
if (data.source_name === 'pos') {
|
|
42
|
+
const domainCompany = await (0, typeorm_1.getRepository)(biz_base_1.Company).findOne({
|
|
43
|
+
where: { domain: marketplaceStore.domain }
|
|
44
|
+
});
|
|
45
|
+
const bizplaces = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).find({
|
|
46
|
+
where: { company: domainCompany },
|
|
47
|
+
relations: ['domain']
|
|
48
|
+
});
|
|
49
|
+
const warehouseDomains = bizplaces.map((bizplace) => bizplace.domain);
|
|
50
|
+
const selectedWarehouseDomain = warehouseDomains.filter(domain => domain.description === 'default' && domain.extType === 'warehouse');
|
|
51
|
+
const refOrder = { id: data.id, name: data.order_number };
|
|
52
|
+
const lineItems = data.line_items;
|
|
53
|
+
for (var i = 0; i < lineItems.length; i++) {
|
|
54
|
+
const variationId = lineItems[i].variant_id;
|
|
55
|
+
var itemQty = lineItems[i].quantity;
|
|
56
|
+
var itemUomValue = 0;
|
|
57
|
+
const marketplaceProductVariation = await (0, typeorm_1.getRepository)(marketplace_base_1.MarketplaceProductVariation).findOne({
|
|
58
|
+
where: {
|
|
59
|
+
variationId,
|
|
60
|
+
domain: marketplaceStore.domain
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const warehouseProduct = await (0, typeorm_1.getRepository)(product_base_1.Product).findOne({
|
|
64
|
+
where: {
|
|
65
|
+
sku: marketplaceProductVariation.sku
|
|
66
|
+
},
|
|
67
|
+
relations: ['bizplace']
|
|
68
|
+
});
|
|
69
|
+
const inventories = await (0, typeorm_1.getRepository)(warehouse_base_1.Inventory).find({
|
|
70
|
+
where: {
|
|
71
|
+
product: warehouseProduct,
|
|
72
|
+
domain: selectedWarehouseDomain[0],
|
|
73
|
+
status: 'STORED'
|
|
74
|
+
},
|
|
75
|
+
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
|
|
76
|
+
});
|
|
77
|
+
for (var j = 0; j < inventories.length; j++) {
|
|
78
|
+
var inventory = inventories[j];
|
|
79
|
+
if (inventory.qty >= itemQty) {
|
|
80
|
+
itemUomValue = (inventory.uomValue / inventory.qty) * itemQty;
|
|
81
|
+
inventory.qty -= itemQty;
|
|
82
|
+
inventory.uomValue -= itemUomValue;
|
|
83
|
+
await (0, warehouse_base_1.generateInventoryHistory)(inventory, refOrder, warehouse_base_1.INVENTORY_TRANSACTION_TYPE.SALES_ADJUSTMENT, -itemQty, -itemUomValue, null);
|
|
84
|
+
if (inventory.qty === 0) {
|
|
85
|
+
inventory.status = warehouse_base_1.INVENTORY_STATUS.TERMINATED;
|
|
86
|
+
await (0, warehouse_base_1.generateInventoryHistory)(inventory, refOrder, warehouse_base_1.INVENTORY_STATUS.TERMINATED, 0, 0, null);
|
|
87
|
+
}
|
|
88
|
+
itemQty = 0;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
itemQty -= inventory.qty;
|
|
92
|
+
itemUomValue = (inventory.uomValue / inventory.qty) * itemQty;
|
|
93
|
+
inventory.qty -= itemQty;
|
|
94
|
+
inventory.uomValue -= itemUomValue;
|
|
95
|
+
await (0, warehouse_base_1.generateInventoryHistory)(inventory, refOrder, warehouse_base_1.INVENTORY_TRANSACTION_TYPE.SALES_ADJUSTMENT, -itemQty, -itemUomValue, null);
|
|
96
|
+
if (inventory.qty === 0) {
|
|
97
|
+
inventory.status = warehouse_base_1.INVENTORY_STATUS.TERMINATED;
|
|
98
|
+
await (0, warehouse_base_1.generateInventoryHistory)(inventory, refOrder, warehouse_base_1.INVENTORY_STATUS.TERMINATED, 0, 0, null);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (itemQty == 0) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
context.status = 200;
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=shopify-pos-public-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopify-pos-public-router.js","sourceRoot":"","sources":["../../server/routers/shopify-pos-public-router.ts"],"names":[],"mappings":";;;;;;AACA,uDAA4D;AAC5D,6CAA4C;AAC5C,qFAAmF;AACnF,uEAA8E;AAC9E,+DAAsD;AACtD,mEAKuC;AACvC,4DAA+B;AAC/B,qCAAuC;AAEvC,MAAM,aAAa,GAAG,YAAM,CAAC,GAAG,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAA;AACrE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAA;AAE9B,QAAA,sBAAsB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAElD,8BAAsB,CAAC,IAAI,CAAC,gCAAgC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACpF,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IAE9B,MA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AAQ,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAA;oBAC7D,SAAS,CAAC,GAAG,IAAI,OAAO,CAAA;oBACxB,SAAS,CAAC,QAAQ,IAAI,YAAY,CAAA;oBAElC,MAAM,IAAA,yCAAwB,EAC5B,SAAS,EACT,QAAQ,EACR,2CAA0B,CAAC,gBAAgB,EAC3C,CAAC,OAAO,EACR,CAAC,YAAY,EACb,IAAI,CACL,CAAA;oBAED,IAAI,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE;wBACvB,SAAS,CAAC,MAAM,GAAG,iCAAgB,CAAC,UAAU,CAAA;wBAE9C,MAAM,IAAA,yCAAwB,EAAC,SAAS,EAAE,QAAQ,EAAE,iCAAgB,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;qBAC7F;iBACF;gBAED,IAAI,OAAO,IAAI,CAAC,EAAE;oBAChB,MAAK;iBACN;aACF;SACF;KACF;IAED,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;AACtB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shopify_pos_public_router_1 = require("./routers/shopify-pos-public-router");
|
|
4
|
+
const etrax_router_1 = require("./routers/etrax-router");
|
|
5
|
+
const debug = require('debug')('things-factory:operato-mms:routes');
|
|
6
|
+
process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
|
|
7
|
+
globalPublicRouter.use(shopify_pos_public_router_1.shopifyPosPublicRouter.routes(), shopify_pos_public_router_1.shopifyPosPublicRouter.allowedMethods());
|
|
8
|
+
globalPublicRouter.use(etrax_router_1.etraxRouter.routes(), etrax_router_1.etraxRouter.allowedMethods());
|
|
9
|
+
});
|
|
10
|
+
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => { });
|
|
11
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,mFAA4E;AAC5E,yDAAoD;AAEpD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mCAAmC,CAAC,CAAA;AAEnE,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF,kBAAkB,CAAC,GAAG,CAAC,kDAAsB,CAAC,MAAM,EAAE,EAAE,kDAAsB,CAAC,cAAc,EAAE,CAAC,CAAA;IAChG,kBAAkB,CAAC,GAAG,CAAC,0BAAW,CAAC,MAAM,EAAE,EAAE,0BAAW,CAAC,cAAc,EAAE,CAAC,CAAA;AAC5E,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE,GAAE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.interfaceHelper = void 0;
|
|
8
|
+
const env_1 = require("@things-factory/env");
|
|
9
|
+
const oauth2_client_1 = require("@things-factory/oauth2-client");
|
|
10
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
11
|
+
const typeorm_1 = require("typeorm");
|
|
12
|
+
const url_1 = require("url");
|
|
13
|
+
const platforms = ((_a = env_1.config.get('oauth2')) === null || _a === void 0 ? void 0 : _a.platforms) || [];
|
|
14
|
+
const API_URL_MAP = new Map(platforms.map(platform => [platform.name, platform.apiURL]));
|
|
15
|
+
exports.interfaceHelper = {
|
|
16
|
+
async fetch(platform, endPoint, method, context, body) {
|
|
17
|
+
const { domain } = context.state;
|
|
18
|
+
const url = new url_1.URL(API_URL_MAP.get(platform));
|
|
19
|
+
url.host = domain.subdomain + '.' + url.host;
|
|
20
|
+
url.pathname += '/' + endPoint;
|
|
21
|
+
url.pathname.replace(/\/+/g, '/');
|
|
22
|
+
endPoint = decodeURIComponent(url.href);
|
|
23
|
+
const accessToken = await this.getAccessToken(domain);
|
|
24
|
+
const requestInit = {
|
|
25
|
+
method,
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/json',
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
Authorization: `Bearer ${accessToken}`
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (body)
|
|
33
|
+
requestInit.body = JSON.stringify(body);
|
|
34
|
+
const res = await (0, node_fetch_1.default)(endPoint, requestInit);
|
|
35
|
+
if (res.ok) {
|
|
36
|
+
const { result } = await res.json();
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const errorcode = res.status;
|
|
41
|
+
const message = await res.text();
|
|
42
|
+
return { errorcode, message };
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
async getAccessToken(domain) {
|
|
46
|
+
const { accessToken } = await (0, typeorm_1.getRepository)(oauth2_client_1.Oauth2Client).findOne({
|
|
47
|
+
domain,
|
|
48
|
+
name: 'Operato Hub'
|
|
49
|
+
});
|
|
50
|
+
return accessToken;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=interface-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-helper.js","sourceRoot":"","sources":["../../server/util/interface-helper.ts"],"names":[],"mappings":";;;;;;;AAAA,6CAA4C;AAC5C,iEAA4D;AAE5D,4DAA+C;AAC/C,qCAAuC;AACvC,6BAAyB;AAIzB,MAAM,SAAS,GAAuC,CAAA,MAAA,YAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,0CAAE,SAAS,KAAI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,IAAI,EAAE,CAAA;YACnC,OAAO,MAAM,CAAA;SACd;aAAM;YACL,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAA;YAC5B,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;YAChC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;SAC9B;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc;QACjC,MAAM,EAAE,WAAW,EAAE,GAAiB,MAAM,IAAA,uBAAa,EAAC,4BAAY,CAAC,CAAC,OAAO,CAAC;YAC9E,MAAM;YACN,IAAI,EAAE,aAAa;SACpB,CAAC,CAAA;QAEF,OAAO,WAAW,CAAA;IACpB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoGenerator = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
class NoGenerator {
|
|
6
|
+
static id() {
|
|
7
|
+
return `${(0, uuid_1.v4)()}`;
|
|
8
|
+
}
|
|
9
|
+
static sku() {
|
|
10
|
+
return `SKU-${(0, uuid_1.v4)()}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.NoGenerator = NoGenerator;
|
|
14
|
+
//# sourceMappingURL=no-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-generator.js","sourceRoot":"","sources":["../../server/util/no-generator.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAEnC,MAAa,WAAW;IACtB,MAAM,CAAC,EAAE;QACP,OAAO,GAAG,IAAA,SAAM,GAAE,EAAE,CAAA;IACtB,CAAC;IAED,MAAM,CAAC,GAAG;QACR,OAAO,OAAO,IAAA,SAAM,GAAE,EAAE,CAAA;IAC1B,CAAC;CACF;AARD,kCAQC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-mms",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.675",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -59,52 +59,52 @@
|
|
|
59
59
|
"@operato/scene-table": "^0.1.8",
|
|
60
60
|
"@operato/scene-timer": "^0.1.8",
|
|
61
61
|
"@operato/scene-wheel-sorter": "^0.1.8",
|
|
62
|
-
"@things-factory/apptool-ui": "^4.3.
|
|
63
|
-
"@things-factory/attachment-base": "^4.3.
|
|
64
|
-
"@things-factory/auth-ui": "^4.3.
|
|
65
|
-
"@things-factory/biz-base": "^4.3.
|
|
66
|
-
"@things-factory/board-service": "^4.3.
|
|
67
|
-
"@things-factory/board-ui": "^4.3.
|
|
68
|
-
"@things-factory/code-ui": "^4.3.
|
|
69
|
-
"@things-factory/context-ui": "^4.3.
|
|
70
|
-
"@things-factory/dashboard": "^4.3.
|
|
71
|
-
"@things-factory/export-ui": "^4.3.
|
|
72
|
-
"@things-factory/export-ui-csv": "^4.3.
|
|
73
|
-
"@things-factory/export-ui-excel": "^4.3.
|
|
74
|
-
"@things-factory/geography": "^4.3.
|
|
75
|
-
"@things-factory/grist-ui": "^4.3.
|
|
76
|
-
"@things-factory/help": "^4.3.
|
|
77
|
-
"@things-factory/i18n-base": "^4.3.
|
|
78
|
-
"@things-factory/import-ui": "^4.3.
|
|
79
|
-
"@things-factory/import-ui-excel": "^4.3.
|
|
80
|
-
"@things-factory/integration-fulfillment": "^4.3.
|
|
81
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
82
|
-
"@things-factory/lite-menu": "^4.3.
|
|
83
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
84
|
-
"@things-factory/more-ui": "^4.3.
|
|
85
|
-
"@things-factory/notification": "^4.3.
|
|
86
|
-
"@things-factory/oauth2-client": "^4.3.
|
|
62
|
+
"@things-factory/apptool-ui": "^4.3.675",
|
|
63
|
+
"@things-factory/attachment-base": "^4.3.675",
|
|
64
|
+
"@things-factory/auth-ui": "^4.3.675",
|
|
65
|
+
"@things-factory/biz-base": "^4.3.675",
|
|
66
|
+
"@things-factory/board-service": "^4.3.675",
|
|
67
|
+
"@things-factory/board-ui": "^4.3.675",
|
|
68
|
+
"@things-factory/code-ui": "^4.3.675",
|
|
69
|
+
"@things-factory/context-ui": "^4.3.675",
|
|
70
|
+
"@things-factory/dashboard": "^4.3.675",
|
|
71
|
+
"@things-factory/export-ui": "^4.3.675",
|
|
72
|
+
"@things-factory/export-ui-csv": "^4.3.675",
|
|
73
|
+
"@things-factory/export-ui-excel": "^4.3.675",
|
|
74
|
+
"@things-factory/geography": "^4.3.675",
|
|
75
|
+
"@things-factory/grist-ui": "^4.3.675",
|
|
76
|
+
"@things-factory/help": "^4.3.675",
|
|
77
|
+
"@things-factory/i18n-base": "^4.3.675",
|
|
78
|
+
"@things-factory/import-ui": "^4.3.675",
|
|
79
|
+
"@things-factory/import-ui-excel": "^4.3.675",
|
|
80
|
+
"@things-factory/integration-fulfillment": "^4.3.675",
|
|
81
|
+
"@things-factory/integration-lmd": "^4.3.675",
|
|
82
|
+
"@things-factory/lite-menu": "^4.3.675",
|
|
83
|
+
"@things-factory/marketplace-base": "^4.3.675",
|
|
84
|
+
"@things-factory/more-ui": "^4.3.675",
|
|
85
|
+
"@things-factory/notification": "^4.3.675",
|
|
86
|
+
"@things-factory/oauth2-client": "^4.3.675",
|
|
87
87
|
"@things-factory/pdf": "^4.3.591",
|
|
88
|
-
"@things-factory/product-base": "^4.3.
|
|
89
|
-
"@things-factory/resource-ui": "^4.3.
|
|
88
|
+
"@things-factory/product-base": "^4.3.675",
|
|
89
|
+
"@things-factory/resource-ui": "^4.3.675",
|
|
90
90
|
"@things-factory/scene-data-transform": "^4.3.591",
|
|
91
91
|
"@things-factory/scene-excel": "^4.3.591",
|
|
92
92
|
"@things-factory/scene-firebase": "^4.3.591",
|
|
93
93
|
"@things-factory/scene-form": "^4.3.591",
|
|
94
94
|
"@things-factory/scene-google-map": "^4.3.591",
|
|
95
95
|
"@things-factory/scene-graphql": "^4.3.591",
|
|
96
|
-
"@things-factory/scene-label": "^4.3.
|
|
96
|
+
"@things-factory/scene-label": "^4.3.675",
|
|
97
97
|
"@things-factory/scene-marker": "^4.3.591",
|
|
98
98
|
"@things-factory/scene-mqtt": "^4.3.591",
|
|
99
99
|
"@things-factory/scene-restful": "^4.3.591",
|
|
100
100
|
"@things-factory/scene-visualizer": "^4.3.591",
|
|
101
|
-
"@things-factory/setting-ui": "^4.3.
|
|
102
|
-
"@things-factory/system-ui": "^4.3.
|
|
103
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
101
|
+
"@things-factory/setting-ui": "^4.3.675",
|
|
102
|
+
"@things-factory/system-ui": "^4.3.675",
|
|
103
|
+
"@things-factory/warehouse-base": "^4.3.675"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@things-factory/builder": "^4.3.591",
|
|
107
107
|
"@types/node-fetch": "^2.5.7"
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "71e1820fa406b37bab179e29d0d08a37ffb68b85"
|
|
110
110
|
}
|