mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fixes for tests
This commit is contained in:
parent
e329c24879
commit
af28b02fae
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -49,7 +49,7 @@ class StoreClientRequest extends Request
|
||||
|
||||
}
|
||||
|
||||
Log::error($rules);
|
||||
// Log::error($rules);
|
||||
|
||||
return $rules;
|
||||
|
||||
|
@ -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};
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 .= '<tr class="line_taxes">';
|
||||
$data .= '<td>'. $tax['name'] .'</td>';
|
||||
$data .= '<td>'. Number::formatMoney($tax['total'], $this->client->currency, $this->client->country, $this->client->getMergedSettings()) .'</td></tr>';
|
||||
$data .= '<td>'. Number::formatMoney($tax['total'], $this->client) .'</td></tr>';
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -44,7 +44,7 @@ class RecurringInvoicesCronTest extends TestCase
|
||||
//spin up 5 valid and 1 invalid recurring invoices
|
||||
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', Carbon::now()->addMinutes(30))->get();
|
||||
|
||||
Log::error(Carbon::now()->addMinutes(30)->format(config('ninja.date_time_format')));
|
||||
// Log::error(Carbon::now()->addMinutes(30)->format(config('ninja.date_time_format')));
|
||||
|
||||
$recurring_invoices->each(function ($inv, $key) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user