comee_core 0.1.12 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/comee/core/back_order.rb +1 -1
  3. data/app/models/comee/core/client_order.rb +2 -15
  4. data/app/models/comee/core/client_price.rb +12 -2
  5. data/app/models/comee/core/field_mapping.rb +9 -0
  6. data/app/models/comee/core/invoice.rb +6 -4
  7. data/app/models/comee/core/invoice_item.rb +3 -3
  8. data/app/models/comee/core/master_price.rb +3 -3
  9. data/app/models/comee/core/order_source.rb +8 -0
  10. data/app/models/comee/core/sales_order.rb +36 -0
  11. data/app/models/comee/core/sales_order_item.rb +20 -0
  12. data/app/services/comee/core/product_lookup_service.rb +1 -1
  13. data/db/migrate/{20230812190652_create_comee_core_client_orders.rb → 20230812190652_create_comee_core_sales_orders.rb} +10 -7
  14. data/db/migrate/{20230812212844_create_comee_core_client_order_items.rb → 20230812212844_create_comee_core_sales_order_items.rb} +5 -4
  15. data/db/migrate/20230813235946_create_comee_core_master_prices.rb +8 -4
  16. data/db/migrate/20230814151601_create_comee_core_client_prices.rb +6 -4
  17. data/db/migrate/20230915205522_create_comee_core_invoices.rb +2 -2
  18. data/db/migrate/20230915205648_create_comee_core_invoice_items.rb +3 -3
  19. data/db/migrate/20230929115336_create_comee_core_order_sources.rb +10 -0
  20. data/db/migrate/20230929120051_create_comee_core_field_mappings.rb +15 -0
  21. data/db/migrate/20230929130910_create_comee_core_client_orders.rb +18 -0
  22. data/lib/comee/core/version.rb +1 -1
  23. data/spec/factories/comee/core/client_orders.rb +3 -8
  24. data/spec/factories/comee/core/client_prices.rb +2 -4
  25. data/spec/factories/comee/core/field_mappings.rb +8 -0
  26. data/spec/factories/comee/core/invoice_items.rb +1 -1
  27. data/spec/factories/comee/core/invoices.rb +1 -1
  28. data/spec/factories/comee/core/master_prices.rb +4 -4
  29. data/spec/factories/comee/core/order_sources.rb +6 -0
  30. data/spec/factories/comee/core/sales_order_items.rb +9 -0
  31. data/spec/factories/comee/core/sales_orders.rb +16 -0
  32. metadata +16 -7
  33. data/app/models/comee/core/client_order_item.rb +0 -13
  34. data/spec/factories/comee/core/client_order_items.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7530cbd96ea9cc406bcfb8ef5c890a8cdfa31d5f43c3d09c07afba8c4c0ce3c
4
- data.tar.gz: e8a22cb3298284e49c74ead3edc5fe1168c03e9029f15c3a270c2d6df6414cf3
3
+ metadata.gz: bbd554c8a5918b912f0d9b2fee535998739a2b7a39192db601992be00fd8d8a8
4
+ data.tar.gz: 24693f3a557171aea57c69f95614cc08b59a4b2882c98720d8d028eedc6ba3b9
5
5
  SHA512:
6
- metadata.gz: 463c027f00ad2b09037e091b4fe2cdbfc5b0139c9f3856f81e8f3dde30bf88c3cf1e23d70a56c2acee2f122d7e4ece7d83ade7b9713736b92e1ee7ce62684f95
7
- data.tar.gz: 4f6b18b777eaeff508c4c00e23396d9ab1abf740fde0cb155abf00ee2d2ba99eba9d8fbef882b41b0eafea779f1205cc8c08cff0a0ee92308b3e8ddc39e16aea
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
 
@@ -1,23 +1,10 @@
1
1
  module Comee
2
2
  module Core
3
3
  class ClientOrder < ApplicationRecord
4
+ belongs_to :order_source
4
5
  belongs_to :client
5
- has_many :client_order_items
6
6
 
