dedicated keys for nordigen

This commit is contained in:
paulwer 2023-12-11 09:23:35 +01:00
parent cd4dbb897f
commit 3229650858
5 changed files with 12 additions and 14 deletions

View File

@ -186,13 +186,12 @@ class NordigenController extends BaseController
$bank_integration->company_id = $company->id;
$bank_integration->account_id = $company->account_id;
$bank_integration->user_id = $company->owner()->id;
// $bank_integration->bank_account_id = $nordigen_account['id']; // TODO
$bank_integration->nordigen_account_id = $nordigen_account['id'];
$bank_integration->bank_account_type = $nordigen_account['account_type'];
$bank_integration->bank_account_name = $nordigen_account['account_name'];
$bank_integration->bank_account_status = $nordigen_account['account_status'];
$bank_integration->bank_account_number = $nordigen_account['account_number'];
// $bank_integration->provider_id = $nordigen_account['provider_id']; // TODO
$bank_integration->nordigen_meta = (string) $nordigen_account['id'] . "," . $nordigen_account['provider_id']; // TODO: maybe move to bank_account_id and provider_id
$bank_integration->nordigen_provider_id = $nordigen_account['provider_id'];
$bank_integration->provider_name = $nordigen_account['provider_name'];
$bank_integration->nickname = $nordigen_account['nickname'];
$bank_integration->balance = $nordigen_account['current_balance'];

View File

@ -268,8 +268,8 @@ class BankIntegrationController extends BaseController
$nordigen = new Nordigen($user->account->bank_integration_nordigen_secret_id, $user->account->bank_integration_nordigen_secret_key);
BankIntegration::withTrashed()->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->each(function (BankIntegration $bank_integration) use ($nordigen, $user) {
$account = $nordigen->getAccount(explode(',', $bank_integration->nordigen_meta)[0]);
BankIntegration::withTrashed()->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->each(function (BankIntegration $bank_integration) use ($nordigen) {
$account = $nordigen->getAccount($bank_integration->nordigen_account_id);
if (!$account) {
$bank_integration->disabled_upstream = true;

View File

@ -120,9 +120,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
private function updateAccount()
{
$bank_account_id = explode(',', $this->bank_integration->nordigen_meta)[0]; // maybe replace it later with bank_account_id
if (!$this->nordigen->isAccountActive($bank_account_id)) {
if (!$this->nordigen->isAccountActive($this->bank_integration->nordigen_account_id)) {
$this->bank_integration->disabled_upstream = true;
$this->bank_integration->save();
$this->stop_loop = false;
@ -130,7 +128,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
return;
}
$this->nordigen_account = $this->nordigen->getAccount($bank_account_id);
$this->nordigen_account = $this->nordigen->getAccount($this->bank_integration->nordigen_account_id);
$this->bank_integration->bank_account_status = $this->nordigen_account['account_status'];
$this->bank_integration->balance = $this->nordigen_account['current_balance'];
@ -144,7 +142,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
{
//Get transaction count object
$transactions = $this->nordigen->getTransactions($this->nordigen_account["id"], $this->from_date);
$transactions = $this->nordigen->getTransactions($this->bank_integration->nordigen_account_id, $this->from_date);
//Get int count
$count = sizeof($transactions);

View File

@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int $account_id
* @property int $company_id
* @property int $user_id
* @property string $integration_type
* @property string $provider_name
* @property int $provider_id
* @property int $bank_account_id
@ -30,7 +31,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property float $balance
* @property int|null $currency
* @property string $nickname
* @property string $nordigen_meta // TODO: maybe move to bank_account_id and provider_id
* @property string $nordigen_account_id
* @property string $nordigen_provider_id
* @property string|null $from_date
* @property bool $is_deleted
* @property int|null $created_at

View File

@ -16,9 +16,8 @@ return new class extends Migration {
{
Schema::table('bank_integrations', function (Blueprint $table) {
$table->string('integration_type')->nullable();
$table->string('nordigen_meta')->nullable(); // accountId,institutionId @todo: maybe replace with the following below
// $table->string('provider_id'); // migrate to string, because nordigen provides a string like: SANDBOXFINANCE_SFIN0000
// $table->string('bank_account_id'); // migrate to string, because nordigen uses uuid() strings
$table->string('nordigen_account_id')->nullable();
$table->string('nordigen_provider_id')->nullable();
});
// migrate old account to be used with yodlee