colissimo_label 0.14.0 → 0.19.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/colissimo_label/generate_label.rb +29 -8
- data/lib/colissimo_label/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58ca859be28bd4c1904888ffd0a04ce9f2a0fe3eb4685d530a9c63ac64fc24d
|
4
|
+
data.tar.gz: b0101152eecda5a85baaf0f02e337abde20d525646e4c91751104dbc423cb554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf756d30f2c61764de70d2e60dbc0d5d0ecd1dbe75a6411a05457e8981042cddec79ebf37143fd5048a60a057e39649060a2e84614233c0f671be3fa97b012d9
|
7
|
+
data.tar.gz: 01c0681b6bc6c1a619299a6bd94f3151cd8a01ed3ccf4bfe22a8f4fcff77b7b4232cb9f833c5c46d72e2a5fd648869a25bf389f4ad02b5808b5bc3e1576cc423
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 0.19.0
|
2
|
+
|
3
|
+
- Add new option field: specific TVA number for customs
|
4
|
+
|
5
|
+
## 0.18.0
|
6
|
+
|
7
|
+
- Add new fields for UK after Brexit
|
8
|
+
|
9
|
+
## 0.17.0
|
10
|
+
|
11
|
+
- Add Sweden to mandatory signature countries
|
12
|
+
|
13
|
+
## 0.16.0
|
14
|
+
|
15
|
+
- Use correct default value for insurance
|
16
|
+
|
17
|
+
## 0.15.0
|
18
|
+
|
19
|
+
- Comment insurance value
|
20
|
+
|
1
21
|
## 0.14.0
|
2
22
|
|
3
23
|
- Ensure local path is present
|
@@ -14,9 +14,11 @@ class ColissimoLabel::GenerateLabel
|
|
14
14
|
@pickup_type = options.fetch(:pickup_type, nil)
|
15
15
|
@total_weight = options.fetch(:total_weight, nil)
|
16
16
|
@customs_total_weight = options.fetch(:customs_total_weight, nil)
|
17
|
+
@customs_tva_number = options.fetch(:customs_tva_number, nil)
|
17
18
|
@customs_data = options.fetch(:customs_data, nil)
|
18
19
|
@with_signature = options.fetch(:with_signature, false)
|
19
|
-
@insurance_value = options.fetch(:insurance_value,
|
20
|
+
@insurance_value = options.fetch(:insurance_value, nil)
|
21
|
+
@eori_number = options.fetch(:eori_number, nil)
|
20
22
|
@label_output_format = options.fetch(:label_output_format, 'PDF_10x15_300dpi')
|
21
23
|
@errors = []
|
22
24
|
end
|
@@ -50,7 +52,7 @@ class ColissimoLabel::GenerateLabel
|
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
|
-
if status == 400
|
55
|
+
if status == 400 || status == 500
|
54
56
|
error_message = response.body.to_s.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').scan(/"messageContent":"(.*?)"/).last&.first
|
55
57
|
raise StandardError, error_message
|
56
58
|
elsif status == 503
|
@@ -98,8 +100,9 @@ class ColissimoLabel::GenerateLabel
|
|
98
100
|
"addressee": {
|
99
101
|
"address": format_addressee
|
100
102
|
}
|
101
|
-
}.merge(
|
102
|
-
}.
|
103
|
+
}.merge(customs_letter)
|
104
|
+
}.merge(customs_fields)
|
105
|
+
.compact)
|
103
106
|
end
|
104
107
|
|
105
108
|
# Services =>
|
@@ -168,11 +171,12 @@ class ColissimoLabel::GenerateLabel
|
|
168
171
|
end
|
169
172
|
|
170
173
|
# Déclaration douanière de type CN23
|
171
|
-
def
|
174
|
+
def customs_letter
|
172
175
|
if require_customs?
|
173
176
|
{
|
174
177
|
"customsDeclarations": {
|
175
|
-
"includeCustomsDeclarations": 1, # Inclure déclaration
|
178
|
+
"includeCustomsDeclarations": 1, # Inclure déclaration,
|
179
|
+
"importersReference": @customs_tva_number, # Numéro TVA pour la douane, si besoin
|
176
180
|
"contents": {
|
177
181
|
"article": @customs_data.map { |customs|
|
178
182
|
{
|
@@ -203,8 +207,25 @@ class ColissimoLabel::GenerateLabel
|
|
203
207
|
end
|
204
208
|
end
|
205
209
|
|
210
|
+
def customs_fields
|
211
|
+
if require_customs?
|
212
|
+
{
|
213
|
+
"fields": {
|
214
|
+
"customField": [
|
215
|
+
{
|
216
|
+
"key": 'EORI',
|
217
|
+
"value": @eori_number
|
218
|
+
}
|
219
|
+
]
|
220
|
+
}
|
221
|
+
}
|
222
|
+
else
|
223
|
+
{}
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
206
227
|
def require_customs?
|
207
|
-
%w[CH NO US].include?(@destination_country)
|
228
|
+
%w[CH NO US GB].include?(@destination_country)
|
208
229
|
end
|
209
230
|
|
210
231
|
# Certains pays, comme l'Allemagne, requiert une signature pour la livraison
|
@@ -214,7 +235,7 @@ class ColissimoLabel::GenerateLabel
|
|
214
235
|
# BPR : Colissimo - Point Retrait – en Bureau de Poste
|
215
236
|
# A2P : Colissimo - Point Retrait – en relais Pickup ou en consigne Pickup Station
|
216
237
|
def product_code
|
217
|
-
if %w[DE IT ES GB LU NL DK AT].include?(@destination_country)
|
238
|
+
if %w[DE IT ES GB LU NL DK AT SE].include?(@destination_country)
|
218
239
|
'DOS'
|
219
240
|
elsif !@pickup_id.nil? && %w[FR].include?(@destination_country)
|
220
241
|
@pickup_type || 'BPR'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colissimo_label
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FloXcoder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
185
|
+
rubygems_version: 3.2.3
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Generate Colissimo label for all countries
|