diff --git a/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php b/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php new file mode 100644 index 000000000000..fe08a7ed7463 --- /dev/null +++ b/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php @@ -0,0 +1,74 @@ + Array + ( + [0] => stdClass Object + ( + [CONTAINER] => bank + [providerAccountId] => 11308693 + [accountName] => My CD - 8878 + [accountStatus] => ACTIVE + [accountNumber] => xxxx8878 + [aggregationSource] => USER + [isAsset] => 1 + [balance] => stdClass Object + ( + [currency] => USD + [amount] => 49778.07 + ) + + [id] => 12331861 + [includeInNetWorth] => 1 + [providerId] => 18769 + [providerName] => Dag Site Captcha + [isManual] => + [currentBalance] => stdClass Object + ( + [currency] => USD + [amount] => 49778.07 + ) + + [accountType] => CD + [displayedName] => LORETTA + [createdDate] => 2022-07-28T06:55:33Z + [lastUpdated] => 2022-07-28T06:56:09Z + [dataset] => Array + ( + [0] => stdClass Object + ( + [name] => BASIC_AGG_DATA + [additionalStatus] => AVAILABLE_DATA_RETRIEVED + [updateEligibility] => ALLOW_UPDATE + [lastUpdated] => 2022-07-28T06:55:50Z + [lastUpdateAttempt] => 2022-07-28T06:55:50Z + ) + + ) + + ) + ) + */ + +class AccountTransformer +{ + + public static function transform(array $account) + { + return [ + ]; + } +} + + diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php new file mode 100644 index 000000000000..108bf98f5b6a --- /dev/null +++ b/app/Http/Controllers/BankIntegrationController.php @@ -0,0 +1,42 @@ + 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', + ]; + + public function getEntityType() + { + return self::class; + } + + public function company() + { + return $this->belongsTo(Company::class); + } + + public function user() + { + return $this->belongsTo(User::class)->withTrashed(); + } + + public function account() + { + return $this->belongsTo(Account::class)->withTrashed(); + } + +} \ No newline at end of file diff --git a/app/Transformers/BankIntegrationTransformer.php b/app/Transformers/BankIntegrationTransformer.php new file mode 100644 index 000000000000..7f06a9a95697 --- /dev/null +++ b/app/Transformers/BankIntegrationTransformer.php @@ -0,0 +1,77 @@ + (string) $this->encodePrimaryKey($bank_integration->id), + 'provider_bank_name' => $bank_integration->provider_bank_name ?: '', + 'bank_account_id' => $bank_integration->bank_account_id ?: '', + 'bank_account_name' => $bank_integration->bank_account_name ?: '', + 'bank_account_number' => $bank_integration->bank_account_number ?: '', + 'bank_account_status' => $bank_integration->bank_account_status ?: '', + 'bank_account_type' => $bank_integration->bank_account_type ?: '', + 'balance' => (float)$bank_integration->balance ?: 0, + 'currency' => $bank_integration->currency ?: '', + ]; + } + + public function includeAccount(BankIntegration $bank_integration) + { + $transformer = new AccountTransformer($this->serializer); + + return $this->includeItem($bank_integration->account, $transformer, Account::class); + } + + public function includeCompany(BankIntegration $bank_integration) + { + $transformer = new CompanyTransformer($this->serializer); + + return $this->includeItem($bank_integration->company, $transformer, Company::class); + } + +} diff --git a/database/migrations/2022_08_05_023357_bank_integration.php b/database/migrations/2022_08_05_023357_bank_integration.php index 65ae46ddd259..650ae4354b4d 100644 --- a/database/migrations/2022_08_05_023357_bank_integration.php +++ b/database/migrations/2022_08_05_023357_bank_integration.php @@ -14,24 +14,21 @@ return new class extends Migration public function up() { - Schema::table('bank_integration', function (Blueprint $table) { + Schema::create('bank_integrations', function (Blueprint $table) { $table->id(); $table->unsignedInteger('account_id'); $table->unsignedInteger('company_id'); $table->unsignedInteger('user_id'); - $table->string('account_type')->nullable(); - // $table->bigInteger('bank_account_id'); //providerAccountId - // $table->bigInteger('bank_id'); //providerId - $table->text('bank_name'); //providerName - $table->text('account_name')->nullable(); //accountName - $table->text('account_number')->nullable(); //accountNumber - $table->text('account_status')->nullable(); //accountStatus - $table->text('account_type')->nullable(); //CONTAINER + $table->text('provider_bank_name'); //providerName ie Chase + $table->bigInteger('bank_account_id'); //id + $table->text('bank_account_name')->nullable(); //accountName + $table->text('bank_account_number')->nullable(); //accountNumber + $table->text('bank_account_status')->nullable(); //accountStatus + $table->text('bank_account_type')->nullable(); //CONTAINER $table->decimal('balance', 20, 6)->default(0); //currentBalance.amount $table->text('currency')->nullable(); //currentBalance.currency - $table-> $table->timestamps(6); $table->softDeletes('deleted_at', 6);