-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat invoice custom sections - models updates (#2859)
## Context In order to save invoice custom sections, we need to make create new models related to the new tables ## Description Added - InvoiceCustomSection - AppliedInvoiceCustomSection - InvoiceCustomSectionSelection Updated - Organization - Customer
- Loading branch information
1 parent
01bc75a
commit 89ad7de
Showing
14 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class AppliedInvoiceCustomSection < ApplicationRecord | ||
belongs_to :invoice | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: applied_invoice_custom_sections | ||
# | ||
# id :uuid not null, primary key | ||
# code :string not null | ||
# details :string | ||
# display_name :string | ||
# name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# invoice_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_applied_invoice_custom_sections_on_invoice_id (invoice_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (invoice_id => invoices.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
class InvoiceCustomSection < ApplicationRecord | ||
include Discard::Model | ||
self.discard_column = :deleted_at | ||
|
||
belongs_to :organization | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: invoice_custom_sections | ||
# | ||
# id :uuid not null, primary key | ||
# code :string not null | ||
# deleted_at :datetime | ||
# description :string | ||
# details :string | ||
# display_name :string | ||
# name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organization_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# idx_on_organization_id_deleted_at_225e3f789d (organization_id,deleted_at) | ||
# index_invoice_custom_sections_on_organization_id (organization_id) | ||
# index_invoice_custom_sections_on_organization_id_and_code (organization_id,code) UNIQUE | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (organization_id => organizations.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
class InvoiceCustomSectionSelection < ApplicationRecord | ||
belongs_to :invoice_custom_section | ||
belongs_to :organization, optional: true | ||
belongs_to :customer, optional: true | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: invoice_custom_section_selections | ||
# | ||
# id :uuid not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# customer_id :uuid | ||
# invoice_custom_section_id :uuid not null | ||
# organization_id :uuid | ||
# | ||
# Indexes | ||
# | ||
# idx_on_invoice_custom_section_id_7edbcef7b5 (invoice_custom_section_id) | ||
# index_invoice_custom_section_selections_on_customer_id (customer_id) | ||
# index_invoice_custom_section_selections_on_organization_id (organization_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (customer_id => customers.id) | ||
# fk_rails_... (invoice_custom_section_id => invoice_custom_sections.id) | ||
# fk_rails_... (organization_id => organizations.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :applied_invoice_custom_section do | ||
invoice | ||
code { Faker::Lorem.words(number: 3).join('_') } | ||
name { Faker::Lorem.words(number: 3).join(' ') } | ||
display_name { Faker::Lorem.words(number: 3).join(' ') } | ||
details { 'These details are shown in the invoice' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :invoice_custom_section do | ||
organization | ||
code { Faker::Lorem.words(number: 3).join('_') } | ||
name { Faker::Lorem.words(number: 3).join(' ') } | ||
display_name { Faker::Lorem.words(number: 3).join(' ') } | ||
details { 'These details are shown in the invoice' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe AppliedInvoiceCustomSection, type: :model do | ||
subject(:applied_invoice_custom_section) { create(:applied_invoice_custom_section) } | ||
|
||
it { is_expected.to belong_to(:invoice) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe InvoiceCustomSection, type: :model do | ||
subject(:invoice_custom_section) { create(:invoice_custom_section) } | ||
|
||
it { is_expected.to belong_to(:organization) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters