comee_core 0.1.82 → 0.1.84

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: aec2eead92d024daab37e1477e49f59cf15b03710c8f2846cca144a2991bb2a1
4
- data.tar.gz: 11b7949daff48bb2b49466abbede7b76c39b1e862bb332a1b5f5999308b1fcc4
3
+ metadata.gz: 88c220e6b121eb2fc8a4191d432f5063df0bad832d3489443798c44618421797
4
+ data.tar.gz: 78c951ec96109410776b2345b927772a6e069ef078b558e69f7bbef0b49fca67
5
5
  SHA512:
6
- metadata.gz: 438cb2d9d91f97c3d7ab2aa099e949045dadcf67528b9eb146b356adaa9bb849776256fc5c258ef99b461252ba6765e80e2d864c31f35f631a5db70e7417c176
7
- data.tar.gz: 986ce5f97c44033fc95ff38ace756d151dcaeef290be9b6d4fa0349898c6f4c851a918d74242bd71462eb04fde947def19ded389c56c570ae432aae59eb29431
6
+ metadata.gz: 726ab140419d49fb2b08bc68beb970cdc3f5f34ea5de70ed0f65d90a4b2930fb3a976def5dadd5837ca48e5c5a237d75dec8b5ad333c380f048302c224d588e7
7
+ data.tar.gz: 0a49d0031869536a37b50af5a67d86ca6e51bfc3631d3191965c90270d2dbe14949e748464ad164530543a48e353b355ed012321a6ada12dc574592301519aa5
@@ -3,7 +3,12 @@ module Comee
3
3
  class CustomerOrdersController < ApplicationController
4
4
  include Common
5
5
 
6
- before_action :set_service, only: %i[submit submit_for_confirmation accept cancel]
6
+ before_action :set_service, only: %i[create_with_items submit submit_for_confirmation accept cancel]
7
+
8
+ def create_with_items
9
+ order = @service.create(create_with_item_params)
10
+ render json: {success: true, data: serialize(order)}
11
+ end
7
12
 
8
13
  def submit
9
14
  order = @service.submit(params[:id])
@@ -45,6 +50,11 @@ module Comee
45
50
  :file)
46
51
  end
47
52
 
53
+ 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])
56
+ end
57
+
48
58
  def set_service
49
59
  @service = CustomerOrderService.new
50
60
  end
@@ -0,0 +1,13 @@
1
+ module Comee
2
+ module Core
3
+ class FulfillmentCentersController < ApplicationController
4
+ include Common
5
+
6
+ private
7
+
8
+ def model_params
9
+ params.require(:payload).permit(:code, :name, :address, :email, service: [])
10
+ end
11
+ end
12
+ end
13
+ end
@@ -27,6 +27,11 @@ module Comee
27
27
  render json: {success: true, data: serialize(data)}
28
28
  end
29
29
 
30
+ def categories
31
+ root = Product.find_by(code: "root")
32
+ render json: {success: true, data: serialize(root.children)}
33
+ end
34
+
30
35
  def filter
31
36
  products = Product.ransack(params[:q]).result
32
37
  render json: {success: true, data: serialize(products)}
@@ -6,7 +6,10 @@ module Comee
6
6
 
7
7
  def index
8
8
  super do
9
- Comee::Core::SalesOrder.includes(:customer_order, :fulfillment_center, :sales_order_items).all
9
+ [
10
+ Comee::Core::SalesOrder.includes(:customer_order, :fulfillment_center, :sales_order_items).all,
11
+ include: ["sales_order_items", "sales_order_items.product", "sales_order_items.unit"]
12
+ ]
10
13
  end
11
14
  end
12
15
 
@@ -9,16 +9,28 @@ module Comee
9
9
  end
10
10
 
11
11
  def index
12
- data = if block_given?
13
- yield
14
- else
15
- @clazz.all
16
- end
12
+ data = nil
13
+ options = {}
14
+ if block_given?
15
+ incoming = yield
16
+ if incoming.instance_of?(Array)
17
+ data, options = incoming
18
+ else
19
+ data = incoming
20
+ end
21
+ else
22
+ data = @clazz.all
23
+ end
24
+ # data, options = if block_given?
25
+ # yield
26
+ # else
27
+ # [@clazz.all, {}]
28
+ # end
17
29
  page = params[:page]
18
30
  if page
19
- render json: {success: true, data: serialize(data), page: page, total: @clazz.count}
31
+ render json: {success: true, data: serialize(data, options), page: page, total: @clazz.count}
20
32
  else
21
- render json: {success: true, data: serialize(data)}
33
+ render json: {success: true, data: serialize(data, options)}
22
34
  end
23
35
  end
24
36
 
@@ -58,8 +70,8 @@ module Comee
58
70
 
59
71
  private
60
72
 
