Skip to content

Commit

Permalink
Merge pull request #2420 from Leantime/timesheet-Refactor
Browse files Browse the repository at this point in the history
updates to tests
  • Loading branch information
marcelfolaron authored Mar 18, 2024
2 parents 810a631 + 133e540 commit f650db6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/Core/Support/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,6 @@ public function percent(): string
*/
public function decimal(): string
{
return number_format($this->value, 2);
return number_format((float)$this->value, 2);
}
}
5 changes: 4 additions & 1 deletion app/Domain/Api/Controllers/Jsonrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,15 @@ private function returnResponse(array|null $returnValue, string $id = null): Res
*/
private function returnError(string $errorMessage, int $errorcode, mixed $additional_info = null, int|string|null $id = 0): Response
{

//TODO: And FYI. json_encode cannot encode throwable. https://github.com/pmjones/throwable-properties
//For now we'll just return the message
return $this->tpl->displayJson([
'jsonrpc' => '2.0',
'error' => [
'code' => $errorcode,
'message' => $errorMessage,
'data' => $additional_info,
'data' => $additional_info->getMessage(),
],
'id' => $id,
]);
Expand Down
5 changes: 4 additions & 1 deletion app/Domain/Timesheets/Repositories/Timesheets.php
Original file line number Diff line number Diff line change
Expand Up @@ -856,12 +856,15 @@ public function punchOut(int $ticketId): float|false|int
VALUES (:sessionId, :ticketId, :workDate, :hoursWorked, 'GENERAL_BILLABLE')
ON DUPLICATE KEY UPDATE hours = hours + :hoursWorked";


$userStartOfDay = dtHelper()::createFromTimestamp($inTimestamp)->setToUserTimezone()->startOfDay();

$call = $this->dbcall(func_get_args(), ['dbcall_key' => 'insert']);
$call->prepare($query);
$call->bindValue(':ticketId', $ticketId);
$call->bindValue(':sessionId', $_SESSION['userdata']['id']);
$call->bindValue(':hoursWorked', $hoursWorked);
$call->bindValue(':workDate', (new Carbon($inTimestamp, $_SESSION['usersettings.timezone']))->setTimezone('UTC'));
$call->bindValue(':workDate', $userDay->formatDateTimeForDb());

$call->execute();

Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Timesheets/Templates/editTime.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
jQuery(document).ready(function ($) {
jQuery("#datepicker, #date, #invoicedCompDate, #invoicedEmplDate, #paidDate").datepicker({
numberOfMonths: 1,
dateFormat: leantime.dateHelper.getFormatFromSettings("dateformat", "jquery")
dateFormat: leantime.dateHelper.getFormatFromSettings("dateformat", "jquery"),
dayNames: leantime.i18n.__("language.dayNames").split(","),
dayNamesMin: leantime.i18n.__("language.dayNamesMin").split(","),
dayNamesShort: leantime.i18n.__("language.dayNamesShort").split(","),
Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Timesheets/Templates/showMy.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class="hourCell"
$i = 0;
foreach ($days as $day) {
?>
<td width="7%" class="rowday<?php echo ($i + 1); ?><?php if ($dateFrom->addDays($i)->isToday()) {
<td width="7%" class="rowday<?php echo ($i + 1); ?><?php if ($dateFrom->addDays($i)->setToUserTimezone()->isToday()) {
echo " active";
} ?>">
<input type="text" class="hourCell" name="new|GENERAL_BILLABLE|<?php echo $dateFrom->addDays($i)->formatDateForUser() ?>|<?php echo $dateFrom->addDays($i)->getTimestamp() ?>" value="0" />
Expand Down
4 changes: 0 additions & 4 deletions tests/Acceptance/TimesheetCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ public function deleteTimesheet(AcceptanceTester $I): void
$I->see('Should the timesheet really be deleted?');

$I->click('.nyroModalLink .button');
$I->waitForElement('.growl', 60);
$I->wait(1);
$I->see('Time entry deleted successfully');

$I->waitForElementVisible('#allTimesheetsTable');
$I->cantSee('#1 - Edit');
Expand All @@ -240,7 +237,6 @@ private function changeUsersTimeZone(AcceptanceTester $I, string $timezone = 'Am
$I->waitForElementVisible('#timezone');
$I->selectOption('#timezone', $timezone);
$I->click('#saveSettings');
$I->waitForElement('.growl', 120);

$I->seeInDatabase('zp_settings', [
'key' => 'usersettings.1.timezone',
Expand Down

0 comments on commit f650db6

Please sign in to comment.