comee_core 0.3.44 → 0.3.45
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cdf83e72f0053b9db40024b34cc8ec6a9e801503882b53aa18cf471f4fbd4e9
|
4
|
+
data.tar.gz: cd461f1b90d26b2cd310b880740e041eeac305916a028a0f0cabee1889e192e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09c222ad1003b4c1b78dcb312c86b7972e7d15d2dbe5053acdcb82bc65944b0a551f23cd00c1b16a0a85438a4fcc602e606447113398cacdaa9998c48aaa2343'
|
7
|
+
data.tar.gz: e48fe3fa4a1930568b5b29fc0b40a78c9b4fca15b878b68e5ba2cad80db67734842a60e3342507faf0391c781e13e84cf1302486c6b858221bae46c0bd76723b
|
@@ -2,6 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class CreditNote < ApplicationRecord
|
4
4
|
before_validation :generate_credit_note_no, if: proc { |note| note.credit_note_no.nil? }
|
5
|
+
after_save :update_amount_credited, if: proc { |note| note.approved? }
|
5
6
|
|
6
7
|
belongs_to :invoice
|
7
8
|
has_many :credit_note_items
|
@@ -29,6 +30,11 @@ module Comee
|
|
29
30
|
self.credit_note_no = Util.generate_number("CreditNote", "credit_note_no", year, "-", 100001)
|
30
31
|
end
|
31
32
|
|
33
|
+
def update_amount_credited
|
34
|
+
invoice.amount_credited = invoice.calculate_amount_credited
|
35
|
+
invoice.save!
|
36
|
+
end
|
37
|
+
|
32
38
|
def validate_total_price
|
33
39
|
return unless total_price && invoice
|
34
40
|
|
@@ -28,6 +28,7 @@ module Comee
|
|
28
28
|
validates :status, :payment_status, presence: true
|
29
29
|
validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
30
30
|
validates :amount_paid, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
31
|
+
validates :amount_credited, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
31
32
|
|
32
33
|
validates :pct_advanced,
|
33
34
|
presence: true,
|
@@ -85,6 +86,12 @@ module Comee
|
|
85
86
|
payments.sum(:amount)
|
86
87
|
end
|
87
88
|
|
89
|
+
def calculate_amount_credited
|
90
|
+
credited = CreditNote.where(invoice_id: id, status: CreditNote.statuses[:approved])
|
91
|
+
total = credited.sum(:total_price) + credited.sum(:vat)
|
92
|
+
total.round(2)
|
93
|
+
end
|
94
|
+
|
88
95
|
def self.ransackable_attributes(_auth_object = nil)
|
89
96
|
%w[
|
90
97
|
id
|
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.3.
|
4
|
+
version: 0.3.45
|
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-08-
|
11
|
+
date: 2024-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -538,6 +538,7 @@ files:
|
|
538
538
|
- db/migrate/20240803231700_update_invoice_fields.rb
|
539
539
|
- db/migrate/20240805085256_add_details_to_shipment_instruction_item.rb
|
540
540
|
- db/migrate/20240805093326_update_details_column_in_shipment_instruction_items.rb
|
541
|
+
- db/migrate/20240807050230_add_amount_credited_to_invoice.rb
|
541
542
|
- lib/comee/core.rb
|
542
543
|
- lib/comee/core/engine.rb
|
543
544
|
- lib/comee/core/version.rb
|