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

Minor fixes for Bank Transactions / Integratiosn

This commit is contained in:
David Bomba 2022-11-04 12:55:17 +11:00
parent ce5dfa2717
commit 0fc0ff25bd
8 changed files with 74 additions and 11 deletions

View File

@ -174,6 +174,20 @@ class Yodlee
}
public function getAccount($account_id)
{
$token = $this->getAccessToken();
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->getEndpoint(). "/accounts/{$account_id}", []);
if($response->successful())
return true;
if($response->failed())
return false;
}
public function deleteAccount($account_id)
{

View File

@ -33,6 +33,8 @@ class YodleeController extends BaseController
$company = $request->getCompany();
//ensure user is enterprise!!
if($company->account->bank_integration_account_id){
$flow = 'edit';

View File

@ -26,7 +26,7 @@
* @OA\Property(property="tax_name3", type="string", example="", description="The tax name"),
* @OA\Property(property="tax_rate3", type="number", format="float", example="10.00", description="The tax rate"),
* @OA\Property(property="total_taxes", type="number", format="float", example="10.00", description="The total taxes for the quote"),
* @OA\Property(property="line_items", type="object", example="[{"product_key":"test", "unit_cost":10},{"product_key":"test", "unit_cost":10}]", description="An array of line items of the quote"),
* @OA\Property(property="line_items", type="object", example="", description="An array of line items of the quote"),
* @OA\Property(property="amount", type="number", format="float", example="10.00", description="The total amount of the quote"),
* @OA\Property(property="balance", type="number", format="float", example="10.00", description="The balance due of the quote"),
* @OA\Property(property="paid_to_date", type="number", format="float", example="10.00", description="The amount that has been paid to date on the quote"),

View File

@ -68,7 +68,13 @@ class ProcessBankTransactions implements ShouldQueue
do{
$this->processTransactions();
try {
$this->processTransactions();
}
catch(\Exception $e) {
nlog("{$this->bank_integration_account_id} - exited abnormally => ". $e->getMessage());
return;
}
}
while($this->stop_loop);
@ -83,6 +89,14 @@ class ProcessBankTransactions implements ShouldQueue
$yodlee = new Yodlee($this->bank_integration_account_id);
if(!$yodlee->getAccount($this->bank_integration->bank_account_id))
{
$this->bank_integration->disabled_upstream = true;
$this->bank_integration->save();
$this->stop_loop = false;
return;
}
$data = [
'top' => 500,
'fromDate' => $this->from_date,
@ -102,7 +116,8 @@ class ProcessBankTransactions implements ShouldQueue
//if no transactions, update the from_date and move on
if(count($transactions) == 0){
$this->bank_integration->from_date = now();
$this->bank_integration->from_date = now()->subDays(2);
$this->bank_integration->disabled_upstream = false;
$this->bank_integration->save();
$this->stop_loop = false;
return;
@ -144,8 +159,7 @@ class ProcessBankTransactions implements ShouldQueue
if($count < 500){
$this->stop_loop = false;
$this->bank_integration->from_date = now();
$this->bank_integration->from_date = now()->subDays(2);
$this->bank_integration->save();
}

View File

@ -64,8 +64,8 @@ class BankTransactionSync implements ShouldQueue
// $queue = Ninja::isHosted() ? 'bank' : 'default';
// if($account->isPaid())
// {
if($account->isPaid() && $account->plan == 'enterprise')
{
$account->bank_integrations->each(function ($bank_integration) use ($account){
@ -73,7 +73,7 @@ class BankTransactionSync implements ShouldQueue
});
// }
}
});
}

View File

@ -60,6 +60,7 @@ class BankIntegrationTransformer extends EntityTransformer
'nickname' => (string)$bank_integration->nickname ?: '',
'from_date' => (string)$bank_integration->from_date ?: '',
'is_deleted' => (bool) $bank_integration->is_deleted,
'disabled_upstream' => (bool) $bank_integration->disabled_upstream,
'created_at' => (int) $bank_integration->created_at,
'updated_at' => (int) $bank_integration->updated_at,
'archived_at' => (int) $bank_integration->deleted_at,

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('bank_integrations', function (Blueprint $table) {
$table->boolean('disabled_upstream')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};

View File

@ -43,14 +43,14 @@
<div class="flex flex-col justify-center items-center mt-10" id="container-fastlink">
<div class="mb-4">
@if($account && !$account->isPaid())
<div>
<div class="max-h-28">
<img src="{{ asset('images/invoiceninja-black-logo-2.png') }}"
class="border-b border-gray-100 h-18 pb-4" alt="Invoice Ninja logo">
</div>
@elseif(isset($company) && !is_null($company))
<div>
<div class="max-h-28">
<img src="{{ $company->present()->logo() }}"
class="mx-auto border-b border-gray-100 h-18 pb-4" alt="{{ $company->present()->name() }} logo">
class="mx-auto border-b border-gray-100 h-18 pb-4" style="max-width: 400px;" alt="{{ $company->present()->name() }} logo">
</div>
@endif
</div>