@gls_spain/gps-common 33.0.0 → 33.0.2

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.
@@ -2,14 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
5
- <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/schemas/definitions/defaults.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/defaults.js" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/schemas/definitions/gls-spain-integration-events.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/gls-spain-integration-events.js" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/schemas/definitions/historic-records.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/historic-records.js" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/schemas/definitions/init.js" beforeDir="false" />
10
- <change beforePath="$PROJECT_DIR$/schemas/definitions/networks.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/networks.js" afterDir="false" />
11
5
  <change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
12
- <change beforePath="$PROJECT_DIR$/schemas/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/index.js" afterDir="false" />
13
6
  </list>
14
7
  <option name="SHOW_DIALOG" value="false" />
15
8
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -590,7 +583,10 @@
590
583
  <workItem from="1595531893690" duration="4660000" />
591
584
  <workItem from="1595572792857" duration="2475000" />
592
585
  <workItem from="1595668967544" duration="116000" />
593
- <workItem from="1595832239784" duration="10600000" />
586
+ <workItem from="1595832239784" duration="11480000" />
587
+ <workItem from="1595858491503" duration="4159000" />
588
+ <workItem from="1595865087442" duration="564000" />
589
+ <workItem from="1595914052000" duration="948000" />
594
590
  </task>
595
591
  <servers />
596
592
  </component>
@@ -633,22 +629,22 @@
633
629
  <screen x="0" y="23" width="2048" height="1129" />
634
630
  </state>
635
631
  <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1595577705727" />
636
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1595847055405">
632
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1595874624892">
637
633
  <screen x="0" y="23" width="2048" height="1129" />
638
634
  </state>
639
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1595847055405" />
640
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1595847055405">
635
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1595874624892" />
636
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1595874624891">
641
637
  <screen x="0" y="23" width="2048" height="1129" />
642
638
  </state>
643
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1595847055405" />
644
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1595847055404">
639
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1595874624891" />
640
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1595874624891">
645
641
  <screen x="0" y="23" width="2048" height="1129" />
646
642
  </state>
647
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1595847055404" />
648
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1595847055405">
643
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1595874624891" />
644
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1595874624892">
649
645
  <screen x="0" y="23" width="2048" height="1129" />
650
646
  </state>
651
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1595847055405" />
647
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1595874624892" />
652
648
  <state x="689" y="276" width="670" height="676" key="search.everywhere.popup" timestamp="1595579270021">
653
649
  <screen x="0" y="23" width="2048" height="1129" />
654
650
  </state>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [33.0.2](https://github.com/GLS-Spain/gps-common/compare/v33.0.1...v33.0.2) (2020-07-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix super admin find sales request, should be find by network and shop, not only shop ([56403be](https://github.com/GLS-Spain/gps-common/commit/56403be066b6d24f1689c1681a58c83d80f01454))
7
+
8
+ ## [33.0.1](https://github.com/GLS-Spain/gps-common/compare/v33.0.0...v33.0.1) (2020-07-27)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * rework the defaults sales settings because the old structure did not work for some combinations ([7e36141](https://github.com/GLS-Spain/gps-common/commit/7e36141e227a6bb74be4886c9144916fc6d63d25))
14
+
1
15
  # [33.0.0](https://github.com/GLS-Spain/gps-common/compare/v32.5.0...v33.0.0) (2020-07-27)
2
16
 
3
17
 
@@ -564,6 +564,17 @@ field used for any resource in the API.
564
564
 
565
565
  ## Defaults schema
566
566
 
567
+ ### Sales price calculation
568
+
569
+ The API calculates the price for a destination (country and optional postal code) by scanning the \`salesSettings\` and following this steps:
570
+
571
+ 1. For each zone:
572
+ 1.1. If the destination is in \`excludes\` skip the zone.
573
+ 1.2. Else if the destination is in \`includes\` save the match and the length of the prefix.
574
+ 1.3. Else skip this zone.
575
+ 2. If there is only one matched zone choose that one.
576
+ 3. Else choose the first one among the matched zones with the longest prefix.
577
+
567
578
  <SchemaDefinition schemaRef="#/components/schemas/defaults" />
568
579
 
569
580
  ## Counters schema
@@ -1260,8 +1271,7 @@ Update the default settings.
1260
1271
  If the \`derivationSettings\` or \`expirationSettings\` are updated, the update will propagate to the \`defaults\` property of all networks
1261
1272
  and shops.
1262
1273
 
1263
- If the \`salesSettings\` contain duplicated zones, countries or postal codes, or if a country or postal codes references a non existent
1264
- zone, the API will return a \`500 InconsistentSalesSettingsError\`.
1274
+ If the \`salesSettings\` contains duplicated zones names the API will return a \`500 InconsistentSalesSettingsError\`.
1265
1275
 
1266
1276
  ${securitySchemes.tokens}
1267
1277
  ${securitySchemes.superAdminRole}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "33.0.0",
3
+ "version": "33.0.2",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -50,10 +50,20 @@ const saleSize = () => ({
50
50
  enum: ['xs', 's', 'm', 'l', 'xl'],
51
51
  });
52
52
 
53
+ const saleZoneRegion = () => ({
54
+ type: 'object',
55
+ properties: {
56
+ country: country(),
57
+ postalCodePrefix: { type: 'string', minLength: 1 },
58
+ },
59
+ required: ['country'],
60
+ additionalProperties: false,
61
+ });
62
+
53
63
  const saleZone = () => ({
54
64
  type: 'object',
55
65
  properties: {
56
- name: { type: 'string', trim: true },
66
+ name: { type: 'string', trim: true, minLength: 1 },
57
67
  prices: {
58
68
  type: 'object',
59
69
  properties: {
@@ -66,64 +76,20 @@ const saleZone = () => ({
66
76
  required: ['xs', 's', 'm', 'l', 'xl'],
67
77
  additionalProperties: false,
68
78
  },
79
+ includes: { type: 'array', items: saleZoneRegion(), uniqueItems: true },
80
+ excludes: { type: 'array', items: saleZoneRegion(), uniqueItems: true },
69
81
  },
70
- required: ['name', 'prices'],
71
- additionalProperties: false,
72
- });
73
-
74
- const salePostalCodeZone = () => ({
75
- type: 'object',
76
- properties: {
77
- prefix: {
78
- type: 'string',
79
- description: 'include only the postal codes that begin with this prefix',
80
- },
81
- zone: {
82
- oneOf: [
83
- {
84
- type: 'string',
85
- description: 'name of the zone for this country and postal codes, must exist in the zones array',
86
- },
87
- {
88
- type: 'null',
89
- description: 'set to null to prevent sales to this country and postal codes',
90
- },
91
- ],
92
- },
93
- },
94
- required: ['prefix', 'zone'],
82
+ required: ['name', 'prices', 'includes', 'excludes'],
95
83
  additionalProperties: false,
96
84
  });
97
85
 
98
- const saleCountry = () => ({
99
- type: 'object',
100
- properties: {
101
- country: country(),
102
- postalCodesZones: { type: 'array', items: salePostalCodeZone(), uniqueItems: true },
103
- defaultZone: {
104
- oneOf: [
105
- {
106
- type: 'string',
107
- description: 'name of the default zone for this country, must exist in the zones array',
108
- },
109
- {
110
- type: 'null',
111
- description: 'set to null to prevent sales to this country by default',
112
- },
113
- ],
114
- },
115
- },
116
- required: ['country', 'postalCodesZones', 'defaultZone'],
117
- });
118
-
119
86
  const salesSettings = () => ({
120
87
  title: 'sales settings',
121
88
  type: 'object',
122
89
  properties: {
123
90
  zones: { type: 'array', items: saleZone(), uniqueItems: true, minItems: 1 },
124
- countries: { type: 'array', items: saleCountry(), uniqueItems: true, minItems: 1 },
125
91
  },
126
- required: ['zones', 'countries'],
92
+ required: ['zones'],
127
93
  additionalProperties: false,
128
94
  });
129
95
 
@@ -122,7 +122,9 @@ const findByNetwork = () => mergeSchemas(objectWithNetworkId(), { title: 'find b
122
122
 
123
123
  const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop' });
124
124
 
125
- const findSalesSuperAdminRequest = () => findRequest({ oneOf: [findAll(), findByNetwork(), findByShop(), findById()] });
125
+ const findByNetworkAndShop = () => mergeSchemas(objectWithNetworkId(), objectWithShopId(), { title: 'find by network and shop' });
126
+
127
+ const findSalesSuperAdminRequest = () => findRequest({ oneOf: [findAll(), findByNetwork(), findByNetworkAndShop(), findById()] });
126
128
 
127
129
  const findSalesNetworkAdminRequest = () => findRequest({ oneOf: [findAll(), findByShop(), findById()] });
128
130