mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
reactivate softDeleted Accounts & revoke where deleted_at query
- softDelete, when reconnecting to avoid double transactions - remove deleted_at query because unnecessary
This commit is contained in:
parent
54a8d13e28
commit
c43c85022b
@ -202,7 +202,7 @@ class NordigenController extends BaseController
|
||||
|
||||
$nordigen_account = $nordigen->getAccount($nordigenAccountId);
|
||||
|
||||
$existing_bank_integration = BankIntegration::where('nordigen_account_id', $nordigen_account['id'])->where('company_id', $company->id)->first();
|
||||
$existing_bank_integration = BankIntegration::withTrashed()->where('nordigen_account_id', $nordigen_account['id'])->where('company_id', $company->id)->first();
|
||||
|
||||
if (!$existing_bank_integration) {
|
||||
|
||||
@ -237,6 +237,7 @@ class NordigenController extends BaseController
|
||||
$existing_bank_integration->disabled_upstream = false;
|
||||
$existing_bank_integration->auto_sync = true;
|
||||
$existing_bank_integration->from_date = now()->subDays(90); // default max-fetch interval of nordigen is 90 days
|
||||
$existing_bank_integration->deleted_at = null;
|
||||
|
||||
$existing_bank_integration->save();
|
||||
|
||||
@ -246,10 +247,8 @@ class NordigenController extends BaseController
|
||||
}
|
||||
|
||||
// perform update in background
|
||||
$company->account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->where('is_deleted', false)->each(function ($bank_integration) {
|
||||
|
||||
$company->account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->each(function ($bank_integration) {
|
||||
ProcessBankTransactionsNordigen::dispatch($bank_integration);
|
||||
|
||||
});
|
||||
|
||||
// prevent rerun of this method with same ref
|
||||
|
@ -98,10 +98,8 @@ class YodleeController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
$company->account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->where('is_deleted', false)->each(function ($bank_integration) use ($company) { // TODO: filter to yodlee only
|
||||
|
||||
$company->account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->each(function ($bank_integration) use ($company) { // TODO: filter to yodlee only
|
||||
ProcessBankTransactionsYodlee::dispatch($company->account, $bank_integration);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -210,16 +210,12 @@ class BankIntegrationController extends BaseController
|
||||
// Processing transactions for each bank account
|
||||
if (Ninja::isHosted() && $user->account->bank_integration_account_id)
|
||||
$user_account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->each(function ($bank_integration) use ($user_account) {
|
||||
|
||||
ProcessBankTransactionsYodlee::dispatch($user_account, $bank_integration);
|
||||
|
||||
});
|
||||
|
||||
if (config('ninja.nordigen.secret_id') && config('ninja.nordigen.secret_key') && (Ninja::isSelfHost() || (Ninja::isHosted() && $user_account->isPaid() && $user_account->plan == 'enterprise')))
|
||||
$user_account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->each(function ($bank_integration) {
|
||||
|
||||
ProcessBankTransactionsNordigen::dispatch($bank_integration);
|
||||
|
||||
});
|
||||
|
||||
Cache::put("throttle_polling:{$user_account->key}", true, 300);
|
||||
@ -272,9 +268,9 @@ class BankIntegrationController extends BaseController
|
||||
|
||||
$nordigen = new Nordigen();
|
||||
|
||||
BankIntegration::withTrashed()->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->whereNotNull('nordigen_account_id')->each(function (BankIntegration $bank_integration) use ($nordigen) {
|
||||
BankIntegration::where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->whereNotNull('nordigen_account_id')->each(function (BankIntegration $bank_integration) use ($nordigen) {
|
||||
$account = $nordigen->getAccount($bank_integration->nordigen_account_id);
|
||||
|
||||
Log::info($bank_integration);
|
||||
if (!$account) {
|
||||
$bank_integration->disabled_upstream = true;
|
||||
|
||||
@ -340,13 +336,13 @@ class BankIntegrationController extends BaseController
|
||||
$account = auth()->user()->account();
|
||||
|
||||
if (Ninja::isHosted() && $account->isPaid() && $account->plan == 'enterprise') {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->where('is_deleted', false)->cursor()->each(function ($bank_integration) use ($account) {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account) {
|
||||
(new ProcessBankTransactionsYodlee($account, $bank_integration))->handle();
|
||||
});
|
||||
}
|
||||
|
||||
if (config("ninja.nordigen.secret_id") && config("ninja.nordigen.secret_key") && (Ninja::isSelfHost() || (Ninja::isHosted() && $account->isPaid() && $account->plan == 'enterprise'))) {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->where('is_deleted', false)->cursor()->each(function ($bank_integration) {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->cursor()->each(function ($bank_integration) {
|
||||
(new ProcessBankTransactionsNordigen($bank_integration))->handle();
|
||||
});
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class BankTransactionSync implements ShouldQueue
|
||||
Account::with('bank_integrations')->whereNotNull('bank_integration_account_id')->cursor()->each(function ($account) {
|
||||
|
||||
if ($account->isPaid() && $account->plan == 'enterprise') {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->where('is_deleted', false)->cursor()->each(function ($bank_integration) use ($account) {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account) {
|
||||
(new ProcessBankTransactionsYodlee($account, $bank_integration))->handle();
|
||||
});
|
||||
}
|
||||
@ -69,7 +69,7 @@ class BankTransactionSync implements ShouldQueue
|
||||
Account::with('bank_integrations')->cursor()->each(function ($account) {
|
||||
|
||||
if ((Ninja::isSelfHost() || (Ninja::isHosted() && $account->isPaid() && $account->plan == 'enterprise'))) {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->where('is_deleted', false)->cursor()->each(function ($bank_integration) {
|
||||
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->cursor()->each(function ($bank_integration) {
|
||||
(new ProcessBankTransactionsNordigen($bank_integration))->handle();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user