comee_core 0.3.2 → 0.3.4
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/app/controllers/comee/core/clients_controller.rb +1 -1
- data/app/controllers/comee/core/customs_details_controller.rb +8 -0
- data/app/controllers/comee/core/users_controller.rb +3 -3
- data/app/serializers/comee/core/client_serializer.rb +1 -1
- data/app/services/comee/core/beo_service.rb +168 -19
- data/config/routes.rb +1 -0
- data/db/migrate/20240628205454_add_print_details_field_to_customer.rb +5 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/clients.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6574ea36fe12881077a861e6fb2606b08049a6c45c68777b865b73866a1155c1
|
4
|
+
data.tar.gz: 5829e9439f0796f165e5e065c311147d674314d4e8261162f38bdc7e1f826ce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a018ba9b48a1e0eb39f2b98cf4a779a495d5b46680e8370dca36c5d9a5aad08f03dd74fe95f23d2ea34669b393500997dded35f3ba3dffdf880378b32f5bba9c
|
7
|
+
data.tar.gz: bbdc8bc1570bfd605b90abcff20d72614ba198ca00180460d935863ffdccef69647f86cbf2c8788021dc8e2765d9028a04cf19d07679f64775b874e07a258c4a
|
@@ -57,7 +57,7 @@ module Comee
|
|
57
57
|
|
58
58
|
def model_params
|
59
59
|
params.require(:payload).permit(:code, :name, :match_code, :address, :locale, :user_id, :parent_id, :currency,
|
60
|
-
:subsidiary, :country_id, :tax_code, :vat_number, consignees: [])
|
60
|
+
:subsidiary, :country_id, :tax_code, :vat_number, :print_details, consignees: [])
|
61
61
|
end
|
62
62
|
|
63
63
|
def agent_params
|
@@ -16,6 +16,14 @@ module Comee
|
|
16
16
|
render json: {success: false, error: e.message}, status: 422
|
17
17
|
end
|
18
18
|
|
19
|
+
def generate_beo_xml
|
20
|
+
service = BeoService.new(publish_params[:ids])
|
21
|
+
data = service.preprocess_data(xml: true)
|
22
|
+
render json: {success: true, data: data}
|
23
|
+
rescue StandardError => e
|
24
|
+
render json: {success: false, error: e.message}, status: 422
|
25
|
+
end
|
26
|
+
|
19
27
|
private
|
20
28
|
|
21
29
|
def publish_params
|
@@ -8,12 +8,12 @@ module Comee
|
|
8
8
|
if @user.authenticate(change_password_params[:old_password])
|
9
9
|
if @user.update(password: change_password_params[:new_password],
|
10
10
|
password_confirmation: change_password_params[:new_password_confirmation])
|
11
|
-
render json:
|
11
|
+
render json: {success: true, data: serialize(@user)}
|
12
12
|
else
|
13
|
-
render json: {
|
13
|
+
render json: {success: false, error: @user.errors.full_messages[0]}, status: 422
|
14
14
|
end
|
15
15
|
else
|
16
|
-
render json: {error: "Old password
|
16
|
+
render json: {success: false, error: "Old password doesn't match!"}, status: 422
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -2,7 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class ClientSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :code, :name, :match_code, :address, :locale, :user_id, :user_name, :parent_id, :consignees,
|
5
|
-
:shipment_addresses, :tax_code, :vat_number, :currency
|
5
|
+
:shipment_addresses, :tax_code, :vat_number, :currency, :print_details
|
6
6
|
belongs_to :parent
|
7
7
|
belongs_to :country
|
8
8
|
has_many :agents
|
@@ -10,21 +10,42 @@ module Comee
|
|
10
10
|
@ids = ids
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def preprocess_data(xml: false)
|
14
14
|
@ids.each do |id|
|
15
|
-
@line_items =
|
16
|
-
|
17
|
-
|
15
|
+
@line_items = if xml
|
16
|
+
shipment_items = Comee::Core::ShipmentItem.includes(sales_order_item: :sales_order)
|
17
|
+
.where(sales_order_item: {sales_order_id: id})
|
18
|
+
sales_order_item_ids = shipment_items.map { |item| item.sales_order_item_id }
|
19
|
+
Comee::Core::SalesOrderItem.where(id: sales_order_item_ids)
|
20
|
+
else
|
21
|
+
Comee::Core::ShipmentInstructionItem.includes(shipment_item: {sales_order_item: :sales_order})
|
22
|
+
.where(shipment_instruction_id: id)
|
23
|
+
end
|
24
|
+
sales_order_ids = if xml
|
25
|
+
@line_items.map(&:sales_order_id)
|
26
|
+
else
|
27
|
+
@line_items.map { |item| item.shipment_item.sales_order_item.sales_order.id }
|
28
|
+
end
|
18
29
|
@customs_details = Comee::Core::CustomsDetail.includes(sales_order: :customer_order).where(sales_order_id: sales_order_ids)
|
19
30
|
@transportation_routes = []
|
20
31
|
@position_data = []
|
21
32
|
|
22
|
-
packaging_types = @line_items.map
|
33
|
+
packaging_types = @line_items.map do |line_item|
|
34
|
+
if xml
|
35
|
+
Comee::Core::ShipmentItem.find_by(sales_order_item_id: line_item.id).package_type.split(" ")[0]
|
36
|
+
else
|
37
|
+
line_item.shipment_item.package_type.split(" ")[0]
|
38
|
+
end
|
39
|
+
end.uniq
|
23
40
|
|
24
41
|
@no_of_packages = packaging_types.count
|
25
42
|
@package_type = packaging_types.count == 1 && packaging_types.first == "PX" ? "PX" : "PK"
|
26
43
|
@total_weight = @line_items.sum do |line_item|
|
27
|
-
|
44
|
+
if xml
|
45
|
+
(line_item.quantity * line_item.product.weight).round(2)
|
46
|
+
else
|
47
|
+
(line_item.shipment_item.sales_order_item.quantity * line_item.shipment_item.sales_order_item.product.weight).round(2)
|
48
|
+
end
|
28
49
|
end
|
29
50
|
|
30
51
|
raise(StandardError, "No customs detail filed for sales order") unless @customs_details.present?
|
@@ -34,36 +55,37 @@ module Comee
|
|
34
55
|
@transportation_routes << tr["route"][0, 2]
|
35
56
|
end
|
36
57
|
|
37
|
-
prepare_data
|
58
|
+
@data = xml ? generate_xml : prepare_data
|
38
59
|
end
|
39
60
|
|
40
|
-
JSON(@data)
|
61
|
+
xml ? @data : JSON(@data)
|
41
62
|
end
|
42
63
|
|
43
64
|
def position_data
|
44
65
|
position_items = []
|
45
66
|
@line_items.each_with_index do |line_item, index|
|
46
|
-
|
67
|
+
si = line_item.shipment_item
|
68
|
+
customs_detail = @customs_details.find_by(sales_order_id: si.sales_order_item.sales_order_id)
|
47
69
|
mp = Comee::Core::MasterPrice.includes(:country_of_origin).find_by(primary: true,
|
48
|
-
product_id:
|
70
|
+
product_id: si
|
49
71
|
.sales_order_item.product.id)
|
50
|
-
|
72
|
+
|
51
73
|
position_items << {
|
52
74
|
"warePositionsnummer": index + 1,
|
53
|
-
"wareWarennummerKN8":
|
54
|
-
"wareWarenbezeichnung":
|
75
|
+
"wareWarennummerKN8": si.sales_order_item.product.hs_code,
|
76
|
+
"wareWarenbezeichnung": si.sales_order_item.product.hs_description,
|
55
77
|
"wareRegistriernummerFremdsystem": customs_detail.sales_order.customer_order.order_number,
|
56
78
|
"wareUrsprungsbundesland": mp.state_of_origin,
|
57
|
-
"wareEigenmasse":
|
79
|
+
"wareEigenmasse": si.sales_order_item.product.weight * si.sales_order_item.quantity,
|
58
80
|
"wareRohmasse": index.zero? ? @total_weight : 0,
|
59
81
|
"ausfuhrLand": "DE",
|
60
82
|
"ursprungsland": mp.country_of_origin.code,
|
61
83
|
"beantragtesVerfahren": "10",
|
62
84
|
"vorhergehendesVerfahren": "00",
|
63
85
|
"zusatzlichesVerfahren": "F61",
|
64
|
-
"aussenhandelsstatistikMenge":
|
65
|
-
"aussenhandelsstatistikWert": (
|
66
|
-
|
86
|
+
"aussenhandelsstatistikMenge": si.sales_order_item.quantity,
|
87
|
+
"aussenhandelsstatistikWert": (si.sales_order_item.quantity *
|
88
|
+
si.sales_order_item.price * 1.05).round(2),
|
67
89
|
"packstuck": [
|
68
90
|
{
|
69
91
|
"packstuckNummer": index + 1,
|
@@ -79,7 +101,7 @@ module Comee
|
|
79
101
|
end
|
80
102
|
|
81
103
|
def prepare_data
|
82
|
-
|
104
|
+
{
|
83
105
|
"dataIdentifier": "",
|
84
106
|
"kundenNumber": "",
|
85
107
|
"mandantId": "",
|
@@ -155,7 +177,7 @@ module Comee
|
|
155
177
|
def send_customs_details
|
156
178
|
response = HTTParty.post("#{@atlas_base_url}/PutData", headers: {'Content-Type': "application/json",
|
157
179
|
'token': @atlas_token,
|
158
|
-
'bearertoken': bearer_token}, body:
|
180
|
+
'bearertoken': bearer_token}, body: preprocess_data)
|
159
181
|
unless [200, 201].include?(response.code)
|
160
182
|
raise(StandardError,
|
161
183
|
"Failed to send POST request with token: #{response.code} - #{response.body}")
|
@@ -164,6 +186,133 @@ module Comee
|
|
164
186
|
JSON.parse(response.body)
|
165
187
|
end
|
166
188
|
|
189
|
+
def xml_position_data(xml)
|
190
|
+
@line_items.each_with_index do |line_item, index|
|
191
|
+
customs_detail = @customs_details.find_by(sales_order_id: line_item.sales_order_id)
|
192
|
+
mp = Comee::Core::MasterPrice.includes(:country_of_origin).find_by(primary: true,
|
193
|
+
product_id: line_item.product.id)
|
194
|
+
|
195
|
+
xml.Position do
|
196
|
+
xml.Positionsnummer (index + 1).to_s
|
197
|
+
xml.Warenbezeichnung line_item.product.hs_description
|
198
|
+
xml.Registriernummer_Fremdsystem customs_detail.sales_order.customer_order.order_number
|
199
|
+
xml.Kennnummer_der_Sendung @customs_details.map(&:sales_order).map(&:customer_order).map(&:consignee).join(" ")
|
200
|
+
xml.Ursprungsbundesland mp.state_of_origin
|
201
|
+
xml.Ursprungsland mp.country_of_origin.code
|
202
|
+
xml.Eigenmasse line_item.product.weight * line_item.quantity
|
203
|
+
xml.Rohmasse index.zero? ? @total_weight : 0
|
204
|
+
xml.Gefahrgutnummer_UNDG
|
205
|
+
xml.Warennummer_KN8 line_item.product.hs_code
|
206
|
+
xml.Verfahren do
|
207
|
+
xml.angemeldetes "10"
|
208
|
+
xml.vorangegangenes "00"
|
209
|
+
xml.weiteres "F61"
|
210
|
+
xml.Ausfuhrerstattung
|
211
|
+
end
|
212
|
+
xml.Aussenhandelsstatistik do
|
213
|
+
xml.Menge line_item.quantity
|
214
|
+
xml.Wert (line_item.quantity *
|
215
|
+
line_item.price * 1.05).round(2)
|
216
|
+
end
|
217
|
+
xml.Vorpapier do
|
218
|
+
xml.Typ
|
219
|
+
xml.Referenz
|
220
|
+
xml.Zusatz
|
221
|
+
end
|
222
|
+
xml.Packstuecke do
|
223
|
+
xml.Anzahl index.zero? ? @no_of_packages : 0
|
224
|
+
xml.Nummer index + 1
|
225
|
+
xml.Verpackungsart @package_type
|
226
|
+
xml.Zeichen_Nummern customs_detail.sales_order.customer_order.order_number
|
227
|
+
end
|
228
|
+
xml.Unterlage do
|
229
|
+
xml.Qualifizierung
|
230
|
+
xml.Typ
|
231
|
+
xml.Referenz
|
232
|
+
xml.Zusatz
|
233
|
+
xml.Detail
|
234
|
+
xml.Datum_der_Ausstellung
|
235
|
+
xml.Datum_des_Gueltigkeitsendes
|
236
|
+
xml.Wert
|
237
|
+
xml.Masseinheit
|
238
|
+
xml.Aschreibungsmenge
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def generate_xml
|
245
|
+
Nokogiri::XML::Builder.new(encoding: "Windows-1252") do |xml|
|
246
|
+
xml.BEO_ATLAS("xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
247
|
+
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema") do
|
248
|
+
xml.Nachricht do
|
249
|
+
xml.Zollnummer_Sender "4789741"
|
250
|
+
xml.Nachrichten_Typ "DEXPDF"
|
251
|
+
xml.BEO_Atlas_KundenID
|
252
|
+
xml.Anwendung
|
253
|
+
xml.Name "Maveko_korrigiert"
|
254
|
+
end
|
255
|
+
xml.Kopf do
|
256
|
+
xml.EORI_Number "DE47897410000"
|
257
|
+
xml.Art_der_Ausfuhranmeldung @customs_details[0].export_declaration_type
|
258
|
+
xml.Ausfuhrland "DE"
|
259
|
+
xml.Bestimmungsland @customs_details[0].destination_country
|
260
|
+
xml.Container @customs_details[0].containerized == true ? 1 : 0
|
261
|
+
xml.send("Beteiligten-Konstellation", @customs_details[0].participant_constellation.split(" ")[0])
|
262
|
+
xml.send("Gesamt-Rohmasse", @total_weight)
|
263
|
+
xml.Kennnummer_der_Sendung @customs_details.map(&:sales_order).map(&:customer_order).map(&:consignee).join(" ")
|
264
|
+
xml.Bezugsnummer @customs_details.map(&:sales_order).map(&:customer_order).map(&:order_number).join(" ")
|
265
|
+
xml.inlandischerVerkehrszweig @customs_details[0].mode_of_transport
|
266
|
+
xml.verkehrszweigAnDerGrenze @customs_details[0].mode_of_transport_at_border
|
267
|
+
xml.Befoerderungsmittel_an_der_Grenze do
|
268
|
+
xml.Art @customs_details[0].mode_of_transport_type
|
269
|
+
xml.Kennzeichen "UNBEKANNT"
|
270
|
+
end
|
271
|
+
xml.Befoerderungsmittel_am_Abgang do
|
272
|
+
xml.sequenznummer "1"
|
273
|
+
xml.Art @customs_details[0].type_of_identification.split(" ")[0]
|
274
|
+
xml.Kennzeichen @customs_details[0].additional_identifier.split(" ")[0]
|
275
|
+
xml.Staatszugehoerigkeit @customs_details[0].nationality.split(" ")[0]
|
276
|
+
end
|
277
|
+
xml.Ausfuhrzollstelle do
|
278
|
+
xml.Dienststellennummer @customs_details[0].export_customs_office.split(" ")[0]
|
279
|
+
end
|
280
|
+
xml.Vorgesehene_Ausgangszollstelle do
|
281
|
+
xml.Dienststellennummer @customs_details[0].customs_office_of_exit.split(" ")[0]
|
282
|
+
end
|
283
|
+
xml.Geschaeftsvorgang do
|
284
|
+
xml.Art "11"
|
285
|
+
xml.Rechnungspreis @customs_details[0].sales_order.total_price.round(2)
|
286
|
+
xml.Waehrung "EUR"
|
287
|
+
end
|
288
|
+
xml.Befoerderungsroute do
|
289
|
+
@transportation_routes.each do |tr|
|
290
|
+
xml.Land tr
|
291
|
+
end
|
292
|
+
end
|
293
|
+
xml.Empfaenger do
|
294
|
+
xml.Identifikationsart
|
295
|
+
xml.TIN
|
296
|
+
xml.Niederlassungsnummer
|
297
|
+
xml.Name @customs_details[0].sales_order.customer_order.client.name
|
298
|
+
xml.Strasse @address[0]
|
299
|
+
xml.PLZ @address[-1]
|
300
|
+
xml.Ort "#{@address[1].split(' ')[-3]} #{@address[1].split(' ')[-2]}"
|
301
|
+
xml.Land @address[1].split(" ")[-1]
|
302
|
+
end
|
303
|
+
xml.Lieferbedingung do
|
304
|
+
xml.send("Incoterm-Code", @customs_details[0].delivery_term_code[0, 3])
|
305
|
+
xml.Ort "Hamburg"
|
306
|
+
xml.Land "DE"
|
307
|
+
end
|
308
|
+
end
|
309
|
+
xml.Waren do
|
310
|
+
xml_position_data(xml)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end.to_xml
|
314
|
+
end
|
315
|
+
|
167
316
|
private
|
168
317
|
|
169
318
|
def bearer_token
|
data/config/routes.rb
CHANGED
data/lib/comee/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comee_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -515,6 +515,7 @@ files:
|
|
515
515
|
- db/migrate/20240406162711_create_comee_core_goods_issued_items.rb
|
516
516
|
- db/migrate/20240407083617_create_comee_core_email_settings.rb
|
517
517
|
- db/migrate/20240503040722_create_comee_core_client_addresses.rb
|
518
|
+
- db/migrate/20240628205454_add_print_details_field_to_customer.rb
|
518
519
|
- lib/comee/core.rb
|
519
520
|
- lib/comee/core/engine.rb
|
520
521
|
- lib/comee/core/version.rb
|