mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
change account_type
This commit is contained in:
parent
9f062cc4f8
commit
e2d8ac37b5
@ -83,35 +83,33 @@ use App\Helpers\Bank\AccountTransformerInterface;
|
||||
*/
|
||||
|
||||
|
||||
class AccountTransformer implements AccountTransformerInterface
|
||||
{
|
||||
class AccountTransformer implements AccountTransformerInterface {
|
||||
|
||||
public function transform($nordigen_account)
|
||||
{
|
||||
public function transform($nordigen_account) {
|
||||
|
||||
if (!property_exists($nordigen_account, 'data') || !property_exists($nordigen_account, 'metadata') || !property_exists($nordigen_account, 'balances') || !property_exists($nordigen_account, 'institution'))
|
||||
if(!property_exists($nordigen_account, 'data') || !property_exists($nordigen_account, 'metadata') || !property_exists($nordigen_account, 'balances') || !property_exists($nordigen_account, 'institution'))
|
||||
throw new \Exception('invalid dataset');
|
||||
|
||||
$used_balance = $nordigen_account->balances[0];
|
||||
// prefer entry with closingBooked
|
||||
foreach ($nordigen_account->balances as $entry) {
|
||||
if ($entry["balanceType"] === 'closingBooked') { // available: closingBooked, interimAvailable
|
||||
foreach($nordigen_account->balances as $entry) {
|
||||
if($entry["balanceType"] === 'closingBooked') { // available: closingBooked, interimAvailable
|
||||
$used_balance = $entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $nordigen_account->metadata["id"], // TODO: maybe add prefix for unique id between yodlee and nordigen?
|
||||
'account_type' => "bank_account", // TODO: not creditCard, which type should be used here?!
|
||||
'id' => $nordigen_account->metadata["id"],
|
||||
'account_type' => "bank",
|
||||
'account_name' => $nordigen_account->data["iban"],
|
||||
'account_status' => $nordigen_account->metadata["status"],
|
||||
'account_number' => '**** ' . substr($nordigen_account->data["iban"], -7),
|
||||
'account_number' => '**** '.substr($nordigen_account->data["iban"], -7),
|
||||
'provider_account_id' => $nordigen_account->data["iban"],
|
||||
'provider_id' => $nordigen_account->institution["id"],
|
||||
'provider_name' => $nordigen_account->institution["name"],
|
||||
'nickname' => $nordigen_account->data["ownerName"] ? $nordigen_account->data["ownerName"] : '',
|
||||
'current_balance' => (int) $used_balance ? $used_balance["balanceAmount"]["amount"] : 0,
|
||||
'current_balance' => (int)$used_balance ? $used_balance["balanceAmount"]["amount"] : 0,
|
||||
'account_currency' => $used_balance ? $used_balance["balanceAmount"]["currency"] : '',
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user