comee_core 0.1.69 → 0.1.71
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 +40 -2
- data/app/controllers/comee/core/shipment_items_controller.rb +5 -0
- data/app/models/comee/core/sales_order.rb +1 -0
- data/app/serializers/comee/core/sales_order_serializer.rb +1 -1
- data/config/routes.rb +1 -1
- data/lib/comee/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af05a9a39c3e49d30c92aee06f9e27fbe4e02c7c1678a417df369fb88a6bf47b
|
4
|
+
data.tar.gz: a36ab5dcdaea7c2e22d8c41bbfc37d533a42b3472e83494124da6fe5bd9d311e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3adaf0714c2d01b384b240884fe6dd94047cfa04b2f29d0271d97147b94708a8d35312b062b47fa18802e51720cda21e5a844b6e66045e6873287dbee6b93942
|
7
|
+
data.tar.gz: 9df735b384d02638be87742ac3d11f32eac8be43672c1d428d5ff66510b34308eb54f523b6c40717287a1000ed3ebaba74b50c76edff0d288dbccdfbb49aac1a
|
@@ -11,9 +11,47 @@ module Comee
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def filter
|
14
|
-
@client_prices = Comee::Core::ClientPrice.ransack(params[:q]).result
|
14
|
+
@client_prices = Comee::Core::ClientPrice.includes(:client, :product, :unit).ransack(params[:q]).result
|
15
15
|
@client_prices = @client_prices.then(&paginate)
|
16
|
-
|
16
|
+
queries = @client_prices.map { |cp| {itemable_id: cp.client_id, product_id: cp.product_id, itemable_type: "Comee::Core::Client"} }
|
17
|
+
|
18
|
+
lookups = queries.inject(Comee::Core::ProductLookup.none) do |conditions, condition|
|
19
|
+
conditions.or(Comee::Core::ProductLookup.where(condition))
|
20
|
+
end
|
21
|
+
result = @client_prices.each_with_object([]) do |obj, res|
|
22
|
+
item = {
|
23
|
+
id: obj.id,
|
24
|
+
valid_from: obj.valid_from,
|
25
|
+
valid_to: obj.valid_to,
|
26
|
+
price: obj.price,
|
27
|
+
status: obj.status,
|
28
|
+
margin: obj.margin,
|
29
|
+
margin_type: obj.margin_type,
|
30
|
+
client_code: obj.client.code,
|
31
|
+
client_name: obj.client.name,
|
32
|
+
client_address: obj.client.address,
|
33
|
+
product_code: obj.product.code,
|
34
|
+
product_name: obj.product.name,
|
35
|
+
product_description: obj.product.description,
|
36
|
+
product_preferred_units: obj.product.preferred_units,
|
37
|
+
product_weight: obj.product.weight,
|
38
|
+
product_weight_unit: obj.product.weight_unit,
|
39
|
+
product_dimensions: obj.product.dimensions,
|
40
|
+
product_hs_code: obj.product.hs_code,
|
41
|
+
product_hs_description: obj.product.hs_description,
|
42
|
+
product_image: obj.product.thumbnail_image_url,
|
43
|
+
unit_code: obj.unit.code,
|
44
|
+
unit_name: obj.unit.name
|
45
|
+
}
|
46
|
+
lkp = lookups.select { |lookup| lookup.itemable_id == obj.client_id && lookup.product_id == obj.product_id }
|
47
|
+
if lkp.count.positive?
|
48
|
+
item[:client_product_code] = lkp[0].code
|
49
|
+
item[:client_product_name] = lkp[0].item_description
|
50
|
+
end
|
51
|
+
res << item
|
52
|
+
end
|
53
|
+
|
54
|
+
render json: {success: true, data: result}
|
17
55
|
end
|
18
56
|
|
19
57
|
private
|
@@ -3,6 +3,11 @@ module Comee
|
|
3
3
|
class ShipmentItemsController < ApplicationController
|
4
4
|
include Common
|
5
5
|
|
6
|
+
def filter
|
7
|
+
@shipment_item = Comee::Core::ShipmentItem.ransack(params[:q]).result
|
8
|
+
render json: {success: true, data: serialize(@shipment_item)}
|
9
|
+
end
|
10
|
+
|
6
11
|
def filter_with_status
|
7
12
|
items = ShipmentItem.includes(sales_order_item: %i[sales_order product unit])
|
8
13
|
.ransack(params[:q]).result
|
@@ -2,7 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class SalesOrderSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :order_number, :payment_penalty, :status, :total_price, :payment_term, :delivery_term, :amount_paid, :pallete_note,
|
5
|
-
:handover_date, :remark, :files_url
|
5
|
+
:handover_date, :remark, :files_url, :customs_detail
|
6
6
|
belongs_to :customer_order
|
7
7
|
belongs_to :fulfillment_center
|
8
8
|
has_many :sales_order_items
|
data/config/routes.rb
CHANGED
@@ -86,10 +86,10 @@ Comee::Core::Engine.routes.draw do
|
|
86
86
|
get "suggest", controller: :sales_order_items, action: :suggest_values
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
90
89
|
resources :shipment_items do
|
91
90
|
collection do
|
92
91
|
post "filter_with_status"
|
92
|
+
post "filter"
|
93
93
|
end
|
94
94
|
end
|
95
95
|
post "/sales_orders/filter", controller: :sales_orders, action: :filter
|
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.1.
|
4
|
+
version: 0.1.71
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|