idosell 0.4.16 → 0.4.18

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/changelog.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.18] - 2025-12-18
9
+ - Updated to v7.10
10
+ - Updated utils
11
+ - Fixed dates helper default value
12
+ - Improved typing on empty PHP objects conversion
13
+ - Updated axios
14
+
8
15
  ## [0.4.13] - 2025-10-15
9
16
  ### Changed
10
17
  - Updated to v7.2
package/dist/enums.d.ts CHANGED
@@ -384,12 +384,16 @@ export enum PRODUCT_SIZE_COUNTABLE {
384
384
  AUCTIONS = 'productSizesDispositionsInAuctions',
385
385
  }
386
386
 
387
- export enum PRODUCT_SIZE_STRING {
387
+ export enum PRODUCT_SIZE_CODES {
388
388
  NAME = 'sizePanelName',
389
389
  CODE_PRODUCER = 'productSizeCodeProducer',
390
390
  CODE_EXTERNAL = 'productSizeCodeExternal',
391
- LOCATION = 'stockLocationCode',
392
- LOCATION_CODE = 'stockLocationTextId',
391
+ }
392
+
393
+ export enum PRODUCT_SIZE_LOCATIONS {
394
+ CODE = 'stockLocationCode',
395
+ NAME = 'stockLocationTextId',
396
+ ID = 'stockLocationId'
393
397
  }
394
398
 
395
399
  export enum PRODUCE_SIZE_INDEX {
package/dist/enums.js CHANGED
@@ -384,14 +384,18 @@ var PRODUCT_SIZE_COUNTABLE;
384
384
  PRODUCT_SIZE_COUNTABLE["DELIVERIES"] = "productSizesDeliveries";
385
385
  PRODUCT_SIZE_COUNTABLE["AUCTIONS"] = "productSizesDispositionsInAuctions";
386
386
  })(PRODUCT_SIZE_COUNTABLE || (PRODUCT_SIZE_COUNTABLE = {}));
387
- var PRODUCT_SIZE_STRING;
388
- (function (PRODUCT_SIZE_STRING) {
389
- PRODUCT_SIZE_STRING["NAME"] = "sizePanelName";
390
- PRODUCT_SIZE_STRING["CODE_PRODUCER"] = "productSizeCodeProducer";
391
- PRODUCT_SIZE_STRING["CODE_EXTERNAL"] = "productSizeCodeExternal";
392
- PRODUCT_SIZE_STRING["LOCATION"] = "stockLocationCode";
393
- PRODUCT_SIZE_STRING["LOCATION_CODE"] = "stockLocationTextId";
394
- })(PRODUCT_SIZE_STRING || (PRODUCT_SIZE_STRING = {}));
387
+ var PRODUCT_SIZE_CODES;
388
+ (function (PRODUCT_SIZE_CODES) {
389
+ PRODUCT_SIZE_CODES["NAME"] = "sizePanelName";
390
+ PRODUCT_SIZE_CODES["CODE_PRODUCER"] = "productSizeCodeProducer";
391
+ PRODUCT_SIZE_CODES["CODE_EXTERNAL"] = "productSizeCodeExternal";
392
+ })(PRODUCT_SIZE_CODES || (PRODUCT_SIZE_CODES = {}));
393
+ var PRODUCT_SIZE_LOCATIONS;
394
+ (function (PRODUCT_SIZE_LOCATIONS) {
395
+ PRODUCT_SIZE_LOCATIONS["CODE"] = "stockLocationCode";
396
+ PRODUCT_SIZE_LOCATIONS["NAME"] = "stockLocationTextId";
397
+ PRODUCT_SIZE_LOCATIONS["ID"] = "stockLocationId";
398
+ })(PRODUCT_SIZE_LOCATIONS || (PRODUCT_SIZE_LOCATIONS = {}));
395
399
  var PRODUCE_SIZE_INDEX;
