comee_core 0.2.12 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/customer_orders_controller.rb +10 -1
- data/app/controllers/comee/core/sales_order_items_controller.rb +11 -1
- data/app/controllers/comee/core/sales_orders_controller.rb +1 -1
- data/app/models/comee/core/customer_order_item.rb +1 -1
- data/app/serializers/comee/core/sales_order_item_serializer.rb +1 -1
- data/app/services/comee/core/customer_order_service.rb +5 -3
- data/config/routes.rb +2 -1
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/sales_order_items.rb +1 -0
- metadata +2 -2
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
|
@@ -8,7 +8,16 @@ module Comee
|
|
8
8
|
def index
|
9
9
|
super do
|
10
10
|
[
|
11
|
-
CustomerOrder.includes(:client, :
|
11
|
+
CustomerOrder.includes(:client, customer_order_items: :unit).order(:created_at),
|
12
|
+
fields: ["client", "customer_order_items.unit"]
|
13
|
+
]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def show
|
18
|
+
super do
|
19
|
+
[
|
20
|
+
CustomerOrder.includes(:client, customer_order_items: :unit).find(params[:id]),
|
12
21
|
fields: ["client", "customer_order_items.unit"]
|
13
22
|
]
|
14
23
|
end
|
@@ -16,10 +16,16 @@ 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
|
|
23
|
+
def cancel
|
24
|
+
item = set_object
|
25
|
+
item.update(canceled: true)
|
26
|
+
render_content(item)
|
27
|
+
end
|
28
|
+
|
23
29
|
def destroy
|
24
30
|
Comee::Core::SalesOrderItem.destroy(params[:id])
|
25
31
|
render json: {success: true}
|
@@ -27,6 +33,10 @@ module Comee
|
|
27
33
|
|
28
34
|
private
|
29
35
|
|
36
|
+
def suggest_params
|
37
|
+
params.require(:payload).permit(:unit_id, :quantity)
|
38
|
+
end
|
39
|
+
|
30
40
|
def model_params
|
31
41
|
params.require(:payload).permit(:sales_order_id, :customer_order_item_id, :product_id, :unit_id, :quantity, :quantity_delivered,
|
32
42
|
:customer_item_no, :customer_item_description, :price, :handover_date, :delivery_date,
|
@@ -60,7 +60,7 @@ module Comee
|
|
60
60
|
def model_params
|
61
61
|
params.require(:payload).permit(:order_number, :order_date, :customer_order_id, :fulfillment_center_id, :client_id,
|
62
62
|
:order_terms, :shipment_address, :delivery_address, :invoice_address, :destination,
|
63
|
-
:handover_date, :shipping_date, :delivery_date, :consignee, :payment_term, :
|
63
|
+
:handover_date, :shipping_date, :delivery_date, :consignee, :payment_term, :delivery_term,
|
64
64
|
:payment_penalty, :status, :total_price, :amount_paid, :pallete_note, :remark,
|
65
65
|
files: [])
|
66
66
|
end
|
@@ -2,7 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class SalesOrderItemSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :customer_item_no, :customer_item_description, :quantity, :quantity_delivered, :price, :handover_date,
|
5
|
-
:delivery_date, :eb_number, :lead_time, :comment, :action_note, :po_reference, :total_price
|
5
|
+
:delivery_date, :eb_number, :lead_time, :comment, :action_note, :po_reference, :total_price, :canceled
|
6
6
|
|
7
7
|
belongs_to :sales_order
|
8
8
|
belongs_to :customer_order_item
|
@@ -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,8 @@ 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
|
+
post "cancel"
|
116
117
|
end
|
117
118
|
end
|
118
119
|
resources :shipment_items do
|
data/lib/comee/core/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.14
|
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-
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|