comee_core 0.1.89 → 0.1.91

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/comee/core/clients_controller.rb +8 -1
  3. data/app/controllers/comee/core/customer_orders_controller.rb +11 -4
  4. data/app/controllers/comee/core/sales_orders_controller.rb +1 -1
  5. data/app/controllers/comee/core/shipment_items_controller.rb +12 -0
  6. data/app/models/comee/core/back_order.rb +1 -1
  7. data/app/models/comee/core/client.rb +1 -0
  8. data/app/models/comee/core/client_price.rb +1 -0
  9. data/app/models/comee/core/customer_order.rb +1 -1
  10. data/app/models/comee/core/customer_order_item.rb +1 -1
  11. data/app/models/comee/core/invoice.rb +1 -0
  12. data/app/models/comee/core/item_status.rb +1 -1
  13. data/app/models/comee/core/master_price.rb +1 -0
  14. data/app/models/comee/core/pickup_schedule.rb +4 -0
  15. data/app/models/comee/core/product.rb +1 -1
  16. data/app/models/comee/core/product_lookup.rb +1 -1
  17. data/app/models/comee/core/purchase_order.rb +1 -0
  18. data/app/models/comee/core/purchase_order_item.rb +1 -0
  19. data/app/models/comee/core/quotation_request.rb +1 -1
  20. data/app/models/comee/core/quotation_request_item.rb +1 -1
  21. data/app/models/comee/core/sales_order.rb +2 -0
  22. data/app/models/comee/core/sales_order_item.rb +5 -0
  23. data/app/models/comee/core/shipment_instruction.rb +1 -1
  24. data/app/models/comee/core/shipment_item.rb +1 -1
  25. data/app/models/comee/core/supplier.rb +1 -1
  26. data/app/models/comee/core/transport_availability.rb +1 -1
  27. data/app/models/comee/core/unit.rb +1 -1
  28. data/app/models/comee/core/warehouse_shipment.rb +1 -1
  29. data/app/serializers/comee/core/client_serializer.rb +1 -1
  30. data/app/serializers/comee/core/customer_order_serializer.rb +4 -1
  31. data/app/serializers/comee/core/sales_order_serializer.rb +1 -0
  32. data/app/services/comee/core/customer_order_service.rb +2 -1
  33. data/config/routes.rb +2 -0
  34. data/db/migrate/20230728123039_create_comee_core_clients.rb +1 -0
  35. data/db/migrate/20230811083239_create_comee_core_customer_orders.rb +5 -0
  36. data/db/migrate/20230812190652_create_comee_core_sales_orders.rb +4 -0
  37. data/lib/comee/core/version.rb +1 -1
  38. data/spec/factories/comee/core/clients.rb +1 -0
  39. data/spec/factories/comee/core/customer_orders.rb +5 -0
  40. data/spec/factories/comee/core/sales_orders.rb +1 -0
  41. metadata +2 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2215fbbb3c1a9e0c836eb20902ea9c9871e473d08bb17c0659ca6c20236daeb
4
- data.tar.gz: a546d3c21ef0b354c9ff61159309919145de3335e16639d9674a6ae1f2414824
3
+ metadata.gz: 14e262013c470d553126a6ecad9eb449dc01732b39cf3b683b4b7e6089f6cea4
4
+ data.tar.gz: bf5cca3975a004dbea56eab907497cc6d1006a7ae941ff0a9d7e4bd5578f8e79
5
5
  SHA512:
6
- metadata.gz: e00d19d0c5d47518505c4a4b5f7ef3a336807966795d933cff8ce7f133dfe32aebc50d76cb2d8dbd78b1010e89d271be9cf3dd6d1b30175b1405f50024108559
7
- data.tar.gz: 5a9d63dd29c4ec4ed87b555dc7cb7b316d1fb69f97dbbc59f14dbc6cc638fd34ca0291103cb355078903276963911bd7953be094daeb3be86fd91157c7fc4039
6
+ metadata.gz: 49c812d17aaee3068d9b677f814cc1b3d5b8da0f6e5313e6289a7942f6ea040a8a012d477fc9ed9d540aead752c3bfe650a29b110c2af30b7c6ea0fcf3cf5e0e
7
+ data.tar.gz: 5886c9b99451ba968ac667d77d130ea25740c57149edc9b28a3591eb8d2841bc963a97aa118257013e4a954ef608431c53a4b67e530173e19e63afab706300ff
@@ -8,10 +8,17 @@ module Comee
8
8
  render json: {success: true, data: serialize(@clients)}
