comee_core 0.3.40 → 0.3.42
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 +4 -4
- data/app/models/comee/core/invoice.rb +34 -1
- data/app/models/comee/core/invoice_item.rb +1 -1
- data/db/migrate/20240803194006_change_reference_in_invoice_to_polymorphic.rb +20 -0
- data/db/migrate/20240803231700_update_invoice_fields.rb +7 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/invoice_items.rb +1 -1
- data/spec/factories/comee/core/invoices.rb +13 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5543b44e3e8230affe2c45fa5850176535bff3c1e52ae12e7943265db65e840d
|
4
|
+
data.tar.gz: 8a53148bbf0c6a70e1efa88070820b5892bf871d24f8c50b7a2926626f652c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2224cc02486c9aa4e57429827fce56803b5ac5a2ef4b5fb28b5e5b464e1f1f4e00694b3be0b03111175a74787f5ccf22373d0c7e3a67441221af2bd3f42b375d
|
7
|
+
data.tar.gz: e636c80554eb4262e96660fae38c767f2052d2553e89815bbc2faf6716eeb66ec56077679c22cb973829dfbf3f947e01c0f0039cab2fb782424f634be53cc355
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class Invoice < ApplicationRecord
|
4
|
+
ADVANCE = "Advance".freeze
|
5
|
+
DELIVERY = "Delivery".freeze
|
6
|
+
DIRECT = "Direct".freeze
|
7
|
+
|
8
|
+
INVOICE_TYPES = [ADVANCE, DELIVERY, DIRECT].freeze
|
9
|
+
|
4
10
|
before_validation :generate_invoice_no, if: proc { |inv| inv.invoice_no.nil? }
|
5
11
|
before_save :calculate_due_date, unless: proc { |inv| inv.date_issued.nil? }
|
6
12
|
|
7
13
|
belongs_to :sales_order
|
8
|
-
belongs_to :pod
|
14
|
+
belongs_to :pod, optional: true
|
9
15
|
belongs_to :invoice_address,
|
10
16
|
-> { where(address_type: ClientAddress::INVOICING_ADDRESS) },
|
11
17
|
class_name: "Comee::Core::ClientAddress"
|
@@ -23,9 +29,35 @@ module Comee
|
|
23
29
|
validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
24
30
|
validates :amount_paid, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
|
25
31
|
|
32
|
+
validates :pct_advanced,
|
33
|
+
presence: true,
|
34
|
+
numericality: {greater_than: 0, less_than_or_equal_to: 100},
|
35
|
+
if: -> { advance? }
|
36
|
+
validates :pct_advanced,
|
37
|
+
absence: true,
|
38
|
+
if: -> { delivery? || direct? }
|
39
|
+
validates :pod_id,
|
40
|
+
presence: true,
|
41
|
+
if: -> { delivery? }
|
42
|
+
validates :pod_id,
|
43
|
+
absence: true,
|
44
|
+
if: -> { advance? }
|
45
|
+
|
26
46
|
delegate(:order_number, to: :sales_order, prefix: false)
|
27
47
|
delegate(:reference_no, to: :pod, prefix: true)
|
28
48
|
|
49
|
+
def delivery?
|
50
|
+
invoice_type == DELIVERY
|
51
|
+
end
|
52
|
+
|
53
|
+
def advance?
|
54
|
+
invoice_type == ADVANCE
|
55
|
+
end
|
56
|
+
|
57
|
+
def direct?
|
58
|
+
invoice_type == DIRECT
|
59
|
+
end
|
60
|
+
|
29
61
|
def calculate_total_price
|
30
62
|
self.total_price = calculate_total
|
31
63
|
end
|
@@ -56,6 +88,7 @@ module Comee
|
|
56
88
|
id
|
57
89
|
sales_order_id
|
58
90
|
invoice_no
|
91
|
+
invoice_type
|
59
92
|
date_issued
|
60
93
|
ship_name
|
61
94
|
delivery_date
|
@@ -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
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class UpdateInvoiceFields < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
change_column_null :comee_core_invoices, :pod_id, true
|
4
|
+
add_column :comee_core_invoices, :invoice_type, :string, default: "Delivery"
|
5
|
+
add_column :comee_core_invoices, :pct_advanced, :float, null: true
|
6
|
+
end
|
7
|
+
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -2,12 +2,14 @@ FactoryBot.define do
|
|
2
2
|
factory :invoice, class: "Comee::Core::Invoice" do
|
3
3
|
invoice_no { nil }
|
4
4
|
sales_order
|
5
|
+
invoice_type { Comee::Core::Invoice::DELIVERY }
|
5
6
|
pod
|
6
7
|
date_issued { Date.current }
|
7
8
|
due_date { Date.current.advance(days: 10) }
|
8
9
|
total_price { 0 }
|
9
10
|
amount_paid { 0 }
|
10
11
|
payment_term { Faker::Lorem.sentence }
|
12
|
+
pct_advanced { nil }
|
11
13
|
notifications_sent { 0 }
|
12
14
|
status { Comee::Core::Invoice.statuses[:draft] }
|
13
15
|
payment_status { Comee::Core::Invoice.payment_statuses[:not_paid] }
|
@@ -20,5 +22,16 @@ FactoryBot.define do
|
|
20
22
|
trait :issued do
|
21
23
|
status { Comee::Core::Invoice.statuses[:issued] }
|
22
24
|
end
|
25
|
+
|
26
|
+
trait :advance do
|
27
|
+
invoice_type { Comee::Core::Invoice::ADVANCE }
|
28
|
+
pod { nil }
|
29
|
+
pct_advanced { 25 }
|
30
|
+
end
|
31
|
+
|
32
|
+
trait :direct do
|
33
|
+
invoice_type { Comee::Core::Invoice::DIRECT }
|
34
|
+
pct_advanced { nil }
|
35
|
+
end
|
23
36
|
end
|
24
37
|
end
|
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.
|
4
|
+
version: 0.3.42
|
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-
|
11
|
+
date: 2024-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -534,6 +534,8 @@ 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
|
538
|
+
- db/migrate/20240803231700_update_invoice_fields.rb
|
537
539
|
- lib/comee/core.rb
|
538
540
|
- lib/comee/core/engine.rb
|
539
541
|
- lib/comee/core/version.rb
|