mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Minor changes for braintree
This commit is contained in:
parent
ab6a87885a
commit
e3ac860c5f
@ -28,11 +28,11 @@ class SearchController extends Controller
|
||||
|
||||
public function __invoke(GenericSearchRequest $request)
|
||||
{
|
||||
if(config('scount.driver') == 'elastic' && $request->has('search') && $request->input('search') !== '') {
|
||||
if(config('scout.driver') == 'elastic') {
|
||||
try{
|
||||
return $this->search($request->input('search', ''));
|
||||
return $this->search($request->input('search', '*'));
|
||||
} catch(\Exception $e) {
|
||||
nlog("elk down?");
|
||||
nlog("elk down?" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,11 +211,12 @@ class BaseTransformer
|
||||
public function getClient($client_name, $client_email)
|
||||
{
|
||||
|
||||
if (! empty($client_name)) {
|
||||
if (strlen($client_name ?? '') >=1) {
|
||||
$client_id_search = Client::query()->where('company_id', $this->company->id)
|
||||
->where('is_deleted', false)
|
||||
->where('id_number', $client_name);
|
||||
|
||||
nlog("idnommer ".$client_id_search->count());
|
||||
if ($client_id_search->count() >= 1) {
|
||||
return $client_id_search->first()->id;
|
||||
}
|
||||
@ -226,17 +227,22 @@ class BaseTransformer
|
||||
strtolower(str_replace(' ', '', $client_name)),
|
||||
]);
|
||||
|
||||
|
||||
nlog("client_name_search ".$client_name_search->count());
|
||||
|
||||
if ($client_name_search->count() >= 1) {
|
||||
return $client_name_search->first()->id;
|
||||
}
|
||||
}
|
||||
if (! empty($client_email)) {
|
||||
if (strlen($client_email ?? '' ) >=1) {
|
||||
$contacts = ClientContact::query()->whereHas('client', function ($query) {
|
||||
$query->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id)
|
||||
->where('email', $client_email);
|
||||
|
||||
nlog("contact count = " . $contacts->count());
|
||||
|
||||
if ($contacts->count() >= 1) {
|
||||
return $contacts->first()->client_id;
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ class InvoiceTransformer extends BaseTransformer
|
||||
|
||||
$client_id = null;
|
||||
|
||||
if($this->hasClient($this->getString($invoice_data, 'Name') || $this->getContact($this->getString($invoice_data, 'EmailRecipient')))) {
|
||||
// if($this->hasClient($this->getString($invoice_data, 'Name') || $this->getContact($this->getString($invoice_data, 'EmailRecipient')))) {
|
||||
|
||||
$client_id = $this->getClient($this->getString($invoice_data, 'Name'), $this->getString($invoice_data, 'EmailRecipient'));
|
||||
$client_id = $this->getClient($this->getString($invoice_data, 'Name'), $this->getString($invoice_data, 'EmailRecipient'));
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
if ($client_id) {
|
||||
$transformed['client_id'] = $client_id;
|
||||
|
@ -12,14 +12,15 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Laravel\Scout\Searchable;
|
||||
use App\DataMapper\ClientSync;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\DataMapper\FeesAndLimits;
|
||||
use App\Models\Traits\Excludable;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\ClientSync;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Services\Client\ClientService;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
@ -126,8 +127,6 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
use AppSetup;
|
||||
use ClientGroupSettingsSaver;
|
||||
use Excludable;
|
||||
|
||||
|
||||
use Searchable;
|
||||
|
||||
protected $presenter = ClientPresenter::class;
|
||||
@ -241,8 +240,17 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
|
||||
public function toSearchableArray()
|
||||
{
|
||||
|
||||
$locale = $this->locale();
|
||||
App::setLocale($locale);
|
||||
|
||||
$name = ctrans('texts.client') . " | " . $this->present()->name();
|
||||
|
||||
if(strlen($this->vat_number ?? '') > 1)
|
||||
$name .= " | ". $this->vat_number;
|
||||
|
||||
return [
|
||||
'name' => $this->present()->name(),
|
||||
'name' => $name,
|
||||
'is_deleted' => $this->is_deleted,
|
||||
'hashed_id' => $this->hashed_id,
|
||||
'number' => $this->number,
|
||||
@ -272,6 +280,11 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
];
|
||||
}
|
||||
|
||||
public function getScoutKey()
|
||||
{
|
||||
return $this->hashed_id;
|
||||
}
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return self::class;
|
||||
|
@ -185,6 +185,11 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
||||
];
|
||||
}
|
||||
|
||||
public function getScoutKey()
|
||||
{
|
||||
return $this->hashed_id;
|
||||
}
|
||||
|
||||
/*
|
||||
V2 type of scope
|
||||
*/
|
||||
|
@ -11,12 +11,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\DataMapper\InvoiceSync;
|
||||
use App\Utils\Ninja;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\DataMapper\InvoiceSync;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Utils\Traits\MakesReminders;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use App\Services\Ledger\LedgerService;
|
||||
@ -29,6 +30,7 @@ use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
use App\Utils\Traits\Invoice\ActionsInvoice;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Events\Invoice\InvoiceReminderWasEmailed;
|
||||
use App\Utils\Number;
|
||||
|
||||
/**
|
||||
* App\Models\Invoice
|
||||
@ -146,7 +148,6 @@ class Invoice extends BaseModel
|
||||
use MakesInvoiceValues;
|
||||
use MakesReminders;
|
||||
use ActionsInvoice;
|
||||
|
||||
use Searchable;
|
||||
|
||||
protected $presenter = EntityPresenter::class;
|
||||
@ -244,8 +245,11 @@ class Invoice extends BaseModel
|
||||
|
||||
public function toSearchableArray()
|
||||
{
|
||||
$locale = $this->company->locale();
|
||||
App::setLocale($locale);
|
||||
|
||||
return [
|
||||
'name' => $this->client->present()->name() . ' - ' . $this->number,
|
||||
'name' => ctrans('texts.invoice') . " " . $this->number . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale),
|
||||
'hashed_id' => $this->hashed_id,
|
||||
'number' => $this->number,
|
||||
'is_deleted' => $this->is_deleted,
|
||||
@ -253,14 +257,20 @@ class Invoice extends BaseModel
|
||||
'balance' => (float) $this->balance,
|
||||
'due_date' => $this->due_date,
|
||||
'date' => $this->date,
|
||||
'custom_value1' => $this->custom_value1,
|
||||
'custom_value2' => $this->custom_value2,
|
||||
'custom_value3' => $this->custom_value3,
|
||||
'custom_value4' => $this->custom_value4,
|
||||
'custom_value1' => (string)$this->custom_value1,
|
||||
'custom_value2' => (string)$this->custom_value2,
|
||||
'custom_value3' => (string)$this->custom_value3,
|
||||
'custom_value4' => (string)$this->custom_value4,
|
||||
'company_key' => $this->company->company_key,
|
||||
'po_number' => (string)$this->po_number,
|
||||
];
|
||||
}
|
||||
|
||||
public function getScoutKey()
|
||||
{
|
||||
return $this->hashed_id;
|
||||
}
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return self::class;
|
||||
|
@ -143,6 +143,7 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
||||
$result = $this->braintree->gateway->transaction()->sale([
|
||||
'amount' => $this->braintree->payment_hash->data->amount_with_fee,
|
||||
'paymentMethodToken' => $token->token,
|
||||
'channel' => 'invoiceninja_BT',
|
||||
'options' => [
|
||||
'submitForSettlement' => true,
|
||||
],
|
||||
|
@ -115,6 +115,7 @@ class CreditCard implements LivewireMethodInterface
|
||||
'options' => [
|
||||
'submitForSettlement' => true,
|
||||
],
|
||||
'channel' => 'invoiceninja_BT',
|
||||
'billing' => [
|
||||
'streetAddress' => $this->braintree->client->address1 ?: '',
|
||||
'extendedAddress' => $this->braintree->client->address2 ?: '',
|
||||
|
@ -72,6 +72,7 @@ class PayPal implements LivewireMethodInterface
|
||||
'amount' => $this->braintree->payment_hash->data->amount_with_fee,
|
||||
'paymentMethodToken' => $token,
|
||||
'deviceData' => $state['client-data'],
|
||||
'channel' => 'invoiceninja_BT',
|
||||
'options' => [
|
||||
'submitForSettlement' => true,
|
||||
'paypal' => [
|
||||
|
@ -202,6 +202,9 @@ class BaseRepository
|
||||
|
||||
$model->saveQuietly();
|
||||
|
||||
if(method_exists($model, 'searchable'))
|
||||
$model->searchable();
|
||||
|
||||
/* Model now persisted, now lets do some child tasks */
|
||||
|
||||
if ($model instanceof Invoice) {
|
||||
|
@ -229,7 +229,10 @@ class HtmlEngine
|
||||
|
||||
$data['$status_logo'] = ['value' => '<div class="stamp is-paid"> ' . ctrans('texts.paid') .'</div>', 'label' => ''];
|
||||
|
||||
$data['$show_paid_stamp'] = ['value' => $this->entity->status_id == 4 && $this->settings->show_paid_stamp ? 'flex' : 'none', 'label' => ''];
|
||||
if($this->entity->status_id == 5)
|
||||
$data['$status_logo'] = ['value' => '<div class="stamp is-paid"> ' . ctrans('texts.cancelled') .'</div>', 'label' => ''];
|
||||
|
||||
$data['$show_paid_stamp'] = ['value' => in_array($this->entity->status_id, [4,5]) && $this->settings->show_paid_stamp ? 'flex' : 'none', 'label' => ''];
|
||||
|
||||
$data['$invoice.vendor'] = ['value' => $this->entity->vendor?->present()->name() ?: '', 'label' => ctrans('texts.vendor_name')];
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'refresh_documents' => env('ELASTIC_SCOUT_DRIVER_REFRESH_DOCUMENTS', false),
|
||||
'refresh_documents' => env('ELASTIC_SCOUT_DRIVER_REFRESH_DOCUMENTS', true),
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user