comee_core 0.1.64 → 0.1.66
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 +1 -1
- data/app/controllers/comee/core/product_lookups_controller.rb +24 -0
- data/app/controllers/comee/core/quotation_request_items_controller.rb +2 -1
- data/app/controllers/comee/core/sales_order_items_controller.rb +1 -1
- data/app/controllers/comee/core/sales_orders_controller.rb +3 -2
- data/app/models/comee/core/client.rb +0 -1
- data/app/models/comee/core/client_price.rb +3 -2
- data/app/models/comee/core/product_lookup.rb +5 -1
- data/app/models/comee/core/quotation_request_item.rb +5 -2
- data/app/serializers/comee/core/client_price_serializer.rb +1 -1
- data/app/serializers/comee/core/product_lookup_serializer.rb +8 -0
- data/app/serializers/comee/core/quotation_request_item_serializer.rb +1 -1
- data/app/serializers/comee/core/sales_order_item_serializer.rb +2 -1
- data/app/serializers/comee/core/sales_order_serializer.rb +2 -2
- data/app/services/comee/core/product_lookup_service.rb +2 -3
- data/app/services/comee/core/quotation_request_service.rb +4 -2
- data/config/routes.rb +6 -0
- data/db/migrate/20230728123039_create_comee_core_clients.rb +0 -1
- data/db/migrate/20230812190652_create_comee_core_sales_orders.rb +2 -0
- data/db/migrate/20230812212844_create_comee_core_sales_order_items.rb +1 -0
- data/db/migrate/20230813235946_create_comee_core_master_prices.rb +1 -1
- data/db/migrate/20230814151601_create_comee_core_client_prices.rb +2 -1
- data/db/migrate/{20230914041307_create_comee_core_external_products.rb → 20230914041307_create_comee_core_product_lookups.rb} +2 -1
- data/db/migrate/20231121132709_create_comee_core_quotation_request_items.rb +2 -1
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/client_prices.rb +2 -1
- data/spec/factories/comee/core/clients.rb +0 -1
- data/spec/factories/comee/core/product_lookups.rb +1 -0
- data/spec/factories/comee/core/quotation_request_items.rb +2 -1
- data/spec/factories/comee/core/sales_order_items.rb +1 -0
- data/spec/factories/comee/core/sales_orders.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47cf5679d2c9d6fbc6d6f0c4f7eb3a6a25c402ec3e4aabf667de41c01b3e2f82
|
4
|
+
data.tar.gz: 3fc087959c16abb7bc68c36a0e8f126c21922545a6118d19203f8cb3d95e6e2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f42d06b36fa70926e8cd3e0003522aecdad89a5c6a291fe39158beb29b9a769b03d35aa096e40db2bfdb7ff0d79e25538ee8b835e528bcf1b703f33af93fbff5
|
7
|
+
data.tar.gz: 33719ed3f0a29dd2f68e3c3192158c03a9f361ee62bc640264d385e7233642c4b376347656d71aa838b9aca1535fc1bf18d1f66280878f5efc0195b24e8c28ae
|
@@ -19,7 +19,7 @@ module Comee
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def model_params
|
22
|
-
params.require(:payload).permit(:valid_from, :valid_to, :price, :product_id, :
|
22
|
+
params.require(:payload).permit(:valid_from, :valid_to, :price, :product_id, :margin, :margin_type, :client_id, :previous_price,
|
23
23
|
:unit_id)
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class ProductLookupsController < ApplicationController
|
4
|
+
include Common
|
5
|
+
|
6
|
+
def index
|
7
|
+
super do
|
8
|
+
ProductLookup.includes(:product).all
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def filter
|
13
|
+
lookups = ProductLookup.ransack(params[:q]).result
|
14
|
+
render json: {success: true, data: serialize(lookups)}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def model_params
|
20
|
+
params.required(:payload).permit(:code, :itemable_id, :itemable_type, :item_description, :product_id)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -57,7 +57,7 @@ module Comee
|
|
57
57
|
def model_params
|
58
58
|
params.require(:payload).permit(:sales_order_id, :customer_order_item_id, :product_id, :unit_id, :quantity, :quantity_delivered,
|
59
59
|
:customer_item_no, :price, :delivery_date, :eb_number, :lead_time, :comment, :action_note,
|
60
|
-
:po_reference, :source_id)
|
60
|
+
:po_reference, :pallet_no, :source_id)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -49,8 +49,9 @@ module Comee
|
|
49
49
|
private
|
50
50
|
|
51
51
|
def model_params
|
52
|
-
params.require(:payload).permit(:order_number, :customer_order_id, :payment_penalty, :
|
53
|
-
:total_price, :amount_paid, :pallete_note, :handover_date, :remark,
|
52
|
+
params.require(:payload).permit(:order_number, :customer_order_id, :payment_penalty, :payment_term, :delivery_term, :status,
|
53
|
+
:fulfillment_center_id, :total_price, :amount_paid, :pallete_note, :handover_date, :remark,
|
54
|
+
files: [])
|
54
55
|
end
|
55
56
|
|
56
57
|
def back_order_params
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ClientPrice < Price
|
4
|
+
enum :margin_type, {increase: 0, discount: 1}
|
4
5
|
belongs_to :client
|
5
6
|
belongs_to :previous_price, class_name: "Comee::Core::ClientPrice", optional: true
|
6
7
|
belongs_to :next_price, class_name: "Comee::Core::ClientPrice", optional: true
|
7
8
|
|
8
|
-
validates :price, presence: true
|
9
|
+
validates :price, :margin_type, presence: true
|
9
10
|
validates :price, numericality: {greater_than: 0}
|
10
|
-
validates :
|
11
|
+
validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
11
12
|
validates :product_id, uniqueness: {scope: %i[client_id previous_price_id next_price_id status]}
|
12
13
|
|
13
14
|
def self.ransackable_attributes(_auth_object = nil)
|
@@ -4,7 +4,11 @@ module Comee
|
|
4
4
|
belongs_to :product
|
5
5
|
belongs_to :itemable, polymorphic: true
|
6
6
|
|
7
|
-
validates :code, presence: true
|
7
|
+
validates :code, :item_description, presence: true
|
8
|
+
|
9
|
+
def self.ransackable_attributes(_auth_object = nil)
|
10
|
+
%w[code item_description itemable_id itemable_type product_id]
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -1,14 +1,17 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class QuotationRequestItem < ApplicationRecord
|
4
|
+
enum :margin_type, {increase: 0, discount: 1}
|
4
5
|
belongs_to :product
|
5
6
|
belongs_to :quotation_request
|
6
7
|
belongs_to :unit
|
7
8
|
|
8
|
-
validates :
|
9
|
+
validates :margin_type, :expected_delivery_date, presence: true
|
10
|
+
validates :quantity, :price, presence: true, numericality: {greater_than_or_equal_to: 0}
|
11
|
+
validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
9
12
|
|
10
13
|
def self.ransackable_attributes(_auth_object = nil)
|
11
|
-
%w[quotation_request_id product_id unit_id quantity price
|
14
|
+
%w[quotation_request_id product_id unit_id quantity price margin margin_type expected_delivery_date]
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ClientPriceSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :valid_from, :valid_to, :price, :status, :previous_price
|
4
|
+
attributes :id, :valid_from, :valid_to, :price, :status, :previous_price, :margin, :margin_type
|
5
5
|
belongs_to :product
|
6
6
|
belongs_to :client
|
7
7
|
belongs_to :unit
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class QuotationRequestItemSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :customer_item_no, :price, :
|
4
|
+
attributes :id, :customer_item_no, :price, :margin, :margin_type, :valid_from, :valid_to, :quantity, :expected_delivery_date
|
5
5
|
belongs_to :product
|
6
6
|
belongs_to :quotation_request
|
7
7
|
belongs_to :unit
|
@@ -2,11 +2,12 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class SalesOrderItemSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :customer_item_no, :quantity, :quantity_delivered, :price, :delivery_date, :eb_number, :lead_time, :comment,
|
5
|
-
:action_note, :po_reference, :
|
5
|
+
:action_note, :po_reference, :pallet_no
|
6
6
|
|
7
7
|
belongs_to :sales_order
|
8
8
|
belongs_to :customer_order_item
|
9
9
|
belongs_to :source
|
10
|
+
belongs_to :product
|
10
11
|
belongs_to :unit
|
11
12
|
end
|
12
13
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class SalesOrderSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :order_number, :payment_penalty, :status, :total_price,
|
5
|
-
:
|
4
|
+
attributes :id, :order_number, :payment_penalty, :status, :total_price, :payment_term, :delivery_term, :amount_paid, :pallete_note,
|
5
|
+
:handover_date, :remark, :files_url
|
6
6
|
belongs_to :customer_order
|
7
7
|
belongs_to :fulfillment_center
|
8
8
|
has_many :sales_order_items
|
@@ -21,7 +21,7 @@ module Comee
|
|
21
21
|
|
22
22
|
if from == ORGANIZATION
|
23
23
|
query = ProductLookup.joins(:product).find_by(product: {code: code}, **to)
|
24
|
-
return query
|
24
|
+
return query
|
25
25
|
end
|
26
26
|
|
27
27
|
if to == ORGANIZATION
|
@@ -30,8 +30,7 @@ module Comee
|
|
30
30
|
end
|
31
31
|
|
32
32
|
product = ProductLookup.find_by(code: code, **from).product
|
33
|
-
|
34
|
-
query.code
|
33
|
+
ProductLookup.find_by(product: product, **to)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
@@ -16,7 +16,8 @@ module Comee
|
|
16
16
|
items.each do |item|
|
17
17
|
item[:price] = 0
|
18
18
|
item[:quotation_request_id] = request.id
|
19
|
-
item[:
|
19
|
+
item[:margin] = 0
|
20
|
+
item[:margin_type] = QuotationRequestItem.margin_types[:increase]
|
20
21
|
end
|
21
22
|
QuotationRequestItem.insert_all!(items)
|
22
23
|
end
|
@@ -73,7 +74,8 @@ module Comee
|
|
73
74
|
product_id: item.product_id,
|
74
75
|
unit_id: item.unit_id,
|
75
76
|
price: item.price,
|
76
|
-
|
77
|
+
margin: 0,
|
78
|
+
margin_type: QuotationRequestItem.margin_types[:increase],
|
77
79
|
valid_from: item.valid_from,
|
78
80
|
valid_to: item.valid_to,
|
79
81
|
status: ClientPrice.statuses[:current]
|
data/config/routes.rb
CHANGED
@@ -10,6 +10,8 @@ class CreateComeeCoreSalesOrders < ActiveRecord::Migration[7.0]
|
|
10
10
|
null: true,
|
11
11
|
index: {name: "fc_on_ccso_indx"},
|
12
12
|
foreign_key: {to_table: :comee_core_fulfillment_centers}
|
13
|
+
t.string :payment_term
|
14
|
+
t.string :delivery_term
|
13
15
|
t.float :payment_penalty, null: false, default: 0.0
|
14
16
|
t.integer :status, null: false, default: 0
|
15
17
|
t.float :total_price, null: false, default: 0
|
@@ -7,7 +7,7 @@ class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
|
|
7
7
|
t.date :valid_to, null: false
|
8
8
|
t.float :status, null: false, default: 0
|
9
9
|
t.boolean :primary, null: false, default: false
|
10
|
-
t.
|
10
|
+
t.float :margin, null: false, default: 0
|
11
11
|
t.integer :lead_time
|
12
12
|
t.references :product,
|
13
13
|
null: false,
|
@@ -5,7 +5,8 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
|
|
5
5
|
t.date :valid_to, null: false
|
6
6
|
t.float :price, null: false
|
7
7
|
t.float :status, null: false, default: 0
|
8
|
-
t.
|
8
|
+
t.float :margin, null: false, default: 0
|
9
|
+
t.integer :margin_type, null: false, default: 0
|
9
10
|
t.references :product,
|
10
11
|
null: false,
|
11
12
|
index: {name: "product_on_cccp_indx"},
|
@@ -1,8 +1,9 @@
|
|
1
|
-
class
|
1
|
+
class CreateComeeCoreProductLookups < ActiveRecord::Migration[7.0]
|
2
2
|
def change
|
3
3
|
create_table :comee_core_product_lookups do |t|
|
4
4
|
t.string :code, null: false
|
5
5
|
t.references :itemable, polymorphic: true, null: false
|
6
|
+
t.string :item_description, null: false
|
6
7
|
t.references :product,
|
7
8
|
null: false,
|
8
9
|
index: {name: "product_on_ccep_indx"},
|
@@ -12,7 +12,8 @@ class CreateComeeCoreQuotationRequestItems < ActiveRecord::Migration[7.1]
|
|
12
12
|
t.string :customer_item_no
|
13
13
|
t.float :quantity, null: false
|
14
14
|
t.float :price, null: false, default: 0
|
15
|
-
t.float :
|
15
|
+
t.float :margin, null: false, default: 0
|
16
|
+
t.integer :margin_type, null: false, default: 0
|
16
17
|
t.date :expected_delivery_date, null: false
|
17
18
|
t.boolean :canceled, null: false, default: false
|
18
19
|
t.references :unit,
|
data/lib/comee/core/version.rb
CHANGED
@@ -6,7 +6,8 @@ FactoryBot.define do
|
|
6
6
|
customer_item_no { Faker::Alphanumeric.alpha(number: 10) }
|
7
7
|
quantity { 10 }
|
8
8
|
price { 0 }
|
9
|
-
|
9
|
+
margin { 0 }
|
10
|
+
margin_type { Comee::Core::QuotationRequestItem.margin_types[:increase] }
|
10
11
|
expected_delivery_date { Date.current.advance(days: 15) }
|
11
12
|
canceled { false }
|
12
13
|
valid_from { nil }
|
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.66
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -291,6 +291,7 @@ files:
|
|
291
291
|
- app/controllers/comee/core/item_statuses_controller.rb
|
292
292
|
- app/controllers/comee/core/lookups_controller.rb
|
293
293
|
- app/controllers/comee/core/notifications_controller.rb
|
294
|
+
- app/controllers/comee/core/product_lookups_controller.rb
|
294
295
|
- app/controllers/comee/core/products_controller.rb
|
295
296
|
- app/controllers/comee/core/purchase_order_items_controller.rb
|
296
297
|
- app/controllers/comee/core/purchase_orders_controller.rb
|
@@ -354,6 +355,7 @@ files:
|
|
354
355
|
- app/serializers/comee/core/item_status_serializer.rb
|
355
356
|
- app/serializers/comee/core/lookup_serializer.rb
|
356
357
|
- app/serializers/comee/core/master_price_serializer.rb
|
358
|
+
- app/serializers/comee/core/product_lookup_serializer.rb
|
357
359
|
- app/serializers/comee/core/product_serializer.rb
|
358
360
|
- app/serializers/comee/core/product_type_serializer.rb
|
359
361
|
- app/serializers/comee/core/purchase_order_item_serializer.rb
|
@@ -396,7 +398,7 @@ files:
|
|
396
398
|
- db/migrate/20230812212844_create_comee_core_sales_order_items.rb
|
397
399
|
- db/migrate/20230813235946_create_comee_core_master_prices.rb
|
398
400
|
- db/migrate/20230814151601_create_comee_core_client_prices.rb
|
399
|
-
- db/migrate/
|
401
|
+
- db/migrate/20230914041307_create_comee_core_product_lookups.rb
|
400
402
|
- db/migrate/20230915205522_create_comee_core_invoices.rb
|
401
403
|
- db/migrate/20230915205648_create_comee_core_invoice_items.rb
|
402
404
|
- db/migrate/20230929115336_create_comee_core_order_sources.rb
|