mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Add test for dormant credit cards with zero balance and adjust processor logic (#630)
- Added a new test to validate how dormant credit cards with zero balance and negative available balance are processed. - Updated processor logic to ensure `current_balance` takes precedence when explicitly set to zero, preventing incorrect usage of `available_balance`. Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
This commit is contained in:
@@ -178,4 +178,24 @@ class SimplefinAccountProcessorTest < ActiveSupport::TestCase
|
||||
# Mapper should infer liability from name; final should be negative
|
||||
assert_equal BigDecimal("-100.00"), acct.reload.balance
|
||||
end
|
||||
|
||||
test "dormant credit card with zero balance and negative available-balance shows zero debt" do
|
||||
sfin_acct = SimplefinAccount.create!(
|
||||
simplefin_item: @item,
|
||||
name: "Discover Card",
|
||||
account_id: "cc_dormant",
|
||||
currency: "USD",
|
||||
account_type: "credit",
|
||||
current_balance: BigDecimal("0"),
|
||||
available_balance: BigDecimal("-3800") # credit limit reported as negative
|
||||
)
|
||||
|
||||
acct = accounts(:credit_card)
|
||||
acct.update!(simplefin_account: sfin_acct)
|
||||
|
||||
SimplefinAccount::Processor.new(sfin_acct).send(:process_account!)
|
||||
|
||||
# Should use explicit zero balance, not negative available_balance
|
||||
assert_equal BigDecimal("0"), acct.reload.balance
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user