This commit is contained in:
paulwer 2023-12-13 16:32:51 +01:00
parent 7a70eb873f
commit 4a42e11884
8 changed files with 17 additions and 22 deletions

View File

@ -29,10 +29,10 @@ class YodleeController extends BaseController
$company = $request->getCompany(); $company = $request->getCompany();
if ($company->account->bank_integration_yodlee_account_id) { if ($company->account->bank_integration_account_id) {
$flow = 'edit'; $flow = 'edit';
$token = $company->account->bank_integration_yodlee_account_id; $token = $company->account->bank_integration_account_id;
} else { } else {
$flow = 'add'; $flow = 'add';
@ -40,7 +40,7 @@ class YodleeController extends BaseController
$token = $response->user->loginName; $token = $response->user->loginName;
$company->account->bank_integration_yodlee_account_id = $token; $company->account->bank_integration_account_id = $token;
$company->push(); $company->push();
} }
@ -301,7 +301,7 @@ class YodleeController extends BaseController
return response()->json(['message' => 'Account does not exist.'], 400); return response()->json(['message' => 'Account does not exist.'], 400);
} }
$yodlee = new Yodlee($user->account->bank_integration_yodlee_account_id); $yodlee = new Yodlee($user->account->bank_integration_account_id);
$summary = $yodlee->getAccountSummary($account_number); $summary = $yodlee->getAccountSummary($account_number);

View File

