1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Prevent endless loop of disabled upstream notifications

This commit is contained in:
David Bomba 2024-01-12 17:46:55 +11:00
parent f37c01bf50
commit 07f830e0ab
3 changed files with 21 additions and 17 deletions

View File

@ -70,7 +70,7 @@ class BankTransactionSync implements ShouldQueue
Account::with('bank_integrations')->whereNotNull('bank_integration_account_id')->cursor()->each(function ($account) { Account::with('bank_integrations')->whereNotNull('bank_integration_account_id')->cursor()->each(function ($account) {
if ($account->isEnterprisePaidClient()) { if ($account->isEnterprisePaidClient()) {
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account) { $account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->where('disabled_upstream', 0)->cursor()->each(function ($bank_integration) use ($account) {
(new ProcessBankTransactionsYodlee($account->id, $bank_integration))->handle(); (new ProcessBankTransactionsYodlee($account->id, $bank_integration))->handle();
}); });
} }
@ -86,7 +86,7 @@ class BankTransactionSync implements ShouldQueue
Account::with('bank_integrations')->cursor()->each(function ($account) { Account::with('bank_integrations')->cursor()->each(function ($account) {
if ((Ninja::isSelfHost() || (Ninja::isHosted() && $account->isEnterprisePaidClient()))) { if ((Ninja::isSelfHost() || (Ninja::isHosted() && $account->isEnterprisePaidClient()))) {
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->cursor()->each(function ($bank_integration) { $account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->where('disabled_upstream', 0)->cursor()->each(function ($bank_integration) {
(new ProcessBankTransactionsNordigen($bank_integration))->handle(); (new ProcessBankTransactionsNordigen($bank_integration))->handle();
}); });
} }

View File

@ -91,8 +91,8 @@ class AccountTransformer extends EntityTransformer
'trial_days_left' => Ninja::isHosted() ? (int) $account->getTrialDays() : 0, 'trial_days_left' => Ninja::isHosted() ? (int) $account->getTrialDays() : 0,
'account_sms_verified' => (bool) $account->account_sms_verified, 'account_sms_verified' => (bool) $account->account_sms_verified,
'has_iap_plan' => (bool)$account->inapp_transaction_id, 'has_iap_plan' => (bool)$account->inapp_transaction_id,
'tax_api_enabled' => (bool) config('services.tax.zip_tax.key') ? true : false 'tax_api_enabled' => (bool) config('services.tax.zip_tax.key') ? true : false,
'nordigen_enabled' => (bool) (config('ninja.nordigen.secret_id') && config('ninja.nordigen.secret_key')) ? true : false
]; ];
} }

View File

@ -1,12 +1,13 @@
<?php <?php
use App\Utils\Ninja;
use App\Models\Account; use App\Models\Account;
use App\Models\BankIntegration; use App\Models\BankIntegration;
use App\Models\BankTransaction; use App\Models\BankTransaction;
use App\Repositories\BankTransactionRepository;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Repositories\BankTransactionRepository;
return new class extends Migration { return new class extends Migration {
/** /**
@ -22,6 +23,8 @@ return new class extends Migration {
$table->text('nordigen_transaction_id')->nullable(); $table->text('nordigen_transaction_id')->nullable();
}); });
if(Ninja::isSelfHost())
{
// remove invalid transactions // remove invalid transactions
BankIntegration::query()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->cursor()->each(function ($bank_integration) { BankIntegration::query()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->cursor()->each(function ($bank_integration) {
$bank_integration->from_date = now()->subDays(90); $bank_integration->from_date = now()->subDays(90);
@ -36,6 +39,7 @@ return new class extends Migration {
}); });
}); });
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.