diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index cfd55e7cb291..076e0cd4b853 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -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); diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 8886433fa348..4b5efbf8b480 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -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]; } diff --git a/app/Transformers/CompanyGatewayTransformer.php b/app/Transformers/CompanyGatewayTransformer.php index 104a61530e66..91046958a1ea 100644 --- a/app/Transformers/CompanyGatewayTransformer.php +++ b/app/Transformers/CompanyGatewayTransformer.php @@ -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); + } + } diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 1e27cc7457c9..bdcd1527f3dd 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -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); diff --git a/app/Transformers/GatewayTransformer.php b/app/Transformers/GatewayTransformer.php new file mode 100644 index 000000000000..5ffe8e2a6151 --- /dev/null +++ b/app/Transformers/GatewayTransformer.php @@ -0,0 +1,56 @@ + $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, + ]; + } +} \ No newline at end of file diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index bbd72c47b164..cb9ffde72ca0 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -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) diff --git a/composer.json b/composer.json index e41ca512e311..b5212f5d9103 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index de7b527be184..c576c37649a2 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -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'));