comee_core 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/users_controller.rb +18 -0
- data/app/serializers/comee/core/sales_order_item_serializer.rb +1 -1
- data/app/services/comee/core/customer_order_service.rb +28 -8
- data/config/routes.rb +5 -1
- data/db/migrate/20230812212844_create_comee_core_sales_order_items.rb +1 -0
- data/lib/comee/core/version.rb +1 -1
- 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: fc0763d813df0b1e3ddf87c6a4212f0c0bf6f85e60744ade8f1d216fb2eefb9e
|
4
|
+
data.tar.gz: 664f56499508ef5699bdeb95543f442d9dcc58f43d0cb05bdafa5eda0c4868a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 828cfd039c47d92f5cbb4c1039cb84006227a74e2dfc908b8003e9531eae83afb61f6d8fcac7ac3786b4b69199a36c68e31c53aa38684fcdbb29b7d259d241fb
|
7
|
+
data.tar.gz: 3876f53bbb1c93e16eeff25e49f9b8e6d398797bc553ffeaf76af572a277da90eded3932d41e813004d7d620d07b8fcf47623dbd207649d3d01b22183e43f55b
|
@@ -3,8 +3,26 @@ module Comee
|
|
3
3
|
class UsersController < ApplicationController
|
4
4
|
include Common
|
5
5
|
|
6
|
+
def change_password
|
7
|
+
@user = current_user
|
8
|
+
if @user.authenticate(change_password_params[:old_password])
|
9
|
+
if @user.update(password: change_password_params[:new_password],
|
10
|
+
password_confirmation: change_password_params[:new_password_confirmation])
|
11
|
+
render json: @user, serializer: UserSerializer, status: :ok
|
12
|
+
else
|
13
|
+
render json: {errors: @user.errors.full_messages}, status: 422
|
14
|
+
end
|
15
|
+
else
|
16
|
+
render json: {error: "Old password is incorrect"}, status: :unauthorized
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
private
|
7
21
|
|
22
|
+
def change_password_params
|
23
|
+
params.require(:payload).permit(:old_password, :new_password, :new_password_confirmation)
|
24
|
+
end
|
25
|
+
|
8
26
|
def model_params
|
9
27
|
params.require(:payload).permit(:name, :email, :active, :password, :password_confirmation)
|
10
28
|
end
|
@@ -3,7 +3,7 @@ module Comee
|
|
3
3
|
class SalesOrderItemSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :serial_no, :customer_item_no, :customer_item_description, :quantity, :quantity_delivered, :quantity_canceled,
|
5
5
|
:price, :handover_date, :delivery_date, :eb_number, :lead_time, :comment, :action_note, :purchase_order_item_id,
|
6
|
-
:total_price, :canceled, :processing_status
|
6
|
+
:total_price, :canceled, :processing_status, :additional_details
|
7
7
|
belongs_to :sales_order
|
8
8
|
belongs_to :customer_order_item
|
9
9
|
belongs_to :source
|
@@ -169,7 +169,18 @@ module Comee
|
|
169
169
|
product_id: order_items.map(&:product_id),
|
170
170
|
status: ClientPrice.statuses[:current]
|
171
171
|
)
|
172
|
-
master_prices = MasterPrice.where(primary: true, status: Price.statuses[:current],
|
172
|
+
master_prices = MasterPrice.includes(:supplier).where(primary: true, status: Price.statuses[:current],
|
173
|
+
product: order_items.map(&:product))
|
174
|
+
main_query = ProductLookup.includes(:itemable).where(itemable_type: "Comee::Core::Supplier")
|
175
|
+
queries = master_prices.each_with_object([]) do |obj, res|
|
176
|
+
res << {
|
177
|
+
product_id: obj.product_id,
|
178
|
+
itemable_id: obj.supplier_id
|
179
|
+
}
|
180
|
+
end
|
181
|
+
product_lookups = queries.inject(main_query) do |conditions, condition|
|
182
|
+
conditions.or(ProductLookup.where(condition))
|
183
|
+
end
|
173
184
|
items = order_items.each_with_object([]) do |item, res|
|
174
185
|
next if item.canceled?
|
175
186
|
|
@@ -178,13 +189,16 @@ module Comee
|
|
178
189
|
quantity = convert_quantity(item.quantity, item.unit_id, unit_id)
|
179
190
|
client_price = client_prices.find { |price| price.product_id == item.product_id }
|
180
191
|
master_price = master_prices.find { |price| price.product_id == item.product_id }
|
181
|
-
|
182
|
-
|
183
|
-
else
|
184
|
-
raise(StandardError, "No price entry could be found for product `#{item.product.code}`.") unless master_price
|
185
|
-
|
186
|
-
price = convert_price(master_price.selling_price, master_price.unit_id, unit_id)
|
192
|
+
product_lookup = product_lookups.find do |lookup|
|
193
|
+
lookup.product_id == master_price.product_id && lookup.itemable_id == master_price.supplier_id
|
187
194
|
end
|
195
|
+
raise(StandardError, "No primary supplier found for product #{item.customer_item_no}") unless master_price
|
196
|
+
|
197
|
+
price = if client_price
|
198
|
+
convert_price(client_price.price, client_price.unit_id, unit_id)
|
199
|
+
else
|
200
|
+
convert_price(master_price.selling_price, master_price.unit_id, unit_id)
|
201
|
+
end
|
188
202
|
|
189
203
|
res << {
|
190
204
|
sales_order_id: sales_order.id,
|
@@ -199,7 +213,13 @@ module Comee
|
|
199
213
|
total_price: quantity * price,
|
200
214
|
delivery_date: item.delivery_date,
|
201
215
|
handover_date: order.handover_date,
|
202
|
-
lead_time: master_price&.lead_time
|
216
|
+
lead_time: master_price&.lead_time,
|
217
|
+
additional_details: {
|
218
|
+
supplier_id: master_price.supplier_id,
|
219
|
+
supplier_name: master_price.supplier.name,
|
220
|
+
supplier_item_no: product_lookup.code,
|
221
|
+
supplier_description: product_lookup.item_description
|
222
|
+
}
|
203
223
|
}
|
204
224
|
end
|
205
225
|
SalesOrderItem.insert_all!(items)
|
data/config/routes.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.1
|
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-06-
|
11
|
+
date: 2024-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|