Feature: Automatically calculate tickert to invoice based off time worked rounded up to the near 15 min mark multiplied by Client Rate, Changed all Price, cost fields to use text field with numeric patterns instead of number fields, set pricing to always display 2 decimal spots

This commit is contained in:
johnnyq
2023-09-22 15:19:05 -04:00
parent 1ccaa936ac
commit 61c9c0c8b9
37 changed files with 111 additions and 66 deletions

View File

@@ -743,4 +743,26 @@ function shortenClient($client) {
}
return strtoupper(substr($shortened, 0, 3));
}
function roundUpToNearest15($time) {
// Extract hours, minutes, and seconds from the time string
list($hours, $minutes, $seconds) = explode(':', $time);
// Convert everything to seconds for easier calculation
$totalSeconds = ($hours * 3600) + ($minutes * 60) + $seconds;
// Calculate the remainder when divided by 900 seconds (15 minutes)
$remainder = $totalSeconds % 900;
// If there's any remainder, round up to the next 15 minutes
if ($remainder > 0) {
$totalSeconds += (900 - $remainder);
}
// Convert total seconds to the decimal format
$decimalHours = $totalSeconds / 3600;
// Return the formatted string
return number_format($decimalHours, 2);
}