Merge pull request #8337 from turbo124/v5-develop

Improve rounding for negative numbers
This commit is contained in:
David Bomba 2023-03-06 11:12:42 +11:00 committed by GitHub
commit 7b7ce234c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class UpdateBankIntegrationRequest extends Request
{
/* Ensure we have a client name, and that all emails are unique*/
$rules = [
'bank_account_name' => 'bail|sometimes|min:3',
'auto_sync' => 'sometimes|bool'
];

View File

@ -94,7 +94,6 @@ class BaseImport
$csv = base64_decode($base64_encoded_csv);
$csv = Reader::createFromString($csv);
$csvdelimiter = self::detectDelimiter($csv);
nlog("delmiter = {$csvdelimiter}");
$csv->setDelimiter($csvdelimiter);
$stmt = new Statement();

View File

@ -231,12 +231,15 @@ class Number
/* 08-01-2022 allow increased precision for unit price*/
$v = rtrim(sprintf('%f', $value), '0');
$parts = explode('.', $v);
/* 08-02-2023 special if block to render $0.5 to $0.50*/
if ($v < 1 && strlen($v) == 3) {
$precision = 2;
} elseif ($v < 1) {
$precision = strlen($v) - strrpos($v, '.') - 1;
} elseif(is_array($parts) && $parts[0] != 0) {
$precision = 2;
}
$value = number_format($v, $precision, $decimal, $thousand);