comee_core 0.3.11 → 0.3.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b6796c9762235ab680c6f6448e3a3477c5e416fea5be8c3c4ccc64a64e71bf6
4
- data.tar.gz: 11ad8734fe46aa084620a083e8ed3272f3a2fad35ca6e285ab6057d2afc35877
3
+ metadata.gz: 37e018316397b9835966d15f409f2884a9e1cc3749eef845f92f36a4ab72ecad
4
+ data.tar.gz: 5bf530dcf32e3567c152ff57ba3d339a4f0f0feae80581d85215daa3c124d77a
5
5
  SHA512:
6
- metadata.gz: 90d030062d66d47f417224fcb7ea25384f52c28b29c6eca5b7e88d3fbed8d54f91f027bf0ee39d53a0fb7eda44f3e23a930baf748af1f9f1e5d4b9015328d932
7
- data.tar.gz: 5b7d36dfee0389e38716b66b6d4bce04214847eee0e3320d421861d29d5d1abed5730197e946d8704ff9cc937250e78aef17a8990ee4612269d0743274586e72
6
+ metadata.gz: 102bc7736fb711184cc69fc515df446b4c850eeab201a3eb8449b524b5fa2c780f74208489732a4f111dcb3f92609db9b980298e3f20275bd6ef7aa09fbe16c1
7
+ data.tar.gz: 1d3c76695cadb18c210e59084e0e350f865d86a4a5d1c0df4b7eec91eca7cf4cacf8d9cc650ccab00f959c0eb8673f6ee39d9ca72987f498344fd329eba52627
@@ -39,6 +39,7 @@ module Comee
39
39
  def update_sales_order
40
40
  sales_order.calculate_total_price
41
41
  sales_order.calculate_vat
42
+ sales_order.save!
42
43
  end
43
44
 
44
45
  def quantity_remaining
@@ -160,27 +160,32 @@ module Comee
160
160
  shipping_date: order.shipping_date,
161
161
  delivery_date: order.final_delivery_date,
162
162
  consignee: order.consignee,
163
- created_by: accepted_by || ""
163
+ created_by: accepted_by || "",
164
+ consolidator_date: order.consolidator_date,
165
+ voyage_no: order.voyage_no,
166
+ shipping_arrangement: order.shipping_arrangement
164
167
  )
165
168
  order_items = order.customer_order_items.includes(:product, :unit)
166
169
  client_id = order.client.parent_id || order.client_id
170
+ product_ids = order_items.map(&:product_id).uniq
167
171
  client_prices = ClientPrice.where(
168
172
  client_id: client_id,
169
- product_id: order_items.map(&:product_id),
173
+ product_id: product_ids,
170
174
  status: ClientPrice.statuses[:current]
171
175
  )
172
176
  master_prices = MasterPrice.includes(:supplier).where(primary: true, status: Price.statuses[:current],
173
- product: order_items.map(&:product))
174
- main_query = ProductLookup.includes(:itemable).where(itemable_type: "Comee::Core::Supplier")
177
+ product_id: product_ids)
175
178
  queries = master_prices.each_with_object([]) do |obj, res|
176
179
  res << {
177
180
  product_id: obj.product_id,
178
181
  itemable_id: obj.supplier_id
179
182
  }
180
183
  end
181
- product_lookups = queries.inject(main_query) do |conditions, condition|
184
+
185
+ product_lookups = queries.inject(ProductLookup.none) do |conditions, condition|
182
186
  conditions.or(ProductLookup.where(condition))
183
187
  end
188
+ product_lookups = product_lookups.includes(:itemable).where(itemable_type: "Comee::Core::Supplier")
184
189
  items = order_items.each_with_object([]) do |item, res|
185
190
  next if item.canceled?
186
191
 
@@ -189,9 +194,7 @@ module Comee
189
194
  quantity = convert_quantity(item.quantity, item.unit_id, unit_id)
190
195
  client_price = client_prices.find { |price| price.product_id == item.product_id }
191
196
  master_price = master_prices.find { |price| price.product_id == item.product_id }
192
- product_lookup = product_lookups.find do |lookup|
193
- lookup.product_id == master_price.product_id && lookup.itemable_id == master_price.supplier_id
194
- end
197
+ product_lookup = product_lookups.find { |lookup| lookup.product_id == item.product_id }
195
198
  raise(StandardError, "No primary supplier found for product #{item.customer_item_no}") unless master_price
196
199
 
197
200
  price = if client_price
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.3.11".freeze
3
+ VERSION = "0.3.13".freeze
4
4
  end
5
5
  end
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.11
4
+ version: 0.3.13
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-01 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers