comee_core 0.1.10 → 0.1.12

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: 75efe50766a9b07ed19c73cf8102bc7b17dcd21d6b7936e1fc6df6f130e96ff2
4
- data.tar.gz: bcc9e495cde736a992355c3e17b5f1fa6c1f1ce04bd56ca0c6f87f95a85966df
3
+ metadata.gz: e7530cbd96ea9cc406bcfb8ef5c890a8cdfa31d5f43c3d09c07afba8c4c0ce3c
4
+ data.tar.gz: e8a22cb3298284e49c74ead3edc5fe1168c03e9029f15c3a270c2d6df6414cf3
5
5
  SHA512:
6
- metadata.gz: e569094649d5a95f37c524620e5f54faee56d2a9751b29cf8e49b5f9fc43b30c37e767e67f49f065b0075c77a5d4a5ade1b5c08dc2951a4d4f54a6ea79e651f8
7
- data.tar.gz: b930dc71cd29633746849fe94d2bd40163b36359215ecfe9d162d0d785a96320f5dd727bcfe5cf6eea9795ed27b389cacc67adb9dc36036ce721ca6244860e48
6
+ metadata.gz: 463c027f00ad2b09037e091b4fe2cdbfc5b0139c9f3856f81e8f3dde30bf88c3cf1e23d70a56c2acee2f122d7e4ece7d83ade7b9713736b92e1ee7ce62684f95
7
+ data.tar.gz: 4f6b18b777eaeff508c4c00e23396d9ab1abf740fde0cb155abf00ee2d2ba99eba9d8fbef882b41b0eafea779f1205cc8c08cff0a0ee92308b3e8ddc39e16aea
@@ -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
@@ -5,6 +5,9 @@ module Comee
5
5
  belongs_to :product
6
6
 
7
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)
8
11
  end
9
12
  end
10
13
  end
@@ -12,12 +12,31 @@ module Comee
12
12
  validates :date_issued, :payment_term, :status, :payment_status, presence: true
13
13
  validates :additional_charges, :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
14
14
 
15
+ delegate(:order_number, to: :client_order)
16
+
15
17
  def update_invoice_total
16
18
  self.additional_charges ||= 0
17
19
  self.total_price ||= 0
18
20
  self.total_price -= additional_charges_was if additional_charges_was && additional_charges_changed?
19
21
  self.total_price += additional_charges
20
22
  end
23
+
24
+ def self.ransackable_attributes(auth_object = nil)
25
+ [
26
+ "client_order_id",
27
+ "invoice_no",
28
+ "date_issued",
29
+ "ship_name",
30
+ "delivery_date",
31
+ "voyage_no",
32
+ "status",
33
+ "payment_status"
34
+ ]
35
+ end
36
+
37
+ def self.ransackable_associations(auth_object = nil)
38
+ []
39
+ end
21
40
  end
22
41
  end
23
42
  end
@@ -7,7 +7,11 @@ module Comee
7
7
  belongs_to :client_order_item
8
8
  belongs_to :invoice
9
9
 
10
- validates :quantity, :unit_price, :total_price, presence: true, numericality: {greater_than: 0}
10
+ validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
11
+ validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
12
+
13
+ delegate(:product_code, to: :client_order_item)
14
+ delegate(:product_name, to: :client_order_item)
11
15
 
12
16
  def update_invoice_total
13
17
  invoice.total_price = InvoiceItem.where(invoice: invoice).map(&:total_price).sum
@@ -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
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,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.10"
3
+ VERSION = "0.1.12"
4
4
  end
5
5
  end
@@ -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
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.10
4
+ version: 0.1.12
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-18 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
@@ -262,6 +263,7 @@ files:
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