mirror of
https://github.com/we-promise/sure.git
synced 2026-07-18 15:55:22 +00:00
fix(wise): address PR #2433 review feedback
- Wire @wise_items into AccountsController#index so linked accounts appear on /accounts - Fix find_wise_account_for_linking to preserve .active scope via .merge instead of .then - Fix cross-currency incoming transfer amount to use targetValue instead of sourceValue - Add missing select_profiles.session_expired locale key - Add missing account_name interpolation to link_existing_account success notice - Use i18n for profile type labels in profile_display_name - Trigger wise_item.sync_later after account linking in all three linking actions - Isolate fee transaction failure so it no longer aborts the main transfer import - Use bare raise in WiseActivity/WiseEntry processors to preserve original backtrace - Re-raise in WiseItem::Unlinking to prevent silently orphaned Holdings - Fix avatar badge to use design system tokens (bg-container-inset, text-primary)
This commit is contained in:
@@ -25,17 +25,22 @@ class WiseEntry::Processor
|
||||
end
|
||||
|
||||
result = import_main_transaction
|
||||
import_fee_transaction if fee > 0
|
||||
|
||||
if fee > 0
|
||||
begin
|
||||
import_fee_transaction
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn "WiseEntry::Processor - Fee transaction failed for transfer #{safe_id}: #{e.message}"
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
rescue ArgumentError => e
|
||||
Rails.logger.error "WiseEntry::Processor - Validation error for transfer #{safe_id}: #{e.message}"
|
||||
raise
|
||||
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
|
||||
Rails.logger.error "WiseEntry::Processor - Failed to save transfer #{safe_id}: #{e.message}"
|
||||
raise StandardError, "Failed to import transaction: #{e.message}"
|
||||
rescue => e
|
||||
Rails.logger.error "WiseEntry::Processor - Unexpected error for transfer #{safe_id}: #{e.class} - #{e.message}"
|
||||
raise StandardError, "Unexpected error: #{e.message}"
|
||||
raise
|
||||
end
|
||||
|
||||
private
|
||||
@@ -93,9 +98,13 @@ class WiseEntry::Processor
|
||||
|
||||
# Expenses (outgoing) → positive amount in Sure convention.
|
||||
# Incomes (incoming) → negative amount in Sure convention.
|
||||
# Incoming cross-currency transfers use targetValue (what actually arrived) not sourceValue.
|
||||
def main_amount
|
||||
value = data[:sourceValue].to_d.abs
|
||||
outgoing? ? value : -value
|
||||
if outgoing?
|
||||
data[:sourceValue].to_d.abs
|
||||
else
|
||||
-(data[:targetValue].to_d.abs)
|
||||
end
|
||||
end
|
||||
|
||||
# Fee is the difference between what was debited and what the recipient received,
|
||||
|
||||
Reference in New Issue
Block a user