mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for Number class. (#3020)
* Implement transformer for ClientGatewayTokens * Add company_gateway_id to client gateway token transformer * Fixes for client model * Fixes for Number class
This commit is contained in:
parent
2ddc87ba6e
commit
3fe3c04091
@ -320,7 +320,7 @@ class Client extends BaseModel
|
||||
//Also need to harvest the list of client gateway tokens and present these
|
||||
//for instant payment
|
||||
|
||||
$company_gateways = $this->client->getSetting('company_gateway_ids');
|
||||
$company_gateways = $this->getSetting('company_gateway_ids');
|
||||
|
||||
if($company_gateways)
|
||||
$gateways = $this->company->company_gateways->whereIn('id', $payment_gateways);
|
||||
|
44
app/Transformers/ClientGatewayTokenTransformer.php
Normal file
44
app/Transformers/ClientGatewayTokenTransformer.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
/**
|
||||
* Class ClientGatewayTokenTransformer.
|
||||
*
|
||||
*/
|
||||
class ClientGatewayTokenTransformer extends EntityTransformer
|
||||
{
|
||||
use MakesHash;
|
||||
/**
|
||||
* @param ClientGatewayToken $cgt
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function transform(ClientGatewayToken $cgt)
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $this->encodePrimaryKey($cgt->id),
|
||||
'token' => (string)$cgt->token ?: '',
|
||||
'gateway_customer_reference' => $cgt->gateway_customer_reference ?: '',
|
||||
'gateway_type_id' => (string)$cgt->gateway_type_id ?: '',
|
||||
'company_gateway_id' => (string)$this->encodePrimaryKey($cgt->company_gateway_id) ?: '',
|
||||
'is_default' => (bool) $cgt->is_default,
|
||||
'updated_at' => $cgt->updated_at,
|
||||
'archived_at' => $cgt->deleted_at,
|
||||
];
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ namespace App\Transformers;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Transformers\ClientGatewayTokenTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
/**
|
||||
@ -30,6 +32,7 @@ class ClientTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'gateway_tokens'
|
||||
];
|
||||
|
||||
|
||||
@ -45,7 +48,12 @@ class ClientTransformer extends EntityTransformer
|
||||
return $this->includeCollection($client->contacts, $transformer, ClientContact::class);
|
||||
}
|
||||
|
||||
public function includeGatewayTokens(Client $client)
|
||||
{
|
||||
$transformer = new ClientGatewayTokenTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($client->gateway_tokens, $transformer, ClientGatewayToken::class);
|
||||
}
|
||||
/**
|
||||
* @param Client $client
|
||||
*
|
||||
@ -65,6 +73,7 @@ class ClientTransformer extends EntityTransformer
|
||||
'last_login' => (int)$client->last_login,
|
||||
'address1' => $client->address1 ?: '',
|
||||
'address2' => $client->address2 ?: '',
|
||||
'phone' => $client->phone ?: '',
|
||||
'city' => $client->city ?: '',
|
||||
'state' => $client->state ?: '',
|
||||
'postal_code' => $client->postal_code ?: '',
|
||||
|
@ -70,13 +70,13 @@ class Number
|
||||
$swapSymbol = $currency->swap_currency_symbol;
|
||||
|
||||
/* Country settings override client settings */
|
||||
if (property_exists($client->country, 'thousand_separator'))
|
||||
if(isset($client->country->thousand_separator))
|
||||
$thousand = $client->country->thousand_separator;
|
||||
|
||||
if (property_exists($client->country, 'decimal_separator'))
|
||||
if(isset($client->country->decimal_separator))
|
||||
$decimal = $client->country->decimal_separator;
|
||||
|
||||
if(property_exists($client->country, 'swap_currency_symbol'))
|
||||
if(isset($client->country->swap_currency_symbol))
|
||||
$swapSymbol = $client->country->swap_currency_symbol;
|
||||
|
||||
$value = number_format($value, $precision, $decimal, $thousand);
|
||||
|
@ -274,6 +274,7 @@ class CreateUsersTable extends Migration
|
||||
$table->text('private_notes')->nullable();
|
||||
$table->text('client_hash')->nullable();
|
||||
$table->string('logo', 255)->nullable();
|
||||
$table->string('phone', 255)->nullable();
|
||||
|
||||
$table->decimal('balance', 13, 2)->default(0);
|
||||
$table->decimal('paid_to_date', 13, 2)->default(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user