comee_core 0.2.24 → 0.2.26
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 +4 -4
- data/app/controllers/concerns/comee/core/common.rb +1 -0
- data/app/models/comee/core/invoice_item.rb +6 -0
- data/app/models/comee/core/payment.rb +11 -0
- data/app/models/comee/core/payment_deposit.rb +3 -2
- data/db/migrate/20240125003634_create_comee_core_payment_deposits.rb +1 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/payment_deposits.rb +2 -1
- data/spec/factories/comee/core/payments.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cab65061584474d2bff1d09b4615f74c6755284c5870b624fa06407660f9816
|
4
|
+
data.tar.gz: 9572b9050b8d0d0df0116c57e70f0804244592c0ea3b88d8cbc2185390c6a164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16fa96b65ac32cbcad028f5cc489c3f607507bfe9fdeee2c036bc824dac5df46e8b6754d058439f8e510a9e56545a5cad63f54ac65ccbb063b691c49cecefd70
|
7
|
+
data.tar.gz: 1a041a308a441889bb5360f36b36fa6991d47032bea60960f19b26320511b0c17f73daa8a091ffd0df3b55a26081d3aed3cc3232d9bc035b1227a03e9062b6e6
|
@@ -2,6 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class InvoiceItem < ApplicationRecord
|
4
4
|
before_save { self.total_price = unit_price * quantity }
|
5
|
+
after_save :update_invoice_price
|
5
6
|
|
6
7
|
belongs_to :shipment_instruction_item
|
7
8
|
belongs_to :invoice
|
@@ -9,6 +10,11 @@ module Comee
|
|
9
10
|
|
10
11
|
validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
|
11
12
|
validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
13
|
+
|
14
|
+
def update_invoice_price
|
15
|
+
invoice.total_price = invoice.invoice_items.sum(:total_price)
|
16
|
+
invoice.save!
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -5,6 +5,7 @@ module Comee
|
|
5
5
|
belongs_to :payment_deposit
|
6
6
|
|
7
7
|
validates :amount, presence: true, numericality: {greater_than: 0}
|
8
|
+
validate :validate_amount
|
8
9
|
|
9
10
|
def self.ransackable_attributes(_auth_object = nil)
|
10
11
|
%w[id created_at updated_at]
|
@@ -13,6 +14,16 @@ module Comee
|
|
13
14
|
def self.ransackable_associations(_auth_object = nil)
|
14
15
|
%w[payment_deposit invoice]
|
15
16
|
end
|
17
|
+
|
18
|
+
def validate_amount
|
19
|
+
return unless amount && payment_deposit
|
20
|
+
|
21
|
+
running_total = payment_deposit.payments.sum(:amount)
|
22
|
+
running_total -= amount_was if id
|
23
|
+
remaining = payment_deposit.amount - running_total
|
24
|
+
error = "Amount exceeded. The maximum amount you can set is #{remaining}"
|
25
|
+
errors.add(:base, error) if amount > remaining
|
26
|
+
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
end
|
@@ -5,11 +5,12 @@ module Comee
|
|
5
5
|
belongs_to :currency
|
6
6
|
has_many :payments
|
7
7
|
|
8
|
-
|
8
|
+
enum :status, {pending: 0, processed: 1}
|
9
|
+
validates :reference_no, :date_issued, :status, presence: true
|
9
10
|
validates :amount, presence: true, numericality: {greater_than: 0}
|
10
11
|
|
11
12
|
def self.ransackable_attributes(_auth_object = nil)
|
12
|
-
%w[id reference_no bank_reference date_issued]
|
13
|
+
%w[id reference_no bank_reference date_issued status]
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.ransackable_associations(_auth_object = nil)
|
data/lib/comee/core/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|