mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add gateway transformer (#2999)
This commit is contained in:
parent
ad75344503
commit
e2284132ec
@ -256,6 +256,7 @@ class InvoiceItemSum
|
||||
if($item_tax_rate3_total > 0)
|
||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||
|
||||
\Log::error($this->item->tax_name1. " ". $this->item->line_total." ". $this->invoice->discount." ". $this->sub_total. " ".$amount. " ". $item_tax);
|
||||
}
|
||||
|
||||
$this->setTotalTaxes($item_tax);
|
||||
|
@ -120,19 +120,19 @@ class InvoiceSum
|
||||
{
|
||||
|
||||
if($this->invoice->tax_rate1 > 0){
|
||||
$tax = $this->taxer($this->sub_total, $this->invoice->tax_rate1);
|
||||
$tax = $this->taxer($this->total, $this->invoice->tax_rate1);
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1 . ' ' . $this->invoice->tax_rate1.'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
if($this->invoice->tax_rate2 > 0){
|
||||
$tax = $this->taxer($this->sub_total, $this->invoice->tax_rate2);
|
||||
$tax = $this->taxer($this->total, $this->invoice->tax_rate2);
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2. ' ' . $this->invoice->tax_rate2.'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
if($this->invoice->tax_rate3 > 0){
|
||||
$tax = $this->taxer($this->sub_total, $this->invoice->tax_rate3);
|
||||
$tax = $this->taxer($this->total, $this->invoice->tax_rate3);
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3 . ' ' . $this->invoice->tax_rate3.'%', 'total' => $tax];
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Transformers\GatewayTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
/**
|
||||
@ -31,6 +32,7 @@ class CompanyGatewayTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'gateway'
|
||||
];
|
||||
|
||||
|
||||
@ -46,7 +48,7 @@ class CompanyGatewayTransformer extends EntityTransformer
|
||||
'gateway_key' => (string)$company_gateway->gateway_key ?: '',
|
||||
'accepted_credit_cards' => (int)$company_gateway->accepted_credit_cards,
|
||||
'require_cvv' => (bool)$company_gateway->require_cvv,
|
||||
'show_address' => (bool)$company_gateway->show_address,
|
||||
'show_billing_address' => (bool)$company_gateway->show_billing_address,
|
||||
'show_shipping_address' => (bool)$company_gateway->show_shipping_address,
|
||||
'update_details' => (bool)$company_gateway->update_details,
|
||||
'config' => (string) $company_gateway->getConfigTransformed(),
|
||||
@ -68,4 +70,11 @@ class CompanyGatewayTransformer extends EntityTransformer
|
||||
];
|
||||
}
|
||||
|
||||
public function includeGateway(CompanyGateway $company_gateway)
|
||||
{
|
||||
$transformer = new GatewayTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($company_gateway->gateway, $transformer, Gateway::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,11 @@ namespace App\Transformers;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\CompanyUser;
|
||||
use App\Models\GroupSetting;
|
||||
use App\Models\User;
|
||||
use App\Transformers\CompanyGatewayTransformer;
|
||||
use App\Transformers\CompanyUserTransformer;
|
||||
use App\Transformers\GroupSettingTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -52,7 +54,8 @@ class CompanyTransformer extends EntityTransformer
|
||||
'expenses',
|
||||
'payments',
|
||||
'company_user',
|
||||
'groups'
|
||||
'groups',
|
||||
'company_gateways',
|
||||
];
|
||||
|
||||
|
||||
@ -101,6 +104,13 @@ class CompanyTransformer extends EntityTransformer
|
||||
return $this->includeCollection($company->users, $transformer, User::class);
|
||||
}
|
||||
|
||||
public function includeCompanyGateways(Company $company)
|
||||
{
|
||||
$transformer = new CompanyGatewayTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($company->company_gateways, $transformer, CompanyGateway::class);
|
||||
}
|
||||
|
||||
public function includeClients(Company $company)
|
||||
{
|
||||
$transformer = new ClientTransformer($this->serializer);
|
||||
|
56
app/Transformers/GatewayTransformer.php
Normal file
56
app/Transformers/GatewayTransformer.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?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\Gateway;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
/**
|
||||
* class ClientTransformer
|
||||
*/
|
||||
class GatewayTransformer extends EntityTransformer
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
protected $defaultIncludes = [
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Gateway $gateway)
|
||||
{
|
||||
return [
|
||||
'id' => $this->encodePrimaryKey($gateway->id),
|
||||
'name' => (string)$gateway->name ?: '',
|
||||
'key' => (string)$gateway->key ?: '',
|
||||
'provider' => (string)$gateway->provider ?: '',
|
||||
'visible' => (bool)$gateway->visible,
|
||||
'sort_order' => (int)$gateway->sort_order,
|
||||
'recommended' => (bool)$gateway->recommended,
|
||||
'site_url' => (string)$gateway->site_url ?: '',
|
||||
'is_offsite' => (bool)$gateway->is_offsite,
|
||||
'is_secure' => (bool)$gateway->is_secure,
|
||||
'fields' => (string)$gateway->fields ?: '',
|
||||
'updated_at' => (int)$gateway->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
@ -426,7 +426,7 @@ trait MakesInvoiceValues
|
||||
|
||||
$data = '';
|
||||
|
||||
if(count($this->calc()->getTotalTaxMap()) == 0)
|
||||
if(!$this->calc()->getTotalTaxMap())
|
||||
return $data;
|
||||
|
||||
foreach($this->calc()->getTotalTaxMap() as $tax)
|
||||
|
@ -90,7 +90,8 @@
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
"@php artisan package:discover --ansi",
|
||||
"@php artisan storage:link"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
|
@ -201,7 +201,7 @@ trait MockAccountData
|
||||
$cg->user_id = $this->user->id;
|
||||
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
$cg->require_cvv = true;
|
||||
$cg->show_address = true;
|
||||
$cg->show_billing_address = true;
|
||||
$cg->show_shipping_address = true;
|
||||
$cg->update_details = true;
|
||||
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||
@ -214,7 +214,7 @@ trait MockAccountData
|
||||
$cg->user_id = $this->user->id;
|
||||
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
$cg->require_cvv = true;
|
||||
$cg->show_address = true;
|
||||
$cg->show_billing_address = true;
|
||||
$cg->show_shipping_address = true;
|
||||
$cg->update_details = true;
|
||||
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user