comee_core 0.2.74 → 0.2.76
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/clients_controller.rb +4 -3
- data/app/controllers/comee/core/products_controller.rb +9 -3
- data/app/controllers/comee/core/suppliers_controller.rb +1 -1
- data/app/models/comee/core/client.rb +1 -0
- data/app/models/comee/core/client_address.rb +1 -1
- data/app/models/comee/core/master_price.rb +1 -0
- data/app/models/comee/core/product.rb +2 -2
- data/app/models/comee/core/supplier.rb +1 -1
- data/app/serializers/comee/core/client_address_serializer.rb +1 -1
- data/app/serializers/comee/core/client_serializer.rb +2 -1
- data/app/serializers/comee/core/master_price_serializer.rb +2 -1
- data/app/serializers/comee/core/product_serializer.rb +2 -2
- data/app/serializers/comee/core/supplier_serializer.rb +1 -1
- data/config/routes.rb +3 -0
- data/db/migrate/20240601094028_add_additional_fields.rb +32 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/client_addresses.rb +1 -0
- data/spec/factories/comee/core/products.rb +2 -1
- data/spec/factories/comee/core/suppliers.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 300022f87054a7910cee755a85daa8b02afb1131fc313fb7335b3169094d9cd6
|
4
|
+
data.tar.gz: 322deb26131db4347a067ccccc1226648cad60012da51414bc388f49c8e909d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c71677f694e85591ae9f3c556393b2b1fac636cf4832c5da7cddcf855eb83294b1d5dfedd6416fc7d7a9c89bcce28883eda72ab6a5fae723a399ab1a2fb46f9d
|
7
|
+
data.tar.gz: d8478bc7889140d81851f51da46a3d07b121564d71d5eb5bc0bc7612772b893bab2090bf6baa34271696d4ebc9741813dcde76fb981c1074fd3e132e15a04c3c
|
@@ -5,12 +5,13 @@ module Comee
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
Client.includes(:parent, :agents, :contacts, :client_warehouses, :user, :currency).all
|
8
|
+
Client.includes(:parent, :agents, :contacts, :client_warehouses, :country, :user, :currency).all
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def filter
|
13
|
-
clients = Client.includes(:parent, :agents, :contacts, :client_warehouses, :user, :currency)
|
13
|
+
clients = Client.includes(:parent, :agents, :contacts, :client_warehouses, :country, :user, :currency)
|
14
|
+
.ransack(params[:q]).result
|
14
15
|
render_content(clients)
|
15
16
|
end
|
16
17
|
|
@@ -56,7 +57,7 @@ module Comee
|
|
56
57
|
|
57
58
|
def model_params
|
58
59
|
params.require(:payload).permit(:code, :name, :address, :locale, :user_id, :parent_id, :currency, :subsidiary,
|
59
|
-
consignees: [])
|
60
|
+
:country_id, :tax_code, :vat_number, consignees: [])
|
60
61
|
end
|
61
62
|
|
62
63
|
def agent_params
|
@@ -31,6 +31,12 @@ module Comee
|
|
31
31
|
render_content(root.children)
|
32
32
|
end
|
33
33
|
|
34
|
+
def customers
|
35
|
+
clients = ProductLookup.where(product_id: params[:id], itemable_type: "Comee::Core::Client")
|
36
|
+
.map(&:itemable)
|
37
|
+
render_content(clients)
|
38
|
+
end
|
39
|
+
|
34
40
|
def filter
|
35
41
|
data = Product.ransack(params[:q]).result
|
36
42
|
render_content(data)
|
@@ -39,9 +45,9 @@ module Comee
|
|
39
45
|
private
|
40
46
|
|
41
47
|
def model_params
|
42
|
-
params.required(:payload)
|
43
|
-
|
44
|
-
|
48
|
+
params.required(:payload)
|
49
|
+
.permit(:code, :name, :description, :customs_description, :parent_id, :thumbnail_image, :source_id, :weight,
|
50
|
+
:weight_unit_id, :dimensions, :hs_code, :hs_description, images: [], preferred_units: %i[id code label])
|
45
51
|
end
|
46
52
|
|
47
53
|
def price_params
|
@@ -3,6 +3,7 @@ module Comee
|
|
3
3
|
class Client < ApplicationRecord
|
4
4
|
belongs_to :user, optional: true
|
5
5
|
belongs_to :parent, class_name: "Comee::Core::Client", optional: true
|
6
|
+
belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup", optional: true
|
6
7
|
belongs_to :currency, optional: true
|
7
8
|
has_and_belongs_to_many :contacts, join_table: :comee_core_clients_contacts
|
8
9
|
has_and_belongs_to_many :agents, join_table: :comee_core_clients_agents
|
@@ -10,7 +10,7 @@ module Comee
|
|
10
10
|
belongs_to :client
|
11
11
|
belongs_to :country, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup"
|
12
12
|
|
13
|
-
validates :address_line1, :address_type, presence: true
|
13
|
+
validates :name, :address_line1, :address_type, presence: true
|
14
14
|
validates :address_type, inclusion: {in: ADDRESS_TYPES}
|
15
15
|
end
|
16
16
|
end
|
@@ -5,6 +5,7 @@ module Comee
|
|
5
5
|
belongs_to :supplier
|
6
6
|
belongs_to :previous_price, class_name: "Comee::Core::MasterPrice", optional: true
|
7
7
|
belongs_to :next_price, class_name: "Comee::Core::MasterPrice", optional: true
|
8
|
+
belongs_to :country_of_origin, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup", optional: true
|
8
9
|
belongs_to :product_lookup, optional: true
|
9
10
|
|
10
11
|
validates :purchase_price, :selling_price, presence: true
|
@@ -11,7 +11,7 @@ module Comee
|
|
11
11
|
belongs_to :weight_unit, class_name: "Comee::Core::Unit", optional: true
|
12
12
|
|
13
13
|
validates :code, presence: true, uniqueness: true
|
14
|
-
validates :name, presence: true
|
14
|
+
validates :name, :customs_description, presence: true
|
15
15
|
|
16
16
|
scope :leafs, -> { where(leaf: true) }
|
17
17
|
|
@@ -30,7 +30,7 @@ module Comee
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.ransackable_attributes(_auth_object = nil)
|
33
|
-
%w[id code name description leaf]
|
33
|
+
%w[id code name description customs_description leaf]
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.ransackable_associations(_auth_object = nil)
|
@@ -6,7 +6,7 @@ module Comee
|
|
6
6
|
has_and_belongs_to_many :contacts, join_table: :comee_core_suppliers_contacts
|
7
7
|
|
8
8
|
validates :code, presence: true, uniqueness: true
|
9
|
-
validates :name, :address, :locale, presence: true
|
9
|
+
validates :name, :address, :locale, :payment_terms, presence: true
|
10
10
|
|
11
11
|
def self.ransackable_attributes(_auth_object = nil)
|
12
12
|
%w[id user_id code address locale]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ClientAddressSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type, :client_id
|
4
|
+
attributes :id, :name, :address_line1, :street, :city, :state, :country_id, :postal_code, :address_type, :client_id
|
5
5
|
|
6
6
|
belongs_to :client
|
7
7
|
belongs_to :country
|
@@ -2,8 +2,9 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class ClientSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :code, :name, :address, :locale, :user_id, :user_name, :parent_id, :consignees, :shipment_addresses,
|
5
|
-
:currency
|
5
|
+
:tax_code, :vat_number, :currency
|
6
6
|
belongs_to :parent
|
7
|
+
belongs_to :country
|
7
8
|
has_many :agents
|
8
9
|
has_many :contacts
|
9
10
|
has_many :client_warehouses
|
@@ -2,11 +2,12 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class MasterPriceSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :purchase_price, :selling_price, :valid_from, :valid_to, :primary, :margin, :lead_time, :status,
|
5
|
-
:price_status
|
5
|
+
:price_status, :state_of_origin
|
6
6
|
belongs_to :product
|
7
7
|
belongs_to :supplier
|
8
8
|
belongs_to :product_lookup
|
9
9
|
belongs_to :unit
|
10
|
+
belongs_to :country_of_origin
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class ProductSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :code, :name, :description, :thumbnail_image_url, :images_url, :preferred_units,
|
5
|
-
:dimensions, :hs_code, :hs_description, :parent_id
|
4
|
+
attributes :id, :code, :name, :description, :customs_description, :thumbnail_image_url, :images_url, :preferred_units,
|
5
|
+
:weight, :dimensions, :hs_code, :hs_description, :parent_id
|
6
6
|
belongs_to :source
|
7
7
|
belongs_to :weight_unit
|
8
8
|
end
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
class AddAdditionalFields < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
add_column :comee_core_client_addresses, :name, :string, null: false, default: "Default"
|
4
|
+
add_column :comee_core_products, :customs_description, :string, null: true
|
5
|
+
add_column :comee_core_suppliers, :payment_terms, :string, null: false, default: "30 Days Net"
|
6
|
+
add_column :comee_core_suppliers, :vat_number, :string, null: true
|
7
|
+
add_column :comee_core_suppliers, :tax_code, :string, null: true
|
8
|
+
add_column :comee_core_clients, :tax_code, :string, null: true
|
9
|
+
add_column :comee_core_clients, :vat_number, :string, null: true
|
10
|
+
add_column :comee_core_master_prices, :state_of_origin, :string, null: true
|
11
|
+
add_reference :comee_core_master_prices,
|
12
|
+
:country_of_origin,
|
13
|
+
null: true,
|
14
|
+
index: {name: "coo_on_ccmp_indx"},
|
15
|
+
foreign_key: {to_table: :comee_core_lookups}
|
16
|
+
add_reference :comee_core_clients,
|
17
|
+
:country,
|
18
|
+
null: true,
|
19
|
+
index: {name: "country_on_ccc_indx"},
|
20
|
+
foreign_key: {to_table: :comee_core_lookups}
|
21
|
+
reversible do |dir|
|
22
|
+
dir.up do
|
23
|
+
execute <<-SQL
|
24
|
+
UPDATE comee_core_products
|
25
|
+
SET customs_description = description
|
26
|
+
SQL
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
change_column_null :comee_core_products, :customs_description, false
|
31
|
+
end
|
32
|
+
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :product, class: "Comee::Core::Product" do
|
3
3
|
transient do
|
4
|
-
root { Comee::Core::Product.where(code: "ROOT", name: "Products", leaf: false).first_or_create }
|
4
|
+
root { Comee::Core::Product.where(code: "ROOT", name: "Products", customs_description: "Products", leaf: false).first_or_create }
|
5
5
|
end
|
6
6
|
sequence(:code) { |n| "#{Faker::Alphanumeric.unique.alpha(number: 6)}-#{n}" }
|
7
7
|
name { Faker::Name.name }
|
8
8
|
description { Faker::Lorem.sentence }
|
9
|
+
customs_description { Faker::Lorem.sentence }
|
9
10
|
leaf { true }
|
10
11
|
ancestry { root.id.to_s }
|
11
12
|
preferred_units { [] }
|
@@ -4,6 +4,9 @@ FactoryBot.define do
|
|
4
4
|
name { Faker::Name.name }
|
5
5
|
address { Faker::Address.full_address }
|
6
6
|
locale { "en" }
|
7
|
+
payment_terms { Faker::Lorem.word }
|
8
|
+
vat_number { Faker::Alphanumeric.alpha(number: 8) }
|
9
|
+
tax_code { Faker::Alphanumeric.alpha(number: 8) }
|
7
10
|
user
|
8
11
|
currency
|
9
12
|
end
|
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.76
|
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-
|
11
|
+
date: 2024-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -470,6 +470,7 @@ files:
|
|
470
470
|
- db/migrate/20240425121701_add_purchase_status_to_sales_order_and_purchase_requisition.rb
|
471
471
|
- db/migrate/20240503040722_create_comee_core_client_addresses.rb
|
472
472
|
- db/migrate/20240515173010_add_serial_no_to_line_items.rb
|
473
|
+
- db/migrate/20240601094028_add_additional_fields.rb
|
473
474
|
- lib/comee/core.rb
|
474
475
|
- lib/comee/core/engine.rb
|
475
476
|
- lib/comee/core/version.rb
|