comee_core 0.1.13 → 0.1.15

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: e3e105a8c7e7254936a7db749a048935e743a23d2098650380a34a8bf55bc620
4
- data.tar.gz: f38e93115c2d99cb771e261a16b86183b4a06dc497f937b67be1af502f1f9d0d
3
+ metadata.gz: 043ed1a164fa93440307c74baae5cca804e78ce043d1463eb5680cc76cef451d
4
+ data.tar.gz: c48d480a64a3eb1585351a98497a6507e456bf00782c60f8dace90a607c83f92
5
5
  SHA512:
6
- metadata.gz: 136ec7b8f11718c0822ccacb0177c39e602a95e0b182f136a5cead06b11e06ffb8df5924aa2671841eb00f889bbaf794578444b06c92b305b739cca4bc77008e
7
- data.tar.gz: 49ddfc65ef76c8c0fef5a0cf51e9d881f0eb621afa04a6f61dea4b89f0d914bde27a6cdc3b1d1d8952885dc30ddffbb9444bd277c76705faef6d7f4484786781
6
+ metadata.gz: 6e45c3b4df5048fc6e9f0b6d34700cd8bce34223e73f67c4a3ff35506ff371ee44efb355d60330a6d75a57bd614d5e5150f8d992cafdab73c47ee88b3ecf9f43
7
+ data.tar.gz: 593b15735e3294c82069a5151fcfff0a8c74eef4fd97b35b81dcda5f17dd321c25dc7aec687224b004303be1e292b43b427cf817b237983b6cab2f041dba60a7
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class BackOrder < ApplicationRecord
4
- enum :status, {draft: 0, confirmed: 1}
4
+ enum :status, {draft: 0, submitted: 1, confirmed: 2}
5
5
 
6
6
  after_create_commit :notify_supplier
7
7
 
@@ -0,0 +1,10 @@
1
+ module Comee
2
+ module Core
3
+ class ClientOrder < ApplicationRecord
4
+ belongs_to :order_source
5
+ belongs_to :client
6
+
7
+ validates :url, :processed, presence: true
8
+ end
9
+ end
10
+ end
@@ -1,11 +1,13 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ClientPrice < ApplicationRecord
4
+ enum :status, {old: 0, current: 1, future: 2}
4
5
  belongs_to :product
5
6
  belongs_to :client
7
+ belongs_to :previous_price, class_name: "Comee::Core::ClientPrice", optional: true
6
8
 
7
- validates :valid_from, :valid_to, :new_price, presence: true
8
- validates :old_price, :new_price, numericality: {greater_than: 0, allow_nil: true}
9
+ validates :valid_from, :valid_to, :price, :status, presence: true
10
+ validates :price, numericality: {greater_than: 0}
9
11
  validates :product_id, uniqueness: {scope: :client_id}
10
12
  validate :validate_price_validity_dates
11
13
 
@@ -17,7 +19,7 @@ module Comee
17
19
  end
18
20
 
19
21
  def self.ransackable_attributes(auth_object = nil)
20
- ["valid_from", "valid_to", "new_price", "old_price", "product_id", "client_id"]
22
+ ["valid_from", "valid_to", "price", "status", "product_id", "client_id", "previous_price_id"]
21
23
  end
22
24
 
23
25
  def self.ransackable_associations(auth_object = nil)
@@ -0,0 +1,9 @@
1
+ module Comee
2
+ module Core
3
+ class FieldMapping < ApplicationRecord
4
+ enum :level, {client_order: 0, client_item: 1}
5
+ belongs_to :order_source
6
+ validates :source, :destination, :level, :order_source, presence: true
7
+ end
8
+ end
9
+ end
@@ -3,10 +3,10 @@ module Comee
3
3
  class MasterPrice < ApplicationRecord
4
4
  belongs_to :supplier
5
5
  belongs_to :product
6
+ belongs_to :previous_price, class_name: "Comee::Core::MasterPrice", optional: true
6
7
 
7
- validates :pp_valid_from, :pp_valid_to, :sp_valid_from, :sp_valid_to, :new_pprice, :new_sprice, presence: true
8
- validates :old_pprice, :old_sprice, numericality: {greater_than: 0, allow_nil: true}
9
- validates :new_pprice, :new_sprice, numericality: {greater_than: 0}
8
+ validates :purchase_price, :selling_price, :pp_valid_from, :pp_valid_to, :sp_valid_from, :sp_valid_to, presence: true
9
+ validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
10
10
  validates :product_id, uniqueness: {scope: :supplier_id}
11
11
  validate :validate_primary_price, :validate_purchase_price_validity_dates, :validate_selling_price_validity_dates
12
12
 
@@ -0,0 +1,8 @@
1
+ module Comee
2
+ module Core
3
+ class OrderSource < ApplicationRecord
4
+ has_many :field_mappings
5
+ validates :base_url, :name, presence: true
6
+ end
7
+ end
8
+ end
@@ -4,7 +4,7 @@ module Comee
4
4
  belongs_to :client
5
5
  has_many :sales_order_items
6
6
 
7
- enum :status, {draft: 0, confirmed: 1}
7
+ enum :status, {draft: 0, confirmed: 1, canceled: 2}
8
8
 
9
9
  validates :order_number, presence: true, uniqueness: true
10
10
  validates :order_date, :expected_delivery_date, :delivery_address, :invoice_address, :status, presence: true
@@ -6,7 +6,7 @@ class CreateComeeCoreSalesOrders < ActiveRecord::Migration[7.0]
6
6
  t.date :expected_delivery_date, null: false
7
7
  t.references :client,
8
8
  null: false,
9
- index: {name: "client_on_ccco_indx"},
9
+ index: {name: "client_on_ccso_indx"},
10
10
  foreign_key: {to_table: :comee_core_clients}
11
11
  t.json :client_terms
12
12
  t.integer :payment_no_of_days, null: false, default: 0
@@ -1,15 +1,15 @@
1
1
  class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :comee_core_master_prices do |t|
4
+ t.float :purchase_price, null: false
5
+ t.float :selling_price, null: false
4
6
  t.date :pp_valid_from, null: false
5
7
  t.date :pp_valid_to, null: false
6
8
  t.date :sp_valid_from, null: false
7
9
  t.date :sp_valid_to, null: false
8
- t.float :old_pprice, null: true
9
- t.float :new_pprice, null: false
10
- t.float :old_sprice, null: true
11
- t.float :new_sprice, null: false
10
+ t.boolean :active, null: false
12
11
  t.boolean :primary, null: false
12
+ t.integer :margin, null: false
13
13
  t.references :product,
14
14
  null: false,
15
15
  index: {name: "product_on_ccsp_indx"},
@@ -18,6 +18,10 @@ class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
18
18
  null: false,
19
19
  index: {name: "supplier_on_ccsp_indx"},
20
20
  foreign_key: {to_table: :comee_core_suppliers}
21
+ t.references :previous_price,
22
+ null: true,
23
+ index: {name: "previous_price_on_ccsp_indx"},
24
+ foreign_key: {to_table: :comee_core_master_prices}
21
25
 
22
26
  t.timestamps
23
27
  end
@@ -3,10 +3,8 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
3
3
  create_table :comee_core_client_prices do |t|
4
4
  t.date :valid_from, null: false
5
5
  t.date :valid_to, null: false
6
- t.float :old_price, null: true
7
- t.float :new_price, null: false
8
- t.float :future_price, null: true
9
- t.date :future_validity, null: true
6
+ t.float :price, null: false
7
+ t.float :status, null: false, default: 0
10
8
  t.references :product,
11
9
  null: false,
12
10
  index: {name: "product_on_cccp_indx"},
@@ -15,6 +13,10 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
15
13
  null: false,
16
14
  index: {name: "client_on_cccp_indx"},
17
15
  foreign_key: {to_table: :comee_core_clients}
16
+ t.references :previous_price,
17
+ null: true,
18
+ index: {name: "previous_price_on_cccp_indx"},
19
+ foreign_key: {to_table: :comee_core_client_prices}
18
20
 
19
21
  t.timestamps
20
22
  end
@@ -0,0 +1,10 @@
1
+ class CreateComeeCoreOrderSources < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :comee_core_order_sources do |t|
4
+ t.string :base_url, null: false
5
+ t.string :name, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ class CreateComeeCoreFieldMappings < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :comee_core_field_mappings do |t|
4
+ t.string :source, null: false
5
+ t.string :destination, null: false
6
+ t.integer :level, null: false, default: 0
7
+ t.references :order_source,
8
+ null: false,
9
+ index: {name: "order_source_on_cfm_indx"},
10
+ foreign_key: {to_table: :comee_core_order_sources}
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class CreateComeeCoreClientOrders < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :comee_core_client_orders do |t|
4
+ t.references :order_source,
5
+ null: false,
6
+ index: {name: "order_source_on_ccco_indx"},
7
+ foreign_key: {to_table: :comee_core_order_sources}
8
+ t.string :url, null: false
9
+ t.boolean :processed, null: false, default: true
10
+ t.references :client,
11
+ null: false,
12
+ index: {name: "client_on_ccco_indx"},
13
+ foreign_key: {to_table: :comee_core_clients}
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.13"
3
+ VERSION = "0.1.15"
4
4
  end
