comee_core 0.2.74 → 0.2.76

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7637cf6daeec977e6222697ac258f13cdcb33798d78fc31fe111233e16dc4cd
4
- data.tar.gz: febca6c6cbbae3250e1d52159aff0a17e16c3cb28f3a5cb1ed01db51a8976ba7
3
+ metadata.gz: 300022f87054a7910cee755a85daa8b02afb1131fc313fb7335b3169094d9cd6
4
+ data.tar.gz: 322deb26131db4347a067ccccc1226648cad60012da51414bc388f49c8e909d1
5
5
  SHA512:
6
- metadata.gz: a48d13cc574afa60e54d5bb4485cc98662a03e66b8d5701dc3a7baadd304c280699f888e6f7318e138d8935d00bc8c00df1987f2a6c95ddca6b0642ccdf08b2a
7
- data.tar.gz: 42978d335f03b548bc112a18ff510cb5796a6985296bd977339de6d4258f30717319379af523818c903297c1699d53c971634e2d0129bc371932910e253f40ba
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).ransack(params[:q]).result
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).permit(:code, :name, :description, :parent_id, :thumbnail_image, :source_id, :weight,
43
- :weight_unit_id, :dimensions, :hs_code, :hs_description, images: [],
44
- preferred_units: %i[id code label])
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
@@ -17,7 +17,7 @@ module Comee
17
17
  private
18
18
 
19
19
  def model_params
20
- params.require(:payload).permit(:code, :name, :address, :locale, :currency_id)
20
+ params.require(:payload).permit(:code, :name, :address, :locale, :payment_terms, :currency_id)
21
21
  end
22
22
  end
23
23
  end
@@ -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, :weight,
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
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class SupplierSerializer < ActiveModel::Serializer
4
- attributes :id, :code, :name, :address, :locale, :user_id
4
+ attributes :id, :code, :name, :address, :locale, :user_id, :payment_terms
5
5
  belongs_to :currency
6
6
  end
7
7
  end
data/config/routes.rb CHANGED
@@ -24,6 +24,9 @@ Comee::Core::Engine.routes.draw do
24
24
  post "filter"
25
25
  get "categories"
26
26
  end
27
+ member do
28
+ get "customers"
29
+ end
27
30
  end
28
31
  resources :product_lookups do
29
32
  collection do
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.74".freeze
3
+ VERSION = "0.2.76".freeze
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :client_address, class: "Comee::Core::ClientAddress" do
3
3
  client
4
+ name { Faker::Name.name }
4
5
  address_line1 { Faker::Address.street_address }
5
6
  street { Faker::Address.street_name }
6
7
  city { Faker::Address.city }
@@ -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.74
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-05-24 00:00:00.000000000 Z
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