comee_core 0.2.13 → 0.2.14
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac759817de32ff973fe059159a63dd455821779c29124d8cc40763ee85e37f1
|
4
|
+
data.tar.gz: b848191c7faf98be197912ef1709617441aa229e501d09051d2cf05a3255e9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51f9017b7fe3286c0d6968f6e46c970d7dc4dbcb613ab74abdc14cbd1e4dadd97888a45facfdbb9e9bcdebc5c1c0cb981faf80cb0070a253ba848910582bfb07
|
7
|
+
data.tar.gz: b98b538ddb7c0ca35870d1bf03557f035aacc15315cd17ec6814e3082d4f2c37055ebef011286dc66821b1d58e461262bcd7cc630d677d32318ee772ebac54bd
|
@@ -16,7 +16,7 @@ module Comee
|
|
16
16
|
|
17
17
|
def suggest_values
|
18
18
|
service = CustomerOrderService.new
|
19
|
-
result = service.suggest_values(params[:id],
|
19
|
+
result = service.suggest_values(params[:id], suggest_params[:quantity], suggest_params[:unit_id])
|
20
20
|
render json: {success: true, data: result}
|
21
21
|
end
|
22
22
|
|
@@ -33,6 +33,10 @@ module Comee
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
+
def suggest_params
|
37
|
+
params.require(:payload).permit(:unit_id, :quantity)
|
38
|
+
end
|
39
|
+
|
36
40
|
def model_params
|
37
41
|
params.require(:payload).permit(:sales_order_id, :customer_order_item_id, :product_id, :unit_id, :quantity, :quantity_delivered,
|
38
42
|
:customer_item_no, :customer_item_description, :price, :handover_date, :delivery_date,
|
@@ -71,12 +71,14 @@ module Comee
|
|
71
71
|
(quantity / conversion.factor).round
|
72
72
|
end
|
73
73
|
|
74
|
-
def suggest_values(item_id, new_unit_id)
|
74
|
+
def suggest_values(item_id, new_quantity, 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(
|
79
|
-
|
78
|
+
quantity = convert_quantity(new_quantity, item.unit_id, new_unit_id)
|
79
|
+
client = Client.find(item.customer_order.client_id)
|
80
|
+
client_id = client.parent_id || client.id
|
81
|
+
client_price = ClientPrice.find_by(product_id: item.product_id, client_id: client_id)
|
80
82
|
if client_price
|
81
83
|
price = convert_price(client_price.price, client_price.unit_id, new_unit_id)
|
82
84
|
else
|
data/config/routes.rb
CHANGED
@@ -112,7 +112,7 @@ Comee::Core::Engine.routes.draw do
|
|
112
112
|
end
|
113
113
|
resources :sales_order_items, except: [:index] do
|
114
114
|
member do
|
115
|
-
|
115
|
+
post "suggest", controller: :sales_order_items, action: :suggest_values
|
116
116
|
post "cancel"
|
117
117
|
end
|
118
118
|
end
|
data/lib/comee/core/version.rb
CHANGED