9
9
  end
10
10
 
11
+ def consignees
12
+ client = Comee::Core::Client.find(params[:id])
13
+ render json: {success: true, data: client.consignees}
14
+ rescue StandardError => e
15
+ render json: {success: false, error: e.message}
16
+ end
17
+
11
18
  private
12
19
 
13
20
  def model_params
14
- params.require(:payload).permit(:code, :name, :address, :locale, :user_id, :parent_id)
21
+ params.require(:payload).permit(:code, :name, :address, :locale, :user_id, :parent_id, consignees: [])
15
22
  end
16
23
  end
17
24
  end
@@ -46,13 +46,20 @@ module Comee
46
46
  private
47
47
 
48
48
  def model_params
49
- params.require(:payload).permit(:order_number, :order_date, :order_terms, :delivery_address, :invoice_address, :status, :client_id,
50
- :file)
49
+ params.require(:payload)
50
+ .permit(
51
+ :order_number, :order_date, :order_terms, :consignee, :final_destination, :final_delivery_date, :handover_date,
52
+ :shipping_date, :delivery_address, :invoice_address, :status, :client_id, :file
53
+ )
51
54
  end
52
55
 
53
56
  def create_with_item_params
54
- params.require(:payload).permit(:order_number, :order_date, :order_terms, :delivery_address, :invoice_address, :status, :client_id,
55
- items: %i[customer_item_no product_id quantity price unit_id delivery_date])
57
+ params.require(:payload)
58
+ .permit(
59
+ :order_number, :order_date, :order_terms, :consignee, :final_destination, :final_delivery_date, :handover_date,
60
+ :shipping_date, :delivery_address, :invoice_address, :status, :client_id,
61
+ items: %i[customer_item_no product_id quantity price unit_id delivery_date]
62
+ )
56
63
  end
57
64
 
58
65
  def set_service
@@ -54,7 +54,7 @@ module Comee
54
54
  def model_params
55
55
  params.require(:payload).permit(:order_number, :customer_order_id, :payment_penalty, :payment_term, :delivery_term, :status,
56
56
  :fulfillment_center_id, :total_price, :amount_paid, :pallete_note, :handover_date, :remark,
57
- files: [])
57
+ :client_id, files: [])
58
58
  end
59
59
 
60
60
  def back_order_params
@@ -8,6 +8,18 @@ module Comee
8
8
  render json: {success: true, data: serialize(@shipment_item)}
9
9
  end
10
10
 
11
+ def filter_for_client
12
+ shipment_items = Comee::Core::ShipmentItem.joins(sales_order_item: :sales_order)
13
+ .where(
14
+ comee_core_sales_order_items: {
15
+ comee_core_sales_orders: {
16
+ client_id: params[:id]
17
+ }
18
+ }
19
+ )
20
+ render json: {success: true, data: serialize(shipment_items)}
21
+ end
22
+
11
23
  def filter_with_status
12
24
  items = ShipmentItem.includes(sales_order_item: %i[sales_order product unit])
13
25
  .ransack(params[:q]).result
@@ -14,7 +14,7 @@ module Comee
14
14
  delegate(:name, to: :supplier, prefix: true)
15
15
 
16
16
  def self.ransackable_attributes(_auth_object = nil)
17
- %w[delivery_address delivery_date invoice_address order_date order_number status supplier_id]
17
+ %w[id delivery_address delivery_date invoice_address order_date order_number status supplier_id]
18
18
  end
19
19
 
20
20
  def self.ransackable_associations(_auth_object = nil)
@@ -12,6 +12,7 @@ module Comee
12
12
 
13
13
  def self.ransackable_attributes(_auth_object = nil)