61
- def serialize(data)
62
- ActiveModelSerializers::SerializableResource.new(data)
73
+ def serialize(data, options = {})
74
+ ActiveModelSerializers::SerializableResource.new(data, options)
63
75
  end
64
76
 
65
77
  def set_clazz
@@ -9,6 +9,10 @@ module Comee
9
9
  def self.ransackable_attributes(_auth_object = nil)
10
10
  %w[code item_description itemable_id itemable_type product_id]
11
11
  end
12
+
13
+ def self.ransackable_associations(_auth_object = nil)
14
+ []
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -8,6 +8,10 @@ module Comee
8
8
 
9
9
  validates :reference_no, presence: true, uniqueness: true
10
10
  validates :status, presence: true
11
+
12
+ def self.ransackable_attributes(_auth_object = nil)
13
+ %w[client_id reference_no status]
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -0,0 +1,7 @@
1
+ module Comee
2
+ module Core
3
+ class FulfillmentCenterSerializer < ActiveModel::Serializer
4
+ attributes :id, :code, :name, :address, :email, :service
5
+ end
6
+ end
7
+ end
@@ -1,6 +1,19 @@
1
1
  module Comee
2
2
  module Core
3
3
  class CustomerOrderService
4
+ def create(params)
5
+ order = nil
6
+ params = params.with_indifferent_access
7
+ ActiveRecord::Base.transaction do
8
+ order_params = params.except(:items)
9
+ order = Comee::Core::CustomerOrder.create(**order_params)
10
+ items = params.slice(:items)[:items]
11
+ items.each { |item| item[:customer_order_id] = order.id }
12
+ Comee::Core::CustomerOrderItem.insert_all!(items)
13
+ end
14
+ order
15
+ end
16
+
4
17
  ##
5
18
  # This method converts a price value per a unit of measure to a price value per another
6
19
  # unit of measure.
data/config/routes.rb CHANGED
@@ -8,12 +8,17 @@ Comee::Core::Engine.routes.draw do
8
8
  post "mark_as_unread", controller: :notifications, action: :mark_as_unread
9
9
  end
10
10
  end
11
- post "/suppliers/filter", controller: :suppliers, action: :filter
12
- resources :suppliers
11
+ resources :suppliers do
12
+ collection do
13
+ post "filter"
14
+ end
15
+ end
13
16
  resources :products do
14
17
  collection do
15
18
  post "master_prices"
16
19
  post "client_prices"
20
+ post "filter"
21
+ get "categories"
17
22
  end
18
23
  end
19
24
  resources :product_lookups do
@@ -42,7 +47,6 @@ Comee::Core::Engine.routes.draw do
42
47
  end
43
48
  end
44
49
  resources :external_rfqs
45
- post "/customer_orders/filter", controller: :customer_orders, action: :filter
46
50
  resources :customer_orders do
47
51
  member do
48
52
  post "submit"
@@ -50,6 +54,10 @@ Comee::Core::Engine.routes.draw do
50
54
  post "accept"
51
55
  post "cancel"
52
56
  end
57
+ collection do
58
+ post "filter"
59
+ post "create_with_items"
60
+ end
53
61
  end
54
62
  resources :customer_order_items do
55
63
  collection do
@@ -106,7 +114,10 @@ Comee::Core::Engine.routes.draw do
106
114
  end
107
115
  end
108
116
  resources :customs_details
109
- resources :item_statuses
110
- post "/item_statuses/filter", controller: :item_statuses, action: :filter
111
- post "/products/filter", controller: :products, action: :filter
117
+ resources :item_statuses do
118
+ collection do
119
+ post "filter"
120
+ end
121
+ end
122
+ resources :fulfillment_centers
112
123
  end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.82".freeze
3
+ VERSION = "0.1.84".freeze
4
4
  end
5
5
  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.82
4
+ version: 0.1.84
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-06 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -288,6 +288,7 @@ files:
288
288
  - app/controllers/comee/core/customer_orders_controller.rb
289
289
  - app/controllers/comee/core/customs_details_controller.rb
290
290
  - app/controllers/comee/core/external_rfqs_controller.rb
291
+ - app/controllers/comee/core/fulfillment_centers_controller.rb
291
292
  - app/controllers/comee/core/item_statuses_controller.rb
292
293
  - app/controllers/comee/core/lookups_controller.rb
293
294
  - app/controllers/comee/core/notifications_controller.rb
@@ -356,6 +357,7 @@ files:
356
357
  - app/serializers/comee/core/customer_order_serializer.rb
357
358
  - app/serializers/comee/core/customs_detail_serializer.rb
358
359
  - app/serializers/comee/core/external_rfq_serializer.rb
360
+ - app/serializers/comee/core/fulfillment_center_serializer.rb
359
361
  - app/serializers/comee/core/item_status_serializer.rb
360
362
  - app/serializers/comee/core/lookup_serializer.rb
361
363
  - app/serializers/comee/core/master_price_serializer.rb