comee_core 0.1.80 → 0.1.82
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/client_prices_controller.rb +16 -49
- data/app/models/comee/core/client_price.rb +1 -1
- data/app/models/comee/core/master_price.rb +1 -1
- data/app/serializers/comee/core/client_price_serializer.rb +1 -0
- data/app/serializers/comee/core/master_price_serializer.rb +1 -0
- data/config/routes.rb +1 -0
- data/lib/comee/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec2eead92d024daab37e1477e49f59cf15b03710c8f2846cca144a2991bb2a1
|
4
|
+
data.tar.gz: 11b7949daff48bb2b49466abbede7b76c39b1e862bb332a1b5f5999308b1fcc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438cb2d9d91f97c3d7ab2aa099e949045dadcf67528b9eb146b356adaa9bb849776256fc5c258ef99b461252ba6765e80e2d864c31f35f631a5db70e7417c176
|
7
|
+
data.tar.gz: 986ce5f97c44033fc95ff38ace756d151dcaeef290be9b6d4fa0349898c6f4c851a918d74242bd71462eb04fde947def19ded389c56c570ae432aae59eb29431
|
@@ -10,57 +10,24 @@ module Comee
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def fetch_for_client
|
14
|
+
client = Comee::Core::Client.find(params[:id])
|
15
|
+
client_id = client.parent_id || client.id
|
16
|
+
prices = Comee::Core::ClientPrice.includes(:client, :product, :unit, :product_lookup)
|
17
|
+
.where(client_id: client_id)
|
18
|
+
total = prices.count
|
19
|
+
prices = prices.then(&paginate)
|
20
|
+
|
21
|
+
render json: {success: true, data: serialize(prices), page: params[:page], total: total}
|
22
|
+
end
|
23
|
+
|
13
24
|
def filter
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
25
|
+
prices = Comee::Core::ClientPrice.includes(:client, :product, :unit, :product_lookup)
|
26
|
+
.ransack(params[:q]).result
|
27
|
+
total = prices.count
|
28
|
+
prices = prices.then(&paginate)
|
18
29
|
|
19
|
-
|
20
|
-
conditions.or(Comee::Core::ProductLookup.where(condition))
|
21
|
-
end
|
22
|
-
result = @client_prices.each_with_object([]) do |obj, res|
|
23
|
-
item = {
|
24
|
-
id: obj.id,
|
25
|
-
valid_from: obj.valid_from,
|
26
|
-
valid_to: obj.valid_to,
|
27
|
-
price: obj.price,
|
28
|
-
status: obj.status,
|
29
|
-
margin: obj.margin,
|
30
|
-
margin_type: obj.margin_type,
|
31
|
-
client_id: obj.client.id,
|
32
|
-
client_code: obj.client.code,
|
33
|
-
client_name: obj.client.name,
|
34
|
-
client_address: obj.client.address,
|
35
|
-
product_id: obj.product.id,
|
36
|
-
product_code: obj.product.code,
|
37
|
-
product_name: obj.product.name,
|
38
|
-
product_description: obj.product.description,
|
39
|
-
product_preferred_units: obj.product.preferred_units,
|
40
|
-
product_weight: obj.product.weight,
|
41
|
-
product_weight_unit: obj.product.weight_unit,
|
42
|
-
product_dimensions: obj.product.dimensions,
|
43
|
-
product_hs_code: obj.product.hs_code,
|
44
|
-
product_hs_description: obj.product.hs_description,
|
45
|
-
product_image: obj.product.thumbnail_image_url,
|
46
|
-
unit_id: obj.unit.id,
|
47
|
-
unit_code: obj.unit.code,
|
48
|
-
unit_name: obj.unit.name
|
49
|
-
}
|
50
|
-
lkp = lookups.select { |lookup| lookup.itemable_id == obj.client_id && lookup.product_id == obj.product_id }
|
51
|
-
if lkp.count.positive?
|
52
|
-
item[:client_product_code] = lkp[0].code
|
53
|
-
item[:client_product_name] = lkp[0].item_description
|
54
|
-
end
|
55
|
-
res << item
|
56
|
-
end
|
57
|
-
result = {success: true, data: result}
|
58
|
-
page = params[:page]
|
59
|
-
if page
|
60
|
-
result[:page] = page
|
61
|
-
result[:total] = total
|
62
|
-
end
|
63
|
-
render json: result
|
30
|
+
render json: {success: true, data: serialize(prices), page: params[:page], total: total}
|
64
31
|
end
|
65
32
|
|
66
33
|
private
|
data/config/routes.rb
CHANGED
@@ -68,6 +68,7 @@ Comee::Core::Engine.routes.draw do
|
|
68
68
|
resources :clients do
|
69
69
|
member do
|
70
70
|
get "rfq_products", controller: :quotation_requests, action: :rfq_products_for_client
|
71
|
+
get "prices", controller: :client_prices, action: :fetch_for_client
|
71
72
|
end
|
72
73
|
collection do
|
73
74
|
post "filter"
|
data/lib/comee/core/version.rb
CHANGED