1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Fixes and improvements for templates

This commit is contained in:
David Bomba 2024-03-11 19:37:53 +11:00
parent f0ad4175aa
commit 08dee1309e
4 changed files with 43 additions and 40 deletions

View File

@ -328,6 +328,7 @@ class InvoiceFilters extends QueryFilters
}
if($sort_col[0] == 'number') {
// return $this->builder->orderByRaw('CAST(number AS UNSIGNED), number ' . $dir);
return $this->builder->orderByRaw('ABS(number) ' . $dir);
}

View File

@ -427,6 +427,6 @@ $_contact->push();
public function render()
{
return render('components.livewire.required-client-infox');
return render('components.livewire.required-client-info');
}
}

View File

@ -1032,6 +1032,8 @@ class TemplateService
'payment_balance' => $purchase_order->client->payment_balance,
'credit_balance' => $purchase_order->client->credit_balance,
'vat_number' => $purchase_order->client->vat_number ?? '',
'address' => $purchase_order->client->present()->address(),
'shipping_address' => $purchase_order->client->present()->shipping_address(),
] : [],
'status_id' => (string)($purchase_order->status_id ?: 1),
'status' => PurchaseOrder::stringStatus($purchase_order->status_id ?? 1),

View File

@ -93,59 +93,59 @@ class Number
* @param string $value The formatted number to be converted back to float
* @return float The formatted value
*/
public static function parseFloat2($value)
public static function parseFloat($value)
{
if(!$value)
return 0;
//remove everything except for numbers, decimals, commas and hyphens
$value = preg_replace('/[^0-9.,-]+/', '', $value);
$decimal = strpos($value, '.');
$comma = strpos($value, ',');
if($comma === false) //no comma must be a decimal number already
return (float) $value;
if($decimal < $comma){ //decimal before a comma = euro
$value = str_replace(['.',','], ['','.'], $value);
// $value = str_replace(',', '.', $value);
return (float) $value;
}
//comma first = traditional thousan separator
$value = str_replace(',', '', $value);
return (float)$value;
// if(!$value)
// return 0;
// $multiplier = false;
// //remove everything except for numbers, decimals, commas and hyphens
// $value = preg_replace('/[^0-9.,-]+/', '', $value);
// if(substr($value, 0,1) == '-')
// $multiplier = -1;
// $decimal = strpos($value, '.');
// $comma = strpos($value, ',');
// if($comma === false) //no comma must be a decimal number already
// return (float) $value;
// $s = str_replace(',', '.', $value);
// $s = preg_replace("/[^0-9\.]/", '', $s);
// if ($s < 1) {
// return (float) $s;
// if($decimal < $comma){ //decimal before a comma = euro
// $value = str_replace(['.',','], ['','.'], $value);
// // $value = str_replace(',', '.', $value);
// return (float) $value;
// }
// $s = str_replace('.', '', substr($s, 0, -3)).substr($s, -3);
// //comma first = traditional thousan separator
// $value = str_replace(',', '', $value);
// return (float)$value;
if(!$value)
return 0;
// if($multiplier)
// $s = floatval($s)*-1;
$multiplier = false;
// return (float) $s;
if(substr($value, 0,1) == '-')
$multiplier = -1;
$s = str_replace(',', '.', $value);
$s = preg_replace("/[^0-9\.]/", '', $s);
if ($s < 1) {
return (float) $s;
}
$s = str_replace('.', '', substr($s, 0, -3)).substr($s, -3);
if($multiplier)
$s = floatval($s)*-1;
return (float) $s;
}
//next iteration of float parsing
public static function parseFloat($value)
public static function parseFloat2($value)
{
if(!$value) {