mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8662 from turbo124/v5-develop
Silence errors on company logo delete.
This commit is contained in:
commit
9b25f860fc
@ -81,6 +81,19 @@ class AccountTransformer implements AccountTransformerInterface
|
||||
|
||||
public function transformAccount($account)
|
||||
{
|
||||
$current_balance = 0;
|
||||
$account_currency = '';
|
||||
|
||||
if(property_exists($account, 'currentBalance')) {
|
||||
$current_balance = $account->currentBalance->amount ?? 0;
|
||||
$account_currency = $account->currentBalance->currency ?? '';
|
||||
}
|
||||
elseif(property_exists($account, 'balance')){
|
||||
$current_balance = $account->balance->amount ?? 0;
|
||||
$account_currency = $account->balance->currency ?? '';
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'id' => $account->id,
|
||||
'account_type' => $account->CONTAINER,
|
||||
@ -92,8 +105,8 @@ class AccountTransformer implements AccountTransformerInterface
|
||||
'provider_id' => $account->providerId,
|
||||
'provider_name' => $account->providerName,
|
||||
'nickname' => property_exists($account, 'nickname') ? $account->nickname : '',
|
||||
'current_balance' => property_exists($account, 'currentBalance') ? $account->currentBalance->amount : 0,
|
||||
'account_currency' => property_exists($account, 'currency') ? $account->currentBalance->currency : '',
|
||||
'current_balance' => $current_balance,
|
||||
'account_currency' => $account_currency,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +185,21 @@ class Yodlee
|
||||
}
|
||||
}
|
||||
|
||||
public function getAccountSummary($account_id)
|
||||
{
|
||||
$token = $this->getAccessToken();
|
||||
|
||||
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->getEndpoint(). "/accounts/{$account_id}", []);
|
||||
|
||||
if ($response->successful()) {
|
||||
return $response->object();
|
||||
}
|
||||
|
||||
if ($response->failed()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAccount($account_id)
|
||||
{
|
||||
$token = $this->getAccessToken();
|
||||
|
@ -209,7 +209,12 @@ class BankIntegrationController extends BaseController
|
||||
$accounts = $yodlee->getAccounts();
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
if (!BankIntegration::withTrashed()->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->exists()) {
|
||||
if ($bi = BankIntegration::withTrashed()->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->first()){
|
||||
$bi->balance = $account['current_balance'];
|
||||
$bi->currency = $account['account_currency'];
|
||||
$bi->save();
|
||||
}
|
||||
else {
|
||||
$bank_integration = new BankIntegration();
|
||||
$bank_integration->company_id = $user->company()->id;
|
||||
$bank_integration->account_id = $user->account_id;
|
||||
|
@ -24,6 +24,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
use App\Notifications\Ninja\GenericNinjaAdminNotification;
|
||||
use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer;
|
||||
|
||||
class ProcessBankTransactions implements ShouldQueue
|
||||
{
|
||||
@ -99,6 +100,24 @@ class ProcessBankTransactions implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$account_summary = $yodlee->getAccountSummary($this->bank_integration->bank_account_id);
|
||||
|
||||
if($account_summary) {
|
||||
|
||||
$at = new AccountTransformer();
|
||||
$account = $at->transform($account_summary);
|
||||
|
||||
$this->bank_integration->balance = $account['current_balance'];
|
||||
$this->bank_integration->currency = $account['account_currency'];
|
||||
$this->bank_integration->save();
|
||||
|
||||
}
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
nlog("YODLEE: unable to update account summary for {$this->bank_integration->bank_account_id} => ". $e->getMessage());
|
||||
}
|
||||
|
||||
$data = [
|
||||
'top' => 500,
|
||||
'fromDate' => $this->from_date,
|
||||
|
@ -43,6 +43,10 @@ class UnlinkFile implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Storage::disk($this->disk)->delete($this->file_path);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,9 +212,9 @@ class FacturaEInvoice extends AbstractService
|
||||
|
||||
private function setPoNumber(): self
|
||||
{
|
||||
if(strlen($this->invoice->po_number) > 1) {
|
||||
$this->fac->setReferences($this->invoice->po_number);
|
||||
}
|
||||
$po = $this->invoice->po_number ?? '';
|
||||
|
||||
$this->fac->setReferences($po, $this->invoice->custom_value1, $this->invoice->custom_value2);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -233,10 +233,10 @@ class FacturaEInvoice extends AbstractService
|
||||
|
||||
foreach($this->invoice->line_items as $item) {
|
||||
$this->fac->addItem(new FacturaeItem([
|
||||
'name' => $item->product_key,
|
||||
'description' => $item->notes,
|
||||
'name' => $item->notes,
|
||||
'description' => $item->product_key,
|
||||
'quantity' => $item->quantity,
|
||||
'unitPrice' => $item->cost,
|
||||
'unitPriceWithoutTax' => $item->cost,
|
||||
'discountsAndRebates' => $item->discount,
|
||||
'charges' => [],
|
||||
'discounts' => [],
|
||||
|
@ -20,6 +20,20 @@ return new class extends Migration
|
||||
$ir->decimal_separator = ',';
|
||||
$ir->save();
|
||||
}
|
||||
|
||||
$ld = \App\Models\Currency::find(115);
|
||||
|
||||
if(!$ld) {
|
||||
$ld = new \App\Models\Currency();
|
||||
$ld->id = 115;
|
||||
$ld->code = 'LYD';
|
||||
$ld->name = 'Libyan Dinar';
|
||||
$ld->symbol = 'LD';
|
||||
$ld->thousand_separator = ',';
|
||||
$ld->decimal_separator = '.';
|
||||
$ld->precision = 3;
|
||||
$ld->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user