mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 15:19:38 +02:00
Breaks our Plaid sync process out into more manageable classes. Notably, this moves the sync process to a distinct, 2-step flow: 1. Import stage - we first make API calls and import Plaid data to "mirror" tables 2. Processing stage - read the raw data, apply business rules, build internal domain models and sync balances This provides several benefits: - Plaid syncs can now be "replayed" without fetching API data again - Mirror tables provide better audit and debugging capabilities - Eliminates the "all or nothing" sync behavior that is currently in place, which is brittle
33 lines
622 B
Ruby
33 lines
622 B
Ruby
class CreditCard < ApplicationRecord
|
|
include Accountable
|
|
|
|
SUBTYPES = {
|
|
"credit_card" => { short: "Credit Card", long: "Credit Card" }
|
|
}.freeze
|
|
|
|
class << self
|
|
def color
|
|
"#F13636"
|
|
end
|
|
|
|
def icon
|
|
"credit-card"
|
|
end
|
|
|
|
def classification
|
|
"liability"
|
|
end
|
|
end
|
|
|
|
def available_credit_money
|
|
available_credit ? Money.new(available_credit, account.currency) : nil
|
|
end
|
|
|
|
def minimum_payment_money
|
|
minimum_payment ? Money.new(minimum_payment, account.currency) : nil
|
|
end
|
|
|
|
def annual_fee_money
|
|
annual_fee ? Money.new(annual_fee, account.currency) : nil
|
|
end
|
|
end
|