comee_core 0.2.14 → 0.2.16

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: dac759817de32ff973fe059159a63dd455821779c29124d8cc40763ee85e37f1
4
- data.tar.gz: b848191c7faf98be197912ef1709617441aa229e501d09051d2cf05a3255e9a9
3
+ metadata.gz: 406c93dca731f87dea5f764260975fb10ea432aa054d6b619faaf0a4430af097
4
+ data.tar.gz: ca8d491fc263c2cd7abc3618f8dc1a54ff544137674936527ed3e2511c299033
5
5
  SHA512:
6
- metadata.gz: 51f9017b7fe3286c0d6968f6e46c970d7dc4dbcb613ab74abdc14cbd1e4dadd97888a45facfdbb9e9bcdebc5c1c0cb981faf80cb0070a253ba848910582bfb07
7
- data.tar.gz: b98b538ddb7c0ca35870d1bf03557f035aacc15315cd17ec6814e3082d4f2c37055ebef011286dc66821b1d58e461262bcd7cc630d677d32318ee772ebac54bd
6
+ metadata.gz: 9d77f8b9c8ab3e2dcf258faf3312a7f44698f608a7c59a7a024c3a361261b348f17c1868f7685579ffef5db0d63c1a76e95b2d81f8f1eca4c3cd2ef7216bbd37
7
+ data.tar.gz: c0ac3ee94586168c23566ca9ef133c4b092d66cf6ac764d152e1a5c8fb37f4ae051db50eaa4ab14f42efb7a4bb0198648a4e6d6a99c2f9fb60ce785f2f2b02c6
@@ -9,6 +9,7 @@ module Comee
9
9
  :sales_order,
10
10
  :customer_order_item,
11
11
  :source,
12
+ :product,
12
13
  :unit
13
14
  ).where(sales_order_id: params[:id])
14
15
  end
@@ -16,7 +17,7 @@ module Comee
16
17
 
17
18
  def suggest_values
18
19
  service = CustomerOrderService.new
19
- result = service.suggest_values(params[:id], suggest_params[:quantity], suggest_params[:unit_id])
20
+ result = service.suggest_values(params[:id], suggest_params[:unit_id])
20
21
  render json: {success: true, data: result}
21
22
  end
22
23
 
@@ -34,7 +35,7 @@ module Comee
34
35
  private
35
36
 
36
37
  def suggest_params
37
- params.require(:payload).permit(:unit_id, :quantity)
38
+ params.permit(:unit_id, :quantity)
38
39
  end
39
40
 
40
41
  def model_params
@@ -6,7 +6,7 @@ module Comee
6
6
 
7
7
  def index
8
8
  super do
9
- data = SalesOrder.includes(:customer_order, :fulfillment_center, :sales_order_items, :client).all
9
+ data = SalesOrder.includes(:customer_order, :client, sales_order_items: :unit).order(created_at: :desc)
10
10
  [
11
11
  data,
12
12
  fields: ["client", "customer_order", "sales_order_items", "sales_order_items.product", "sales_order_items.unit"]
@@ -14,12 +14,20 @@ module Comee
14
14
  end
15
15
  end
16
16
 
17
+ def show
18
+ super do
19
+ [
20
+ SalesOrder.includes(:customer_order, :client, sales_order_items: :unit).find(params[:id]),
21
+ fields: ["client", "customer_order", "sales_order_items", "sales_order_items.product", "sales_order_items.unit"]
22
+ ]
23
+ end
24
+ end
25
+
17
26
  def filter
18
27
  data = SalesOrder.includes(
19
28
  :customer_order,
20
29
  :client,
21
- :fulfillment_center,
22
- :sales_order_items
30
+ sales_order_items: :unit
23
31
  ).ransack(params[:q]).result
24
32
  render_content(data)
25
33
  end
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class User < ApplicationRecord
4
- enum :user_type, {supplier: 0, admin: 1, client: 2, worker: 3}
4
+ enum :user_type, {supplier: 0, admin: 1, client: 2, clerk: 3, order_manager: 4}
5
5
 
6
6
  has_secure_password
7
7
  has_many :notifications, as: :recipient, dependent: :destroy
@@ -71,11 +71,11 @@ module Comee
71
71
  (quantity / conversion.factor).round
72
72
  end
73
73
 
74
- def suggest_values(item_id, new_quantity, new_unit_id)
74
+ def suggest_values(item_id, new_unit_id)
75
75
  item = CustomerOrderItem.includes(:customer_order).find_by(id: item_id)
76
76
  raise(StandardError, "Order item with id `#{item_id}` not found.") unless item
77
77
 
78
- quantity = convert_quantity(new_quantity, item.unit_id, new_unit_id)
78
+ quantity = convert_quantity(item.quantity, item.unit_id, new_unit_id)
79
79
  client = Client.find(item.customer_order.client_id)
80
80
  client_id = client.parent_id || client.id
81
81
  client_price = ClientPrice.find_by(product_id: item.product_id, client_id: client_id)
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.14".freeze
3
+ VERSION = "0.2.16".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.14
4
+ version: 0.2.16
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-09 00:00:00.000000000 Z
11
+ date: 2024-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers