cardus 0.0.8 → 0.0.10
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/.eslintrc +9 -1
- package/dist/index.js +3 -2
- package/dist/insertTempShipment/index.js +2 -2
- package/dist/types/index.js +24 -0
- package/index.ts +7 -3
- package/insertTempShipment/index.ts +4 -4
- package/package.json +1 -1
- package/types/index.ts +27 -0
package/.eslintrc
CHANGED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
},
|
|
7
7
|
"plugins": ["@typescript-eslint"],
|
|
8
8
|
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
|
9
|
-
"rules": {
|
|
9
|
+
"rules": {
|
|
10
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
11
|
+
"@typescript-eslint/no-misused-promises": [
|
|
12
|
+
"error",
|
|
13
|
+
{
|
|
14
|
+
"checksVoidReturn": false
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
10
18
|
"env": {
|
|
11
19
|
"browser": false,
|
|
12
20
|
"es2021": true
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ class IntegrationManager {
|
|
|
40
40
|
this.insertTempShipment = (_b) => __awaiter(this, [_b], void 0, function* ({ order, agencyId, warehouseId, sellerAddress, idUsuario }) {
|
|
41
41
|
const tempShipmentData = yield (0, insertTempShipment_1.cookTempShipment)({
|
|
42
42
|
order,
|
|
43
|
-
|
|
43
|
+
shipmentType: this.shipmentType,
|
|
44
44
|
agencyId,
|
|
45
45
|
warehouseId,
|
|
46
46
|
sellerAddress,
|
|
@@ -79,6 +79,7 @@ class IntegrationManager {
|
|
|
79
79
|
addressesService: params.addressesService,
|
|
80
80
|
countriesService: params.countriesService
|
|
81
81
|
};
|
|
82
|
+
this.shipmentType = params.shipmentType;
|
|
82
83
|
this.type = params.type;
|
|
83
84
|
this.executionManager = params.executionManager;
|
|
84
85
|
this.findNextPickupDate = params.findNextPickupDate;
|
|
@@ -103,7 +104,7 @@ class IntegrationManager {
|
|
|
103
104
|
const parsedOrder = modificarOrdenOriginal({ originalOrder: order });
|
|
104
105
|
const duplicatedTempShipment = yield integrationsService.checkDuplicateTempShipment(parsedOrder.codigoEnvioExterno, idUsuario);
|
|
105
106
|
if (duplicatedTempShipment)
|
|
106
|
-
|
|
107
|
+
throw new Error('Envio Duplicado');
|
|
107
108
|
return this.insertOrder({
|
|
108
109
|
order: parsedOrder,
|
|
109
110
|
agencyId,
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.cookTempShipment = void 0;
|
|
16
16
|
const moment_1 = __importDefault(require("moment"));
|
|
17
|
-
const cookTempShipment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ order,
|
|
17
|
+
const cookTempShipment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ order, shipmentType, agencyId, warehouseId, sellerAddress, idUsuario, findNextPickupDate, countriesService }) {
|
|
18
18
|
let zonaLLegada = {};
|
|
19
19
|
if (order.codigoPaisLLegada)
|
|
20
20
|
zonaLLegada = yield countriesService.getCountryFromCountryCode(order.codigoPaisLLegada);
|
|
@@ -101,7 +101,7 @@ const cookTempShipment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ or
|
|
|
101
101
|
});
|
|
102
102
|
const setBultos = (order) => ({
|
|
103
103
|
num_bultos: warehouseId ? 0 : order.lineas.length,
|
|
104
|
-
tipo_envio:
|
|
104
|
+
tipo_envio: shipmentType,
|
|
105
105
|
codigo_envio_externo: order.codigoEnvioExterno,
|
|
106
106
|
id_almacen: warehouseId
|
|
107
107
|
});
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shipmentTypes = {
|
|
4
|
+
NORMAL: 1,
|
|
5
|
+
EXCEL: 7,
|
|
6
|
+
RECTIFICATIVO: 8,
|
|
7
|
+
PRESTASHOP_MODULE: 15,
|
|
8
|
+
API: 16,
|
|
9
|
+
EBAY: 17,
|
|
10
|
+
ABONO: 18,
|
|
11
|
+
WOOCOMMERCE: 19,
|
|
12
|
+
ALIEXPRESS: 22,
|
|
13
|
+
SHOPIFY: 23,
|
|
14
|
+
ECWID: 31,
|
|
15
|
+
CARGOS: 40,
|
|
16
|
+
DAILY_PICKUP: 50,
|
|
17
|
+
FLASH_SHIPMENT: 51,
|
|
18
|
+
WITHDRAWALL: 52,
|
|
19
|
+
SHIPMENT_SCHEME: 53,
|
|
20
|
+
PRESTASHOP: 115,
|
|
21
|
+
AMAZON: 118,
|
|
22
|
+
JOOM: 119,
|
|
23
|
+
HOLDED: 120,
|
|
24
|
+
ETSY: 121,
|
|
25
|
+
NORMAL_V2: 122
|
|
26
|
+
};
|
package/index.ts
CHANGED
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
Type,
|
|
14
14
|
SellerAddress,
|
|
15
15
|
OriginalOrder,
|
|
16
|
-
ModifiedOrder
|
|
16
|
+
ModifiedOrder,
|
|
17
|
+
ShipmentType
|
|
17
18
|
} from './types';
|
|
18
19
|
|
|
19
20
|
interface Services {
|
|
@@ -27,12 +28,14 @@ export class IntegrationManager {
|
|
|
27
28
|
type: Type;
|
|
28
29
|
executionManager: ExecutionManager;
|
|
29
30
|
findNextPickupDate: FindNextPickupDate;
|
|
31
|
+
shipmentType: ShipmentType;
|
|
30
32
|
|
|
31
33
|
constructor(params: {
|
|
32
34
|
integrationsService: IntegrationsService;
|
|
33
35
|
addressesService: AddressesService;
|
|
34
36
|
countriesService: CountriesService;
|
|
35
37
|
type: Type;
|
|
38
|
+
shipmentType: ShipmentType;
|
|
36
39
|
executionManager: ExecutionManager;
|
|
37
40
|
findNextPickupDate: FindNextPickupDate;
|
|
38
41
|
}) {
|
|
@@ -41,6 +44,7 @@ export class IntegrationManager {
|
|
|
41
44
|
addressesService: params.addressesService,
|
|
42
45
|
countriesService: params.countriesService
|
|
43
46
|
};
|
|
47
|
+
this.shipmentType = params.shipmentType;
|
|
44
48
|
this.type = params.type;
|
|
45
49
|
this.executionManager = params.executionManager;
|
|
46
50
|
this.findNextPickupDate = params.findNextPickupDate;
|
|
@@ -78,7 +82,7 @@ export class IntegrationManager {
|
|
|
78
82
|
parsedOrder.codigoEnvioExterno,
|
|
79
83
|
idUsuario
|
|
80
84
|
);
|
|
81
|
-
if (duplicatedTempShipment)
|
|
85
|
+
if (duplicatedTempShipment) throw new Error('Envio Duplicado');
|
|
82
86
|
|
|
83
87
|
return this.insertOrder({
|
|
84
88
|
order: parsedOrder,
|
|
@@ -162,7 +166,7 @@ export class IntegrationManager {
|
|
|
162
166
|
}) => {
|
|
163
167
|
const tempShipmentData = await cookTempShipment({
|
|
164
168
|
order,
|
|
165
|
-
|
|
169
|
+
shipmentType: this.shipmentType,
|
|
166
170
|
agencyId,
|
|
167
171
|
warehouseId,
|
|
168
172
|
sellerAddress,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
ShipmentType,
|
|
4
4
|
Shipment,
|
|
5
5
|
ModifiedOrder,
|
|
6
6
|
CountriesService,
|
|
@@ -12,7 +12,7 @@ type ZonaLLegada = { nombre_pais: string; id_pais: number };
|
|
|
12
12
|
|
|
13
13
|
export const cookTempShipment = async ({
|
|
14
14
|
order,
|
|
15
|
-
|
|
15
|
+
shipmentType,
|
|
16
16
|
agencyId,
|
|
17
17
|
warehouseId,
|
|
18
18
|
sellerAddress,
|
|
@@ -21,7 +21,7 @@ export const cookTempShipment = async ({
|
|
|
21
21
|
countriesService
|
|
22
22
|
}: {
|
|
23
23
|
order: ModifiedOrder;
|
|
24
|
-
|
|
24
|
+
shipmentType: ShipmentType;
|
|
25
25
|
agencyId: number;
|
|
26
26
|
warehouseId: number;
|
|
27
27
|
sellerAddress: SellerAddress;
|
|
@@ -142,7 +142,7 @@ export const cookTempShipment = async ({
|
|
|
142
142
|
|
|
143
143
|
const setBultos = (order: ModifiedOrder) => ({
|
|
144
144
|
num_bultos: warehouseId ? 0 : order.lineas.length,
|
|
145
|
-
tipo_envio:
|
|
145
|
+
tipo_envio: shipmentType,
|
|
146
146
|
codigo_envio_externo: order.codigoEnvioExterno,
|
|
147
147
|
id_almacen: warehouseId
|
|
148
148
|
});
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -36,6 +36,33 @@ export type Shipment = {
|
|
|
36
36
|
id_almacen: number;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const shipmentTypes = {
|
|
40
|
+
NORMAL: 1,
|
|
41
|
+
EXCEL: 7,
|
|
42
|
+
RECTIFICATIVO: 8,
|
|
43
|
+
PRESTASHOP_MODULE: 15,
|
|
44
|
+
API: 16,
|
|
45
|
+
EBAY: 17,
|
|
46
|
+
ABONO: 18,
|
|
47
|
+
WOOCOMMERCE: 19,
|
|
48
|
+
ALIEXPRESS: 22,
|
|
49
|
+
SHOPIFY: 23,
|
|
50
|
+
ECWID: 31,
|
|
51
|
+
CARGOS: 40,
|
|
52
|
+
DAILY_PICKUP: 50,
|
|
53
|
+
FLASH_SHIPMENT: 51,
|
|
54
|
+
WITHDRAWALL: 52,
|
|
55
|
+
SHIPMENT_SCHEME: 53,
|
|
56
|
+
PRESTASHOP: 115,
|
|
57
|
+
AMAZON: 118,
|
|
58
|
+
JOOM: 119,
|
|
59
|
+
HOLDED: 120,
|
|
60
|
+
ETSY: 121,
|
|
61
|
+
NORMAL_V2: 122
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type ShipmentType = (typeof shipmentTypes)[keyof typeof shipmentTypes];
|
|
65
|
+
|
|
39
66
|
export type Bulto = {
|
|
40
67
|
id_envio: number;
|
|
41
68
|
bulto: {
|