@ -208,7 +208,7 @@ class BankIntegrationController extends BaseController
$this->refreshAccountsNordigen($user); $this->refreshAccountsNordigen($user);
// Processing transactions for each bank account // Processing transactions for each bank account
if (Ninja::isHosted() && $user->account->bank_integration_yodlee_account_id) 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)->where('auto_sync', true)->each(function ($bank_integration) use ($user_account) {
ProcessBankTransactionsYodlee::dispatch($user_account, $bank_integration); ProcessBankTransactionsYodlee::dispatch($user_account, $bank_integration);
@ -229,10 +229,10 @@ class BankIntegrationController extends BaseController
private function refreshAccountsYodlee(User $user) private function refreshAccountsYodlee(User $user)
{ {
if (!$user->account->bank_integration_yodlee_account_id) if (!$user->account->bank_integration_account_id)
return; return;
$yodlee = new Yodlee($user->account->bank_integration_yodlee_account_id); $yodlee = new Yodlee($user->account->bank_integration_account_id);
$accounts = $yodlee->getAccounts(); $accounts = $yodlee->getAccounts();
@ -319,11 +319,11 @@ class BankIntegrationController extends BaseController
private function removeAccountYodlee(Account $account, BankIntegration $bank_integration) private function removeAccountYodlee(Account $account, BankIntegration $bank_integration)
{ {
if (!$account->bank_integration_yodlee_account_id) { if (!$account->bank_integration_account_id) {
return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400); return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400);
} }
$yodlee = new Yodlee($account->bank_integration_yodlee_account_id); $yodlee = new Yodlee($account->bank_integration_account_id);
$yodlee->deleteAccount($bank_integration->bank_account_id); $yodlee->deleteAccount($bank_integration->bank_account_id);
} }

View File

@ -88,8 +88,8 @@ class MatchBankTransactions implements ShouldQueue
$this->company = Company::query()->find($this->company_id); $this->company = Company::query()->find($this->company_id);
if ($this->company->account->bank_integration_yodlee_account_id) { if ($this->company->account->bank_integration_account_id) {
$yodlee = new Yodlee($this->company->account->bank_integration_yodlee_account_id); $yodlee = new Yodlee($this->company->account->bank_integration_account_id);
} else { } else {
$yodlee = false; $yodlee = false;
} }

View File

@ -77,7 +77,7 @@ class ProcessBankTransactionsYodlee implements ShouldQueue
try { try {
$this->processTransactions(); $this->processTransactions();
} catch (\Exception $e) { } catch (\Exception $e) {
nlog("{$this->account->bank_integration_yodlee_account_id} - exited abnormally => " . $e->getMessage()); nlog("{$this->account->bank_integration_account_id} - exited abnormally => " . $e->getMessage());
$content = [ $content = [
"Processing transactions for account: {$this->bank_integration->account->key} failed", "Processing transactions for account: {$this->bank_integration->account->key} failed",
@ -97,7 +97,7 @@ class ProcessBankTransactionsYodlee implements ShouldQueue
private function processTransactions() private function processTransactions()
{ {
$yodlee = new Yodlee($this->account->bank_integration_yodlee_account_id); $yodlee = new Yodlee($this->account->bank_integration_account_id);
if (!$yodlee->getAccount($this->bank_integration->bank_account_id)) { if (!$yodlee->getAccount($this->bank_integration->bank_account_id)) {
$this->bank_integration->disabled_upstream = true; $this->bank_integration->disabled_upstream = true;
@ -193,7 +193,7 @@ class ProcessBankTransactionsYodlee implements ShouldQueue
public function middleware() public function middleware()
{ {
return [new WithoutOverlapping($this->account->bank_integration_yodlee_account_id)]; return [new WithoutOverlapping($this->account->bank_integration_account_id)];
} }
public function backoff() public function backoff()

View File

@ -52,7 +52,7 @@ class BankTransactionSync implements ShouldQueue
if (Ninja::isHosted()) { // @turbo124 @todo I migrated the schedule for the job within the kernel to execute on all platforms and use the same expression here to determine if yodlee can run or not. Please chek/verify if (Ninja::isHosted()) { // @turbo124 @todo I migrated the schedule for the job within the kernel to execute on all platforms and use the same expression here to determine if yodlee can run or not. Please chek/verify
nlog("syncing transactions - yodlee"); nlog("syncing transactions - yodlee");
Account::with('bank_integrations')->whereNotNull('bank_integration_yodlee_account_id')->cursor()->each(function ($account) { Account::with('bank_integrations')->whereNotNull('bank_integration_account_id')->cursor()->each(function ($account) {
if ($account->isPaid() && $account->plan == 'enterprise') { if ($account->isPaid() && $account->plan == 'enterprise') {
$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)->cursor()->each(function ($bank_integration) use ($account) {

View File

@ -69,7 +69,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $account_sms_verification_code * @property string|null $account_sms_verification_code
* @property string|null $account_sms_verification_number * @property string|null $account_sms_verification_number
* @property bool $account_sms_verified * @property bool $account_sms_verified
* @property string|null $bank_integration_yodlee_account_id * @property string|null $bank_integration_account_id
* @property int $is_trial * @property int $is_trial
* @property-read int|null $bank_integrations_count * @property-read int|null $bank_integrations_count
* @property-read int|null $companies_count * @property-read int|null $companies_count

View File

@ -26,11 +26,6 @@ return new class extends Migration {
$bank_integration->save(); $bank_integration->save();
}); });
// MAYBE migration of account->bank_account_id etc
Schema::table('accounts', function (Blueprint $table) {
$table->renameColumn('bank_integration_account_id', 'bank_integration_yodlee_account_id');
});
// MAYBE migration of account->bank_account_id etc // MAYBE migration of account->bank_account_id etc
Schema::table('bank_transactions', function (Blueprint $table) { Schema::table('bank_transactions', function (Blueprint $table) {
$table->string('debitor')->nullable(); // iban, credit-card info or else $table->string('debitor')->nullable(); // iban, credit-card info or else

View File

@ -75,7 +75,7 @@ class YodleeApiTest extends TestCase
public function testIncomeMatchingAndPaymentGeneration() public function testIncomeMatchingAndPaymentGeneration()
{ {
$this->account->bank_integration_yodlee_account_id = 'sbMem62e1e69547bfb2'; $this->account->bank_integration_account_id = 'sbMem62e1e69547bfb2';
$this->account->save(); $this->account->save();
$invoice = Invoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]); $invoice = Invoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);