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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/comee/core/client_prices_controller.rb +1 -1
  3. data/app/controllers/comee/core/product_lookups_controller.rb +24 -0
  4. data/app/controllers/comee/core/quotation_request_items_controller.rb +2 -1
  5. data/app/controllers/comee/core/sales_order_items_controller.rb +1 -1
  6. data/app/controllers/comee/core/sales_orders_controller.rb +3 -2
  7. data/app/models/comee/core/client.rb +0 -1
  8. data/app/models/comee/core/client_price.rb +3 -2
  9. data/app/models/comee/core/product_lookup.rb +5 -1
  10. data/app/models/comee/core/quotation_request_item.rb +5 -2
  11. data/app/serializers/comee/core/client_price_serializer.rb +1 -1
  12. data/app/serializers/comee/core/product_lookup_serializer.rb +8 -0
  13. data/app/serializers/comee/core/quotation_request_item_serializer.rb +1 -1
  14. data/app/serializers/comee/core/sales_order_item_serializer.rb +2 -1
  15. data/app/serializers/comee/core/sales_order_serializer.rb +2 -2
  16. data/app/services/comee/core/product_lookup_service.rb +2 -3
  17. data/app/services/comee/core/quotation_request_service.rb +4 -2
  18. data/config/routes.rb +6 -0
  19. data/db/migrate/20230728123039_create_comee_core_clients.rb +0 -1
  20. data/db/migrate/20230812190652_create_comee_core_sales_orders.rb +2 -0
  21. data/db/migrate/20230812212844_create_comee_core_sales_order_items.rb +1 -0
  22. data/db/migrate/20230813235946_create_comee_core_master_prices.rb +1 -1
  23. data/db/migrate/20230814151601_create_comee_core_client_prices.rb +2 -1
  24. data/db/migrate/{20230914041307_create_comee_core_external_products.rb → 20230914041307_create_comee_core_product_lookups.rb} +2 -1
  25. data/db/migrate/20231121132709_create_comee_core_quotation_request_items.rb +2 -1
  26. data/lib/comee/core/version.rb +1 -1
  27. data/spec/factories/comee/core/client_prices.rb +2 -1
  28. data/spec/factories/comee/core/clients.rb +0 -1
  29. data/spec/factories/comee/core/product_lookups.rb +1 -0
  30. data/spec/factories/comee/core/quotation_request_items.rb +2 -1
  31. data/spec/factories/comee/core/sales_order_items.rb +1 -0
  32. data/spec/factories/comee/core/sales_orders.rb +2 -0
  33. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4cd6ae8953f0384e6621da475902a2cc7dbde2c84878da91a819a3bb4dd03ef
4
- data.tar.gz: cffd56f30c07ea7030935b845baffc6285d0064e2cc6e5c7557bc7b4a39ce805
3
+ metadata.gz: 47cf5679d2c9d6fbc6d6f0c4f7eb3a6a25c402ec3e4aabf667de41c01b3e2f82
4
+ data.tar.gz: 3fc087959c16abb7bc68c36a0e8f126c21922545a6118d19203f8cb3d95e6e2d
5
5
  SHA512:
6
- metadata.gz: 8d3565e8fad90e32587fafa45309b44faaeb04326aaf5ce108dbe4be90150858d40a88476c2b76fa4163552e6066ee05ec76fa3fd7698b8263661c5712e77f99
7
- data.tar.gz: 4ee979f53c118c6c372d794657140d347b9177467ab3a041bb684e870f261b35b0511da3fc14c1a64923d5d18c98fa33d5e50a79aecdfc94dc436855fd46dc83
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, :discount, :client_id, :previous_price,
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
@@ -32,7 +32,8 @@ module Comee
32
32
  :customer_item_no,
33
33
  :price,
34
34
  :quantity,
35
- :discount,
35
+ :margin,
36
+ :margin_type,
36
37
  :valid_from,
37
38
  :valid_to,
38
39
  :product_id,
@@ -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, :status, :fulfillment_center_id,
53
- :total_price, :amount_paid, :pallete_note, :handover_date, :remark, files: [])
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
@@ -15,7 +15,6 @@ module Comee
15
15
  address
16
16
  code
17
17
  name
18
- discount
19
18
  locale
20
19
  ]
21
20
  end
@@ -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 :discount, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
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 :quantity, :price, :discount, :expected_delivery_date, presence: true
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 discount expected_delivery_date]
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
@@ -0,0 +1,8 @@
1
+ module Comee
2
+ module Core
3
+ class ProductLookupSerializer < ActiveModel::Serializer
4
+ attributes :id, :code, :itemable_id, :itemable_type, :item_description
5
+ belongs_to :product
6
+ end
7
+ end
8
+ end
@@ -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, :discount, :valid_from, :valid_to, :quantity, :expected_delivery_date
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, :product, :unit
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
- :amount_paid, :pallete_note, :handover_date, :remark, :files_url
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.code
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
- query = ProductLookup.find_by(product: product, **to)
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[:discount] = 0
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
- discount: 0,
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
@@ -15,6 +15,12 @@ Comee::Core::Engine.routes.draw do
15
15
  post "client_prices"
16
16
  end
17
17
  end
18
+ resources :product_lookups do
19
+ collection do
20
+ post "filter"
21
+ end
22
+ end
23
+
18
24
  resources :lookups
19
25
  resources :quotation_requests do
20
26
  collection do
@@ -9,7 +9,6 @@ class CreateComeeCoreClients < ActiveRecord::Migration[7.0]
9
9
  t.string :name, null: false
10
10
  t.string :address, null: false
11
11
  t.string :locale, null: false, default: "en"
12
- t.string :discount, null: false, default: 0
13
12
 
14
13
  t.timestamps
15
14
  end
@@ -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
@@ -33,6 +33,7 @@ class CreateComeeCoreSalesOrderItems < ActiveRecord::Migration[7.0]
33
33
  t.string :comment
34
34
  t.string :action_note
35
35
  t.string :po_reference
36
+ t.string :pallet_no
36
37
 
37
38
  t.timestamps
38
39
  end
@@ -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.integer :margin, null: false
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.integer :discount, null: false
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 CreateComeeCoreExternalProducts < ActiveRecord::Migration[7.0]
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 :discount, null: false, default: 0
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,
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.64".freeze
3
+ VERSION = "0.1.66".freeze
4
4
  end
5
5
  end
@@ -7,7 +7,8 @@ FactoryBot.define do
7
7
  product
8
8
  client
9
9
  unit
10
- discount { 0 }
10
+ margin { 0.0 }
11
+ margin_type { Comee::Core::ClientPrice.margin_types[:increase] }
11
12
  previous_price { nil }
12
13
  next_price { nil }
13
14
 
@@ -5,6 +5,5 @@ FactoryBot.define do
5
5
  name { Faker::Name.name }
6
6
  address { Faker::Address.full_address }
7
7
  locale { "en" }
8
- discount { 0 }
9
8
  end
10
9
  end
@@ -3,5 +3,6 @@ FactoryBot.define do
3
3
  code { Faker::Alphanumeric.alpha(number: 8) }
4
4
  product
5
5
  itemable factory: :supplier
6
+ item_description { Faker::Lorem.sentence }
6
7
  end
7
8
  end
@@ -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
- discount { 0 }
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 }
@@ -16,5 +16,6 @@ FactoryBot.define do
16
16
  comment { Faker::Lorem.sentence }
17
17
  action_note { Faker::Lorem.sentence }
18
18
  po_reference { Faker::Alphanumeric.alpha(number: 10) }
19
+ pallet_no { Faker::Alphanumeric.alpha(number: 10) }
19
20
  end
20
21
  end
@@ -3,6 +3,8 @@ FactoryBot.define do
3
3
  order_number { Faker::Alphanumeric.alpha(number: 10) }
4
4
  customer_order
5
5
  fulfillment_center
6
+ payment_term { Faker::Lorem.sentence }
7
+ delivery_term { Faker::Lorem.sentence }
6
8
  payment_penalty { 0 }
7
9
  total_price { 0 }
8
10
  amount_paid { 0 }
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.64
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-22 00:00:00.000000000 Z
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/20230914041307_create_comee_core_external_products.rb
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