1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Minor fixes

This commit is contained in:
David Bomba 2024-09-25 09:16:26 +10:00
parent 0f34b3d03d
commit 9d6d6c2254
8 changed files with 91 additions and 19 deletions

View File

@ -44,6 +44,7 @@ use App\Factory\ClientContactFactory;
use App\Factory\VendorContactFactory;
use App\Jobs\Company\CreateCompanyToken;
use App\Models\RecurringInvoiceInvitation;
use App\Utils\Traits\CleanLineItems;
use Symfony\Component\Console\Input\InputOption;
/*
@ -80,10 +81,12 @@ Options:
*/
class CheckData extends Command
{
use CleanLineItems;
/**
* @var string
*/
protected $signature = 'ninja:check-data {--database=} {--fix=} {--portal_url=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=} {--bank_transaction=}';
protected $signature = 'ninja:check-data {--database=} {--fix=} {--portal_url=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=} {--bank_transaction=} {--line_items=}';
/**
* @var string
@ -146,6 +149,10 @@ class CheckData extends Command
$this->fixBankTransactions();
}
if($this->option('line_items')) {
$this->cleanInvoiceLineItems();
}
$this->logMessage('Done: '.strtoupper($this->isValid ? Account::RESULT_SUCCESS : Account::RESULT_FAILURE));
$this->logMessage('Total execution time in seconds: ' . (microtime(true) - $time_start));
@ -1177,4 +1184,21 @@ class CheckData extends Command
});
}
public function cleanInvoiceLineItems()
{
Invoice::withTrashed()->cursor()->each(function ($invoice) {
$invoice->line_items = $this->cleanItems($invoice->line_items);
$invoice->saveQuietly();
});
Credit::withTrashed()->cursor()->each(function ($invoice) {
$invoice->line_items = $this->cleanItems($invoice->line_items);
$invoice->saveQuietly();
});
}
}

View File

@ -354,9 +354,9 @@ class CompanyImport implements ShouldQueue
unlink($tmp_file);
}
if(Storage::exists($this->file_location)) {
unlink(Storage::path($this->file_location));
}
if(Storage::exists($this->file_location))
Storage::delete($this->file_location);
}
//

View File

@ -154,6 +154,20 @@ class NinjaMailerJob implements ShouldQueue
LightLogs::create(new EmailSuccess($this->nmo->company->company_key, $this->nmo->mailable->subject))
->send();
} catch(\Symfony\Component\Mailer\Exception\TransportException $e){
nlog("Mailer failed with a Transport Exception {$e->getMessage()}");
if(Ninja::isHosted() && $this->mailer == 'smtp'){
$settings = $this->nmo->settings;
$settings->email_sending_method = 'default';
$this->company->settings = $settings;
$this->company->save();
}
$this->fail();
$this->cleanUpMailers();
$this->logMailError($e->getMessage(), $this->company->clients()->first());
} catch (\Symfony\Component\Mime\Exception\RfcComplianceException $e) {
nlog("Mailer failed with a Logic Exception {$e->getMessage()}");
$this->fail();

View File

@ -13,13 +13,14 @@ namespace App\Mail\Admin;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\VendorContact;
use App\Utils\Ninja;
use Illuminate\Support\Facades\App;
class ClientUnsubscribedObject
{
public function __construct(
public ClientContact $contact,
public ClientContact | VendorContact$contact,
public Company $company,
private bool $use_react_link = false
) {

View File

@ -203,7 +203,6 @@ class VendorContact extends Authenticatable implements HasLocalePreference
{
return $this
->withTrashed()
// ->company()
->where('id', $this->decodePrimaryKey($value))
->firstOrFail();
}
@ -219,4 +218,15 @@ class VendorContact extends Authenticatable implements HasLocalePreference
return $domain.'/vendor/key_login/'.$this->contact_key;
}
public function getAdminLink($use_react_link = false): string
{
return $use_react_link ? $this->getReactLink() : config('ninja.app_url');
}
private function getReactLink(): string
{
return config('ninja.react_url')."/#/vendors/{$this->vendor->hashed_id}";
}
}

View File

@ -291,6 +291,20 @@ class Email implements ShouldQueue
LightLogs::create(new EmailSuccess($this->company->company_key, $this->mailable->subject))
->send();
} catch(\Symfony\Component\Mailer\Exception\TransportException $e){
nlog("Mailer failed with a Transport Exception {$e->getMessage()}");
if(Ninja::isHosted() && $this->mailer == 'smtp'){
$settings = $this->email_object->settings;
$settings->email_sending_method = 'default';
$this->company->settings = $settings;
$this->company->save();
}
$this->fail();
$this->cleanUpMailers();
$this->logMailError($e->getMessage(), $this->company->clients()->first());
} catch (\Symfony\Component\Mime\Exception\RfcComplianceException $e) {
nlog("Mailer failed with a Logic Exception {$e->getMessage()}");
$this->fail();

View File

@ -46,7 +46,7 @@ class InvoiceTransformer extends BaseTransformer
'public_notes' => data_get($qb_data, 'CustomerMemo.value', false),
'due_date' => data_get($qb_data, 'DueDate', null),
'po_number' => data_get($qb_data, 'PONumber', ""),
'partial' => data_get($qb_data, 'Deposit', 0),
'partial' => (float)data_get($qb_data, 'Deposit', 0),
'line_items' => $this->getLineItems(data_get($qb_data, 'Line', []), data_get($qb_data, 'ApplyTaxAfterDiscount', 'true')),
'payment_ids' => $this->getPayments($qb_data),
'status_id' => Invoice::STATUS_SENT,
@ -66,10 +66,9 @@ class InvoiceTransformer extends BaseTransformer
foreach(data_get($qb_data, 'Line', []) as $line)
{
nlog("iterating");
if(data_get($line, 'DetailType.value') == 'DiscountLineDetail')
{
nlog("found discount");
if(!isset($this->company->custom_fields->surcharge1))
{
@ -77,8 +76,7 @@ class InvoiceTransformer extends BaseTransformer
$this->company->save();
}
nlog(data_get($line, 'Amount', 0) * -1);
return data_get($line, 'Amount', 0) * -1;
return (float)data_get($line, 'Amount', 0) * -1;
}
}
@ -100,7 +98,7 @@ class InvoiceTransformer extends BaseTransformer
$totalTaxRate += $taxRate;
}
return $totalTaxRate;
return (float)$totalTaxRate;
}
@ -143,13 +141,13 @@ class InvoiceTransformer extends BaseTransformer
$item = new InvoiceItem;
$item->product_key = data_get($qb_item, 'SalesItemLineDetail.ItemRef.name', '');
$item->notes = data_get($qb_item,'Description', '');
$item->quantity = data_get($qb_item,'SalesItemLineDetail.Qty', 0);
$item->cost = data_get($qb_item, 'SalesItemLineDetail.UnitPrice', 0);
$item->discount = data_get($item,'DiscountRate', data_get($qb_item,'DiscountAmount', 0));
$item->quantity = (float)data_get($qb_item,'SalesItemLineDetail.Qty', 0);
$item->cost = (float)data_get($qb_item, 'SalesItemLineDetail.UnitPrice', 0);
$item->discount = (float)data_get($item,'DiscountRate', data_get($qb_item,'DiscountAmount', 0));
$item->is_amount_discount = data_get($qb_item,'DiscountAmount', 0) > 0 ? true : false;
$item->type_id = stripos(data_get($qb_item, 'ItemAccountRef.name') ?? '', 'Service') !== false ? '2' : '1';
$item->tax_id = data_get($qb_item, 'TaxCodeRef.value', '') == 'NON' ? Product::PRODUCT_TYPE_EXEMPT : $item->type_id;
$item->tax_rate1 = data_get($qb_item, 'TxnTaxDetail.TaxLine.TaxLineDetail.TaxPercent', 0);
$item->tax_rate1 = (float)data_get($qb_item, 'TxnTaxDetail.TaxLine.TaxLineDetail.TaxPercent', 0);
$item->tax_name1 = $item->tax_rate1 > 0 ? "Sales Tax" : "";
$items[] = (object)$item;
}
@ -161,7 +159,7 @@ class InvoiceTransformer extends BaseTransformer
$item->product_key = ctrans('texts.discount');
$item->notes = ctrans('texts.discount');
$item->quantity = 1;
$item->cost = data_get($qb_item, 'Amount', 0) * -1;
$item->cost = (float)data_get($qb_item, 'Amount', 0) * -1;
$item->discount = 0;
$item->is_amount_discount = true;
$item->type_id = '1';
@ -171,8 +169,6 @@ class InvoiceTransformer extends BaseTransformer
}
}
nlog($items);
return $items;
}

View File

@ -0,0 +1,13 @@
@extends('layouts.ninja')
@section('meta_title', ctrans('texts.error'))
@section('body')
<div class="flex flex-col justify-center items-center mt-10">
<div class="mb-4">
<svg height="60" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 468 222.5" xml:space="preserve"><style>.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#635bff}</style><path class="st0" d="M414 113.4c0-25.6-12.4-45.8-36.1-45.8-23.8 0-38.2 20.2-38.2 45.6 0 30.1 17 45.3 41.4 45.3 11.9 0 20.9-2.7 27.7-6.5v-20c-6.8 3.4-14.6 5.5-24.5 5.5-9.7 0-18.3-3.4-19.4-15.2h48.9c0-1.3.2-6.5.2-8.9zm-49.4-9.5c0-11.3 6.9-16 13.2-16 6.1 0 12.6 4.7 12.6 16h-25.8zM301.1 67.6c-9.8 0-16.1 4.6-19.6 7.8l-1.3-6.2h-22v116.6l25-5.3.1-28.3c3.6 2.6 8.9 6.3 17.7 6.3 17.9 0 34.2-14.4 34.2-46.1-.1-29-16.6-44.8-34.1-44.8zm-6 68.9c-5.9 0-9.4-2.1-11.8-4.7l-.1-37.1c2.6-2.9 6.2-4.9 11.9-4.9 9.1 0 15.4 10.2 15.4 23.3 0 13.4-6.2 23.4-15.4 23.4zM223.8 61.7l25.1-5.4V36l-25.1 5.3zM223.8 69.3h25.1v87.5h-25.1zM196.9 76.7l-1.6-7.4h-21.6v87.5h25V97.5c5.9-7.7 15.9-6.3 19-5.2v-23c-3.2-1.2-14.9-3.4-20.8 7.4zM146.9 47.6l-24.4 5.2-.1 80.1c0 14.8 11.1 25.7 25.9 25.7 8.2 0 14.2-1.5 17.5-3.3V135c-3.2 1.3-19 5.9-19-8.9V90.6h19V69.3h-19l.1-21.7zM79.3 94.7c0-3.9 3.2-5.4 8.5-5.4 7.6 0 17.2 2.3 24.8 6.4V72.2c-8.3-3.3-16.5-4.6-24.8-4.6C67.5 67.6 54 78.2 54 95.9c0 27.6 38 23.2 38 35.1 0 4.6-4 6.1-9.6 6.1-8.3 0-18.9-3.4-27.3-8v23.8c9.3 4 18.7 5.7 27.3 5.7 20.8 0 35.1-10.3 35.1-28.2-.1-29.8-38.2-24.5-38.2-35.7z"/></svg>
</div>
<p>Your session has expired. Connection to Stripe has been cancelled. Please try again.</p>
<span>Click <a class="font-semibold hover:underline" href="{{ $url ?? url('/#/settings/company_gateways') }}">here</a> to continue.</span>
</div>
@endsection