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