comee_core 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3e105a8c7e7254936a7db749a048935e743a23d2098650380a34a8bf55bc620
4
- data.tar.gz: f38e93115c2d99cb771e261a16b86183b4a06dc497f937b67be1af502f1f9d0d
3
+ metadata.gz: bbd554c8a5918b912f0d9b2fee535998739a2b7a39192db601992be00fd8d8a8
4
+ data.tar.gz: 24693f3a557171aea57c69f95614cc08b59a4b2882c98720d8d028eedc6ba3b9
5
5
  SHA512:
6
- metadata.gz: 136ec7b8f11718c0822ccacb0177c39e602a95e0b182f136a5cead06b11e06ffb8df5924aa2671841eb00f889bbaf794578444b06c92b305b739cca4bc77008e
7
- data.tar.gz: 49ddfc65ef76c8c0fef5a0cf51e9d881f0eb621afa04a6f61dea4b89f0d914bde27a6cdc3b1d1d8952885dc30ddffbb9444bd277c76705faef6d7f4484786781
6
+ metadata.gz: cdee0e54cf1f7d7c8ffc5bdba61b980a5548b3f32f240dfd766236f5364e746b7799132826cdbc3d5232f05a810321585cbe0c4f791b60d32fccf7712eef57eb
7
+ data.tar.gz: 439c3a1a44b8da1f87485e4892bd6bf1ebf18cd42508616d1f78f48054d2dc4ed30d5ce1f852b8449f7ec0ac76313302ef8fc0d4c97bf005c0af5be8cb30e39f
@@ -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
 
@@ -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
@@ -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.14"
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.14
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