comee_core 0.2.47 → 0.2.49
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: 067fb1956bf9f0c318d443ac1bc3e57c92b98a7db3afcdaf0a4d0869a5df7989
|
4
|
+
data.tar.gz: c70a6b57d486b4029dc66f4e07e3d8dce94ab3695b0623a582e8e5573e9b1120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3ac1e81c9d58317182cd37e470e4f92516201bddf1d77fc2c5e5412b045dfc340d8c55b6dea389f07059fc6c683bc825d1b25a23102dbbd319f83317e80d26e
|
7
|
+
data.tar.gz: 943ec3ba980dbdfe273afa930fa30f7ad6200ff5085ee6552aec2af978012e8a933e23a0dacc94b2389792c262de0f1bf4dc9d09622864bf10111cbbaa8723df
|
@@ -2,10 +2,16 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class AdditionalItem < ApplicationRecord
|
4
4
|
before_save { self.total_price = unit_price * quantity }
|
5
|
+
after_save { invoice.update_total_price }
|
5
6
|
belongs_to :invoice
|
6
7
|
|
7
8
|
validates :description, presence: true
|
8
9
|
validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
|
10
|
+
|
11
|
+
def update_invoice_price
|
12
|
+
invoice.total_price = invoice.invoice_items.sum(:total_price) + invoice.additional_items.sum(:total_price)
|
13
|
+
invoice.save!
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
@@ -20,6 +20,11 @@ module Comee
|
|
20
20
|
delegate(:order_number, to: :sales_order, prefix: false)
|
21
21
|
delegate(:reference_no, to: :pod, prefix: true)
|
22
22
|
|
23
|
+
def update_total_price
|
24
|
+
self.total_price = invoice_items.sum(:total_price) + additional_items.sum(:total_price)
|
25
|
+
save!
|
26
|
+
end
|
27
|
+
|
23
28
|
def self.ransackable_attributes(_auth_object = nil)
|
24
29
|
%w[
|
25
30
|
id
|
@@ -2,7 +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
|
5
|
+
after_save { invoice.update_total_price }
|
6
6
|
|
7
7
|
belongs_to :shipment_instruction_item
|
8
8
|
belongs_to :invoice
|
@@ -11,10 +11,10 @@ module Comee
|
|
11
11
|
validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
|
12
12
|
validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
13
13
|
|
14
|
-
def update_invoice_price
|
15
|
-
|
16
|
-
|
17
|
-
end
|
14
|
+
# def update_invoice_price
|
15
|
+
# invoice.total_price = invoice.invoice_items.sum(:total_price) + invoice.additional_items.sum(:total_price)
|
16
|
+
# invoice.save!
|
17
|
+
# end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/comee/core/version.rb
CHANGED