Skip to content

Commit fe08cc7

Browse files
committed
feat(payment_terms): Apply nullability for net_payment_term
1 parent 5bb2faf commit fe08cc7

5 files changed

Lines changed: 16 additions & 5 deletions

File tree

app/models/billing_entity.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class BillingEntity < ApplicationRecord
9696
validates :document_number_prefix, length: {minimum: 1, maximum: 10}, allow_nil: true, on: :create
9797
validates :document_number_prefix, length: {minimum: 1, maximum: 10}, on: :update
9898
validates :invoice_grace_period, numericality: {greater_than_or_equal_to: 0}
99-
validates :net_payment_term, numericality: {greater_than_or_equal_to: 0}
99+
validates :net_payment_term, numericality: {greater_than_or_equal_to: 0}, allow_nil: true
100100
validates :logo,
101101
image: {authorized_content_type: %w[image/png image/jpg image/jpeg], max_size: 800.kilobytes},
102102
if: :logo?
@@ -209,7 +209,7 @@ def validate_einvoicing
209209
# legal_number :string
210210
# logo :string
211211
# name :string not null
212-
# net_payment_term :integer default(0), not null
212+
# net_payment_term :integer default(0)
213213
# payment_term :jsonb
214214
# phone :string
215215
# state :string

app/models/invoice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ def set_finalized_at
773773
# finalized_at :datetime
774774
# invoice_type :integer default("subscription"), not null
775775
# issuing_date :date
776-
# net_payment_term :integer default(0), not null
776+
# net_payment_term :integer default(0)
777777
# number :string default(""), not null
778778
# payment_attempts :integer default(0), not null
779779
# payment_dispute_lost_at :datetime
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
class RelaxNetPaymentTermNullability < ActiveRecord::Migration[8.0]
4+
def change
5+
change_column_null :billing_entities, :net_payment_term, true
6+
change_column_null :invoices, :net_payment_term, true
7+
end
8+
end

db/structure.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ CREATE TABLE public.billing_entities (
22822282
finalize_zero_amount_invoice boolean DEFAULT true NOT NULL,
22832283
invoice_footer text,
22842284
invoice_grace_period integer DEFAULT 0 NOT NULL,
2285-
net_payment_term integer DEFAULT 0 NOT NULL,
2285+
net_payment_term integer DEFAULT 0,
22862286
email character varying,
22872287
email_settings character varying[] DEFAULT '{}'::character varying[] NOT NULL,
22882288
eu_tax_management boolean DEFAULT false,
@@ -3622,7 +3622,7 @@ CREATE TABLE public.invoices (
36223622
sub_total_excluding_taxes_amount_cents bigint DEFAULT 0 NOT NULL,
36233623
sub_total_including_taxes_amount_cents bigint DEFAULT 0 NOT NULL,
36243624
payment_due_date date,
3625-
net_payment_term integer DEFAULT 0 NOT NULL,
3625+
net_payment_term integer DEFAULT 0,
36263626
voided_at timestamp(6) without time zone,
36273627
organization_sequential_id integer DEFAULT 0 NOT NULL,
36283628
ready_to_be_refreshed boolean DEFAULT false NOT NULL,
@@ -14205,6 +14205,7 @@ ALTER TABLE ONLY public.membership_roles
1420514205
SET search_path TO "$user", public;
1420614206

1420714207
INSERT INTO "schema_migrations" (version) VALUES
14208+
('20260819134550'),
1420814209
('20260819134021'),
1420914210
('20260819111435'),
1421014211
('20260819111434'),

spec/models/billing_entity_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
expect(billing_entity).to be_valid
8787
end
8888

89+
it { is_expected.to allow_value(nil).for(:net_payment_term) }
90+
8991
it { is_expected.to validate_length_of(:document_number_prefix).is_at_least(1).is_at_most(10).on(:update) }
9092

9193
it { is_expected.to allow_value(nil).for(:document_number_prefix).on(:create) }

0 commit comments

Comments
 (0)