-
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.
add db changes for edit draft invoice feature
- Loading branch information
1 parent
7577eb8
commit ab3724d
Showing
4 changed files
with
73 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,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class AdjustedFee < ApplicationRecord | ||
belongs_to :invoice | ||
belongs_to :fee, optional: true | ||
|
||
enum fee_type: Fee::FEE_TYPES | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateAdjustedFees < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :adjusted_fees, id: :uuid do |t| | ||
t.references :fee, type: :uuid, null: true, index: true, foreign_key: true | ||
t.references :invoice, type: :uuid, null: false, index: true, foreign_key: true | ||
t.references :subscription, type: :uuid, null: true, foreign_key: true, index: true | ||
t.references :charge, type: :uuid, null: true, foreign_key: true, index: true | ||
|
||
t.string :invoice_display_name | ||
t.integer :fee_type | ||
t.boolean :adjusted_units, default: false, null: false | ||
t.boolean :adjusted_amount, default: false, null: false | ||
t.decimal :units, default: '0.0', null: false | ||
t.bigint :unit_amount_cents, null: false, default: 0 | ||
t.jsonb :properties, null: false, default: {} | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :adjusted_fee do | ||
invoice | ||
fee | ||
charge { nil } | ||
subscription | ||
|
||
fee_type { 'subscription' } | ||
|
||
unit_amount_cents { 200 } | ||
units { 2 } | ||
adjusted_amount { true } | ||
|
||
invoice_display_name { Faker::Fantasy::Tolkien.character } | ||
end | ||
end |