comee_core 0.1.11 → 0.1.13

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: b960653bddfcc784aeeab7c000ddf85f8be74276340507a44f0c530788fe3fa3
4
- data.tar.gz: 2e36d57e426e0284b048a5403fd28c3e46eee430a711e113a7936fd131dec724
3
+ metadata.gz: e3e105a8c7e7254936a7db749a048935e743a23d2098650380a34a8bf55bc620
4
+ data.tar.gz: f38e93115c2d99cb771e261a16b86183b4a06dc497f937b67be1af502f1f9d0d
5
5
  SHA512:
6
- metadata.gz: 43384c5f9e58ed88cf4dd867c8d2f1ebcbe676d971adb62eb447f33d488f9335027af47fc9fb5e1e203bf50649e5ed53187d7918904d9711da89bfc722923bff
7
- data.tar.gz: 9bb3a8027300988e252e029ec4b9778c26a7045fadf7766a163a75a3693b0b185b51d5074ec6e3d141cb7f7565ae24c786a26d879252a50a430387802fd0a251
6
+ metadata.gz: 136ec7b8f11718c0822ccacb0177c39e602a95e0b182f136a5cead06b11e06ffb8df5924aa2671841eb00f889bbaf794578444b06c92b305b739cca4bc77008e
7
+ data.tar.gz: 49ddfc65ef76c8c0fef5a0cf51e9d881f0eb621afa04a6f61dea4b89f0d914bde27a6cdc3b1d1d8952885dc30ddffbb9444bd277c76705faef6d7f4484786781
@@ -0,0 +1,13 @@
1
+ module Comee
2
+ module Core
3
+ class ClientsController < ApplicationController
4
+ include Common
5
+
6
+ private
7
+
8
+ def model_params
9
+ params.require(:payload).permit(:code, :name, :address, :locale, :user_id)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -5,6 +5,8 @@ module Comee
5
5
 
6
6
  validates :code, :name, :address, :locale, presence: true
7
7
  validates :code, uniqueness: true
8
+
9
+ delegate(:name, to: :user, prefix: true)
8
10
  end
9
11
  end
10
12
  end
@@ -15,6 +15,14 @@ module Comee
15
15
  period = Period.new(valid_from, valid_to)
16
16
  errors.add(:base, "Price validity date range is not correct.") unless period.valid?
17
17
  end
18
+
19
+ def self.ransackable_attributes(auth_object = nil)
20
+ ["valid_from", "valid_to", "new_price", "old_price", "product_id", "client_id"]
21
+ end
22
+
23
+ def self.ransackable_associations(auth_object = nil)
24
+ []
25
+ end
18
26
  end
19
27
  end
20
28
  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
@@ -20,6 +22,23 @@ module Comee
20
22
  self.total_price -= additional_charges_was if additional_charges_was && additional_charges_changed?
21
23
  self.total_price += additional_charges
22
24
  end
25
+
26
+ def self.ransackable_attributes(auth_object = nil)
27
+ [
28
+ "sales_order_id",
29
+ "invoice_no",
30
+ "date_issued",
31
+ "ship_name",
32
+ "delivery_date",
33
+ "voyage_no",
34
+ "status",
35
+ "payment_status"
36
+ ]
37
+ end
38
+
39
+ def self.ransackable_associations(auth_object = nil)
40
+ ["sales_order"]
41
+ end
23
42
  end
24
43
  end
25
44
  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
@@ -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
@@ -0,0 +1,7 @@
1
+ module Comee
2
+ module Core
3
+ class ClientSerializer < ActiveModel::Serializer
4
+ attributes :id, :code, :name, :address, :locale, :user_id, :user_name
5
+ end
6
+ end
7
+ 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.
data/config/routes.rb CHANGED
@@ -18,4 +18,5 @@ Comee::Core::Engine.routes.draw do
18
18
  resources :currencies
19
19
  resources :units
20
20
  resources :users
21
+ resources :clients
21
22
  end
@@ -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
9
  index: {name: "client_on_ccco_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
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.11"
3
+ VERSION = "0.1.13"
4
4
  end
5
5
  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) }
@@ -10,7 +10,7 @@ FactoryBot.define do
10
10
  total_price { 0 }
11
11
  payment_term { Faker::Lorem.sentence }
12
12
  notifications_sent { 0 }
13
- status { 0 }
13
+ status { Comee::Core::Invoice.statuses[:draft] }
14
14
  payment_status { 0 }
15
15
  end
16
16
  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.11
4
+ version: 0.1.13
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-16 00:00:00.000000000 Z
11
+ date: 2023-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -232,6 +232,7 @@ files:
232
232
  - Rakefile
233
233
  - app/controllers/comee/core/access_controller.rb
234
234
  - app/controllers/comee/core/application_controller.rb
235
+ - app/controllers/comee/core/clients_controller.rb
235
236
  - app/controllers/comee/core/currencies_controller.rb
236
237
  - app/controllers/comee/core/notifications_controller.rb
237
238
  - app/controllers/comee/core/product_types_controller.rb
@@ -247,8 +248,6 @@ files:
247
248
  - app/models/comee/core/back_order.rb
248
249
  - app/models/comee/core/back_order_item.rb
249
250
  - app/models/comee/core/client.rb
250
- - app/models/comee/core/client_order.rb
251
- - app/models/comee/core/client_order_item.rb
252
251
  - app/models/comee/core/client_price.rb
253
252
  - app/models/comee/core/currency.rb
254
253
  - app/models/comee/core/invoice.rb
@@ -258,10 +257,13 @@ files:
258
257
  - app/models/comee/core/product.rb
259
258
  - app/models/comee/core/product_lookup.rb
260
259
  - app/models/comee/core/product_type.rb
260
+ - app/models/comee/core/sales_order.rb
261
+ - app/models/comee/core/sales_order_item.rb
261
262
  - app/models/comee/core/supplier.rb
262
263
  - app/models/comee/core/unit.rb
263
264
  - app/models/comee/core/user.rb
264
265
  - app/notifications/comee/core/new_order_notification.rb
266
+ - app/serializers/comee/core/client_serializer.rb
265
267
  - app/serializers/comee/core/currency_serializer.rb
266
268
  - app/serializers/comee/core/product_serializer.rb
267
269
  - app/serializers/comee/core/product_type_serializer.rb
@@ -288,8 +290,8 @@ files:
288
290
  - db/migrate/20230728123928_create_comee_core_back_orders.rb
289
291
  - db/migrate/20230728125723_create_comee_core_back_order_items.rb
290
292
  - db/migrate/20230730061225_create_comee_core_notifications.rb
291
- - db/migrate/20230812190652_create_comee_core_client_orders.rb
292
- - db/migrate/20230812212844_create_comee_core_client_order_items.rb
293
+ - db/migrate/20230812190652_create_comee_core_sales_orders.rb
294
+ - db/migrate/20230812212844_create_comee_core_sales_order_items.rb
293
295
  - db/migrate/20230813235946_create_comee_core_master_prices.rb
294
296
  - db/migrate/20230814151601_create_comee_core_client_prices.rb
295
297
  - db/migrate/20230914041307_create_comee_core_external_products.rb
@@ -302,8 +304,6 @@ files:
302
304
  - lib/tasks/comee_core_tasks.rake
303
305
  - spec/factories/comee/core/back_order_items.rb
304
306
  - spec/factories/comee/core/back_orders.rb
305
- - spec/factories/comee/core/client_order_items.rb
306
- - spec/factories/comee/core/client_orders.rb
307
307
  - spec/factories/comee/core/client_prices.rb
308
308
  - spec/factories/comee/core/clients.rb
309
309
  - spec/factories/comee/core/currencies.rb
@@ -314,6 +314,8 @@ files:
314
314
  - spec/factories/comee/core/product_lookups.rb
315
315
  - spec/factories/comee/core/product_types.rb
316
316
  - spec/factories/comee/core/products.rb
317
+ - spec/factories/comee/core/sales_order_items.rb
318
+ - spec/factories/comee/core/sales_orders.rb
317
319
  - spec/factories/comee/core/suppliers.rb
318
320
  - spec/factories/comee/core/units.rb
319
321
  - spec/factories/comee/core/users.rb
@@ -339,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
341
  - !ruby/object:Gem::Version
340
342
  version: '0'
341
343
  requirements: []
342
- rubygems_version: 3.4.19
344
+ rubygems_version: 3.4.20
343
345
  signing_key:
344
346
  specification_version: 4
345
347
  summary: An engine for the COMee ERP.
@@ -1,23 +0,0 @@
1
- module Comee
2
- module Core
3
- class ClientOrder < ApplicationRecord
4
- belongs_to :client
5
- has_many :client_order_items
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
21
- end
22
- end
23
- end
@@ -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
@@ -1,13 +0,0 @@
1
- FactoryBot.define do
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) }
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
- end
13
- end