6 changed files with 201 additions and 14 deletions
-
41app/Http/Controllers/Projects/FeesController.php
-
26resources/lang/id/payment.php
-
86resources/views/projects/fees/create.blade.php
-
3resources/views/projects/payments.blade.php
-
12routes/web/projects.php
-
47tests/Feature/Payments/ManageProjectFeesTest.php
@ -0,0 +1,41 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Controllers\Projects; |
||||
|
|
||||
|
use App\Entities\Payments\Payment; |
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Entities\Users\User; |
||||
|
use App\Http\Controllers\Controller; |
||||
|
|
||||
|
/** |
||||
|
* Project Fees Controller |
||||
|
* |
||||
|
* @author Nafies Luthfi <nafiesl@gmail.com> |
||||
|
*/ |
||||
|
class FeesController extends Controller |
||||
|
{ |
||||
|
public function create(Project $project) |
||||
|
{ |
||||
|
$partners = User::pluck('name', 'id')->all(); |
||||
|
return view('projects.fees.create', compact('project', 'partners')); |
||||
|
} |
||||
|
|
||||
|
public function store(Project $project) |
||||
|
{ |
||||
|
$newPaymentData = request()->validate([ |
||||
|
'type_id' => 'required|numeric', |
||||
|
'date' => 'required|date', |
||||
|
'amount' => 'required|numeric', |
||||
|
'partner_id' => 'required|exists:users,id', |
||||
|
'description' => 'required|string', |
||||
|
]); |
||||
|
$newPaymentData['in_out'] = 0; |
||||
|
$newPaymentData['project_id'] = $project->id; |
||||
|
$newPaymentData['partner_type'] = User::class; |
||||
|
|
||||
|
Payment::create($newPaymentData); |
||||
|
|
||||
|
flash()->success(trans('payment.created')); |
||||
|
return redirect()->route('projects.payments', $project->id); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', trans('payment.create_fee')) |
||||
|
|
||||
|
@section('content') |
||||
|
|
||||
|
<ul class="breadcrumb hidden-print"> |
||||
|
<li> |
||||
|
{{ link_to_route( |
||||
|
'projects.index', |
||||
|
trans('project.projects'), |
||||
|
['status' => request('status', $project->status_id)] |
||||
|
) }}</li> |
||||
|
<li>{{ $project->nameLink() }}</li> |
||||
|
<li>{{ link_to_route('projects.payments', trans('payment.list'), [$project->id]) }}</li> |
||||
|
<li class="active">{{ trans('payment.create_fee') }}</li> |
||||
|
</ul> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-md-6"> |
||||
|
{!! Form::open(['route' => ['projects.fees.store', $project->id]]) !!} |
||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('payment.create_fee') }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<div class="row"> |
||||
|
<div class="col-md-4"> |
||||
|
{!! FormField::select( |
||||
|
'partner_id', |
||||
|
$partners, |
||||
|
[ |
||||
|
'placeholder' => 'Pilih Pekerja', |
||||
|
'label' => trans('payment.customer'), |
||||
|
'value' => Request::get('customer_id'), |
||||
|
] |
||||
|
) !!} |
||||
|
</div> |
||||
|
<div class="col-md-4"> |
||||
|
{!! FormField::text('date',['label'=> trans('payment.date')]) !!} |
||||
|
</div> |
||||
|
<div class="col-md-4"> |
||||
|
{!! FormField::price('amount', ['label'=> trans('payment.amount')]) !!} |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="row"> |
||||
|
<div class="col-md-4"> |
||||
|
{!! FormField::radios( |
||||
|
'type_id', |
||||
|
PaymentType::toArray(), |
||||
|
['label' => trans('payment.type'), 'value' => 1, 'list_style' => 'unstyled'] |
||||
|
) !!} |
||||
|
</div> |
||||
|
<div class="col-md-8"> |
||||
|
{!! FormField::textarea('description', ['label' => trans('payment.description'), 'rows' => 3]) !!} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="panel-footer"> |
||||
|
{!! Form::submit(trans('payment.create'), ['class'=>'btn btn-primary']) !!} |
||||
|
{{ link_to_route('projects.payments', trans('app.cancel'), [$project->id], ['class'=>'btn btn-default']) }} |
||||
|
</div> |
||||
|
</div> |
||||
|
{!! Form::close() !!} |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_css') |
||||
|
{!! Html::style(url('assets/css/plugins/jquery.datetimepicker.css')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_js') |
||||
|
{!! Html::script(url('assets/js/plugins/jquery.datetimepicker.js')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('script') |
||||
|
<script> |
||||
|
(function() { |
||||
|
$('#date').datetimepicker({ |
||||
|
timepicker:false, |
||||
|
format:'Y-m-d', |
||||
|
closeOnDateSelect: true |
||||
|
}); |
||||
|
})(); |
||||
|
</script> |
||||
|
@endsection |
||||
@ -0,0 +1,47 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Feature\Payments; |
||||
|
|
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Entities\Users\User; |
||||
|
use Tests\TestCase; |
||||
|
|
||||
|
class ManageProjectFeesTest extends TestCase |
||||
|
{ |
||||
|
/** @test */ |
||||
|
public function admin_can_entry_project_fee_payment() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$worker = factory(User::class)->create(); |
||||
|
$project = factory(Project::class)->create(); |
||||
|
|
||||
|
$this->visit(route('projects.payments', $project->id)); |
||||
|
$this->seePageIs(route('projects.payments', $project->id)); |
||||
|
|
||||
|
$this->click(trans('payment.create_fee')); |
||||
|
$this->seePageIs(route('projects.fees.create', $project->id)); |
||||
|
|
||||
|
// // Fill Form
|
||||
|
$this->submitForm(trans('payment.create'), [ |
||||
|
'date' => '2015-05-01', |
||||
|
'type_id' => 1, |
||||
|
'amount' => 1000000, |
||||
|
'partner_id' => $worker->id, |
||||
|
'description' => 'Honor pengerjaan fitur a project '.$project->name, |
||||
|
]); |
||||
|
|
||||
|
$this->see(trans('payment.created')); |
||||
|
$this->seePageIs(route('projects.payments', $project->id)); |
||||
|
|
||||
|
$this->seeInDatabase('payments', [ |
||||
|
'project_id' => $project->id, |
||||
|
'amount' => 1000000, |
||||
|
'type_id' => 1, |
||||
|
'in_out' => 0, |
||||
|
'date' => '2015-05-01', |
||||
|
'partner_type' => User::class, |
||||
|
'partner_id' => $worker->id, |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue