diff --git a/app/Models/BankIntegration.php b/app/Models/BankIntegration.php index 2d85f3c1e3a3..a1d16afb6769 100644 --- a/app/Models/BankIntegration.php +++ b/app/Models/BankIntegration.php @@ -36,8 +36,6 @@ class BankIntegration extends BaseModel protected $dates = [ ]; - const INTEGRATION_TYPE_NONE = null; - const INTEGRATION_TYPE_YODLEE = 'YODLEE'; const INTEGRATION_TYPE_NORDIGEN = 'NORDIGEN'; diff --git a/database/factories/BankIntegrationFactory.php b/database/factories/BankIntegrationFactory.php index 9d04cdfc56f8..9a739d049f6f 100644 --- a/database/factories/BankIntegrationFactory.php +++ b/database/factories/BankIntegrationFactory.php @@ -26,7 +26,7 @@ class BankIntegrationFactory extends Factory public function definition() { return [ - 'integration_type' => BankIntegration::INTEGRATION_TYPE_NONE, + 'integration_type' => null, 'provider_name' => $this->faker->company(), 'provider_id' => 1, 'bank_account_name' => $this->faker->catchPhrase(), diff --git a/database/migrations/2023_11_26_082959_add_bank_integration_id.php b/database/migrations/2023_11_26_082959_add_bank_integration_id.php index 8895b7729926..1e0fa0d8d6b9 100644 --- a/database/migrations/2023_11_26_082959_add_bank_integration_id.php +++ b/database/migrations/2023_11_26_082959_add_bank_integration_id.php @@ -15,11 +15,11 @@ return new class extends Migration { public function up() { Schema::table('bank_integrations', function (Blueprint $table) { - $table->string('integration_type')->default(BankIntegration::INTEGRATION_TYPE_NONE); + $table->string('integration_type')->nullable(); }); // migrate old account to be used with yodlee - BankIntegration::query()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NONE)->whereNotNull('account_id')->cursor()->each(function ($bank_integration) { + BankIntegration::query()->whereNull('integration_type')->whereNotNull('account_id')->cursor()->each(function ($bank_integration) { $bank_integration->integration_type = BankIntegration::INTEGRATION_TYPE_YODLEE; $bank_integration->save(); }); @@ -30,6 +30,35 @@ return new class extends Migration { $table->string('bank_integration_nordigen_secret_id')->nullable(); $table->string('bank_integration_nordigen_secret_key')->nullable(); }); + + // TODO: assign requisitions, to determine, which requisitions belong to which account and which can be leaned up, when necessary + Schema::create('bank_integration_nordigen_requisitions', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('account_id'); + $table->unsignedInteger('company_id'); + $table->unsignedInteger('user_id'); + + $table->text('provider_name'); //providerName ie Chase + $table->bigInteger('provider_id'); //id of the bank + $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->text('nickname')->default(''); //accountName + $table->date('from_date')->nullable(); + + $table->boolean('is_deleted')->default(0); + + $table->timestamps(6); + $table->softDeletes('deleted_at', 6); + + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade'); + $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade')->onUpdate('cascade'); + $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade')->onUpdate('cascade'); + }); } /**