comee_core 0.3.17 → 0.3.18

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: 31d273c0f307b780445d84f77724d21676a90ecb97923b6e57452f011a31ede1
4
- data.tar.gz: 8e5b700c41f8dcd22bccf746756bfdcc6669a1774622cf9f4dd03c1383a7b6a4
3
+ metadata.gz: f7b45dd03c08ff2f2aaecfa3bb2b4c48c0640240ccc8f2988311754ff25e031a
4
+ data.tar.gz: f992aef504e763d0583ecaecdc1744dede77600bcfcdf2530e21c6da0f14bf27
5
5
  SHA512:
6
- metadata.gz: d8b7269868908faea7b9fce4be61b9a9d0302a29854d29ea37948afd9c0a6ba77949aa5e241bb24ad63cd7b50faad5c2650d57d7311272c131c609511f4c0169
7
- data.tar.gz: a11db8aeef2a636b16b5723c41bd8385107cf8554ddb87ddc98f1173d36fa2611619cce558194059d30e225f38b5596c704fc2f5abb5c6f5a934bdfe6c87a804
6
+ metadata.gz: 99585c3f085b3a361c9cf06b04aa5dca4a5273093457e3f80c2abcb6c139fdb1e49f088db13aa9c02df1a75c8897239aa8d90216acc9e6d6d18a0024b0fc1930
7
+ data.tar.gz: 9a63b2fa0373ee075bb40b16786ba3926c40559410475f11c12bed3b235726c760d196b152a42620e056458f890706439f67d6d97f075b4eda371187c53e1b99
@@ -35,7 +35,7 @@ module Comee
35
35
  def calculate_total
36
36
  items = InvoiceItem.where(invoice_id: id)
37
37
  additionals = AdditionalItem.where(invoice_id: id)
38
- items.sum(:total_price) + additionals.sum(:total_price)
38
+ (items.sum(:total_price) + additionals.sum(:total_price)).round(2)
39
39
  end
40
40
 
41
41
  def self.ransackable_attributes(_auth_object = nil)
@@ -1,12 +1,15 @@
1
1
  module Comee
2
2
  module Core
3
3
  class MasterPrice < Price
4
+ before_save :set_default_currency
5
+
4
6
  enum :price_status, {draft: 0, approved: 1}
5
7
  belongs_to :supplier
6
8
  belongs_to :previous_price, class_name: "Comee::Core::MasterPrice", optional: true
7
9
  belongs_to :next_price, class_name: "Comee::Core::MasterPrice", optional: true
8
10
  belongs_to :country_of_origin, -> { where(lookup_type: :country) }, class_name: "Comee::Core::Lookup", optional: true
9
11
  belongs_to :product_lookup, optional: true
12
+ belongs_to :currency, optional: true
10
13
 
11
14
  validates :purchase_price, :selling_price, presence: true
12
15
  validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
@@ -43,6 +46,12 @@ module Comee
43
46
  end
44
47
  end
45
48
 
49
+ def set_default_currency
50
+ return if currency
51
+
52
+ self.currency = Comee::Core::Currency.find_by(code: "EUR")
53
+ end
54
+
46
55
  def self.ransackable_attributes(_auth_object = nil)
47
56
  %w[
48
57
  id
@@ -20,7 +20,7 @@ module Comee
20
20
 
21
21
  def calculate_total_price
22
22
  items = PurchaseOrderItem.where(purchase_order_id: id)
23
- self.total_price = items.sum(&:total_price)
23
+ self.total_price = items.sum(&:total_price).round(2)
24
24
  end
25
25
 
26
26
  def calculate_vat
@@ -42,7 +42,7 @@ module Comee
42
42
  def calculate_total
43
43
  order_items = SalesOrderItem.where(sales_order_id: id)
44
44
  services = AdditionalService.where(sales_order_id: id)
45
- order_items.sum(&:total_price) + services.sum(&:total_price)
45
+ (order_items.sum(&:total_price) + services.sum(&:total_price)).round(2)
46
46
  end
47
47
 
48
48
  def set_parent_client_name
@@ -2,12 +2,13 @@ module Comee
2
2
  module Core
3
3
  class MasterPriceSerializer < ActiveModel::Serializer
4
4
  attributes :id, :purchase_price, :selling_price, :valid_from, :valid_to, :primary, :margin, :lead_time, :status,
5
- :price_status, :state_of_origin
5
+ :price_status, :state_of_origin, :currency_id
6
6
  belongs_to :product
7
7
  belongs_to :supplier
8
8
  belongs_to :product_lookup
9
9
  belongs_to :unit
10
10
  belongs_to :country_of_origin
11
+ belongs_to :currency
11
12
  end
12
13
  end
13
14
  end
@@ -0,0 +1,9 @@
1
+ class AddCurrencyToMasterPrice < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_reference :comee_core_master_prices,
4
+ :currency,
5
+ index: {name: "currency_on_ccmp_indx"},
6
+ null: true,
7
+ foreign_key: {to_table: :comee_core_currencies}
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.3.17".freeze
3
+ VERSION = "0.3.18".freeze
4
4
  end
5
5
  end
@@ -17,6 +17,7 @@ FactoryBot.define do
17
17
  propagated_to_client { false }
18
18
  country_of_origin factory: :country
19
19
  state_of_origin { "02 - Hamburg" }
20
+ currency
20
21
 
21
22
  trait :approved do
22
23
  price_status { Comee::Core::Price.price_statuses[:approved] }
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.17
4
+ version: 0.3.18
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-07-02 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -534,6 +534,7 @@ files:
534
534
  - db/migrate/20240630122016_create_comee_core_additional_services.rb
535
535
  - db/migrate/20240702151519_add_vat_to_purchase_order.rb
536
536
  - db/migrate/20240702181613_add_vat_to_invoice.rb
537
+ - db/migrate/20240703204755_add_currency_to_master_price.rb
537
538
  - lib/comee/core.rb
538
539
  - lib/comee/core/engine.rb
539
540
  - lib/comee/core/version.rb