comee_core 0.1.66 → 0.1.68

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: 47cf5679d2c9d6fbc6d6f0c4f7eb3a6a25c402ec3e4aabf667de41c01b3e2f82
4
- data.tar.gz: 3fc087959c16abb7bc68c36a0e8f126c21922545a6118d19203f8cb3d95e6e2d
3
+ metadata.gz: 2b8fdd8831c1aff501ec1d4628b22c24f647260b5fe16c0e1ef74b2d96c216c0
4
+ data.tar.gz: 47cd51809f26b8a4403ed05901d133b62ce7588bb436f5fac988d11e92c485c2
5
5
  SHA512:
6
- metadata.gz: f42d06b36fa70926e8cd3e0003522aecdad89a5c6a291fe39158beb29b9a769b03d35aa096e40db2bfdb7ff0d79e25538ee8b835e528bcf1b703f33af93fbff5
7
- data.tar.gz: 33719ed3f0a29dd2f68e3c3192158c03a9f361ee62bc640264d385e7233642c4b376347656d71aa838b9aca1535fc1bf18d1f66280878f5efc0195b24e8c28ae
6
+ metadata.gz: ebe4ec1df9d2eb6ada3b572b6c592f4592cf5d0d03f1877b428cea2f02e5abc7821de4968af7670a7f81d65f26944172410ae4a028457d5a06dc68db8d6038ae
7
+ data.tar.gz: e0515f1d51e41f26a7cd0f3d786d53b4fd6bc095430be347e491a3c7a1482cd5bfd24bc56b81e9901490fea714ff60fc5498dbc5422184154ad80c51da7249f5
@@ -11,7 +11,7 @@ module Comee
11
11
  private
12
12
 
13
13
  def model_params
14
- params.require(:payload).permit(:code, :name, :address, :locale, :user_id)
14
+ params.require(:payload).permit(:code, :name, :address, :locale, :user_id, :parent_id)
15
15
  end
16
16
  end
17
17
  end
@@ -11,7 +11,7 @@ module Comee
11
11
  private
12
12
 
13
13
  def model_params
14
- params.require(:payload).permit(:hash_code, :status, :status_date, :remark, :sales_order_item_id, :details)
14
+ params.require(:payload).permit(:hash_code, :status, :status_date, :remark, :shipment_item_id, :details)
15
15
  end
16
16
  end
17
17
  end
@@ -25,32 +25,32 @@ 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
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
54
 
55
55
  private
56
56
 
@@ -0,0 +1,41 @@
1
+ module Comee
2
+ module Core
3
+ class ShipmentItemsController < ApplicationController
4
+ include Common
5
+
6
+ def filter_with_status
7
+ items = ShipmentItem.includes(sales_order_item: %i[sales_order product unit])
8
+ .ransack(params[:q]).result
9
+ statuses = ItemStatus.where(shipment_item_id: items.map(&:id))
10
+ .select("MAX(id) AS max_id, shipment_item_id")
11
+ .group(:shipment_item_id)
12
+ .all
13
+ ids = statuses.map(&:max_id)
14
+ statuses = ItemStatus.where(id: ids).each_with_object({}) { |status, res| res[status.shipment_item_id] = status }
15
+ result = items.each_with_object([]) do |item, res|
16
+ status = statuses[item.id]
17
+ data = {
18
+ sales_order_no: item.sales_order_item.sales_order.order_number,
19
+ customer_item_no: item.sales_order_item.customer_item_no,
20
+ product_code: item.sales_order_item.product.code,
21
+ unit: item.sales_order_item.unit.code,
22
+ quantity: item.sales_order_item.quantity,
23
+ delivery_date: item.sales_order_item.delivery_date,
24
+ handover_date: item.sales_order_item.sales_order.handover_date,
25
+ po_reference: item.sales_order_item.po_reference,
26
+ status: status&.status
27
+ }
28
+ res << data.merge(status&.details)
29
+ end
30
+ render json: {success: true, data: result}
31
+ end
32
+
33
+ private
34
+
35
+ def model_params
36
+ params.require(:payload).permit(:sales_order_item_id, :quantity, :shipment_status, :status, :handover_date, :delivery_date,
37
+ :pallet_no)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -2,6 +2,7 @@ module Comee
2
2
  module Core
3
3
  class Client < ApplicationRecord
4
4
  belongs_to :user, optional: true
5
+ belongs_to :parent, class_name: "Comee::Core::Client", optional: true
5
6
  has_many :warehouse_shipments
6
7
 
7
8
  validates :code, :name, :address, :locale, presence: true
@@ -1,17 +1,22 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ItemStatus < ApplicationRecord
4
+ INITIALIZED = "Initialized".freeze
4
5
  DELIVERY_NOTE_CREATED = "Delivery note created".freeze
5
6
  COMPLETELY_PICKED_AND_PACKED = "Completely Picked & Packed".freeze
6
7
  PARTIALLY_PICKED_AND_PACKED = "Partially Picked & Packed".freeze
7
8
 
8
- belongs_to :sales_order_item
9
+ belongs_to :shipment_item
9
10
 
10
11
  validates :hash_code, :status, :status_date, presence: true
11
12
 
12
13
  def self.ransackable_attributes(_auth_object = nil)
13
14
  %w[hash_code status status_date sales_order_item_id]
14
15
  end
16
+
17
+ def self.ransackable_associations(_auth_object = nil)
18
+ ["shipment_item"]
19
+ end
15
20
  end
16
21
  end
17
22
  end
@@ -6,8 +6,8 @@ module Comee
6
6
  belongs_to :product
7
7
  belongs_to :unit
8
8
  belongs_to :source, class_name: "Comee::Core::FulfillmentCenter", optional: true
9
- has_many :warehouse_shipment_items
10
- has_many :item_statuses
9
+ # has_many :warehouse_shipment_items
10
+ has_many :shipment_items
11
11
 
12
12
  validates :customer_item_no, :delivery_date, presence: true
13
13
  validates :quantity, :price, presence: true, numericality: {greater_than: 0}
@@ -0,0 +1,20 @@
1
+ module Comee
2
+ module Core
3
+ class ShipmentItem < ApplicationRecord
4
+ enum :status, {active: 0, completed: 1}
5
+
6
+ belongs_to :sales_order_item
7
+
8
+ validates :handover_date, :delivery_date, :shipment_status, :status, presence: true
9
+ validates :quantity, presence: true, numericality: {greater_than: 0}
10
+
11
+ def self.ransackable_attributes(_auth_object = nil)
12
+ %w[delivery_date handover_date pallet_no quantity sales_order_item_id shipment_status]
13
+ end
14
+
15
+ def self.ransackable_associations(_auth_object = nil)
16
+ ["sales_order_item"]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ClientSerializer < ActiveModel::Serializer
4
- attributes :id, :code, :name, :address, :locale, :user_id, :user_name
4
+ attributes :id, :code, :name, :address, :locale, :user_id, :user_name, :parent_id
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ItemStatusSerializer < ActiveModel::Serializer
4
- attributes :id, :status, :status_date, :details, :remark, :sales_order_item_id
4
+ attributes :id, :status, :status_date, :details, :remark, :shipment_item_id
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ 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, :pallet_no
5
+ :action_note, :po_reference
6
6
 
7
7
  belongs_to :sales_order
8
8
  belongs_to :customer_order_item
@@ -0,0 +1,8 @@
1
+ module Comee
2
+ module Core
3
+ class ShipmentItemSerializer < ActiveModel::Serializer
4
+ attributes :id, :quantity, :shipment_status, :status, :handover_date, :delivery_date, :pallet_no
5
+ belongs_to :sales_order_item
6
+ end
7
+ end
8
+ end
data/config/routes.rb CHANGED
@@ -83,7 +83,9 @@ Comee::Core::Engine.routes.draw do
83
83
  member do
84
84
  get "suggest", controller: :sales_order_items, action: :suggest_values
85
85
  end
86
+ end
86
87
 
88
+ resources :shipment_items do
87
89
  collection do
88
90
  post "filter_with_status"
89
91
  end
@@ -9,6 +9,10 @@ class CreateComeeCoreClients < ActiveRecord::Migration[7.0]
9
9
  t.string :name, null: false
10
10
  t.string :address, null: false
11
11
  t.string :locale, null: false, default: "en"
12
+ t.references :parent,
13
+ null: true,
14
+ index: {name: "so_on_ccc_indx"},
15
+ foreign_key: {to_table: :comee_core_clients}
12
16
 
13
17
  t.timestamps
14
18
  end
@@ -33,7 +33,6 @@ 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
37
36
 
38
37
  t.timestamps
39
38
  end
@@ -0,0 +1,18 @@
1
+ class CreateComeeCoreShipmentItems < ActiveRecord::Migration[7.1]
2
+ def change
3
+ create_table :comee_core_shipment_items do |t|
4
+ t.references :sales_order_item,
5
+ index: {name: "soi_on_ccsi_indx"},
6
+ null: false,
7
+ foreign_key: {to_table: :comee_core_sales_order_items}
8
+ t.float :quantity, null: false
9
+ t.string :shipment_status, null: false
10
+ t.integer :status, null: false, default: 0
11
+ t.date :handover_date, null: false
12
+ t.date :delivery_date, null: false
13
+ t.string :pallet_no
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -2,10 +2,10 @@ class CreateComeeCoreItemStatuses < ActiveRecord::Migration[7.1]
2
2
  def change
3
3
  create_table :comee_core_item_statuses do |t|
4
4
  t.bigint :hash_code, null: false
5
- t.references :sales_order_item,
5
+ t.references :shipment_item,
6
6
  null: false,
7
7
  index: {name: "so_on_ccis_indx"},
8
- foreign_key: {to_table: :comee_core_sales_order_items}
8
+ foreign_key: {to_table: :comee_core_shipment_items}
9
9
  t.string :status, null: false
10
10
  t.date :status_date, null: false
11
11
  t.jsonb :details
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.66".freeze
3
+ VERSION = "0.1.68".freeze
4
4
  end
5
5
  end
@@ -5,5 +5,6 @@ FactoryBot.define do
5
5
  name { Faker::Name.name }
6
6
  address { Faker::Address.full_address }
7
7
  locale { "en" }
8
+ parent { nil }
8
9
  end
9
10
  end
@@ -1,7 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :item_status, class: "Comee::Core::ItemStatus" do
3
3
  hash_code { "abcdefg".hash }
4
- sales_order_item
4
+ shipment_item
5
5
  status { Faker::Lorem.word }
6
6
  status_date { Date.current }
7
7
  details { {} }
@@ -16,6 +16,5 @@ 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) }
20
19
  end
21
20
  end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :shipment_item, class: "Comee::Core::ShipmentItem" do
3
+ sales_order_item
4
+ quantity { 50 }
5
+ shipment_status { Faker::Lorem.word }
6
+ status { Comee::Core::ShipmentItem.statuses[:active] }
7
+ handover_date { Date.current.advance(days: 3) }
8
+ delivery_date { Date.current.advance(days: 6) }
9
+ pallet_no { Faker::Alphanumeric.alpha(number: 10) }
10
+ end
11
+ 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.1.66
4
+ version: 0.1.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-25 00:00:00.000000000 Z
11
+ date: 2023-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -299,6 +299,7 @@ files:
299
299
  - app/controllers/comee/core/quotation_requests_controller.rb
300
300
  - app/controllers/comee/core/sales_order_items_controller.rb
301
301
  - app/controllers/comee/core/sales_orders_controller.rb
302
+ - app/controllers/comee/core/shipment_items_controller.rb
302
303
  - app/controllers/comee/core/suppliers_controller.rb
303
304
  - app/controllers/comee/core/unit_conversions_controller.rb
304
305
  - app/controllers/comee/core/units_controller.rb
@@ -338,6 +339,7 @@ files:
338
339
  - app/models/comee/core/quotation_request_item.rb
339
340
  - app/models/comee/core/sales_order.rb
340
341
  - app/models/comee/core/sales_order_item.rb
342
+ - app/models/comee/core/shipment_item.rb
341
343
  - app/models/comee/core/supplier.rb
342
344
  - app/models/comee/core/unit.rb
343
345
  - app/models/comee/core/unit_conversion.rb
@@ -364,6 +366,7 @@ files:
364
366
  - app/serializers/comee/core/quotation_request_serializer.rb
365
367
  - app/serializers/comee/core/sales_order_item_serializer.rb
366
368
  - app/serializers/comee/core/sales_order_serializer.rb
369
+ - app/serializers/comee/core/shipment_item_serializer.rb
367
370
  - app/serializers/comee/core/supplier_serializer.rb
368
371
  - app/serializers/comee/core/unit_conversion_serializer.rb
369
372
  - app/serializers/comee/core/unit_serializer.rb
@@ -416,6 +419,7 @@ files:
416
419
  - db/migrate/20231125122723_create_comee_core_purchase_orders.rb
417
420
  - db/migrate/20231126082907_create_comee_core_purchase_order_items.rb
418
421
  - db/migrate/20231206082503_create_comee_core_unit_conversions.rb
422
+ - db/migrate/20231207153420_create_comee_core_shipment_items.rb
419
423
  - db/migrate/20231207235542_create_comee_core_item_statuses.rb
420
424
  - lib/comee/core.rb
421
425
  - lib/comee/core/engine.rb
@@ -450,6 +454,7 @@ files:
450
454
  - spec/factories/comee/core/quotation_requests.rb
451
455
  - spec/factories/comee/core/sales_order_items.rb
452
456
  - spec/factories/comee/core/sales_orders.rb
457
+ - spec/factories/comee/core/shipment_items.rb
453
458
  - spec/factories/comee/core/suppliers.rb
454
459
  - spec/factories/comee/core/unit_conversions.rb
455
460
  - spec/factories/comee/core/units.rb