comee_core 0.2.48 → 0.2.49

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e5df6c6ea7e337a4d968b87335eabb85a8ef4b9e4d95d537f3eee140db2d099
4
- data.tar.gz: 1ef66c5793d8db8ebfd9b03826ce17010bede69bc8d2e3fb61dd0e24f42074d9
3
+ metadata.gz: 067fb1956bf9f0c318d443ac1bc3e57c92b98a7db3afcdaf0a4d0869a5df7989
4
+ data.tar.gz: c70a6b57d486b4029dc66f4e07e3d8dce94ab3695b0623a582e8e5573e9b1120
5
5
  SHA512:
6
- metadata.gz: 27f2ba5df44031ae31eebb0f1edf5d68970e6637549a61e18dc61779736363b488fc68fc689be396eb17a637e04a927659ecd5dbe40d8d760317147254c87a9f
7
- data.tar.gz: abfebc49a3c9636ea895036ea20332e9dce56526d14b1feab0aacc7f6f506656e3d61c3b66f1fb6965f7d3f3c121dd6b68df15f92d8e0c2acd385e932cf19c46
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 :update_invoice_price
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
- invoice.total_price = invoice.invoice_items.sum(:total_price)
16
- invoice.save!
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
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.48".freeze
3
+ VERSION = "0.2.49".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comee_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.48
4
+ version: 0.2.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.