mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 19:37:32 -05:00 
			
		
		
		
	using nullable as default value for integration_type
This commit is contained in:
		
							parent
							
								
									5616da03c5
								
							
						
					
					
						commit
						ed688afa20
					
				@ -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';
 | 
			
		||||
 | 
			
		||||
@ -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(),
 | 
			
		||||
 | 
			
		||||
@ -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');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user