comee_core 0.3.19 → 0.3.21
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fab2298e1068d07c363f1b68294580c1083674dd2b8e39c138a9915a66e95c5
|
4
|
+
data.tar.gz: 28eee2c59364a03df98d8e8dcf64f5cd1077f6b1c3bd787a27c668ead48bbda2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 786348f507b5a0c8ac4908c07fa36d946dbd938a56fdca4e2f197677532b8ceca183b8228d004ba2c43c825261542439921f26bb05b8221d63b7930fbd20ebb3
|
7
|
+
data.tar.gz: 3fe9e3c69f795418bcc608571c0ef8ea1270e0154d43dd7cf88481d00a527883786f8fe58d5ba3c05fd83fb5193251f5e91d5b51068bae3cded9e31c6d4d01f7
|
@@ -13,41 +13,26 @@ module Comee
|
|
13
13
|
def preprocess_data(xml: false)
|
14
14
|
@ids.each do |id|
|
15
15
|
@line_items = if xml
|
16
|
-
|
17
|
-
|
18
|
-
sales_order_item_ids = shipment_items.map { |item| item.sales_order_item_id }
|
19
|
-
Comee::Core::SalesOrderItem.where(id: sales_order_item_ids)
|
16
|
+
Comee::Core::ShipmentInstructionItem.includes(shipment_item: {sales_order_item: :sales_order})
|
17
|
+
.where(delivery_note_id: id)
|
20
18
|
else
|
21
19
|
Comee::Core::ShipmentInstructionItem.includes(shipment_item: {sales_order_item: :sales_order})
|
22
20
|
.where(shipment_instruction_id: id)
|
23
21
|
end
|
24
|
-
sales_order_ids =
|
25
|
-
|
26
|
-
else
|
27
|
-
@line_items.map { |item| item.shipment_item.sales_order_item.sales_order.id }
|
28
|
-
end
|
22
|
+
sales_order_ids = @line_items.map { |item| item.shipment_item.sales_order_item.sales_order.id }
|
23
|
+
|
29
24
|
@customs_details = Comee::Core::CustomsDetail.includes(sales_order: :customer_order).where(sales_order_id: sales_order_ids)
|
30
25
|
@transportation_routes = []
|
31
26
|
@position_data = []
|
32
27
|
|
33
28
|
packaging_types = @line_items.map do |line_item|
|
34
|
-
|
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
|
29
|
+
line_item.shipment_item.package_type.split(" ")[0]
|
39
30
|
end.uniq
|
40
31
|
|
41
32
|
@no_of_packages = packaging_types.count
|
42
33
|
@package_type = packaging_types.count == 1 && packaging_types.first == "PX" ? "PX" : "PK"
|
43
34
|
@total_weight = @line_items.sum do |line_item|
|
44
|
-
|
45
|
-
xml_line = Comee::Core::ShipmentInstructionItem.where(shipment_item_id: Comee::Core::ShipmentItem
|
46
|
-
.find_by(sales_order_item_id: line_item.id).id).first
|
47
|
-
(xml_line.quantity * xml_line.weight).round(2)
|
48
|
-
else
|
49
|
-
(line_item.quantity * line_item.weight).round(2)
|
50
|
-
end
|
35
|
+
(line_item.quantity * line_item.weight).round(2)
|
51
36
|
end
|
52
37
|
|
53
38
|
raise(StandardError, "No customs detail filed for sales order") unless @customs_details.present?
|
@@ -63,7 +48,11 @@ module Comee
|
|
63
48
|
|
64
49
|
@data = xml ? generate_xml : prepare_data
|
65
50
|
end
|
66
|
-
xml
|
51
|
+
if xml
|
52
|
+
{xml_data: @data, file_name: "#{@customs_details[0].sales_order.customer_order.order_number}_Ausfuhr"}
|
53
|
+
else
|
54
|
+
JSON(@data)
|
55
|
+
end
|
67
56
|
end
|
68
57
|
|
69
58
|
def position_data
|
@@ -81,7 +70,7 @@ module Comee
|
|
81
70
|
"wareWarenbezeichnung": si.sales_order_item.product.customs_description,
|
82
71
|
"wareRegistriernummerFremdsystem": customs_detail.sales_order.customer_order.order_number,
|
83
72
|
"wareUrsprungsbundesland": mp.state_of_origin.split(" ")[0],
|
84
|
-
"wareEigenmasse": line_item.weight * line_item.quantity,
|
73
|
+
"wareEigenmasse": (line_item.weight * line_item.quantity).round(2),
|
85
74
|
"wareRohmasse": index.zero? ? @total_weight : 0,
|
86
75
|
"ausfuhrLand": "DE",
|
87
76
|
"ursprungsland": mp.country_of_origin.code,
|
@@ -193,21 +182,22 @@ module Comee
|
|
193
182
|
|
194
183
|
def xml_position_data(xml)
|
195
184
|
@line_items.each_with_index do |line_item, index|
|
196
|
-
|
185
|
+
sales_order_item = line_item.shipment_item.sales_order_item
|
186
|
+
customs_detail = @customs_details.find_by(sales_order_id: sales_order_item.sales_order_id)
|
197
187
|
mp = Comee::Core::MasterPrice.includes(:country_of_origin).find_by(primary: true,
|
198
|
-
product_id:
|
188
|
+
product_id: sales_order_item.product.id)
|
199
189
|
|
200
190
|
xml.Position do
|
201
191
|
xml.Positionsnummer (index + 1).to_s
|
202
|
-
xml.Warenbezeichnung
|
192
|
+
xml.Warenbezeichnung sales_order_item.product.customs_description
|
203
193
|
xml.Registriernummer_Fremdsystem customs_detail.sales_order.customer_order.order_number
|
204
194
|
xml.Kennnummer_der_Sendung @customs_details.map(&:sales_order).map(&:customer_order).map(&:consignee).join(" ")
|
205
195
|
xml.Ursprungsbundesland mp.state_of_origin.split(" ")[0]
|
206
196
|
xml.Ursprungsland mp.country_of_origin.code
|
207
|
-
xml.Eigenmasse
|
197
|
+
xml.Eigenmasse (sales_order_item.product.weight * sales_order_item.quantity).round(2)
|
208
198
|
xml.Rohmasse index.zero? ? @total_weight : 0
|
209
199
|
xml.Gefahrgutnummer_UNDG
|
210
|
-
xml.Warennummer_KN8
|
200
|
+
xml.Warennummer_KN8 sales_order_item.product.hs_code
|
211
201
|
xml.Verfahren do
|
212
202
|
xml.angemeldetes "10"
|
213
203
|
xml.vorangegangenes "00"
|
@@ -215,9 +205,9 @@ module Comee
|
|
215
205
|
xml.Ausfuhrerstattung
|
216
206
|
end
|
217
207
|
xml.Aussenhandelsstatistik do
|
218
|
-
xml.Menge
|
219
|
-
xml.Wert (
|
220
|
-
|
208
|
+
xml.Menge sales_order_item.quantity
|
209
|
+
xml.Wert (sales_order_item.quantity *
|
210
|
+
sales_order_item.price * 1.05).round(2).to_i
|
221
211
|
end
|
222
212
|
xml.Vorpapier do
|
223
213
|
xml.Typ
|
@@ -175,17 +175,7 @@ module Comee
|
|
175
175
|
)
|
176
176
|
master_prices = MasterPrice.includes(:supplier).where(primary: true, status: Price.statuses[:current],
|
177
177
|
product_id: product_ids)
|
178
|
-
queries = master_prices.each_with_object([]) do |obj, res|
|
179
|
-
res << {
|
180
|
-
product_id: obj.product_id,
|
181
|
-
itemable_id: obj.supplier_id
|
182
|
-
}
|
183
|
-
end
|
184
178
|
|
185
|
-
product_lookups = queries.inject(ProductLookup.none) do |conditions, condition|
|
186
|
-
conditions.or(ProductLookup.where(condition))
|
187
|
-
end
|
188
|
-
product_lookups = product_lookups.includes(:itemable).where(itemable_type: "Comee::Core::Supplier")
|
189
179
|
items = order_items.each_with_object([]) do |item, res|
|
190
180
|
next if item.canceled?
|
191
181
|
|
@@ -194,9 +184,9 @@ module Comee
|
|
194
184
|
quantity = convert_quantity(item.quantity, item.unit_id, unit_id)
|
195
185
|
client_price = client_prices.find { |price| price.product_id == item.product_id }
|
196
186
|
master_price = master_prices.find { |price| price.product_id == item.product_id }
|
197
|
-
product_lookup = product_lookups.find { |lookup| lookup.product_id == item.product_id }
|
198
187
|
raise(StandardError, "No primary supplier found for product #{item.customer_item_no}") unless master_price
|
199
188
|
|
189
|
+
product_lookup = master_price.product_lookup
|
200
190
|
price = if client_price
|
201
191
|
convert_price(client_price.price, client_price.unit_id, unit_id)
|
202
192
|
else
|
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.21
|
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-07-
|
11
|
+
date: 2024-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|