396
400
  (function (PRODUCE_SIZE_INDEX) {
397
401
  PRODUCE_SIZE_INDEX["NAME"] = "sizePanelName";
@@ -406,6 +410,7 @@ export default {
406
410
  RMA_STATUS,
407
411
  PAYMENT_FORMS,
408
412
  PRODUCT_SIZE_COUNTABLE,
409
- PRODUCT_SIZE_STRING,
413
+ PRODUCT_SIZE_CODES,
414
+ PRODUCT_SIZE_LOCATIONS,
410
415
  PRODUCE_SIZE_INDEX
411
416
  };
@@ -1,7 +1,9 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
1
2
  import type { PagableGateway, AppendableGateway, Gateway, DateLike, JSObject } from "./app.d.ts"
2
3
  import type { GetClientsBalanceResponse, BooleanStatusResponse, GetClientsResponse, PostClientsResponse, PutClientsResponse, SearchClientsCrmResponse, GetClientsDeliveryAddressResponse, PostClientsDeliveryAddressResponse, PutClientsDeliveryAddressResponse, VouchersResponse, PutVouchersResponse, SearchClientsGiftcardsResponse, GetClientsGiftcardsTypesResponse, GetClientsMembershipCardsResponse, PutClientsMembershipCardsResponse, SearchClientsNewsletterEmailResponse, SearchClientsNewsletterSmsResponse, GetClientsPayerAddressResponse, PostClientsPayerAddressResponse, PutClientsPayerAddressResponse, GetClientsPricelistsClientsResponse, PutClientsPricelistsClientsResponse, GetClientsPricelistsResponse, PostClientsPricelistsResponse, GetClientsPricelistsProductsResponse, PutClientsPricelistsProductsResponse, GetClientsPricesActiveCardResponse, GetClientsPricesDiscountGroupsResponse, GetClientsPricesDiscountsResponse, PutClientsPricesDiscountsResponse, GetClientsProfitPointsResponse, GetClientsProvinceListResponse, GetClientsTagsResponse, PostClientsTagsResponse, PutClientsTagsResponse, GetConfigVariablesResponse, PutConfigVariablesResponse, GetCouriersAssignedToShippingProfilesResponse, GetCouriersResponse, GetCouriersPickupPointsResponse, PutCouriersPickupPointsResponse, GetCpaCampaignResponse, CmsCampaignResponse, CmsResponse, GetCpaResponse, GetDeliveriesProfilesResponse, GetDeliveriesRegionsResponse, PostDeliveriesRegionsResponse, GetDiscountsGroupsClientsResponse, GetDiscountsGroupsResponse, PostDiscountsGroupsResponse, GetEntriesResponse, PostEntriesResponse, GetEntriesPagesToDisplayResponse, GetEntriesSourcesResponse, GetMenuResponse, PostMenuResponse, PutMenuResponse, PutMenuSortResponse, GetOrdersAnalyticsResponse, GetOrdersAuctionDetailsResponse, PutOrdersCourierResponse, PostOrdersDocumentsCreateResponse, GetOrdersDocumentsResponse, PostOrdersDocumentsResponse, GetOrdersHandlerResponse, GetOrdersHistoryResponse, GetOrdersImagesResponse, PostOrdersImagesResponse, GetOrdersLabelsResponse, SearchOrdersOpinionsResponse, GetOrdersOpinionsRateResponse, SearchOrdersResponse, PostOrdersResponse, PutOrdersResponse, GetOrdersPackagesResponse, PutOrdersPackagesResponse, PutOrdersProductsSerialNumbersResponse, PutOrdersProfitMarginResponse, GetOrdersProfitabilityResponse, GetOrdersStatusesResponse, GetOrdersWarehouseResponse, PostPackagesLabelsResponse, PutPackagesResponse, SearchPackagesResponse, GetPaymentsFormsResponse, GetPaymentsResponse, PostPaymentsResponse, GetPaymentsProfilesResponse, PostPaymentsRepaymentResponse, GetProductsSKUbyBarcodeResponse, PutProductsAttachmentsResponse, GetProductsAuctionsResponse, GetProductsBrandsResponse, PutProductsBrandsResponse, GetProductsCategoriesResponse, PutProductsCategoriesResponse, SearchProductsCategoriesIdosellResponse, GetProductsCodeExistenceResponse, SearchProductsDeliveryTimeResponse, GetProductsDescriptionsResponse, ProductIdentResponse, PutProductsGroupsSettingsResponse, GetProductsIdBySizecodeResponse, PutProductsImagesResponse, GetProductsMarketingPromotionResponse, PostProductsMarketingPromotionResponse, PutProductsMarketingPromotionResponse, GetProductsMarketingZonesResponse, PutProductsMarketingZonesResponse, GetProductsOmnibusPricesResponse, GetProductsOpinionsResponse, PostProductsOpinionsResponse, GetProductsOpinionsRateResponse, PutProductsParametersResponse, SearchProductsParametersResponse, SearchProductsResponse, PostProductsResponse, PutProductsResponse, GetProductsQuestionsResponse, GetProductsReservationsResponse, GetProductsSeriesResponse, PutProductsSeriesResponse, GetProductsSizesResponse, PutProductsSizesResponse, PutProductsStockQuantityResponse, GetProductsStocksResponse, PutProductsStocksResponse, GetProductsStrikethroughPricesResponse, PutProductsSupplierCodeResponse, PutProductsSupplierProductDataResponse, GetResponsibilityEntitiesResponse, PutResponsibilityEntitiesResponse, GetReturnsResponse, PostReturnsResponse, PutReturnsResponse, PutReturnsSerialNumberResponse, GetRmaResponse, PutRmaResponse, GetRmaStatusesResponse, GetShopsCurrenciesResponse, GetShopsLanguagesResponse, GetSizechartsResponse, PutSizechartsResponse, GetSizesResponse, PutSizesResponse, GetSnippetsCampaignResponse, GetSnippetsCookiesResponse, GetSnippetsResponse, GetSystemConfigResponse, GetSystemCurrenciesResponse, PutSystemCurrenciesResponse, GetSystemProcessesAutomationResponse, GetSystemServerLoadResponse, GetSystemServerTimeResponse, GetSystemShopsDataResponse, GetSystemUnitsResponse, PutSystemUnitsResponse, GetSystemUsersResponse, GetVouchersTypesResponse, GetVouchersResponse, GetWarrantiesCountTotalResponse, PutWarrantiesLanguageDataResponse, GetWarrantiesResponse, PutWarrantiesResponse, GetWmsLocationsResponse, GetWmsStocksdocumentsDocumentsResponse, PostWmsStocksdocumentsDocumentsResponse, PutWmsStocksdocumentsDocumentsResponse, GetWmsStocksdocumentsOpenedDocumentsResponse, GetWmsStocksdocumentsProductsResponse, PutWmsStocksdocumentsProductsResponse, GetWmsSuppliersResponse, PutWmsSuppliersResponse } from "./responses.d.ts"
3
4
  import type * as RequestParams from "./reqparams.d.ts";
4
5
  import * as ENUMS from "./enums";
6
+ import utils from "./utils";
5
7
 
6
8
  export interface GetClientsBalanceRequest extends PagableGateway<GetClientsBalanceRequest, GetClientsBalanceResponse> {
7
9
  /** Customer Id */
package/dist/utils.d.ts CHANGED
@@ -1,15 +1,17 @@
1
- import type { PRODUCT_SIZE_COUNTABLE, PRODUCT_SIZE_STRING } from "./enums.d";
1
+ import type { PRODUCT_SIZE_COUNTABLE, PRODUCT_SIZE_LOCATIONS, PRODUCT_SIZE_CODES } from "./enums.d";
2
2
  import type { SearchProductsResponse } from "./responses.d.ts"
3
3
 
4
4
  export type IdosellProduct = SearchProductsResponse['results'][0];
5
5
 
6
6
  export type GetIaICodeFunction = (productId: number|string, sizeId: string) => string;
7
7
 
8
- export type SumProductQuantitiesFunction = (productStocksData: IdosellProduct['productStocksqData'], stockType?: PRODUCT_SIZE_COUNTABLE | `${PRODUCT_SIZE_COUNTABLE}`) => number;
8
+ export type SumProductQuantitiesFunction = (productStocksData: IdosellProduct['productStocksData'], stockType?: PRODUCT_SIZE_COUNTABLE | `${PRODUCT_SIZE_COUNTABLE}`) => number;
9
9
 
10
- export type MapSizeQuantitesFunction = (product: IdosellProduct, stockType?: PRODUCT_SIZE_COUNTABLE | `${PRODUCT_SIZE_COUNTABLE}`) => Record<string,number>;
10
+ export type MapSizeQuantitesFunction = (product: IdosellProduct, stockType?: `${PRODUCT_SIZE_COUNTABLE}`) => Record<string,number>;
11
11
 
12
- export type MapProductCodesFunction = (product: IdosellProduct, codeType?: PRODUCT_SIZE_STRING | `${PRODUCT_SIZE_STRING}`, stockId?: number|string) => Record<string,string>;
12
+ export type MapProductCodesFunction = (product: IdosellProduct, codeType?: `${PRODUCT_SIZE_CODES}`) => Record<string,string>;
13
+
14
+ export type MapProductLocationsFunction = (product: IdosellProduct, stockId?: number, codeType?: `${PRODUCT_SIZE_LOCATIONS}`) => Record<string,string[]>;
13
15
 
14
16
  export type GetLangDataFunction = <T extends { langId: string}>(array: T[], langId?: string) => T|undefined;
15
17
 
@@ -22,6 +24,7 @@ declare namespace utils {
22
24
  const mapProductCodes: MapProductCodesFunction;
23
25
  const getLangData: GetLangDataFunction;
24
26
  const clearParametersLangData: ClearParametersLangDataFunction;
27
+ const mapProductLocations: MapProductLocationsFunction;
25
28
  }
26
29
 
27
30
  export default utils;
package/dist/utils.js CHANGED
@@ -68,29 +68,36 @@ const productSizesPathMap = {
68
68
  'productSizesDispositionsInAuctions',
69
69
  'array'
70
70
  ],
71
- [ENUMS.PRODUCT_SIZE_STRING.NAME]: [
71
+ [ENUMS.PRODUCT_SIZE_CODES.NAME]: [
72
72
  'productSizes',
73
73
  'array'
74
74
  ],
75
- [ENUMS.PRODUCT_SIZE_STRING.CODE_PRODUCER]: [
75
+ [ENUMS.PRODUCT_SIZE_CODES.CODE_PRODUCER]: [
76
76
  'productSizesAttributes',
77
77
  'array'
78
78
  ],
79
- [ENUMS.PRODUCT_SIZE_STRING.CODE_EXTERNAL]: [
79
+ [ENUMS.PRODUCT_SIZE_CODES.CODE_EXTERNAL]: [
80
80
  'productStocksData',
81
81
  'productStocksQuantities',
82
82
  'array',
83
83
  'productSizesData',
84
84
  'array'
85
85
  ],
86
- [ENUMS.PRODUCT_SIZE_STRING.LOCATION]: [
86
+ [ENUMS.PRODUCT_SIZE_LOCATIONS.NAME]: [
87
87
  'productStocksData',
88
88
  'productSizesStocksLocations',
89
89
  'array',
90
90
  'productSizesLocation',
91
91
  'array'
92
92
  ],
93
- [ENUMS.PRODUCT_SIZE_STRING.LOCATION_CODE]: [
93
+ [ENUMS.PRODUCT_SIZE_LOCATIONS.CODE]: [
94
+ 'productStocksData',
95
+ 'productSizesStocksLocations',
96
+ 'array',
97
+ 'productSizesLocation',
98
+ 'array'
99
+ ],
100
+ [ENUMS.PRODUCT_SIZE_LOCATIONS.ID]: [
94
101
  'productStocksData',
95
102
  'productSizesStocksLocations',
96
103
  'array',
@@ -133,14 +140,8 @@ const mapSizeQuantites = (product, nodeName = ENUMS.PRODUCT_SIZE_COUNTABLE.QUANT
133
140
  });
134
141
  return aggregated;
135
142
  };
136
- const mapProductCodes = (product, codeType = ENUMS.PRODUCT_SIZE_STRING.NAME, stockId) => {
137
- let results = getTraversedPathElements(product, codeType);
138
- if (['stockLocationTextId', 'stockLocationCode'].includes(codeType)) {
139
- if (!stockId)
140
- throw new Error("Stock Id is required to map locations");
141
- const prefix = 'M' + stockId;
142
- results = results.filter(item => item.stockLocationTextId.startsWith(prefix));
143
- }
143
+ const mapProductCodes = (product, codeType = ENUMS.PRODUCT_SIZE_CODES.NAME) => {
144
+ const results = getTraversedPathElements(product, codeType);
144
145
  const mapped = {};
145
146
  results.forEach(item => {
146
147
  if (item?.sizeId && item[codeType] !== undefined) {
@@ -153,6 +154,41 @@ const mapProductCodes = (product, codeType = ENUMS.PRODUCT_SIZE_STRING.NAME, sto
153
154
  });
154
155
  return mapped;
155
156
  };
157
+ const SUB_TYPE_NODES = {
158
+ stockLocationTextId: 'stockAdditionalLocationTextId',
159
+ stockLocationId: 'stockAdditionalLocationId',
160
+ stockLocationCode: 'stockAdditionalLocationCode'
161
+ };
162
+ const mapProductLocations = (product, stockId, locationType = ENUMS.PRODUCT_SIZE_LOCATIONS.NAME) => {
163
+ let results = getTraversedPathElements(product, locationType);
164
+ if (stockId) {
165
+ const prefix = 'M' + stockId;
166
+ results = results.filter((location) => location.stockLocationTextId.startsWith(prefix));
167
+ }
168
+ const mapped = {};
169
+ const subNode = SUB_TYPE_NODES[locationType];
170
+ for (const item of results) {
171
+ const { sizeId } = item;
172
+ if (!mapped[sizeId]) {
173
+ mapped[sizeId] = [];
174
+ }
175
+ // main location
176
+ const mainLocation = item[locationType];
177
+ if (mainLocation) {
178
+ mapped[sizeId].push(mainLocation.toString());
179
+ }
180
+ // additional locations
181
+ if (item.stockAdditionalLocations?.length) {
182
+ for (const additional of item.stockAdditionalLocations) {
183
+ const value = additional[subNode];
184
+ if (value) {
185
+ mapped[sizeId].push(value.toString());
186
+ }
187
+ }
188
+ }
189
+ }
190
+ return mapped;
191
+ };
156
192
  const getLangData = (arr, langId = 'pol') => {
157
193
  if (!arr.length)
158
194
  return undefined;
@@ -180,6 +216,7 @@ export default {
180
216
  getIaiCode,
181
217
  mapSizeQuantites,
182
218
  mapProductCodes,
219
+ mapProductLocations,
183
220
  getLangData,
184
221
  clearParametersLangData
185
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idosell",
3
- "version": "0.4.16",
3
+ "version": "0.4.18",
4
4
  "description": "Idosell 3 REST connector",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/gateways.d.ts",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://idosell-converter.vercel.app",
25
25
  "dependencies": {
26
- "axios": "^1.8.4"
26
+ "axios": "^1.13.2"
27
27
  },
28
28
  "type": "module"
29
29
  }
@@ -0,0 +1,343 @@
1
+ import type { SearchProductsResponse } from "$dist/responses";
2
+
3
+ export const STOCK_PRODUCT: SearchProductsResponse['results'][number] = {
4
+ "productId": 541321313,
5
+ "productStocksData": {
6
+ "productSizesDeliveries": [
7
+ {
8
+ "productSizeQuantity": 3,
9
+ "sizeId": "5",
10
+ "sizePanelName": "L"
11
+ },
12
+ {
13
+ "productSizeQuantity": 3,
14
+ "sizeId": "6",
15
+ "sizePanelName": "X"
16
+ }
17
+ ],
18
+ "productStocksQuantities": [
19
+ {
20
+ "stockId": 1,
21
+ "productSizesData": [
22
+ {
23
+ "sizeId": "3",
24
+ "sizePanelName": "S",
25
+ "productSizeCodeExternal": "PX-ZERO-S",
26
+ "productSizeQuantity": 1,
27
+ // @ts-expect-error never needed
28
+ "productSizeReservations": {
29
+ "productSizeReservationOrder": 0
30
+ }
31
+ },
32
+ {
33
+ "sizeId": "4",
34
+ "sizePanelName": "M",
35
+ "productSizeCodeExternal": "PX-ZERO-M",
36
+ "productSizeQuantity": 0,
37
+ // @ts-expect-error never needed
38
+ "productSizeReservations": {
39
+ "productSizeReservationOrder": 0
40
+ }
41
+ },
42
+ {
43
+ "sizeId": "5",
44
+ "sizePanelName": "L",
45
+ "productSizeCodeExternal": "PX-ZERO-L",
46
+ "productSizeQuantity": 0,
47
+ // @ts-expect-error never needed
48
+ "productSizeReservations": {
49
+ "productSizeReservationOrder": 0
50
+ }
51
+ },
52
+ {
53
+ "sizeId": "6",
54
+ "sizePanelName": "XL",
55
+ "productSizeCodeExternal": "PX-ZERO-X",
56
+ "productSizeQuantity": 0,
57
+ // @ts-expect-error never needed
58
+ "productSizeReservations": {
59
+ "productSizeReservationOrder": 0
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "stockId": 3,
66
+ "productSizesData": [
67
+ {
68
+ "sizeId": "3",
69
+ "sizePanelName": "S",
70
+ "productSizeCodeExternal": "PX-ZERO-S",
71
+ "productSizeQuantity": 9,
72
+ // @ts-expect-error never needed
73
+ "productSizeReservations": {
74
+ "productSizeReservationOrder": 2
75
+ }
76
+ },
77
+ {
78
+ "sizeId": "4",
79
+ "sizePanelName": "M",
80
+ "productSizeCodeExternal": "PX-ZERO-M",
81
+ "productSizeQuantity": 10,
82
+ // @ts-expect-error never needed
83
+ "productSizeReservations": {
84
+ "productSizeReservationOrder": 0
85
+ }
86
+ },
87
+ {
88
+ "sizeId": "5",
89
+ "sizePanelName": "L",
90
+ "productSizeCodeExternal": "PX-ZERO-L",
91
+ "productSizeQuantity": 0,
92
+ // @ts-expect-error never needed
93
+ "productSizeReservations": {
94
+ "productSizeReservationOrder": 0
95
+ }
96
+ },
97
+ {
98
+ "sizeId": "6",
99
+ "sizePanelName": "XL",
100
+ "productSizeCodeExternal": "PX-ZERO-X",
101
+ "productSizeQuantity": 0,
102
+ // @ts-expect-error never needed
103
+ "productSizeReservations": {
104
+ "productSizeReservationOrder": 0
105
+ }
106
+ }
107
+ ]
108
+ }
109
+ ],
110
+ "productSizesDispositions": {
111
+ "productSizesDispositionsInSales": [
112
+ {
113
+ "sizeId": "3",
114
+ "sizePanelName": "S",
115
+ "productSizeCodeExternal": "PX-ZERO-S",
116
+ "productSizeQuantityOutsideStock": 0,
117
+ "productSizeQuantityOwnStock": 8,
118
+ "productSizeQuantityAllStocks": 8
119
+ },
120
+ {
121
+ "sizeId": "4",
122
+ "sizePanelName": "M",
123
+ "productSizeCodeExternal": "PX-ZERO-M",
124
+ "productSizeQuantityOutsideStock": 0,
125
+ "productSizeQuantityOwnStock": 10,
126
+ "productSizeQuantityAllStocks": 10
127
+ },
128
+ {
129
+ "sizeId": "5",
130
+ "sizePanelName": "L",
131
+ "productSizeCodeExternal": "PX-ZERO-L",
132
+ "productSizeQuantityOutsideStock": 5,
133
+ "productSizeQuantityOwnStock": 0,
134
+ "productSizeQuantityAllStocks": 5
135
+ },
136
+ {
137
+ "sizeId": "6",
138
+ "sizePanelName": "XL",
139
+ "productSizeCodeExternal": "PX-ZERO-X",
140
+ "productSizeQuantityOutsideStock": 0,
141
+ "productSizeQuantityOwnStock": 0,
142
+ "productSizeQuantityAllStocks": 0
143
+ }
144
+ ],
145
+ "productSizesDispositionsInAuctions": [
146
+ {
147
+ "sizeId": "3",
148
+ "sizePanelName": "S",
149
+ "productSizeCodeExternal": "PX-ZERO-S",
150
+ "productSizeQuantity": 1
151
+ },
152
+ {
153
+ "sizeId": "4",
154
+ "sizePanelName": "M",
155
+ "productSizeCodeExternal": "PX-ZERO-M",
156
+ "productSizeQuantity": 0
157
+ },
158
+ {
159
+ "sizeId": "5",
160
+ "sizePanelName": "L",
161
+ "productSizeCodeExternal": "PX-ZERO-L",
162
+ "productSizeQuantity": 0
163
+ },
164
+ {
165
+ "sizeId": "6",
166
+ "sizePanelName": "XL",
167
+ "productSizeCodeExternal": "PX-ZERO-X",
168
+ "productSizeQuantity": 0
169
+ }
170
+ ]
171
+ },
172
+ "productOrdersUnfinishedQuantities": [
173
+ {
174
+ "stockId": 1,
175
+ "productSizesData": [
176
+ {
177
+ "sizeId": "3",
178
+ "sizePanelName": "S",
179
+ "productSizeCodeExternal": "PX-ZERO-S",
180
+ "productSizeQuantity": 2
181
+ }
182
+ ]
183
+ }
184
+ ],
185
+ "productSizesStocksLocations": [
186
+ {
187
+ "stockId": 1,
188
+ "productSizesLocation": [
189
+ {
190
+ "stockLocationCode": "F",
191
+ "stockAdditionalLocations": [
192
+ {
193
+ "stockAdditionalLocationId": 46,
194
+ "stockAdditionalLocationTextId": "M1\\A015",
195
+ "stockAdditionalLocationCode": "P"
196
+ },
197
+ {
198
+ "stockAdditionalLocationId": 1,
199
+ "stockAdditionalLocationTextId": "M1\\A113",
200
+ "stockAdditionalLocationCode": "A"
201
+ }
202
+ ],
203
+ "sizeId": "3",
204
+ "stockLocationId": 16,
205
+ "stockLocationTextId": "M1\\A014"
206
+ },
207
+ {
208
+ "stockLocationCode": "F",
209
+ "sizeId": "4",
210
+ "stockLocationId": 16,
211
+ "stockLocationTextId": "M1\\A014"
212
+ },
213
+ {
214
+ "stockLocationCode": "B",
215
+ "sizeId": "5",
216
+ "stockLocationId": 4,
217
+ "stockLocationTextId": "M1\\B013"
218
+ },
219
+ {
220
+ "stockLocationCode": "B",
221
+ "sizeId": "6",
222
+ "stockLocationId": 4,
223
+ "stockLocationTextId": "M1\\B013"
224
+ }
225
+ ]
226
+ },
227
+ {
228
+ "stockId": 2,
229
+ "productSizesLocation": [
230
+ {
231
+ "stockLocationCode": "B",
232
+ "sizeId": "3",
233
+ "stockLocationId": 5,
234
+ "stockLocationTextId": "M2\\G013"
235
+ },
236
+ {
237
+ "stockLocationCode": "Q",
238
+ "sizeId": "4",
239
+ "stockLocationId": 50,
240
+ "stockLocationTextId": "M2\\G015"
241
+ },
242
+ {
243
+ "stockLocationCode": "L",
244
+ "sizeId": "5",
245
+ "stockLocationId": 35,
246
+ "stockLocationTextId": "M2\\G114"
247
+ },
248
+ {
249
+ "stockLocationCode": "G",
250
+ "sizeId": "6",
251
+ "stockLocationId": 20,
252
+ "stockLocationTextId": "M2\\G214"
253
+ }
254
+ ]
255
+ },
256
+ {
257
+ "stockId": 3,
258
+ "productSizesLocation": [
259
+ {
260
+ "stockLocationCode": "F",
261
+ "sizeId": "3",
262
+ "stockLocationId": 18,
263
+ "stockLocationTextId": "M3\\K014"
264
+ },
265
+ {
266
+ "stockLocationCode": "B",
267
+ "sizeId": "4",
268
+ "stockLocationId": 6,
269
+ "stockLocationTextId": "M3\\L013"
270
+ },
271
+ {
272
+ "stockLocationCode": "B",
273
+ "sizeId": "5",
274
+ "stockLocationId": 6,
275
+ "stockLocationTextId": "M3\\L013"
276
+ },
277
+ {
278
+ "stockLocationCode": "F",
279
+ "sizeId": "6",
280
+ "stockLocationId": 18,
281
+ "stockLocationTextId": "M3\\K014"
282
+ }
283
+ ]
284
+ }
285
+ ]
286
+ },
287
+ "productSizesAttributes": [
288
+ {
289
+ "productSizeWeightWithoutPackaging": 0,
290
+ "sizeId": "3",
291
+ "sizePanelName": "S",
292
+ "productSizeCodeExternal": "PX-ZERO-S",
293
+ "productSizeCodeProducer": "1234567890128",
294
+ "productInPersistent": "y",
295
+ "productSizeWeight": 0
296
+ },
297
+ {
298
+ "productSizeWeightWithoutPackaging": 0,
299
+ "sizeId": "4",
300
+ "sizePanelName": "M",
301
+ "productSizeCodeExternal": "PX-ZERO-M",
302
+ "productSizeCodeProducer": "1234567890135",
303
+ "productInPersistent": "y",
304
+ "productSizeWeight": 0
305
+ },
306
+ {
307
+ "productSizeWeightWithoutPackaging": 0,
308
+ "sizeId": "5",
309
+ "sizePanelName": "L",
310
+ "productSizeCodeExternal": "PX-ZERO-L",
311
+ "productSizeCodeProducer": "1234567890142",
312
+ "productInPersistent": "y",
313
+ "productSizeWeight": 0
314
+ },
315
+ {
316
+ "productSizeWeightWithoutPackaging": 0,
317
+ "sizeId": "6",
318
+ "sizePanelName": "XL",
319
+ "productSizeCodeExternal": "PX-ZERO-X",
320
+ "productSizeCodeProducer": "1234567890159",
321
+ "productInPersistent": "y",
322
+ "productSizeWeight": 0
323
+ }
324
+ ],
325
+ "productSizes": [
326
+ {
327
+ "sizeId": "3",
328
+ "sizePanelName": "S"
329
+ },
330
+ {
331
+ "sizeId": "4",
332
+ "sizePanelName": "M"
333
+ },
334
+ {
335
+ "sizeId": "5",
336
+ "sizePanelName": "L"
337
+ },
338
+ {
339
+ "sizeId": "6",
340
+ "sizePanelName": "XL"
341
+ }
342
+ ]
343
+ }
@@ -0,0 +1,24 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import ENUMS from '$dist/enums';
5
+
6
+ const CODES = ENUMS.PRODUCT_SIZE_CODES;
7
+
8
+ test('Utils mapProductCodes on sizePanelName', () => {
9
+ expect(CODES.NAME).toEqual('sizePanelName');
10
+ const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.NAME)
11
+ expect(codes).toEqual({"3": "S","4": "M","5": "L","6": "XL"});
12
+ })
13
+
14
+ test('Utils mapProductCodes on productSizeCodeProducer', () => {
15
+ expect(CODES.CODE_PRODUCER).toEqual('productSizeCodeProducer');
16
+ const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_PRODUCER)
17
+ expect(codes).toEqual({"3": "1234567890128","4": "1234567890135","5": "1234567890142","6": "1234567890159"});
18
+ })
19
+
20
+ test('Utils mapProductCodes on productSizeCodeExternal', () => {
21
+ expect(CODES.CODE_EXTERNAL).toEqual('productSizeCodeExternal');
22
+ const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_EXTERNAL)
23
+ expect(codes).toEqual({"3": "PX-ZERO-S","4": "PX-ZERO-M","5": "PX-ZERO-L","6": "PX-ZERO-X"});
24
+ })
@@ -0,0 +1,29 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import { ENUMS } from '$dist';
5
+
6
+ const LOCATION = ENUMS.PRODUCT_SIZE_LOCATIONS;
7
+
8
+ test('Utils mapProductLocations on stockLocationCode', () => {
9
+ expect(LOCATION.CODE).toEqual('stockLocationCode');
10
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.CODE)
11
+ expect(locations).toEqual({"3":["F","P","A"],"4":["F"],"5":["B"],"6":["B"]});
12
+ })
13
+
14
+ test('Utils mapProductLocations on stockLocationTextId', () => {
15
+ expect(LOCATION.NAME).toEqual('stockLocationTextId');
16
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.NAME)
17
+ expect(locations).toEqual({"3":["M1\\A014","M1\\A015","M1\\A113"],"4":["M1\\A014"],"5":["M1\\B013"],"6":["M1\\B013"]});
18
+ })
19
+
20
+ test('Utils mapProductLocations on stockLocationId', () => {
21
+ expect(LOCATION.ID).toEqual('stockLocationId');
22
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.ID)
23
+ expect(locations).toEqual({"3":["16","46","1"],"4":["16"],"5":["4"],"6":["4"]});
24
+ })
25
+
26
+ test('Utils mapProductLocations full', () => {
27
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT)
28
+ expect(locations).toEqual({"3":["M1\\A014","M1\\A015","M1\\A113","M2\\G013","M3\\K014"],"4":["M1\\A014","M2\\G015","M3\\L013"],"5":["M1\\B013","M2\\G114","M3\\L013"],"6":["M1\\B013","M2\\G214","M3\\K014"]});
29
+ })
@@ -0,0 +1,48 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import ENUMS from '$dist/enums';
5
+
6
+ const COUNTABLE = ENUMS.PRODUCT_SIZE_COUNTABLE;
7
+
8
+ test('Utils mapSizeQuantites on productSizeQuantity', () => {
9
+ expect(COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
10
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY)
11
+ expect(quantities).toEqual({"3":10,"4":10,"5":0,"6":0});
12
+ })
13
+
14
+ test('Utils mapSizeQuantites on productSizeQuantityOwnStock', () => {
15
+ expect(COUNTABLE.QUANTITY_OWN).toEqual('productSizeQuantityOwnStock');
16
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OWN)
17
+ expect(quantities).toEqual({"3":8,"4":10,"5":0,"6":0});
18
+ })
19
+
20
+ test('Utils mapSizeQuantites on productSizeQuantityOutsideStock', () => {
21
+ expect(COUNTABLE.QUANTITY_OUTSIDE).toEqual('productSizeQuantityOutsideStock');
22
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OUTSIDE)
23
+ expect(quantities).toEqual({"3":0,"4":0,"5":5,"6":0});
24
+ })
25
+
26
+ test('Utils mapSizeQuantites on productSizeQuantityAllStocks', () => {
27
+ expect(COUNTABLE.QUANTITY_ALL).toEqual('productSizeQuantityAllStocks');
28
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ALL)
29
+ expect(quantities).toEqual({"3":8,"4":10,"5":5,"6":0});
30
+ })
31
+
32
+ test('Utils mapSizeQuantites on productOrdersUnfinishedQuantities', () => {
33
+ expect(COUNTABLE.QUANTITY_ORDERS_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
34
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ORDERS_UNFINISHED)
35
+ expect(quantities).toEqual({"3":2});
36
+ })
37
+
38
+ test('Utils mapSizeQuantites on productSizesDeliveries', () => {
39
+ expect(COUNTABLE.DELIVERIES).toEqual('productSizesDeliveries');
40
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.DELIVERIES)
41
+ expect(quantities).toEqual({"5":3,"6":3});
42
+ })
43
+
44
+ test('Utils mapSizeQuantites on productSizesDispositionsInAuctions', () => {
45
+ expect(COUNTABLE.AUCTIONS).toEqual('productSizesDispositionsInAuctions');
46
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.AUCTIONS)
47
+ expect(quantities).toEqual({"3":1,"4":0,"5":0,"6":0});
48
+ })
@@ -0,0 +1,48 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import ENUMS from '$dist/enums';
5
+
6
+ const COUNTABLE = ENUMS.PRODUCT_SIZE_COUNTABLE;
7
+
8
+ test('Utils sumProductQuantities on productSizeQuantity', () => {
9
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
10
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY)
11
+ expect(sum).toEqual(20);
12
+ })
13
+
14
+ test('Utils sumProductQuantities on productSizeQuantityOwnStock', () => {
15
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OWN).toEqual('productSizeQuantityOwnStock');
16
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OWN)
17
+ expect(sum).toEqual(18);
18
+ })
19
+
20
+ test('Utils sumProductQuantities on productSizeQuantityOutsideStock', () => {
21
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OUTSIDE).toEqual('productSizeQuantityOutsideStock');
22
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OUTSIDE)
23
+ expect(sum).toEqual(5);
24
+ })
25
+
26
+ test('Utils sumProductQuantities on productSizeQuantityAllStocks', () => {
27
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_ALL).toEqual('productSizeQuantityAllStocks');
28
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_ALL)
29
+ expect(sum).toEqual(23);
30
+ })
31
+
32
+ test('Utils sumProductQuantities on productOrdersUnfinishedQuantities', () => {
33
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_ORDERS_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
34
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_ORDERS_UNFINISHED)
35
+ expect(sum).toEqual(2);
36
+ })
37
+
38
+ test('Utils sumProductQuantities on productSizesDeliveries', () => {
39
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.DELIVERIES).toEqual('productSizesDeliveries');
40
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.DELIVERIES)
41
+ expect(sum).toEqual(6);
42
+ })
43
+
44
+ test('Utils sumProductQuantities on productSizesDispositionsInAuctions', () => {
45
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.AUCTIONS).toEqual('productSizesDispositionsInAuctions');
46
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.AUCTIONS)
47
+ expect(sum).toEqual(1);
48
+ })