mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Improvement quality of task faker data
This commit is contained in:
parent
b505bbc6c0
commit
23b58f4e3e
@ -937,7 +937,6 @@ class Company extends BaseModel
|
||||
$date = new \DateTime("now", new \DateTimeZone($timezone->name));
|
||||
$offset -= $date->getOffset();
|
||||
|
||||
// $offset -= $timezone->utc_offset;
|
||||
$offset += ($entity_send_time * 3600);
|
||||
|
||||
return $offset;
|
||||
|
@ -258,8 +258,6 @@ class Task extends BaseModel
|
||||
return
|
||||
collect(json_decode($this->time_log,true))->map(function ($log){
|
||||
|
||||
nlog($log);
|
||||
|
||||
$parent_entity = $this->client ?? $this->company;
|
||||
|
||||
if($log[0])
|
||||
@ -273,4 +271,41 @@ class Task extends BaseModel
|
||||
return $log;
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
|
||||
public function processLogsExpandedNotation()
|
||||
{
|
||||
|
||||
return
|
||||
collect(json_decode($this->time_log,true))->map(function ($log){
|
||||
|
||||
$parent_entity = $this->client ?? $this->company;
|
||||
$logged = [];
|
||||
|
||||
if($log[0] && $log[1] !=0 ) {
|
||||
$duration = $log[1] - $log[0];
|
||||
}
|
||||
else {
|
||||
$duration = 0;
|
||||
}
|
||||
|
||||
if($log[0])
|
||||
$logged['start_date_raw'] = $log[0];
|
||||
$logged['start_date'] = Carbon::createFromTimestamp($log[0])->format($parent_entity->date_format().' H:m:s');
|
||||
|
||||
if($log[1] && $log[1] != 0) {
|
||||
$logged['end_date_raw'] = $log[1];
|
||||
$logged['end_date'] = Carbon::createFromTimestamp($log[1])->format($parent_entity->date_format().' H:m:s');
|
||||
}
|
||||
else{
|
||||
$logged['end_date_raw'] = 0;
|
||||
$logged['end_date'] = ctrans('texts.running');
|
||||
}
|
||||
$logged['duration'] = $duration;
|
||||
|
||||
return $logged;
|
||||
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -845,18 +845,19 @@ class TemplateService
|
||||
{
|
||||
|
||||
return collect($tasks)->map(function ($task) use ($nested) {
|
||||
|
||||
/** @var \App\Models\Task $task */
|
||||
return [
|
||||
'number' => (string) $task->number ?: '',
|
||||
'description' => (string) $task->description ?: '',
|
||||
'duration' => $task->duration ?: 0,
|
||||
'rate' => Number::formatMoney($task->rate ?? 0, $task->client ?? $task->company),
|
||||
'rate_raw' => $task->rate ?? 0,
|
||||
'created_at' => $this->translateDate($task->created_at, $task->client ? $task->client->date_format() : $task->company->date_format(), $task->client ? $task->client->locale() : $task->company->locale()),
|
||||
'updated_at' => $this->translateDate($task->updated_at, $task->client ? $task->client->date_format() : $task->company->date_format(), $task->client ? $task->client->locale() : $task->company->locale()),
|
||||
'date' => $task->calculated_start_date ? $this->translateDate($task->calculated_start_date, $task->client ? $task->client->date_format() : $task->company->date_format(), $task->client ? $task->client->locale() : $task->company->locale()) : '',
|
||||
// 'invoice_id' => $this->encodePrimaryKey($task->invoice_id) ?: '',
|
||||
'project' => ($task->project && !$nested) ? $this->transformProject($task->project, true) : [],
|
||||
'time_log' => $task->processLogs(),
|
||||
'time_log' => $task->processLogsExpandedNotation(),
|
||||
'custom_value1' => $task->custom_value1 ?: '',
|
||||
'custom_value2' => $task->custom_value2 ?: '',
|
||||
'custom_value3' => $task->custom_value3 ?: '',
|
||||
@ -902,6 +903,7 @@ class TemplateService
|
||||
'created_at' => $this->translateDate($project->created_at, $project->client->date_format(), $project->client->locale()),
|
||||
'updated_at' => $this->translateDate($project->updated_at, $project->client->date_format(), $project->client->locale()),
|
||||
'task_rate' => Number::formatMoney($project->task_rate ?? 0, $project->client),
|
||||
'task_rate_raw' => $project->task_rate ?? 0,
|
||||
'due_date' => $project->due_date ? $this->translateDate($project->due_date, $project->client->date_format(), $project->client->locale()) : '',
|
||||
'private_notes' => (string) $project->private_notes ?: '',
|
||||
'public_notes' => (string) $project->public_notes ?: '',
|
||||
|
Loading…
Reference in New Issue
Block a user