|
|
@ -6,7 +6,7 @@ from marshmallow import Schema, fields |
|
|
|
import re |
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
from ..decorators import ensure_logged_in |
|
|
|
from ..decorators import ensure_logged_in |
|
|
|
from ..db_utils import get_transactions, get_account, get_accounts, insert_transaction, whose_account, insert_notification |
|
|
|
from ..db_utils import get_transactions, get_account, get_accounts, insert_transaction, whose_account, insert_notification, get_forex_rate |
|
|
|
from ..models import Account, Notification, Transaction |
|
|
|
from ..models import Account, Notification, Transaction |
|
|
|
from ..utils.iban import check_iban |
|
|
|
from ..utils.iban import check_iban |
|
|
|
from .. import decorators, returns |
|
|
|
from .. import decorators, returns |
|
|
@ -82,15 +82,18 @@ class TransactionsList(MethodView): |
|
|
|
if destination_iban[4:8] == 'FOXB': |
|
|
|
if destination_iban[4:8] == 'FOXB': |
|
|
|
for acc in get_accounts(): |
|
|
|
for acc in get_accounts(): |
|
|
|
if destination_iban == acc.iban: |
|
|
|
if destination_iban == acc.iban: |
|
|
|
|
|
|
|
rate = get_forex_rate(account.currency, acc.currency) |
|
|
|
reverse_transaction = Transaction.new_transaction( |
|
|
|
reverse_transaction = Transaction.new_transaction( |
|
|
|
date_time=date, |
|
|
|
date_time=date, |
|
|
|
transaction_type='receive_transfer', |
|
|
|
transaction_type='receive_transfer', |
|
|
|
status='processed', |
|
|
|
status='processed', |
|
|
|
other_party={'iban': account.iban,}, |
|
|
|
other_party={'iban': account.iban,}, |
|
|
|
extra={ |
|
|
|
extra={ |
|
|
|
'currency': account.currency, |
|
|
|
'currency': acc.currency, |
|
|
|
'amount': -amount, |
|
|
|
'amount': int(-amount * rate), |
|
|
|
'description': description, |
|
|
|
'description': description, |
|
|
|
|
|
|
|
'originalAmount': -amount, |
|
|
|
|
|
|
|
'originalCurrency': account.currency, |
|
|
|
}, |
|
|
|
}, |
|
|
|
) |
|
|
|
) |
|
|
|
insert_transaction(acc.id, reverse_transaction) |
|
|
|
insert_transaction(acc.id, reverse_transaction) |
|
|
|