comee_core 0.1.63 → 0.1.65

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: 7799ea96479660919b2feddcb0ef645e8345a0fcd76d0a964d16444b128cd8a1
4
- data.tar.gz: 3260186fbe16cfaed82416e5ccaf76a039aa9fca284a01ba3fc8ef7c1797c9bd
3
+ metadata.gz: 52af84253c893c7cd0227d8f90bf1cfc08122dddd244dc08b43a35cb37d1e023
4
+ data.tar.gz: '088941a03a3d82ce6139ee9dbbe37184efc8b5f14dfc28bbedc8c7cc01713359'
5
5
  SHA512:
6
- metadata.gz: 6075b7c40bf2255b933d80bcaafc54ec3a45bfd237f5c0759bd47830e0d66b382c97a92a33eb0d82f9974867e2b508036b716bfa451a0c26e67936883f87b753
7
- data.tar.gz: 11e4007cd8d5606f29deca92f6d9fbb801fc3867cee39052440d1e45fb40e11607db1e7dd11284ecac5428e2455e11f2c10abf078565d6ea6d947d88d394ddb7
6
+ metadata.gz: 594acab1ee9e374d297fd00251ec3abffa8a3b3f7fe10aef418fd6209d310a4f55376d1dfac93a3948375afcbf196ff4d0bb4e748b6d83e5acb3087208d5c00f
7
+ data.tar.gz: 39b42c4dea22968643c0a782850fe981599936983494b3621beeeb055d31a7f4f104f040bb5b81d6b658dc9242e21e2b11c326ae6362003914060e7de4cbddc3
@@ -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, images: [])
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,12 +25,39 @@ 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
31
58
  params.require(:payload).permit(:sales_order_id, :customer_order_item_id, :product_id, :unit_id, :quantity, :quantity_delivered,
32
59
  :customer_item_no, :price, :delivery_date, :eb_number, :lead_time, :comment, :action_note,
33
- :po_reference, :source_id)
60
+ :po_reference, :pallet_no, :source_id)
34
61
  end
35
62
  end
36
63
  end
@@ -49,8 +49,9 @@ module Comee
49
49
  private
50
50
 
51
51
  def model_params
52
- params.require(:payload).permit(:order_number, :customer_order_id, :payment_penalty, :status, :fulfillment_center_id,
53
- :total_price, :amount_paid, :pallete_note, :handover_date, :remark, files: [])
52
+ params.require(:payload).permit(:order_number, :customer_order_id, :payment_penalty, :payment_term, :delivery_term, :status,
53
+ :fulfillment_center_id, :total_price, :amount_paid, :pallete_note, :handover_date, :remark,
54
+ files: [])
54
55
  end
55
56
 
56
57
  def back_order_params
@@ -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
@@ -2,10 +2,12 @@ module Comee
2
2
  module Core
3
3
  class SalesOrderItemSerializer < ActiveModel::Serializer
4
4
  attributes :id, :customer_item_no, :quantity, :quantity_delivered, :price, :delivery_date, :eb_number, :lead_time, :comment,
5
- :action_note, :po_reference, :product, :unit
5
+ :action_note, :po_reference, :pallet_no
6
6
 
7
+ belongs_to :sales_order
7
8
  belongs_to :customer_order_item
8
9
  belongs_to :source
10
+ belongs_to :product
9
11
  belongs_to :unit
10
12
  end
11
13
  end
@@ -1,8 +1,8 @@
1
1
  module Comee
2
2
  module Core
3
3
  class SalesOrderSerializer < ActiveModel::Serializer
4
- attributes :id, :order_number, :payment_penalty, :status, :total_price,
5
- :amount_paid, :pallete_note, :handover_date, :remark, :files_url
4
+ attributes :id, :order_number, :payment_penalty, :status, :total_price, :payment_term, :delivery_term, :amount_paid, :pallete_note,
5
+ :handover_date, :remark, :files_url
6
6
  belongs_to :customer_order
7
7
  belongs_to :fulfillment_center
8
8
  has_many :sales_order_items
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"},
@@ -10,6 +10,8 @@ class CreateComeeCoreSalesOrders < ActiveRecord::Migration[7.0]
10
10
  null: true,
11
11
  index: {name: "fc_on_ccso_indx"},
12
12
  foreign_key: {to_table: :comee_core_fulfillment_centers}
13
+ t.string :payment_term
14
+ t.string :delivery_term
13
15
  t.float :payment_penalty, null: false, default: 0.0
14
16
  t.integer :status, null: false, default: 0
15
17
  t.float :total_price, null: false, default: 0
@@ -33,6 +33,7 @@ class CreateComeeCoreSalesOrderItems < ActiveRecord::Migration[7.0]
33
33
  t.string :comment
34
34
  t.string :action_note
35
35
  t.string :po_reference
36
+ t.string :pallet_no
36
37
 
37
38
  t.timestamps
38
39
  end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.63".freeze
3
+ VERSION = "0.1.65".freeze
4
4
  end
5
5
  end
@@ -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
@@ -16,5 +16,6 @@ FactoryBot.define do
16
16
  comment { Faker::Lorem.sentence }
17
17
  action_note { Faker::Lorem.sentence }
18
18
  po_reference { Faker::Alphanumeric.alpha(number: 10) }
19
+ pallet_no { Faker::Alphanumeric.alpha(number: 10) }
19
20
  end
20
21
  end
@@ -3,6 +3,8 @@ FactoryBot.define do
3
3
  order_number { Faker::Alphanumeric.alpha(number: 10) }
4
4
  customer_order
5
5
  fulfillment_center
6
+ payment_term { Faker::Lorem.sentence }
7
+ delivery_term { Faker::Lorem.sentence }
6
8
  payment_penalty { 0 }
7
9
  total_price { 0 }
8
10
  amount_paid { 0 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comee_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.63
4
+ version: 0.1.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.