7
- enum :status, {draft: 0, confirmed: 1}
8
-
9
- validates :order_number, presence: true, uniqueness: true
10
- validates :order_date, :delivery_date, :terms, :delivery_address, :invoice_address, :status, presence: true
11
-
12
- delegate(:name, to: :client, prefix: true)
13
-
14
- def self.ransackable_attributes(auth_object = nil)
15
- ["delivery_address", "delivery_date", "invoice_address", "order_date", "order_number", "status", "client_id"]
16
- end
17
-
18
- def self.ransackable_associations(auth_object = nil)
19
- []
20
- end
7
+ validates :url, :processed, presence: true
21
8
  end
22
9
  end
23
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
 
@@ -15,6 +17,14 @@ module Comee
15
17
  period = Period.new(valid_from, valid_to)
16
18
  errors.add(:base, "Price validity date range is not correct.") unless period.valid?
17
19
  end
20
+
21
+ def self.ransackable_attributes(auth_object = nil)
22
+ ["valid_from", "valid_to", "new_price", "old_price", "product_id", "client_id"]
23
+ end
24
+
25
+ def self.ransackable_associations(auth_object = nil)
26
+ []
27
+ end
18
28
  end
19
29
  end
20
30
  end
@@ -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
@@ -2,9 +2,11 @@ module Comee
2
2
  module Core
3
3
  class Invoice < ApplicationRecord
4
4
  before_save :update_invoice_total
5
- belongs_to :client_order
5
+ belongs_to :sales_order
6
6
  has_many :invoice_items
7
7
 
8
+ has_noticed_notifications model_name: "Comee::Core::Notification"
9
+
8
10
  enum :status, {draft: 0, approved: 1}
9
11
  enum :payment_status, {not_settled: 0, settled: 1}
10
12
 
@@ -12,7 +14,7 @@ module Comee
12
14
  validates :date_issued, :payment_term, :status, :payment_status, presence: true
13
15
  validates :additional_charges, :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
14
16
 
15
- delegate(:order_number, to: :client_order)
17
+ delegate(:order_number, to: :sales_order)
16
18
 
17
19
  def update_invoice_total
18
20
  self.additional_charges ||= 0
@@ -23,7 +25,7 @@ module Comee
23
25
 
24
26
  def self.ransackable_attributes(auth_object = nil)
25
27
  [
26
- "client_order_id",
28
+ "sales_order_id",
27
29
  "invoice_no",
28
30
  "date_issued",
29
31
  "ship_name",
@@ -35,7 +37,7 @@ module Comee
35
37
  end
36
38
 
37
39
  def self.ransackable_associations(auth_object = nil)
38
- []
40
+ ["sales_order"]
39
41
  end
40
42
  end
41
43
  end
@@ -4,14 +4,14 @@ module Comee
4
4
  before_save { self.total_price = unit_price * quantity }
5
5
  after_save :update_invoice_total
6
6
 
7
- belongs_to :client_order_item
7
+ belongs_to :sales_order_item
8
8
  belongs_to :invoice
9
9
 
10
10
  validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
11
11
  validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
12
12
 
13
- delegate(:product_code, to: :client_order_item)
14
- delegate(:product_name, to: :client_order_item)
13
+ delegate(:product_code, to: :sales_order_item)
14
+ delegate(:product_name, to: :sales_order_item)
15
15
 
16
16
  def update_invoice_total
17
17
  invoice.total_price = InvoiceItem.where(invoice: invoice).map(&:total_price).sum
@@ -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
@@ -0,0 +1,36 @@
1
+ module Comee
2
+ module Core
3
+ class SalesOrder < ApplicationRecord
4
+ belongs_to :client
5
+ has_many :sales_order_items
6
+
7
+ enum :status, {draft: 0, confirmed: 1}
8
+
9
+ validates :order_number, presence: true, uniqueness: true
10
+ validates :order_date, :expected_delivery_date, :delivery_address, :invoice_address, :status, presence: true
11
+ validates :payment_no_of_days,
12
+ :payment_discount,
13
+ :payment_penalty,
14
+ presence: true,
15
+ numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
16
+
17
+ delegate(:name, to: :client, prefix: true)
18
+
19
+ def self.ransackable_attributes(auth_object = nil)
20
+ [
21
+ "delivery_address",
22
+ "expected_delivery_date",
23
+ "invoice_address",
24
+ "order_date",
25
+ "order_number",
26
+ "status",
27
+ "client_id"
28
+ ]
29
+ end
30
+
31
+ def self.ransackable_associations(auth_object = nil)
32
+ []
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ module Comee
2
+ module Core
3
+ class SalesOrderItem < ApplicationRecord
4
+ before_validation :set_delivery_date, if: proc { delivery_date.nil? }
5
+
6
+ belongs_to :sales_order
7
+ belongs_to :product
8
+
9
+ validates :delivery_date, presence: true
10
+ validates :quantity, :price, presence: true, numericality: {greater_than: 0}
11
+
12
+ delegate(:name, to: :product, prefix: true)
13
+ delegate(:code, to: :product, prefix: true)
14
+
15
+ def set_delivery_date
16
+ self.delivery_date = sales_order.expected_delivery_date
17
+ end
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ module Comee
5
5
  ##
6
6
  # This method returns a translated code for a given +code+. The +code+ can be
7
7
  # for a supplier or a client. The source of the +code+ is described using the +from+
8
- # parameter. The +from+ parameter is a has which specifies the id of the source
8
+ # parameter. The +from+ parameter is a hash which specifies the id of the source
9
9
  # supplier/client as `itemable_id`, and the data type of the source as itemable_type.
10
10
  # We specify the id and type because the ProductLookup model has a polymorphic relationship
11
11
  # with supplier and client.
@@ -1,24 +1,27 @@
1
- class CreateComeeCoreClientOrders < ActiveRecord::Migration[7.0]
1
+ class CreateComeeCoreSalesOrders < ActiveRecord::Migration[7.0]
2
2
  def change
3
- create_table :comee_core_client_orders do |t|
3
+ create_table :comee_core_sales_orders do |t|
4
4
  t.string :order_number, null: false
5
5
  t.date :order_date, null: false, default: -> { "CURRENT_DATE" }
6
- t.date :delivery_date, null: false
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
- t.json :terms
11
+ t.json :client_terms
12
+ t.integer :payment_no_of_days, null: false, default: 0
13
+ t.float :payment_discount, null: false, default: 0.0
14
+ t.float :payment_penalty, null: false, default: 0.0
12
15
  t.integer :status, null: false, default: 0
13
16
  t.string :delivery_address, null: false
14
17
  t.string :invoice_address, null: false
15
- t.string :remark
16
18
  t.float :total_price, null: true, default: 0
17
19
  t.float :amount_paid, null: true, default: 0
18
20
  t.float :amount_due, null: true, default: 0
21
+ t.string :remark
19
22
 
20
23
  t.timestamps
21
24
  end
22
- add_index :comee_core_client_orders, :order_number, unique: true
25
+ add_index :comee_core_sales_orders, :order_number, unique: true
23
26
  end
24
27
  end
@@ -1,16 +1,17 @@
1
- class CreateComeeCoreClientOrderItems < ActiveRecord::Migration[7.0]
1
+ class CreateComeeCoreSalesOrderItems < ActiveRecord::Migration[7.0]
2
2
  def change
3
- create_table :comee_core_client_order_items do |t|
4
- t.references :client_order,
3
+ create_table :comee_core_sales_order_items do |t|
4
+ t.references :sales_order,
5
5
  null: false,
6
6
  index: {name: "co_on_coi_indx"},
7
- foreign_key: {to_table: :comee_core_client_orders}
7
+ foreign_key: {to_table: :comee_core_sales_orders}
8
8
  t.references :product,
9
9
  null: false,
10
10
  index: {name: "po_on_coi_indx"},
11
11
  foreign_key: {to_table: :comee_core_products}
12
12
  t.integer :quantity, null: false
13
13
  t.integer :price, null: false
14
+ t.date :delivery_date, null: false
14
15
 
15
16
  t.timestamps
16
17
  end
@@ -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
@@ -2,10 +2,10 @@ class CreateComeeCoreInvoices < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :comee_core_invoices do |t|
4
4
  t.string :invoice_no, null: false
5
- t.references :client_order,
5
+ t.references :sales_order,
6
6
  null: false,
7
7
  index: {name: "co_on_cci_indx"},
8
- foreign_key: {to_table: :comee_core_client_orders}
8
+ foreign_key: {to_table: :comee_core_sales_orders}
9
9
  t.date :date_issued, null: false
10
10
  t.string :ship_name
11
11
  t.date :delivery_date
@@ -1,10 +1,10 @@
1
1
  class CreateComeeCoreInvoiceItems < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :comee_core_invoice_items do |t|
4
- t.references :client_order_item,
4
+ t.references :sales_order_item,
5
5
  null: false,
6
- index: {name: "coi_on_ccii_indx"},
7
- foreign_key: {to_table: :comee_core_client_order_items}
6
+ index: {name: "soi_on_ccii_indx"},
7
+ foreign_key: {to_table: :comee_core_sales_order_items}
8
8
  t.float :quantity, null: false
9
9
  t.float :unit_price, null: false
10
10
  t.float :total_price, null: false
@@ -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.12"
3
+ VERSION = "0.1.14"
4
4
  end
5
5
  end
@@ -1,13 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :client_order, class: "Comee::Core::ClientOrder" do
3
- order_number { Faker::Alphanumeric.alpha(number: 10) }
4
- order_date { Date.current }
5
- delivery_date { Date.current.advance(month: 1) }
3
+ order_source
4
+ url { Faker::Internet.url }
5
+ processed { true }
6
6
  client
7
- terms { {payment_terms: "NET 30 days", currency: "Euro", freight_terms: "FOB"} }
8
- status { Comee::Core::ClientOrder.statuses[:draft] }
9
- delivery_address { Faker::Address.full_address }
10
- invoice_address { Faker::Address.full_address }
11
- remark { Faker::Lorem.sentence }
12
7
  end
13
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,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :invoice_item, class: "Comee::Core::InvoiceItem" do
3
- client_order_item
3
+ sales_order_item
4
4
  quantity { 10 }
5
5
  unit_price { 5 }
6
6
  total_price { 50 }
@@ -1,7 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :invoice, class: "Comee::Core::Invoice" do
3
3
  invoice_no { Faker::Alphanumeric.alpha(number: 8) }
4
- client_order
4
+ sales_order
5
5
  date_issued { Date.current }
6
6
  ship_name { Faker::Name.name }
7
7
  delivery_date { Date.current.advance(days: -7) }
@@ -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
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :sales_order_item, class: "Comee::Core::SalesOrderItem" do
3
+ sales_order
4
+ product
5
+ quantity { 100 }
6
+ price { 50 }
7
+ delivery_date { Date.current.advance(month: 1) }
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ FactoryBot.define do
2
+ factory :sales_order, class: "Comee::Core::SalesOrder" do
3
+ order_number { Faker::Alphanumeric.alpha(number: 10) }
4
+ order_date { Date.current }
5
+ expected_delivery_date { Date.current.advance(month: 1) }
6
+ client
7
+ client_terms { Faker::Lorem.sentence }
8
+ payment_no_of_days { 7 }
9
+ payment_discount { 0 }
10
+ payment_penalty { 0 }
11
+ status { Comee::Core::SalesOrder.statuses[:draft] }
12
+ delivery_address { Faker::Address.full_address }
13
+ invoice_address { Faker::Address.full_address }
14
+ remark { Faker::Lorem.sentence }
15
+ end
16
+ 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.12
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-18 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
@@ -249,16 +249,19 @@ files:
249
249
  - app/models/comee/core/back_order_item.rb
250
250
  - app/models/comee/core/client.rb
251
251
  - app/models/comee/core/client_order.rb
252
- - app/models/comee/core/client_order_item.rb
253
252
  - app/models/comee/core/client_price.rb
254
253
  - app/models/comee/core/currency.rb
254
+ - app/models/comee/core/field_mapping.rb
255
255
  - app/models/comee/core/invoice.rb
256
256
  - app/models/comee/core/invoice_item.rb
257
257
  - app/models/comee/core/master_price.rb
258
258
  - app/models/comee/core/notification.rb
259
+ - app/models/comee/core/order_source.rb
259
260
  - app/models/comee/core/product.rb
260
261
  - app/models/comee/core/product_lookup.rb
261
262
  - app/models/comee/core/product_type.rb
263
+ - app/models/comee/core/sales_order.rb
264
+ - app/models/comee/core/sales_order_item.rb
262
265
  - app/models/comee/core/supplier.rb
263
266
  - app/models/comee/core/unit.rb
264
267
  - app/models/comee/core/user.rb
@@ -290,13 +293,16 @@ files:
290
293
  - db/migrate/20230728123928_create_comee_core_back_orders.rb
291
294
  - db/migrate/20230728125723_create_comee_core_back_order_items.rb
292
295
  - db/migrate/20230730061225_create_comee_core_notifications.rb
293
- - db/migrate/20230812190652_create_comee_core_client_orders.rb
294
- - db/migrate/20230812212844_create_comee_core_client_order_items.rb
296
+ - db/migrate/20230812190652_create_comee_core_sales_orders.rb
297
+ - db/migrate/20230812212844_create_comee_core_sales_order_items.rb
295
298
  - db/migrate/20230813235946_create_comee_core_master_prices.rb
296
299
  - db/migrate/20230814151601_create_comee_core_client_prices.rb
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,18 +310,21 @@ 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
307
- - spec/factories/comee/core/client_order_items.rb
308
313
  - spec/factories/comee/core/client_orders.rb
309
314
  - spec/factories/comee/core/client_prices.rb
310
315
  - spec/factories/comee/core/clients.rb
311
316
  - spec/factories/comee/core/currencies.rb
317
+ - spec/factories/comee/core/field_mappings.rb
312
318
  - spec/factories/comee/core/invoice_items.rb
313
319
  - spec/factories/comee/core/invoices.rb
314
320
  - spec/factories/comee/core/master_prices.rb
315
321
  - spec/factories/comee/core/notifications.rb
322
+ - spec/factories/comee/core/order_sources.rb
316
323
  - spec/factories/comee/core/product_lookups.rb
317
324
  - spec/factories/comee/core/product_types.rb
318
325
  - spec/factories/comee/core/products.rb
326
+ - spec/factories/comee/core/sales_order_items.rb
327
+ - spec/factories/comee/core/sales_orders.rb
319
328
  - spec/factories/comee/core/suppliers.rb
320
329
  - spec/factories/comee/core/units.rb
321
330
  - spec/factories/comee/core/users.rb
@@ -341,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
350
  - !ruby/object:Gem::Version
342
351
  version: '0'
343
352
  requirements: []
344
- rubygems_version: 3.4.19
353
+ rubygems_version: 3.4.20
345
354
  signing_key:
346
355
  specification_version: 4
347
356
  summary: An engine for the COMee ERP.
@@ -1,13 +0,0 @@
1
- module Comee
2
- module Core
3
- class ClientOrderItem < ApplicationRecord
4
- belongs_to :client_order
5
- belongs_to :product
6
-
7
- validates :quantity, :price, presence: true, numericality: {greater_than: 0}
8
-
9
- delegate(:name, to: :product, prefix: true)
10
- delegate(:code, to: :product, prefix: true)
11
- end
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- FactoryBot.define do
2
- factory :client_order_item, class: "Comee::Core::ClientOrderItem" do
3
- client_order
4
- product
5
- quantity { 100 }
6
- price { 50 }
7
- end
8
- end