comee_core 0.3.15 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/product_lookups_controller.rb +1 -1
- data/app/models/comee/core/additional_item.rb +5 -3
- data/app/models/comee/core/invoice.rb +14 -3
- data/app/models/comee/core/invoice_item.rb +7 -5
- data/app/models/comee/core/purchase_order.rb +10 -2
- data/app/models/comee/core/purchase_order_item.rb +8 -0
- data/app/models/comee/core/sales_order.rb +8 -7
- data/app/serializers/comee/core/product_lookup_serializer.rb +1 -0
- data/db/migrate/20240702151519_add_vat_to_purchase_order.rb +5 -0
- data/db/migrate/20240702181613_add_vat_to_invoice.rb +5 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/suppliers.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31d273c0f307b780445d84f77724d21676a90ecb97923b6e57452f011a31ede1
|
4
|
+
data.tar.gz: 8e5b700c41f8dcd22bccf746756bfdcc6669a1774622cf9f4dd03c1383a7b6a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8b7269868908faea7b9fce4be61b9a9d0302a29854d29ea37948afd9c0a6ba77949aa5e241bb24ad63cd7b50faad5c2650d57d7311272c131c609511f4c0169
|
7
|
+
data.tar.gz: a11db8aeef2a636b16b5723c41bd8385107cf8554ddb87ddc98f1173d36fa2611619cce558194059d30e225f38b5596c704fc2f5abb5c6f5a934bdfe6c87a804
|
@@ -2,14 +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
|
5
|
+
after_save :update_invoice
|
6
|
+
after_destroy :update_invoice
|
6
7
|
belongs_to :invoice
|
7
8
|
|
8
9
|
validates :description, presence: true
|
9
10
|
validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
|
10
11
|
|
11
|
-
def
|
12
|
-
invoice.
|
12
|
+
def update_invoice
|
13
|
+
invoice.calculate_total_price
|
14
|
+
invoice.calculate_vat
|
13
15
|
invoice.save!
|
14
16
|
end
|
15
17
|
end
|
@@ -22,9 +22,20 @@ module Comee
|
|
22
22
|
delegate(:order_number, to: :sales_order, prefix: false)
|
23
23
|
delegate(:reference_no, to: :pod, prefix: true)
|
24
24
|
|
25
|
-
def
|
26
|
-
self.total_price =
|
27
|
-
|
25
|
+
def calculate_total_price
|
26
|
+
self.total_price = calculate_total
|
27
|
+
end
|
28
|
+
|
29
|
+
def calculate_vat
|
30
|
+
return unless sales_order.client.tax_code == "Inland"
|
31
|
+
|
32
|
+
self.vat = (calculate_total * 0.19).round(2)
|
33
|
+
end
|
34
|
+
|
35
|
+
def calculate_total
|
36
|
+
items = InvoiceItem.where(invoice_id: id)
|
37
|
+
additionals = AdditionalItem.where(invoice_id: id)
|
38
|
+
items.sum(:total_price) + additionals.sum(:total_price)
|
28
39
|
end
|
29
40
|
|
30
41
|
def self.ransackable_attributes(_auth_object = nil)
|
@@ -2,7 +2,8 @@ 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 :update_invoice
|
6
|
+
after_destroy :update_invoice
|
6
7
|
|
7
8
|
belongs_to :shipment_instruction_item
|
8
9
|
belongs_to :invoice
|
@@ -11,10 +12,11 @@ module Comee
|
|
11
12
|
validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0}
|
12
13
|
validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def update_invoice
|
16
|
+
invoice.calculate_total_price
|
17
|
+
invoice.calculate_vat
|
18
|
+
invoice.save!
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -2,7 +2,7 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class PurchaseOrder < ApplicationRecord
|
4
4
|
before_validation :generate_po_number, if: proc { |po| po.po_number.nil? }
|
5
|
-
before_save :
|
5
|
+
before_save :set_terms
|
6
6
|
|
7
7
|
belongs_to :supplier
|
8
8
|
has_many :purchase_order_items
|
@@ -18,11 +18,19 @@ module Comee
|
|
18
18
|
canceled: 5
|
19
19
|
}
|
20
20
|
|
21
|
-
def
|
21
|
+
def calculate_total_price
|
22
22
|
items = PurchaseOrderItem.where(purchase_order_id: id)
|
23
23
|
self.total_price = items.sum(&:total_price)
|
24
24
|
end
|
25
25
|
|
26
|
+
def calculate_vat
|
27
|
+
return unless supplier.tax_code == "Inland"
|
28
|
+
|
29
|
+
items = PurchaseOrderItem.where(purchase_order_id: id)
|
30
|
+
total_price = items.sum(&:total_price)
|
31
|
+
self.vat = (total_price * 0.19).round(2)
|
32
|
+
end
|
33
|
+
|
26
34
|
def self.ransackable_attributes(_auth_object = nil)
|
27
35
|
%w[
|
28
36
|
id
|
@@ -2,6 +2,8 @@ module Comee
|
|
2
2
|
module Core
|
3
3
|
class PurchaseOrderItem < ApplicationRecord
|
4
4
|
before_save :calculate_total_price, :calculate_confirmation_values
|
5
|
+
after_save :update_purchase_order
|
6
|
+
after_destroy :update_purchase_order
|
5
7
|
|
6
8
|
has_one :purchase_order_item_diff
|
7
9
|
|
@@ -32,6 +34,12 @@ module Comee
|
|
32
34
|
self.confirmed_total_price = (confirmed_price * confirmed_quantity).round(2)
|
33
35
|
end
|
34
36
|
|
37
|
+
def update_purchase_order
|
38
|
+
purchase_order.calculate_total_price
|
39
|
+
purchase_order.calculate_vat
|
40
|
+
purchase_order.save!
|
41
|
+
end
|
42
|
+
|
35
43
|
def self.ransackable_attributes(_auth_object = nil)
|
36
44
|
%w[
|
37
45
|
id
|
@@ -30,18 +30,19 @@ module Comee
|
|
30
30
|
allow_nil: true
|
31
31
|
|
32
32
|
def calculate_total_price
|
33
|
-
|
34
|
-
additional_services = AdditionalService.where(sales_order_id: id)
|
35
|
-
self.total_price = sales_order_items.sum(&:total_price) + additional_services.sum(&:total_price)
|
33
|
+
self.total_price = calculate_total
|
36
34
|
end
|
37
35
|
|
38
36
|
def calculate_vat
|
39
37
|
return unless client.tax_code == "Inland"
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
self.vat = (calculate_total * 0.19).round(2)
|
40
|
+
end
|
41
|
+
|
42
|
+
def calculate_total
|
43
|
+
order_items = SalesOrderItem.where(sales_order_id: id)
|
44
|
+
services = AdditionalService.where(sales_order_id: id)
|
45
|
+
order_items.sum(&:total_price) + services.sum(&:total_price)
|
45
46
|
end
|
46
47
|
|
47
48
|
def set_parent_client_name
|
data/lib/comee/core/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -532,6 +532,8 @@ files:
|
|
532
532
|
- db/migrate/20240630063656_add_aliases_field_to_product_lookup.rb
|
533
533
|
- db/migrate/20240630083042_add_agent_to_pickup_schedule.rb
|
534
534
|
- db/migrate/20240630122016_create_comee_core_additional_services.rb
|
535
|
+
- db/migrate/20240702151519_add_vat_to_purchase_order.rb
|
536
|
+
- db/migrate/20240702181613_add_vat_to_invoice.rb
|
535
537
|
- lib/comee/core.rb
|
536
538
|
- lib/comee/core/engine.rb
|
537
539
|
- lib/comee/core/version.rb
|