comee_core 0.3.39 → 0.3.41

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: 7c5bd7ecb372cda637b779b831f195910cb1d8e7a6a4a7a9687d58f6e5063f34
4
- data.tar.gz: 2b66ca4edc892cfacdd239973330ea4ac1ea10ed9c0c749ffa8a67f0e2751621
3
+ metadata.gz: 945ebcfda26158faf04eeb992d73078a05ece14bf999e93287d4f9a40a536f3e
4
+ data.tar.gz: b85605bbe210dafc52a8f1e0f29f572c5ee258cbc65bfa11bfaee65ab88edcc3
5
5
  SHA512:
6
- metadata.gz: 3b23ad79739cf108028d62e244e2cee673f6bca41142c29956eeb903c565ace12997baad341c75c9936f49f44607d28d339a5890dbc976f05fd47203f64a0ca9
7
- data.tar.gz: a4ab86afb792d939cf67d7eb880d1ad5ed1680d7edb9db68e6353de5531fa23fc70405ed22b1bbc2bb53680002805de0b8673cf5b1532747d3d38f610dcf8e31
6
+ metadata.gz: 1c67e379c9ae392240d543c73a99cb89f3084db1648df9ad2310fb5054589fb32a1cb8ab4a2270f1ceaa7f9eefcb018a19cf3c5d56c15de8b0ebb414f6048c76
7
+ data.tar.gz: 6d7578c2ebbf76fcba4ecf48e4ee43130f30a9b73ed5bd83d53e4cffafeb1d8f95dd4dbfbd451edbca971a4722cad75f5c55a8b3dea33aa8373b359ba0f349bf
@@ -5,7 +5,7 @@ module Comee
5
5
  after_save :update_invoice
6
6
  after_destroy :update_invoice
7
7
 
8
- belongs_to :shipment_instruction_item
8
+ belongs_to :invoiceable, polymorphic: true
9
9
  belongs_to :invoice
10
10
  belongs_to :unit
11
11
 
@@ -0,0 +1,20 @@
1
+ class ChangeReferenceInInvoiceToPolymorphic < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_reference :comee_core_invoice_items,
4
+ :invoiceable,
5
+ polymorphic: true,
6
+ index: {name: "invoiceable_on_ccii_indx"}
7
+ reversible do |dir|
8
+ dir.up do
9
+ execute <<-SQL.squish
10
+ UPDATE comee_core_invoice_items
11
+ SET invoiceable_type = 'Comee::Core::ShipmentInstructionItem',
12
+ invoiceable_id = shipment_instruction_item_id
13
+ SQL
14
+ end
15
+ end
16
+ remove_reference :comee_core_invoice_items,
17
+ :shipment_instruction_item,
18
+ foreign_key: {to_table: :comee_core_shipment_instruction_items}
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.3.39".freeze
3
+ VERSION = "0.3.41".freeze
4
4
  end
5
5
  end
@@ -5,9 +5,5 @@ FactoryBot.define do
5
5
  quantity { 1.5 }
6
6
  unit_price { 1.5 }
7
7
  total_price { quantity * unit_price }
8
-
9
- after(:build) do |item, _|
10
- item.credit_note.invoice.total_price = 100
11
- end
12
8
  end
13
9
  end
@@ -1,17 +1,9 @@
1
1
  FactoryBot.define do
2
2
  factory :credit_note_item, class: "Comee::Core::CreditNoteItem" do
3
- transient do
4
- invoice { create(:invoice) }
5
- end
6
- # association :credit_note, invoice: :invoice
7
- # association :invoice_item, invoice: :invoice
3
+ credit_note
4
+ invoice_item { credit_note.invoice.invoice_items.first }
8
5
  quantity { 10 }
9
6
  unit_price { 2 }
10
7
  total_price { quantity * unit_price }
11
-
12
- after(:build) do |item, evaluator|
13
- item.credit_note ||= create(:credit_note, invoice: evaluator.invoice)
14
- item.invoice_item ||= create(:invoice_item, invoice: evaluator.invoice)
15
- end
16
8
  end
17
9
  end
@@ -1,11 +1,16 @@
1
1
  FactoryBot.define do
2
2
  factory :credit_note, class: "Comee::Core::CreditNote" do
3
3
  credit_note_no { nil }
4
- invoice
5
4
  total_price { 0 }
6
5
  vat { 0 }
7
6
  status { Comee::Core::CreditNote.statuses[:draft] }
8
7
  date_issued { Date.current }
9
8
  remark { Faker::Lorem.sentence }
9
+
10
+ after(:build) do |note, _|
11
+ invoice = create(:invoice)
12
+ create(:invoice_item, invoice: invoice)
13
+ note.invoice ||= invoice
14
+ end
10
15
  end
11
16
  end
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :invoice_item, class: "Comee::Core::InvoiceItem" do
3
- shipment_instruction_item
3
+ invoiceable factory: :shipment_instruction_item
4
4
  unit
5
5
  quantity { 10 }
6
6
  unit_price { 5 }
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.39
4
+ version: 0.3.41
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-08-01 00:00:00.000000000 Z
11
+ date: 2024-08-03 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/20240731075328_create_comee_core_credit_notes.rb
535
535
  - db/migrate/20240731080746_create_comee_core_credit_note_items.rb
536
536
  - db/migrate/20240731081502_create_comee_core_credit_note_additional_items.rb
537
+ - db/migrate/20240803194006_change_reference_in_invoice_to_polymorphic.rb
537
538
  - lib/comee/core.rb
538
539
  - lib/comee/core/engine.rb
539
540
  - lib/comee/core/version.rb