10 changed files with 186 additions and 36 deletions
-
15app/Entities/Projects/Job.php
-
9app/Http/Controllers/Projects/JobsController.php
-
1resources/lang/id/app.php
-
32resources/lang/id/project.php
-
25resources/views/invoices/pdf.blade.php
-
20resources/views/projects/jobs/export-html.blade.php
-
3resources/views/projects/jobs/index.blade.php
-
57resources/views/projects/jobs/progress-export-html.blade.php
-
1routes/web/projects.php
-
59tests/Unit/Models/JobTest.php
@ -0,0 +1,57 @@ |
|||
<?php |
|||
// $filename = str_slug(__('project.jobs') . '-' . $project->name) . '.xls';
|
|||
// header("Content-Disposition: attachment; filename=\"$filename\"");
|
|||
// header("Content-Type: application/vnd.ms-excel");
|
|||
?>
|
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
{{-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> --}} |
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|||
<title>{{ __('project.jobs') }} {{ $project->name }}</title> |
|||
{!! Html::style('assets/css/app.css') !!} |
|||
</head> |
|||
<body style="font-family:'Liberation Serif'; font-size: 16px;"> |
|||
<div class="container"> |
|||
<h1 class="page-header text-center">{{ __('project.jobs') }} {{ $project->name }}</h1> |
|||
|
|||
<h2 class="text-center">{{ __('project.progress') }}</h2> |
|||
<table width="100%" class="table table-condensed table-bordered"> |
|||
<tbody> |
|||
<tr> |
|||
<th class="text-center">{{ __('app.table_no') }}</th> |
|||
<th>{{ __('job.name') }}</th> |
|||
<th class="text-center">{{ __('job.price') }}</th> |
|||
<th class="text-center">{{ __('job.progress') }}</th> |
|||
<th class="text-center">{{ __('project.receiveable_earnings') }}</th> |
|||
</tr> |
|||
@foreach($jobs->sortByDesc('progress') as $key => $job) |
|||
<tr> |
|||
<td class="text-center">{{ 1 + $key }}</td> |
|||
<td>{{ $job->name }}</td> |
|||
<td class="text-right">{{ formatRp($job->price) }}</td> |
|||
<td class="text-center">{{ $job->progress }} %</td> |
|||
<td class="text-right">{{ formatRp($job->receiveable_earning) }}</td> |
|||
</tr> |
|||
@endforeach |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<th class="text-right" colspan="2">{{ __('app.total') }}</th> |
|||
<th class="text-right">{{ formatRp($jobs->sum('price')) }}</th> |
|||
<th class="text-center">{{ formatDecimal($project->getJobOveralProgress()) }} %</th> |
|||
<th class="text-right">{{ formatRp($jobs->sum('receiveable_earning')) }}</th> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<div style="margin-bottom: 50px;"> |
|||
<p>{{ __('app.remark') }}:</p> |
|||
<p> |
|||
<strong>{{ __('project.earnings_calculation') }} : </strong><br> |
|||
<strong>{{ __('project.receiveable_earnings') }}</strong> = <strong>{{ __('job.price') }}</strong> * <strong>{{ __('job.progress') }} (%)</strong> |
|||
</p> |
|||
</div> |
|||
</div> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,59 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Unit\Models; |
|||
|
|||
use App\Entities\Projects\Job; |
|||
use App\Entities\Projects\Project; |
|||
use App\Entities\Projects\Task; |
|||
use Illuminate\Support\Collection; |
|||
use Tests\TestCase; |
|||
|
|||
/** |
|||
* Job Model Unit Test. |
|||
* |
|||
* @author Nafies Luthfi <nafiesl@gmail.com> |
|||
*/ |
|||
class JobTest extends TestCase |
|||
{ |
|||
/** @test */ |
|||
public function a_job_belongs_to_a_project() |
|||
{ |
|||
$project = factory(Project::class)->create(); |
|||
$job = factory(Job::class)->create(['project_id' => $project->id]); |
|||
|
|||
$this->assertInstanceOf(Project::class, $job->project); |
|||
$this->assertEquals($project->id, $job->project->id); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function a_job_has_many_tasks() |
|||
{ |
|||
$job = factory(Job::class)->create(); |
|||
$tasks = factory(Task::class, 2)->create(['job_id' => $job->id]); |
|||
|
|||
$this->assertInstanceOf(Collection::class, $job->tasks); |
|||
$this->assertInstanceOf(Task::class, $job->tasks->first()); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function a_job_has_progress_attribute() |
|||
{ |
|||
$job = factory(Job::class)->create(); |
|||
$task1 = factory(Task::class)->create(['job_id' => $job->id, 'progress' => 100]); |
|||
$task2 = factory(Task::class)->create(['job_id' => $job->id, 'progress' => 50]); |
|||
|
|||
// Job progress = job tasks average progress
|
|||
$this->assertEquals(75, $job->progress); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function a_job_has_receiveable_earning_attribute() |
|||
{ |
|||
$job = factory(Job::class)->create(['price' => 1000]); |
|||
$task1 = factory(Task::class)->create(['job_id' => $job->id, 'progress' => 100]); |
|||
$task2 = factory(Task::class)->create(['job_id' => $job->id, 'progress' => 50]); |
|||
|
|||
// Job receiveable earning = job tasks average progress (%) * job price
|
|||
$this->assertEquals(750, $job->receiveable_earning); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue