comee_core 0.1.68 → 0.1.70
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/client_prices_controller.rb +31 -2
- data/app/controllers/comee/core/customer_orders_controller.rb +5 -0
- data/app/controllers/comee/core/shipment_items_controller.rb +5 -0
- data/app/controllers/comee/core/suppliers_controller.rb +5 -0
- data/app/models/comee/core/sales_order.rb +1 -0
- data/app/models/comee/core/supplier.rb +8 -0
- data/app/serializers/comee/core/sales_order_serializer.rb +1 -1
- data/config/routes.rb +3 -1
- data/db/migrate/20230728123039_create_comee_core_clients.rb +1 -1
- 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: 41ae0ec46096a9abb27fe3caddab921d382cf42daef4179106098dc3c91d4104
|
4
|
+
data.tar.gz: 4b3f9fcbe0c755257904faa791bdd8f7c7b8db9e7e55fa357e28408747f2de76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada352a6d3bb9f520ff82f46726be54b39698aaba21991fdc8597ebc0cd725715f4d7256725615bde5476812dcfc8fda9f33edeb22716f99db21e358d2357470
|
7
|
+
data.tar.gz: 7626969d8a7904a01e265fa6b3be9894e8120de56c1aa221102b475a65facb34951c87f18defe565a845a0e48d89b7fb4faa40a0628b9c26fedbaf12ae9c5112
|
@@ -11,9 +11,38 @@ module Comee
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def filter
|
14
|
-
@client_prices = Comee::Core::ClientPrice.ransack(params[:q]).result
|
14
|
+
@client_prices = Comee::Core::ClientPrice.includes(:client, :product, :unit).ransack(params[:q]).result
|
15
15
|
@client_prices = @client_prices.then(&paginate)
|
16
|
-
|
16
|
+
queries = @client_prices.map { |cp| {itemable_id: cp.client_id, product_id: cp.product_id, itemable_type: "Comee::Core::Client"} }
|
17
|
+
|
18
|
+
lookups = queries.inject(Comee::Core::ProductLookup.none) do |conditions, condition|
|
19
|
+
conditions.or(Comee::Core::ProductLookup.where(condition))
|
20
|
+
end
|
21
|
+
result = @client_prices.each_with_object([]) do |obj, res|
|
22
|
+
item = {
|
23
|
+
id: obj.id,
|
24
|
+
valid_from: obj.valid_from,
|
25
|
+
valid_to: obj.valid_to,
|
26
|
+
price: obj.price,
|
27
|
+
status: obj.status,
|
28
|
+
margin: obj.margin,
|
29
|
+
margin_type: obj.margin_type,
|
30
|
+
client_code: obj.client.code,
|
31
|
+
client_name: obj.client.name,
|
32
|
+
product_code: obj.product.code,
|
33
|
+
product_name: obj.product.name,
|
34
|
+
unit_code: obj.unit.code,
|
35
|
+
unit_name: obj.unit.name
|
36
|
+
}
|
37
|
+
lkp = lookups.select { |lookup| lookup.itemable_id == obj.client_id && lookup.product_id == obj.product_id }
|
38
|
+
if lkp.count.positive?
|
39
|
+
item[:client_product_code] = lkp[0].code
|
40
|
+
item[:client_product_name] = lkp[0].item_description
|
41
|
+
end
|
42
|
+
res << item
|
43
|
+
end
|
44
|
+
|
45
|
+
render json: {success: true, data: result}
|
17
46
|
end
|
18
47
|
|
19
48
|
private
|
@@ -33,6 +33,11 @@ module Comee
|
|
33
33
|
render json: {success: false, error: e.message}
|
34
34
|
end
|
35
35
|
|
36
|
+
def filter
|
37
|
+
@customer_orders = Comee::Core::CustomerOrder.ransack(params[:q]).result
|
38
|
+
render json: {success: true, data: serialize(@customer_orders)}
|
39
|
+
end
|
40
|
+
|
36
41
|
private
|
37
42
|
|
38
43
|
def model_params
|
@@ -3,6 +3,11 @@ module Comee
|
|
3
3
|
class ShipmentItemsController < ApplicationController
|
4
4
|
include Common
|
5
5
|
|
6
|
+
def filter
|
7
|
+
@shipment_item = Comee::Core::ShipmentItem.ransack(params[:q]).result
|
8
|
+
render json: {success: true, data: serialize(@shipment_item)}
|
9
|
+
end
|
10
|
+
|
6
11
|
def filter_with_status
|
7
12
|
items = ShipmentItem.includes(sales_order_item: %i[sales_order product unit])
|
8
13
|
.ransack(params[:q]).result
|
@@ -3,6 +3,11 @@ module Comee
|
|
3
3
|
class SuppliersController < ApplicationController
|
4
4
|
include Common
|
5
5
|
|
6
|
+
def filter
|
7
|
+
@supplier = Comee::Core::Supplier.ransack(params[:q]).result
|
8
|
+
render json: {success: true, data: serialize(@supplier)}
|
9
|
+
end
|
10
|
+
|
6
11
|
private
|
7
12
|
|
8
13
|
def model_params
|
@@ -5,6 +5,14 @@ module Comee
|
|
5
5
|
|
6
6
|
validates :code, presence: true, uniqueness: true
|
7
7
|
validates :name, :address, :locale, presence: true
|
8
|
+
|
9
|
+
def self.ransackable_attributes(_auth_object = nil)
|
10
|
+
%w[user_id code address locale]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.ransackable_associations(_auth_object = nil)
|
14
|
+
%w[user]
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
@@ -2,7 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class SalesOrderSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :order_number, :payment_penalty, :status, :total_price, :payment_term, :delivery_term, :amount_paid, :pallete_note,
|
5
|
-
:handover_date, :remark, :files_url
|
5
|
+
:handover_date, :remark, :files_url, :customs_detail
|
6
6
|
belongs_to :customer_order
|
7
7
|
belongs_to :fulfillment_center
|
8
8
|
has_many :sales_order_items
|
data/config/routes.rb
CHANGED
@@ -8,6 +8,7 @@ Comee::Core::Engine.routes.draw do
|
|
8
8
|
post "mark_as_unread", controller: :notifications, action: :mark_as_unread
|
9
9
|
end
|
10
10
|
end
|
11
|
+
post "/suppliers/filter", controller: :suppliers, action: :filter
|
11
12
|
resources :suppliers
|
12
13
|
resources :products do
|
13
14
|
collection do
|
@@ -41,6 +42,7 @@ Comee::Core::Engine.routes.draw do
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
resources :external_rfqs
|
45
|
+
post "/customer_orders/filter", controller: :customer_orders, action: :filter
|
44
46
|
resources :customer_orders do
|
45
47
|
member do
|
46
48
|
post "submit"
|
@@ -84,10 +86,10 @@ Comee::Core::Engine.routes.draw do
|
|
84
86
|
get "suggest", controller: :sales_order_items, action: :suggest_values
|
85
87
|
end
|
86
88
|
end
|
87
|
-
|
88
89
|
resources :shipment_items do
|
89
90
|
collection do
|
90
91
|
post "filter_with_status"
|
92
|
+
post "filter"
|
91
93
|
end
|
92
94
|
end
|
93
95
|
post "/sales_orders/filter", controller: :sales_orders, action: :filter
|
@@ -2,7 +2,7 @@ class CreateComeeCoreClients < ActiveRecord::Migration[7.0]
|
|
2
2
|
def change
|
3
3
|
create_table :comee_core_clients do |t|
|
4
4
|
t.references :user,
|
5
|
-
null:
|
5
|
+
null: true,
|
6
6
|
index: {name: "user_on_ccc_indx"},
|
7
7
|
foreign_key: {to_table: :comee_core_users}
|
8
8
|
t.string :code, null: false
|
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.1.
|
4
|
+
version: 0.1.70
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|