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: 3d634ab9d176cff8de70d3f9773017f390827ba6819d0201801fd23b316c3ec2
4
- data.tar.gz: 364538a72a9bf036f947f2391efe2854ca1e89cce87eccb7c4ca615b295306b7
3
+ metadata.gz: 067fb1956bf9f0c318d443ac1bc3e57c92b98a7db3afcdaf0a4d0869a5df7989
4
+ data.tar.gz: c70a6b57d486b4029dc66f4e07e3d8dce94ab3695b0623a582e8e5573e9b1120
5
5
  SHA512:
6
- metadata.gz: '0538cffa099fcf9b7d423ce3e6815ab64f9570355ed65240cd56427d648a930b1c355fdc57003739d16435773d764409d59d038121a1ff194a5a07341db0fab1'
7
- data.tar.gz: a94b47936abb583cd19448363a22144ad976cffdf16e7b3a2256b1ac7d9bce9d869fe6289ddf313844680dbfbae46bcfa594db153b6d4994da28469da97e5462
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
@@ -12,7 +12,7 @@ module Comee
12
12
  end
13
13
 
14
14
  def self.ransackable_associations(_auth_object = nil)
15
- %w[payment_deposit invoice]
15
+ %w[payment_order supplier_invoice]
16
16
  end
17
17
 
18
18
  def validate_amount
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.47".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.47
4
+ version: 0.2.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.