14
14
  %w[
15
+ id
15
16
  user_id
16
17
  address
17
18
  code
@@ -25,6 +25,7 @@ module Comee
25
25
 
26
26
  def self.ransackable_attributes(_auth_object = nil)
27
27
  %w[
28
+ id
28
29
  valid_from
29
30
  valid_to
30
31
  price
@@ -10,7 +10,7 @@ module Comee
10
10
  validates :order_number, :order_date, :delivery_address, :invoice_address, :status, presence: true
11
11
 
12
12
  def self.ransackable_attributes(_auth_object = nil)
13
- %w[client_id delivery_address invoice_address order_number status]
13
+ %w[id client_id delivery_address invoice_address order_number status]
14
14
  end
15
15
 
16
16
  def self.ransackable_associations(_auth_object = nil)
@@ -8,7 +8,7 @@ module Comee
8
8
  validates :customer_item_no, :quantity, :price, :delivery_date, presence: true
9
9
 
10
10
  def self.ransackable_attributes(_auth_object = nil)
11
- %w[customer_order_id product_id unit_id]
11
+ %w[id customer_order_id product_id unit_id]
12
12
  end
13
13
 
14
14
  def self.ransackable_associations(_auth_object = nil)
@@ -25,6 +25,7 @@ module Comee
25
25
 
26
26
  def self.ransackable_attributes(_auth_object = nil)
27
27
  %w[
28
+ id
28
29
  sales_order_id
29
30
  invoice_no
30
31
  date_issued
@@ -14,7 +14,7 @@ module Comee
14
14
  validates :status, inclusion: {in: STATUSES}
15
15
 
16
16
  def self.ransackable_attributes(_auth_object = nil)
17
- %w[hash_code status status_date sales_order_item_id]
17
+ %w[id hash_code status status_date sales_order_item_id]
18
18
  end
19
19
 
20
20
  def self.ransackable_associations(_auth_object = nil)
@@ -43,6 +43,7 @@ module Comee
43
43
 
44
44
  def self.ransackable_attributes(_auth_object = nil)
45
45
  %w[
46
+ id
46
47
  valid_from
47
48
  valid_to
48
49
  purchase_price
@@ -6,6 +6,10 @@ module Comee
6
6
  belongs_to :pod
7
7
  belongs_to :time_slot
8
8
  validates :status, presence: true
9
+
10
+ def self.ransackable_attributes(_auth_object = nil)
11
+ %w[id driver_license_no plate_no pod_id status time_slot_id truck_no]
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -30,7 +30,7 @@ module Comee
30
30
  end
31
31
 
32
32
  def self.ransackable_attributes(_auth_object = nil)
33
- %w[code name description]
33
+ %w[id code name description]
34
34
  end
35
35
 
36
36
  def self.ransackable_associations(_auth_object = nil)
@@ -7,7 +7,7 @@ module Comee
7
7
  validates :code, :item_description, presence: true
8
8
 
9
9
  def self.ransackable_attributes(_auth_object = nil)
10
- %w[code item_description itemable_id itemable_type product_id]
10
+ %w[id code item_description itemable_id itemable_type product_id]
11
11
  end
12
12
 
13
13
  def self.ransackable_associations(_auth_object = nil)
@@ -11,6 +11,7 @@ module Comee
11
11
  }
12
12
  def self.ransackable_attributes(_auth_object = nil)
13
13
  %w[
14
+ id
14
15
  supplier_id
15
16
  order_date
16
17
  status
@@ -18,6 +18,7 @@ module Comee
18
18
 
19
19
  def self.ransackable_attributes(_auth_object = nil)
20
20
  %w[
21
+ id
21
22
  purchase_order_id
22
23
  sales_order_item_id
23
24
  quantity
@@ -11,7 +11,7 @@ module Comee
11
11
  validates :status, presence: true
12
12
 
13
13
  def self.ransackable_attributes(_auth_object = nil)
14
- %w[client_id reference_no status]
14
+ %w[id client_id reference_no status]
15
15
  end
16
16
 
17
17
  private
@@ -11,7 +11,7 @@ module Comee
11
11
  validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
12
12
 
13
13
  def self.ransackable_attributes(_auth_object = nil)
14
- %w[quotation_request_id product_id unit_id quantity price margin margin_type expected_delivery_date]
14
+ %w[id quotation_request_id product_id unit_id quantity price margin margin_type expected_delivery_date]
15
15
  end
16
16
  end
17
17
  end
@@ -5,6 +5,7 @@ module Comee
5
5
 
6
6
  belongs_to :customer_order
7
7
  belongs_to :fulfillment_center, optional: true
8
+ belongs_to :client
8
9
  has_many :sales_order_items
9
10
  has_many_attached :files
10
11
  has_one :customs_detail
@@ -30,6 +31,7 @@ module Comee
30
31
 
31
32
  def self.ransackable_attributes(_auth_object = nil)
32
33
  %w[
34
+ id
33
35
  order_number
34
36
  status
35
37
  customer_order_id
@@ -15,6 +15,7 @@ module Comee
15
15
 
16
16
  def self.ransackable_attributes(_auth_object = nil)
17
17
  %w[
18
+ id
18
19
  customer_item_no
19
20
  customer_order_item_id
20
21
  delivery_date
@@ -28,6 +29,10 @@ module Comee
28
29
  unit_id
29
30
  ]
30
31
  end
32
+
33
+ def self.ransackable_associations(_auth_object = nil)
34
+ %w[customer_order_item product sales_order source unit]
35
+ end
31
36
  end
32
37
  end
33
38
  end
@@ -10,7 +10,7 @@ module Comee
10
10
  validates :status, presence: true
11
11
 
12
12
  def self.ransackable_attributes(_auth_object = nil)
13
- %w[client_id reference_no status]
13
+ %w[id client_id reference_no status]
14
14
  end
15
15
  end
16
16
  end
@@ -10,7 +10,7 @@ module Comee
10
10
  validates :quantity, presence: true, numericality: {greater_than: 0}
11
11
 
12
12
  def self.ransackable_attributes(_auth_object = nil)
13
- %w[delivery_date handover_date pallet_no quantity sales_order_item_id shipment_status]
13
+ %w[id delivery_date handover_date pallet_no quantity sales_order_item_id shipment_status]
14
14
  end
15
15
 
16
16
  def self.ransackable_associations(_auth_object = nil)
@@ -7,7 +7,7 @@ module Comee
7
7
  validates :name, :address, :locale, presence: true
8
8
 
9
9
  def self.ransackable_attributes(_auth_object = nil)
10
- %w[user_id code address locale]
10
+ %w[id user_id code address locale]
11
11
  end
12
12
 
13
13
  def self.ransackable_associations(_auth_object = nil)
@@ -13,7 +13,7 @@ module Comee
13
13
  end
14
14
 
15
15
  def self.ransackable_attributes(_auth_object = nil)
16
- %w[availability_date weekday weekday_short]
16
+ %w[id availability_date weekday weekday_short]
17
17
  end
18
18
  end
19
19
  end
@@ -15,7 +15,7 @@ module Comee
15
15
  end
16
16
 
17
17
  def self.ransackable_attributes(_auth_object = nil)
18
- %w[code name unit_type]
18
+ %w[id code name unit_type]
19
19
  end
20
20
  end
21
21
  end
@@ -10,7 +10,7 @@ module Comee
10
10
  validates :destination, :delivery_date, :status, presence: true
11
11
 
12
12
  def self.ransackable_attributes(_auth_object = nil)
13
- %w[client_id delivery_date destination id reference_number status]
13
+ %w[id client_id delivery_date destination id reference_number status]
14
14
  end
15
15
 
16
16
  def self.ransackable_associations(_auth_object = nil)
@@ -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, :parent_id
4
+ attributes :id, :code, :name, :address, :locale, :user_id, :user_name, :parent_id, :consignees
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,10 @@
1
1
  module Comee
2
2
  module Core
3
3
  class CustomerOrderSerializer < ActiveModel::Serializer
4
- attributes :id, :order_number, :order_date, :order_terms, :delivery_address, :invoice_address, :status, :file_url, :client
4
+ attributes :id, :order_number, :order_date, :order_terms, :consignee, :final_destination, :final_delivery_date, :handover_date,
5
+ :shipping_date, :delivery_address, :invoice_address, :status, :file_url
6
+
7
+ belongs_to :client
5
8
  has_many :customer_order_items
6
9
  end
7
10
  end
@@ -4,6 +4,7 @@ module Comee
4
4
  attributes :id, :order_number, :payment_penalty, :status, :total_price, :payment_term, :delivery_term, :amount_paid, :pallete_note,
5
5
  :handover_date, :remark, :files_url, :customs_detail
6
6
  belongs_to :customer_order
7
+ belongs_to :client
7
8
  belongs_to :fulfillment_center
8
9
  has_many :sales_order_items
9
10
  end
@@ -135,7 +135,8 @@ module Comee
135
135
  sales_order = SalesOrder.create!(
136
136
  order_number: order.order_number,
137
137
  customer_order: order,
138
- status: SalesOrder.statuses[:draft]
138
+ status: SalesOrder.statuses[:draft],
139
+ client: order.client
139
140
  )
140
141
  order_items = order.customer_order_items.includes(:product, :unit)
141
142
  client_id = order.client.parent_id || order.client_id
data/config/routes.rb CHANGED
@@ -81,6 +81,8 @@ Comee::Core::Engine.routes.draw do
81
81
  member do
82
82
  get "rfq_products", controller: :quotation_requests, action: :rfq_products_for_client
83
83
  get "prices", controller: :client_prices, action: :fetch_for_client
84
+ get "consignees"
85
+ get "shipment_items", controller: :shipment_items, action: :filter_for_client
84
86
  end
85
87
  collection do
86
88
  post "filter"
@@ -13,6 +13,7 @@ class CreateComeeCoreClients < ActiveRecord::Migration[7.0]
13
13
  null: true,
14
14
  index: {name: "so_on_ccc_indx"},
15
15
  foreign_key: {to_table: :comee_core_clients}
16
+ t.string :consignees, array: true, default: []
16
17
 
17
18
  t.timestamps
18
19
  end
@@ -8,6 +8,11 @@ class CreateComeeCoreCustomerOrders < ActiveRecord::Migration[7.1]
8
8
  index: {name: "client_on_cccuo_indx"},
9
9
  foreign_key: {to_table: :comee_core_clients}
10
10
  t.string :order_terms
11
+ t.string :consignee
12
+ t.string :final_destination
13
+ t.date :final_delivery_date
14
+ t.date :handover_date
15
+ t.date :shipping_date
11
16
  t.string :delivery_address, null: false
12
17
  t.string :invoice_address, null: false
13
18
  t.integer :status, null: false, default: 0
@@ -10,6 +10,10 @@ 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.references :client,
14
+ null: false,
15
+ index: {name: "client_on_ccso_indx"},
16
+ foreign_key: {to_table: :comee_core_clients}
13
17
  t.string :payment_term
14
18
  t.string :delivery_term
15
19
  t.float :payment_penalty, null: false, default: 0.0
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.89".freeze
3
+ VERSION = "0.1.91".freeze
4
4
  end
5
5
  end
@@ -6,5 +6,6 @@ FactoryBot.define do
6
6
  address { Faker::Address.full_address }
7
7
  locale { "en" }
8
8
  parent { nil }
9
+ consignees { [] }
9
10
  end
10
11
  end
@@ -4,6 +4,11 @@ FactoryBot.define do
4
4
  order_date { Date.current }
5
5
  client
6
6
  order_terms { Faker::Lorem.sentence }
7
+ consignee { Faker::Name.name }
8
+ final_destination { Faker::Address.full_address }
9
+ final_delivery_date { Faker::Date.between(from: Date.current.advance(days: 20), to: Date.current.advance(months: 2)) }
10
+ handover_date { final_delivery_date.advance(days: -10) }
11
+ shipping_date { handover_date.advance(days: 10) }
7
12
  delivery_address { Faker::Address.full_address }
8
13
  invoice_address { Faker::Address.full_address }
9
14
  status { 0 }
@@ -3,6 +3,7 @@ FactoryBot.define do
3
3
  order_number { Faker::Alphanumeric.alpha(number: 10) }
4
4
  customer_order
5
5
  fulfillment_center
6
+ client
6
7
  payment_term { Faker::Lorem.sentence }
7
8
  delivery_term { Faker::Lorem.sentence }
8
9
  payment_penalty { 0 }
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.89
4
+ version: 0.1.91
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -240,34 +240,6 @@ dependencies:
240
240
  - - ">="
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
- - !ruby/object:Gem::Dependency
244
- name: spring
245
- requirement: !ruby/object:Gem::Requirement
246
- requirements:
247
- - - ">="
248
- - !ruby/object:Gem::Version
249
- version: '0'
250
- type: :development
251
- prerelease: false
252
- version_requirements: !ruby/object:Gem::Requirement
253
- requirements:
254
- - - ">="
255
- - !ruby/object:Gem::Version
256
- version: '0'
257
- - !ruby/object:Gem::Dependency
258
- name: spring-commands-rspec
259
- requirement: !ruby/object:Gem::Requirement
260
- requirements:
261
- - - ">="
262
- - !ruby/object:Gem::Version
263
- version: '0'
264
- type: :development
265
- prerelease: false
266
- version_requirements: !ruby/object:Gem::Requirement
267
- requirements:
268
- - - ">="
269
- - !ruby/object:Gem::Version
270
- version: '0'
271
243
  description: An engine which contains core models and end-points for the COMee ERP.
272
244
  email:
273
245
  - henockl@live.com