5
5
  end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :client_order, class: "Comee::Core::ClientOrder" do
3
+ order_source
4
+ url { Faker::Internet.url }
5
+ processed { true }
6
+ client
7
+ end
8
+ end
@@ -2,10 +2,8 @@ FactoryBot.define do
2
2
  factory :client_price, class: "Comee::Core::ClientPrice" do
3
3
  valid_from { Date.current.advance(months: -1) }
4
4
  valid_to { Date.current.advance(months: 1) }
5
- old_price { 100 }
6
- new_price { 110 }
7
- future_price { nil }
8
- future_validity { nil }
5
+ status { 0 }
6
+ price { 100 }
9
7
  product
10
8
  client
11
9
  end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :field_mapping, class: "Comee::Core::FieldMapping" do
3
+ source { Faker::Lorem.word }
4
+ destination { Faker::Lorem.word }
5
+ level { Comee::Core::FieldMapping.levels[:client_item] }
6
+ order_source
7
+ end
8
+ end
@@ -1,14 +1,14 @@
1
1
  FactoryBot.define do
2
2
  factory :master_price, class: "Comee::Core::MasterPrice" do
3
+ purchase_price { 100.0 }
4
+ selling_price { 90.0 }
3
5
  pp_valid_from { Date.current.advance(months: -1) }
4
6
  pp_valid_to { Date.current.advance(months: 1) }
5
7
  sp_valid_from { Date.current.advance(months: -1) }
6
8
  sp_valid_to { Date.current.advance(months: 1) }
7
- old_pprice { nil }
8
- new_pprice { 100 }
9
- old_sprice { nil }
10
- new_sprice { 120 }
9
+ active { true }
11
10
  primary { false }
11
+ margin { 10.0 }
12
12
  product
13
13
  supplier
14
14
  end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :order_source, class: "Comee::Core::OrderSource" do
3
+ base_url { Faker::Internet.url }
4
+ name { Faker::Name.name }
5
+ end
6
+ 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.1.13
4
+ version: 0.1.15
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-09-30 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -248,12 +248,15 @@ files:
248
248
  - app/models/comee/core/back_order.rb
249
249
  - app/models/comee/core/back_order_item.rb
250
250
  - app/models/comee/core/client.rb
251
+ - app/models/comee/core/client_order.rb
251
252
  - app/models/comee/core/client_price.rb
252
253
  - app/models/comee/core/currency.rb
254
+ - app/models/comee/core/field_mapping.rb
253
255
  - app/models/comee/core/invoice.rb
254
256
  - app/models/comee/core/invoice_item.rb
255
257
  - app/models/comee/core/master_price.rb
256
258
  - app/models/comee/core/notification.rb
259
+ - app/models/comee/core/order_source.rb
257
260
  - app/models/comee/core/product.rb
258
261
  - app/models/comee/core/product_lookup.rb
259
262
  - app/models/comee/core/product_type.rb
@@ -297,6 +300,9 @@ files:
297
300
  - db/migrate/20230914041307_create_comee_core_external_products.rb
298
301
  - db/migrate/20230915205522_create_comee_core_invoices.rb
299
302
  - db/migrate/20230915205648_create_comee_core_invoice_items.rb
303
+ - db/migrate/20230929115336_create_comee_core_order_sources.rb
304
+ - db/migrate/20230929120051_create_comee_core_field_mappings.rb
305
+ - db/migrate/20230929130910_create_comee_core_client_orders.rb
300
306
  - lib/comee/core.rb
301
307
  - lib/comee/core/engine.rb
302
308
  - lib/comee/core/version.rb
@@ -304,13 +310,16 @@ files:
304
310
  - lib/tasks/comee_core_tasks.rake
305
311
  - spec/factories/comee/core/back_order_items.rb
306
312
  - spec/factories/comee/core/back_orders.rb
313
+ - spec/factories/comee/core/client_orders.rb
307
314
  - spec/factories/comee/core/client_prices.rb
308
315
  - spec/factories/comee/core/clients.rb
309
316
  - spec/factories/comee/core/currencies.rb
317
+ - spec/factories/comee/core/field_mappings.rb
310
318
  - spec/factories/comee/core/invoice_items.rb
311
319
  - spec/factories/comee/core/invoices.rb
312
320
  - spec/factories/comee/core/master_prices.rb
313
321
  - spec/factories/comee/core/notifications.rb
322
+ - spec/factories/comee/core/order_sources.rb
314
323
  - spec/factories/comee/core/product_lookups.rb
315
324
  - spec/factories/comee/core/product_types.rb
316
325
  - spec/factories/comee/core/products.rb