comee_core 0.1.62 → 0.1.64
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/products_controller.rb +2 -1
- data/app/controllers/comee/core/sales_order_items_controller.rb +27 -0
- data/app/models/comee/core/back_order_item.rb +1 -1
- data/app/models/comee/core/product.rb +1 -0
- data/app/models/comee/core/sales_order_item.rb +16 -0
- data/app/serializers/comee/core/product_serializer.rb +3 -1
- data/app/serializers/comee/core/sales_order_item_serializer.rb +1 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20230728014322_create_comee_core_products.rb +8 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/products.rb +5 -0
- 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: c4cd6ae8953f0384e6621da475902a2cc7dbde2c84878da91a819a3bb4dd03ef
|
4
|
+
data.tar.gz: cffd56f30c07ea7030935b845baffc6285d0064e2cc6e5c7557bc7b4a39ce805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d3565e8fad90e32587fafa45309b44faaeb04326aaf5ce108dbe4be90150858d40a88476c2b76fa4163552e6066ee05ec76fa3fd7698b8263661c5712e77f99
|
7
|
+
data.tar.gz: 4ee979f53c118c6c372d794657140d347b9177467ab3a041bb684e870f261b35b0511da3fc14c1a64923d5d18c98fa33d5e50a79aecdfc94dc436855fd46dc83
|
@@ -35,7 +35,8 @@ module Comee
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def model_params
|
38
|
-
params.required(:payload).permit(:code, :name, :description, :parent_id, :thumbnail_image, :preferred_units, :source_id,
|
38
|
+
params.required(:payload).permit(:code, :name, :description, :parent_id, :thumbnail_image, :preferred_units, :source_id, :weight,
|
39
|
+
:weight_unit_id, :dimensions, :hs_code, :hs_description, images: [])
|
39
40
|
end
|
40
41
|
|
41
42
|
def price_params
|
@@ -25,6 +25,33 @@ module Comee
|
|
25
25
|
render json: {success: true}
|
26
26
|
end
|
27
27
|
|
28
|
+
def filter_with_status
|
29
|
+
items = SalesOrderItem.includes(:sales_order, :product, :unit)
|
30
|
+
.ransack(params[:q]).result
|
31
|
+
statuses = ItemStatus.where(sales_order_item_id: items.map(&:id))
|
32
|
+
.select("MAX(id) AS max_id, sales_order_item_id")
|
33
|
+
.group(:sales_order_item_id)
|
34
|
+
.all
|
35
|
+
ids = statuses.map(&:max_id)
|
36
|
+
statuses = ItemStatus.where(id: ids).each_with_object({}) { |status, res| res[status.sales_order_item_id] = status }
|
37
|
+
result = items.each_with_object([]) do |item, res|
|
38
|
+
status = statuses[item.id]
|
39
|
+
data = {
|
40
|
+
sales_order_no: item.sales_order.order_number,
|
41
|
+
customer_item_no: item.customer_item_no,
|
42
|
+
product_code: item.product.code,
|
43
|
+
unit: item.unit.code,
|
44
|
+
quantity: item.quantity,
|
45
|
+
delivery_date: item.delivery_date,
|
46
|
+
handover_date: item.sales_order.handover_date,
|
47
|
+
po_reference: item.po_reference,
|
48
|
+
status: status&.status
|
49
|
+
}
|
50
|
+
res << data.merge(status&.details)
|
51
|
+
end
|
52
|
+
render json: {success: true, data: result}
|
53
|
+
end
|
54
|
+
|
28
55
|
private
|
29
56
|
|
30
57
|
def model_params
|
@@ -11,7 +11,7 @@ module Comee
|
|
11
11
|
presence: true, numericality: {greater_than: 0}
|
12
12
|
|
13
13
|
delegate(:code, :name, :description, to: :product, prefix: true)
|
14
|
-
delegate(:unit_code, :unit_name, to: :product, prefix: false)
|
14
|
+
# delegate(:unit_code, :unit_name, to: :product, prefix: false)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -8,6 +8,7 @@ module Comee
|
|
8
8
|
has_many_attached :images
|
9
9
|
|
10
10
|
belongs_to :source, class_name: "Comee::Core::FulfillmentCenter", optional: true
|
11
|
+
belongs_to :weight_unit, class_name: "Comee::Core::Unit", optional: true
|
11
12
|
|
12
13
|
validates :code, presence: true, uniqueness: true
|
13
14
|
validates :name, presence: true
|
@@ -12,6 +12,22 @@ module Comee
|
|
12
12
|
validates :customer_item_no, :delivery_date, presence: true
|
13
13
|
validates :quantity, :price, presence: true, numericality: {greater_than: 0}
|
14
14
|
validates :quantity_delivered, numericality: {greater_than_or_equal_to: 0}
|
15
|
+
|
16
|
+
def self.ransackable_attributes(_auth_object = nil)
|
17
|
+
%w[
|
18
|
+
customer_item_no
|
19
|
+
customer_order_item_id
|
20
|
+
delivery_date
|
21
|
+
eb_number
|
22
|
+
handover_date
|
23
|
+
lead_time
|
24
|
+
po_reference
|
25
|
+
product_id
|
26
|
+
sales_order_id
|
27
|
+
source_id
|
28
|
+
unit_id
|
29
|
+
]
|
30
|
+
end
|
15
31
|
end
|
16
32
|
end
|
17
33
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ProductSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :code, :name, :description, :thumbnail_image_url, :images_url, :preferred_units
|
4
|
+
attributes :id, :code, :name, :description, :thumbnail_image_url, :images_url, :preferred_units, :weight, :dimensions, :hs_code,
|
5
|
+
:hs_description
|
5
6
|
belongs_to :source
|
7
|
+
belongs_to :weight_unit
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
@@ -4,6 +4,7 @@ module Comee
|
|
4
4
|
attributes :id, :customer_item_no, :quantity, :quantity_delivered, :price, :delivery_date, :eb_number, :lead_time, :comment,
|
5
5
|
:action_note, :po_reference, :product, :unit
|
6
6
|
|
7
|
+
belongs_to :sales_order
|
7
8
|
belongs_to :customer_order_item
|
8
9
|
belongs_to :source
|
9
10
|
belongs_to :unit
|
data/config/routes.rb
CHANGED
@@ -77,6 +77,10 @@ Comee::Core::Engine.routes.draw do
|
|
77
77
|
member do
|
78
78
|
get "suggest", controller: :sales_order_items, action: :suggest_values
|
79
79
|
end
|
80
|
+
|
81
|
+
collection do
|
82
|
+
post "filter_with_status"
|
83
|
+
end
|
80
84
|
end
|
81
85
|
post "/sales_orders/filter", controller: :sales_orders, action: :filter
|
82
86
|
resources :sales_orders do
|
@@ -7,6 +7,14 @@ class CreateComeeCoreProducts < ActiveRecord::Migration[7.0]
|
|
7
7
|
t.boolean :leaf, null: false, default: true
|
8
8
|
t.string :ancestry
|
9
9
|
t.jsonb :preferred_units, null: false, default: []
|
10
|
+
t.float :weight
|
11
|
+
t.references :weight_unit,
|
12
|
+
null: true,
|
13
|
+
index: {name: "wu_on_ccp_indx"},
|
14
|
+
foreign_key: {to_table: :comee_core_units}
|
15
|
+
t.string :dimensions
|
16
|
+
t.string :hs_code
|
17
|
+
t.string :hs_description
|
10
18
|
t.references :source,
|
11
19
|
null: true,
|
12
20
|
index: {name: "source_on_ccp_indx"},
|
data/lib/comee/core/version.rb
CHANGED
@@ -9,6 +9,11 @@ FactoryBot.define do
|
|
9
9
|
leaf { true }
|
10
10
|
ancestry { root.id.to_s }
|
11
11
|
preferred_units { [] }
|
12
|
+
weight { 10 }
|
13
|
+
weight_unit factory: :unit
|
14
|
+
dimensions { "2cm x 3cm x 1cm" }
|
15
|
+
hs_code { Faker::Alphanumeric.alpha(number: 10) }
|
16
|
+
hs_description { Faker::Lorem.sentence }
|
12
17
|
source factory: :fulfillment_center
|
13
18
|
end
|
14
19
|
end
|