1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00

remove auto_sync condition, because manual sync should also sync bank_integrations, which are not marked as auto_sync + better handling for yodlee

This commit is contained in:
paulwer 2023-12-20 18:17:08 +01:00
parent 4f3422620e
commit 9c920f9ddf
2 changed files with 4 additions and 10 deletions

View File

@ -35,7 +35,6 @@ use App\Utils\Traits\MakesHash;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Log;
class BankIntegrationController extends BaseController
{
@ -209,12 +208,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) {
$user_account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_YODLEE)->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) {
$user_account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->each(function ($bank_integration) {
ProcessBankTransactionsNordigen::dispatch($bank_integration);
});
@ -225,7 +224,7 @@ class BankIntegrationController extends BaseController
private function refreshAccountsYodlee(User $user)
{
if (!$user->account->bank_integration_account_id)
if (!Ninja::isHosted() || !$user->account->bank_integration_account_id)
return;
$yodlee = new Yodlee($user->account->bank_integration_account_id);
@ -261,8 +260,6 @@ class BankIntegrationController extends BaseController
private function refreshAccountsNordigen(User $user)
{
$account = $user->account;
if (!(config('ninja.nordigen.secret_id') && config('ninja.nordigen.secret_key')))
return;
@ -270,7 +267,6 @@ class BankIntegrationController extends BaseController
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;

View File

@ -13,7 +13,6 @@ namespace App\Jobs\Bank;
use App\Helpers\Bank\Nordigen\Nordigen;
use App\Libraries\MultiDB;
use App\Models\Account;
use App\Models\BankIntegration;
use App\Models\BankTransaction;
use App\Models\Company;
@ -24,7 +23,6 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Log;
class ProcessBankTransactionsNordigen implements ShouldQueue
{
@ -91,7 +89,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
try {
$this->processTransactions();
} catch (\Exception $e) {
// reset from_date in case this was the error (self-heal) and perform a max sync of data we can fetch (next-time) @todo we should analyze the error for this
// reset from_date in case this was the error (self-heal) and perform a max sync of data we can fetch (next-time)
$this->bank_integration->from_date = now()->subDays(90);
$this->bank_integration->save();