diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index d391088115..3f21321300 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -395,7 +395,7 @@ class InvoiceController extends BaseController $invoice = $this->invoice_repo->save($request->all(), $invoice); - event(new InvoiceWasUpdated($invoice->with('client,client.currency'))); + event(new InvoiceWasUpdated($invoice)); return $this->itemResponse($invoice); diff --git a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php new file mode 100644 index 0000000000..b98f208c4f --- /dev/null +++ b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php @@ -0,0 +1,305 @@ +invoice; + + $invoice->load('client', 'client.currency'); $path = 'public/' . $invoice->client->client_hash . '/invoices/'; $file_path = $path . $invoice->invoice_number . '.pdf'; diff --git a/app/Models/Client.php b/app/Models/Client.php index 44732f2fff..2a75e7b8d7 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -86,15 +86,15 @@ class Client extends BaseModel 'id_number', ]; - /* + protected $with = [ - 'contacts', - 'primary_contact', - 'country', - 'shipping_country', - 'company' + //'currency', + // 'primary_contact', + // 'country', + // 'shipping_country', + // 'company' ]; - */ + protected $casts = [ 'settings' => 'object', 'updated_at' => 'timestamp', diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 2a8d7dc73d..4f9ba7f68c 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -11,6 +11,7 @@ namespace App\Utils; +use App\Models\Currency; use Illuminate\Support\Facades\Log; /** @@ -61,7 +62,7 @@ class Number //public static function formatMoney($value, $currency, $country, $settings) :string public static function formatMoney($value, $client) :string { -//\Log::error(debug_backtrace()[1]['function']); + $thousand = $client->currency->thousand_separator; $decimal = $client->currency->decimal_separator; $precision = $client->currency->precision; @@ -78,14 +79,14 @@ class Number $value = number_format($value, $precision, $decimal, $thousand); $symbol = $client->currency->symbol; - if ($client->getSetting('show_currency_code') == "TRUE") { + if ($client->getSetting('show_currency_code') === true) { return "{$value} {$code}"; } elseif ($swapSymbol) { return "{$value} " . trim($symbol); - } elseif ($client->getSetting('show_currency_code') == "FALSE") { + } elseif ($client->getSetting('show_currency_code') === false) { return "{$symbol}{$value}"; } else { - return self::formatValue($value, $currency); + return self::formatValue($value, $client->currency); } } } diff --git a/tests/Feature/ClientModelTest.php b/tests/Feature/ClientModelTest.php index baebb16cbd..a32354f714 100644 --- a/tests/Feature/ClientModelTest.php +++ b/tests/Feature/ClientModelTest.php @@ -24,7 +24,7 @@ class ClientModelTest extends TestCase $this->makeTestData(); - if(config('ninja.testvars.travis') == FALSE) + if(config('ninja.testvars.travis') == false) $this->markTestSkipped('Skip test for Travis'); }