comee_core 0.2.9 → 0.2.11

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: 75cd14e3ed3329b96dc20bf368531adf8815d87203806676981c474c4424ed81
4
- data.tar.gz: c6acddbca363dded60b68edb8294ef976851ba74a1e8ae1c69345ec6afd4849c
3
+ metadata.gz: e9ecb44f38bb1bbc8fe8accb8d1df84c10de099038728c077948c25584770250
4
+ data.tar.gz: 46c2e7d55a8ad2dd8abbc414f595a1128566c48d6c9e053bcdd849f9a32d4242
5
5
  SHA512:
6
- metadata.gz: 31ebedac27bceca15a479cb24855c87587279eb2b356101a86a8216426e20f4b80929977559ccb86a1b3489b0fd4b86caad61f70dc22790673abbff9380e9e71
7
- data.tar.gz: 6272f45a27fa7124ff0b86a1076113ed525821d3814da39d48f6a3d3bfabdf5bfdb0eb314563d17985bd879b51eca4b57ad43d92d6589d2155b8587baf2feb0b
6
+ metadata.gz: 86f577f8514711c9d0c32e81ce657016fc36b0d95b13f4e4e2953f9ff696688f6ffd5bd7cf9ed20df3b51349668f552df34bd7dc03fffb476ced35523e61b1c0
7
+ data.tar.gz: 9a65691ef5ba903d3ef4f501ba7f698608db2e01b5510693a238f944745e295374ac4b47288f3a337116ac6f14b14c4d13174bfe62c3b7cfcd7cb6b20343a006
@@ -63,6 +63,16 @@ module Comee
63
63
  render_content(prices)
64
64
  end
65
65
 
66
+ def fetch_one
67
+ price = ClientPrice.includes(:client, :product, :unit, :product_lookup)
68
+ .find_by(
69
+ client_id: params[:id],
70
+ product_id: fetch_one_params[:product_id],
71
+ status: Price.statuses[:current]
72
+ )
73
+ render_content(price)
74
+ end
75
+
66
76
  def approve
67
77
  price = ClientPrice.find(params[:id])
68
78
  price = price.approve
@@ -84,6 +94,10 @@ module Comee
84
94
  :unit_id)
85
95
  end
86
96
 
97
+ def fetch_one_params
98
+ params.permit(:product_id)
99
+ end
100
+
87
101
  def extend_params
88
102
  params.require(:payload).permit(:valid_to)
89
103
  end
@@ -3,8 +3,14 @@ module Comee
3
3
  class ClientsController < ApplicationController
4
4
  include Common
5
5
 
6
+ def index
7
+ super do
8
+ Client.includes(:parent, :agents, :contacts, :client_warehouses, :user, :currency).all
9
+ end
10
+ end
11
+
6
12
  def filter
7
- clients = Client.includes(:parent, :agents, :contacts, :client_warehouses).ransack(params[:q]).result
13
+ clients = Client.includes(:parent, :agents, :contacts, :client_warehouses, :user, :currency).ransack(params[:q]).result
8
14
  render_content(clients)
9
15
  end
10
16
 
@@ -3,6 +3,15 @@ module Comee
3
3
  class CustomerOrderItemsController < ApplicationController
4
4
  include Common
5
5
 
6
+ def index
7
+ super do
8
+ [
9
+ CustomerOrderItem.includes(:product, :unit).all,
10
+ fields: ["unit"]
11
+ ]
12
+ end
13
+ end
14
+
6
15
  def cancel
7
16
  CustomerOrderItem.where(id: params[:ids]).update_all(canceled: true)
8
17
  render json: {success: true}
@@ -10,7 +19,7 @@ module Comee
10
19
 
11
20
  def filter
12
21
  data = CustomerOrderItem.includes(:product, :unit).ransack(params[:q]).result
13
- render_content(data)
22
+ render_content(data, {fields: ["unit"]})
14
23
  end
15
24
 
16
25
  def destroy
@@ -5,6 +5,15 @@ module Comee
5
5
 
6
6
  before_action :set_service, only: %i[create_with_items submit submit_for_confirmation accept cancel]
7
7
 
8
+ def index
9
+ super do
10
+ [
11
+ CustomerOrder.includes(:client, :customer_order_items).all,
12
+ fields: ["client", "customer_order_items.unit"]
13
+ ]
14
+ end
15
+ end
16
+
8
17
  def create_with_items
9
18
  order = @service.create(create_with_item_params)
10
19
  render json: {success: true, data: serialize(order)}
@@ -9,6 +9,16 @@ module Comee
9
9
  end
10
10
  end
11
11
 
12
+ def fetch_one
13
+ lookup = ProductLookup.includes(:product)
14
+ .find_by(
15
+ itemable_id: params[:id],
16
+ itemable_type: "Comee::Core::Client",
17
+ product_id: fetch_one_params[:product_id]
18
+ )
19
+ render_content(lookup)
20
+ end
21
+
12
22
  def filter
13
23
  data = ProductLookup.ransack(params[:q]).result
14
24
  render_content(data)
@@ -16,6 +26,10 @@ module Comee
16
26
 
17
27
  private
18
28
 
29
+ def fetch_one_params
30
+ params.permit(:product_id)
31
+ end
32
+
19
33
  def model_params
20
34
  params.required(:payload).permit(:code, :itemable_id, :itemable_type, :item_description, :product_id)
21
35
  end
@@ -1,7 +1,8 @@
1
1
  module Comee
2
2
  module Core
3
3
  class CustomerOrderItemSerializer < ActiveModel::Serializer
4
- attributes :id, :customer_item_no, :quantity, :price, :total_price, :delivery_date, :canceled
4
+ attributes :id, :customer_item_no, :quantity, :price, :total_price, :delivery_date, :canceled, :customer_order_id,
5
+ :product_id, :unit_id
5
6
  belongs_to :product
6
7
  belongs_to :unit
7
8
  belongs_to :customer_order
data/config/routes.rb CHANGED
@@ -87,6 +87,8 @@ Comee::Core::Engine.routes.draw do
87
87
  get "shipment_items", controller: :shipment_items, action: :filter_for_client
88
88
  post "create_agent"
89
89
  post "create_contact"
90
+ post "price", controller: :client_prices, action: :fetch_one
91
+ post "product_lookup", controller: :product_lookups, action: :fetch_one
90
92
  end
91
93
  collection do
92
94
  post "filter"
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.9".freeze
3
+ VERSION = "0.2.11".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.2.9
4
+ version: 0.2.11
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-02-04 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers