diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index e69b0c4a7d8f..9079eb13b31c 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -31,8 +31,7 @@ class PaymentFilters extends QueryFilters * */ public function filter(string $filter = '') : Builder - {Log::error('ewwo'); - Log::error($filter); + { if(strlen($filter) == 0) return $this->builder; diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 8acb3344b62e..7860925c8f1c 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -62,9 +62,9 @@ class InvoiceController extends Controller })->editColumn('due_date', function ($invoice){ return $this->formatDate($invoice->due_date, $invoice->client->date_format()); })->editColumn('balance', function ($invoice) { - return Number::formatMoney($invoice->balance, $invoice->client->currency, $invoice->client->country, $invoice->client->getMergedSettings()); + return Number::formatMoney($invoice->balance, $invoice->client); })->editColumn('amount', function ($invoice) { - return Number::formatMoney($invoice->amount, $invoice->client->currency, $invoice->client->country, $invoice->client->getMergedSettings()); + return Number::formatMoney($invoice->amount, $invoice->client); }) ->rawColumns(['checkbox', 'action', 'status_id']) ->make(true); @@ -125,7 +125,7 @@ class InvoiceController extends Controller $invoices->filter(function ($invoice){ return $invoice->isPayable(); })->map(function ($invoice){ - $invoice->balance = Number::formatMoney($invoice->balance, $invoice->client->currency, $invoice->client->country, $invoice->client->getMergedSettings()); + $invoice->balance = Number::formatMoney($invoice->balance, $invoice->client; $invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format()); return $invoice; diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 54ba4cfb3428..be8479c534e1 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -47,7 +47,7 @@ class QueryLogging $count = count($queries); $timeEnd = microtime(true); $time = $timeEnd - $timeStart; - //Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); + Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); // if($count > 16) // Log::info($queries); diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index 8ab46de52117..251b17dbb410 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -49,7 +49,7 @@ class StoreClientRequest extends Request } - Log::error($rules); + // Log::error($rules); return $rules; diff --git a/app/Models/Client.php b/app/Models/Client.php index 700cc019ee7d..f48e53e560b4 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -154,16 +154,28 @@ class Client extends BaseModel public function getSetting($setting) { + // Log::error('does prop exist? = ' . property_exists($this->settings, $setting)); + // Log::error('does prop have val? = ' . isset($this->settings->{str_replace("'","",$setting)})); + // Log::error('client'); + // Log::error(print_r($this,1)); + // Log::error('company'); + // Log::error(print_r($this->company,1)); + // Log::error('company settings'); + // Log::error(print_r($this->company->settings,1)); + // Log::error('cli = '.$this->settings->{$setting}); + // Log::error('co = '.$this->company->settings->{$setting}); + //check client level first - if(property_exists($this->settings, $setting) && isset($this->settings->{$setting})) + if($this->settings && isset($this->settings->{$setting}) && property_exists($this->settings, $setting)) return $this->settings->{$setting}; //check group level (if a group is assigned) - if($this->group_settings && property_exists($this->group_settings, $setting) && isset($this->group_settings->{$setting})) + if($this->group_settings && isset($this->group_settings->{$setting}) && property_exists($this->group_settings, $setting)) return $this->group_settings->{$setting}; //check company level - + if(isset($this->company->settings->{$setting}) && property_exists($this->company->settings, $setting)) + return $this->company->settings->{$setting}; } diff --git a/app/Utils/Number.php b/app/Utils/Number.php index db315ee4f80b..0c795d186a00 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -58,30 +58,31 @@ class Number * * @return string The formatted value */ - public static function formatMoney($value, $currency, $country, $settings) :string + //public static function formatMoney($value, $currency, $country, $settings) :string + public static function formatMoney($value, $client) :string { - $thousand = $currency->thousand_separator; - $decimal = $currency->decimal_separator; - $precision = $currency->precision; - $code = $currency->code; - $swapSymbol = $country->swap_currency_symbol; + $thousand = $client->currency->thousand_separator; + $decimal = $client->currency->decimal_separator; + $precision = $client->currency->precision; + $code = $client->currency->code; + $swapSymbol = $client->country->swap_currency_symbol; /* Country settings override client settings */ - if ($country->thousand_separator) - $thousand = $country->thousand_separator; + if ($client->country->thousand_separator) + $thousand = $client->country->thousand_separator; - if ($country->decimal_separator) - $decimal = $country->decimal_separator; + if ($client->country->decimal_separator) + $decimal = $client->country->decimal_separator; $value = number_format($value, $precision, $decimal, $thousand); - $symbol = $currency->symbol; + $symbol = $client->currency->symbol; - if ($settings->show_currency_code == "TRUE") { + if ($client->getSetting('show_currency_code') == "TRUE") { return "{$value} {$code}"; } elseif ($swapSymbol) { return "{$value} " . trim($symbol); - } elseif ($settings->show_currency_symbol == "TRUE") { + } elseif ($client->getSetting('show_currency_symbol') == "TRUE") { return "{$symbol}{$value}"; } else { return self::formatValue($value, $currency); diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index dd593e947556..f94e0957f200 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -167,13 +167,13 @@ trait MakesInvoiceValues // $data['$quantity'] = ; // $data['$line_total'] = ; // $data['$paid_to_date'] = ; - $data['$discount'] = Number::formatMoney($this->calc()->getTotalDiscount(), $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $data['$subtotal'] = Number::formatMoney($this->calc()->getSubTotal(), $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $data['$balance_due'] = Number::formatMoney($this->balance, $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $data['$partial_due'] = Number::formatMoney($this->partial, $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $data['$total'] = Number::formatMoney($this->calc()->getTotal(), $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $data['$balance'] = Number::formatMoney($this->calc()->getBalance(), $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $data['$taxes'] = Number::formatMoney($this->calc()->getTotalTaxes(), $this->client->currency, $this->client->country, $this->client->getMergedSettings()); + $data['$discount'] = Number::formatMoney($this->calc()->getTotalDiscount(), $this->client); + $data['$subtotal'] = Number::formatMoney($this->calc()->getSubTotal(), $this->client); + $data['$balance_due'] = Number::formatMoney($this->balance, $this->client); + $data['$partial_due'] = Number::formatMoney($this->partial, $this->client); + $data['$total'] = Number::formatMoney($this->calc()->getTotal(), $this->client); + $data['$balance'] = Number::formatMoney($this->calc()->getBalance(), $this->client); + $data['$taxes'] = Number::formatMoney($this->calc()->getTotalTaxes(), $this->client); $data['$terms'] = $this->terms; // $data['$your_invoice'] = ; // $data['$quote'] = ; @@ -365,14 +365,14 @@ trait MakesInvoiceValues foreach($items as $item) { - $item->cost = Number::formatMoney($item->cost, $this->client->currency, $this->client->country, $this->client->getMergedSettings()); - $item->line_total = Number::formatMoney($item->line_total, $this->client->currency, $this->client->country, $this->client->getMergedSettings()); + $item->cost = Number::formatMoney($item->cost, $this->client); + $item->line_total = Number::formatMoney($item->line_total, $this->client); if(isset($item->discount) && $item->discount > 0) { if($item->is_amount_discount) - $item->discount = Number::formatMoney($item->discount, $this->client->currency, $this->client->country, $this->client->getMergedSettings()); + $item->discount = Number::formatMoney($item->discount, $this->client); else $item->discount = $item->discount . '%'; } @@ -403,7 +403,7 @@ trait MakesInvoiceValues { $data .= '