mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Fix account creation
This commit is contained in:
parent
ace7fb48ee
commit
48ade396ca
17 changed files with 204 additions and 90 deletions
|
@ -1,9 +1,14 @@
|
|||
class Account < ApplicationRecord
|
||||
# VALID_ACCOUNT_TYPES = %w[Investment Depository Credit Loan Property Vehicle OtherAsset OtherLiability].freeze
|
||||
|
||||
belongs_to :family
|
||||
|
||||
delegated_type :accountable, types: %w[ Credit Depository Investment Loan OtherAsset OtherLiability Property Vehicle], dependent: :destroy
|
||||
delegated_type :accountable, types: %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle], dependent: :destroy
|
||||
|
||||
scope :depository, -> { where(type: "Depository") }
|
||||
delegate :icon, :type_name, :color, to: :accountable
|
||||
|
||||
# Class method to get a representative instance of each accountable type
|
||||
def self.accountable_type_instances
|
||||
accountable_types.map do |type|
|
||||
type.constantize.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::Credit < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-credit-card.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Credit Card"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#E6F6FA]",
|
||||
text: "text-[#189FC7]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::Depository < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-bank-accounts.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Bank Accounts"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#EAF4FF]",
|
||||
text: "text-[#3492FB]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::Investment < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-bank-accounts.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Investments"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#EDF7F4]",
|
||||
text: "text-[#1BD5A1]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::Loan < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-bank-accounts.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Loan"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#EDF7F4]",
|
||||
text: "text-[#1BD5A1]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::OtherAsset < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-bank-accounts.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Other Asset"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#EDF7F4]",
|
||||
text: "text-[#1BD5A1]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::OtherLiability < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-bank-accounts.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Other Liability"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#EDF7F4]",
|
||||
text: "text-[#1BD5A1]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::Property < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-real-estate.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Real Estate"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#FEF0F7]",
|
||||
text: "text-[#F03695]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
class Account::Vehicle < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
def icon
|
||||
"icon-bank-accounts.svg"
|
||||
end
|
||||
|
||||
def type_name
|
||||
"Vehicle"
|
||||
end
|
||||
|
||||
def color
|
||||
{
|
||||
background: "bg-[#EDF7F4]",
|
||||
text: "text-[#1BD5A1]"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
class Depository < Account
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue