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 +4 -4
- data/app/controllers/comee/core/clients_controller.rb +1 -1
- data/app/controllers/comee/core/item_statuses_controller.rb +1 -1
- data/app/controllers/comee/core/sales_order_items_controller.rb +26 -26
- data/app/controllers/comee/core/shipment_items_controller.rb +41 -0
- data/app/models/comee/core/client.rb +1 -0
- data/app/models/comee/core/item_status.rb +6 -1
- data/app/models/comee/core/sales_order_item.rb +2 -2
- data/app/models/comee/core/shipment_item.rb +20 -0
- data/app/serializers/comee/core/client_serializer.rb +1 -1
- data/app/serializers/comee/core/item_status_serializer.rb +1 -1
- data/app/serializers/comee/core/sales_order_item_serializer.rb +1 -1
- data/app/serializers/comee/core/shipment_item_serializer.rb +8 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20230728123039_create_comee_core_clients.rb +4 -0
- data/db/migrate/20230812212844_create_comee_core_sales_order_items.rb +0 -1
- data/db/migrate/20231207153420_create_comee_core_shipment_items.rb +18 -0
- data/db/migrate/20231207235542_create_comee_core_item_statuses.rb +2 -2
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/clients.rb +1 -0
- data/spec/factories/comee/core/item_statuses.rb +1 -1
- data/spec/factories/comee/core/sales_order_items.rb +0 -1
- data/spec/factories/comee/core/shipment_items.rb +11 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b8fdd8831c1aff501ec1d4628b22c24f647260b5fe16c0e1ef74b2d96c216c0
|
4
|
+
data.tar.gz: 47cd51809f26b8a4403ed05901d133b62ce7588bb436f5fac988d11e92c485c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(:hash_code, :status, :status_date, :remark, :
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
@@ -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 :
|
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 :
|
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
|
@@ -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
|
5
|
+
:action_note, :po_reference
|
6
6
|
|
7
7
|
belongs_to :sales_order
|
8
8
|
belongs_to :customer_order_item
|
data/config/routes.rb
CHANGED
@@ -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
|
@@ -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 :
|
5
|
+
t.references :shipment_item,
|
6
6
|
null: false,
|
7
7
|
index: {name: "so_on_ccis_indx"},
|
8
|
-
foreign_key: {to_table: :
|
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
|
data/lib/comee/core/version.rb
CHANGED
@@ -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.
|
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-
|
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
|