diff --git a/app/Entities/BaseRepository.php b/app/Entities/BaseRepository.php
index b06e708..f15846d 100755
--- a/app/Entities/BaseRepository.php
+++ b/app/Entities/BaseRepository.php
@@ -21,7 +21,11 @@ abstract class BaseRepository extends EloquentRepository
public function getCustomersAndVendorsList()
{
- return User::orderBy('name')->hasRoles(['customer', 'vendor'])->pluck('name', 'id');
+ $partnerList = [
+ 'Customer' => Customer::orderBy('name')->pluck('name', 'id')->all(),
+ 'Vendor' => Vendor::orderBy('name')->pluck('name', 'id')->all(),
+ ];
+ return $partnerList;
}
public function getWorkersList()
diff --git a/app/Http/Controllers/PaymentsController.php b/app/Http/Controllers/PaymentsController.php
index 35a58fe..97d9519 100755
--- a/app/Http/Controllers/PaymentsController.php
+++ b/app/Http/Controllers/PaymentsController.php
@@ -21,7 +21,7 @@ class PaymentsController extends Controller
public function index(Request $request)
{
- $payments = $this->repo->getPayments($request->only('q', 'customer_id'));
+ $payments = $this->repo->getPayments($request->only('q', 'customer_id'));
$usersList = User::pluck('name', 'id')->all();
return view('payments.index', compact('payments', 'usersList'));
}
@@ -29,8 +29,8 @@ class PaymentsController extends Controller
public function create()
{
$projects = $this->repo->getProjectsList();
- $customers = $this->repo->getCustomersAndVendorsList();
- return view('payments.create', compact('projects', 'customers'));
+ $partners = $this->repo->getCustomersAndVendorsList();
+ return view('payments.create', compact('projects', 'partners'));
}
public function store(CreateRequest $request)
@@ -48,13 +48,13 @@ class PaymentsController extends Controller
public function edit(Payment $payment)
{
$projects = $this->repo->getProjectsList();
- $customers = $this->repo->getCustomersAndVendorsList();
- return view('payments.edit', compact('payment', 'projects', 'customers'));
+ $partners = $this->repo->getCustomersAndVendorsList();
+ return view('payments.edit', compact('payment', 'projects', 'partners'));
}
public function update(UpdateRequest $request, $paymentId)
{
- $payment = $this->repo->update($request->except(['_method','_token']), $paymentId);
+ $payment = $this->repo->update($request->except(['_method', '_token']), $paymentId);
flash()->success(trans('payment.updated'));
return redirect()->route('payments.show', $paymentId);
}
diff --git a/resources/views/payments/create.blade.php b/resources/views/payments/create.blade.php
index ef44086..562ad30 100755
--- a/resources/views/payments/create.blade.php
+++ b/resources/views/payments/create.blade.php
@@ -35,7 +35,7 @@
{!! FormField::select('project_id', $projects, ['label'=> trans('payment.project'),'value' => Request::get('project_id')]) !!}
- {!! FormField::select('customer_id', $customers, ['label'=> trans('payment.customer'),'value' => Request::get('customer_id')]) !!}
+ {!! FormField::select('customer_id', $partners, ['label'=> trans('payment.customer'),'value' => Request::get('customer_id')]) !!}
{!! FormField::textarea('description',['label'=> trans('payment.description'),'rows' => 3]) !!}
@@ -69,4 +69,4 @@
});
})();
-@endsection
\ No newline at end of file
+@endsection
diff --git a/resources/views/payments/edit.blade.php b/resources/views/payments/edit.blade.php
index 3841858..887ead9 100755
--- a/resources/views/payments/edit.blade.php
+++ b/resources/views/payments/edit.blade.php
@@ -32,7 +32,7 @@
{!! FormField::select('project_id', $projects, ['label'=> trans('payment.project')]) !!}
- {!! FormField::select('customer_id', $customers, ['label'=> trans('payment.customer')]) !!}
+ {!! FormField::select('customer_id', $partners, ['label'=> trans('payment.customer')]) !!}
{!! FormField::textarea('description',['label'=> trans('payment.description')]) !!}
@@ -73,4 +73,4 @@
});
})();
-@endsection
\ No newline at end of file
+@endsection
diff --git a/tests/Feature/Payments/ManagePaymentsTest.php b/tests/Feature/Payments/ManagePaymentsTest.php
index 74c2ec9..a0a8dff 100644
--- a/tests/Feature/Payments/ManagePaymentsTest.php
+++ b/tests/Feature/Payments/ManagePaymentsTest.php
@@ -2,19 +2,20 @@
namespace Tests\Feature\Payments;
+use App\Entities\Partners\Customer;
+use App\Entities\Partners\Vendor;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
-use App\Entities\Users\User;
use Tests\TestCase;
class ManagePaymentsTest extends TestCase
{
/** @test */
- public function admin_can_entry_project_a_cashin_payment()
+ public function admin_can_entry_project_an_income_payment()
{
- $user = $this->adminUserSigningIn();
- $customer = $this->createUser('customer');
- $project = factory(Project::class)->create();
+ $user = $this->adminUserSigningIn();
+ $customer = factory(Customer::class)->create();
+ $project = factory(Project::class)->create();
$this->visit(route('payments.index'));
$this->seePageIs(route('payments.index'));
@@ -31,15 +32,20 @@ class ManagePaymentsTest extends TestCase
$this->press(trans('payment.create'));
$this->see(trans('payment.created'));
- $this->seeInDatabase('payments', ['project_id' => $project->id,'amount' => 1000000,'in_out' => 1,'date' => '2015-05-01']);
+ $this->seeInDatabase('payments', [
+ 'project_id' => $project->id,
+ 'amount' => 1000000,
+ 'in_out' => 1,
+ 'date' => '2015-05-01',
+ 'customer_id' => $customer->id,
+ ]);
}
-
/** @test */
- public function admin_can_entry_project_a_cashout_payment()
+ public function admin_can_entry_project_an_expanse_payment()
{
- $user = $this->adminUserSigningIn();
- $customer = $this->createUser('customer');
+ $user = $this->adminUserSigningIn();
+ $vendor = factory(Vendor::class)->create();
$project = factory(Project::class)->create();
$this->visit(route('payments.index'));
@@ -53,22 +59,32 @@ class ManagePaymentsTest extends TestCase
$this->select(3, 'type_id');
$this->type(1000000, 'amount');
$this->select($project->id, 'project_id');
- $this->select($customer->id, 'customer_id');
+ $this->select($vendor->id, 'customer_id');
$this->type('Pembayaran DP', 'description');
$this->press(trans('payment.create'));
$this->see(trans('payment.created'));
- $this->seeInDatabase('payments', ['project_id' => $project->id,'amount' => 1000000,'in_out' => 0,'date' => '2015-05-01']);
+ $this->seeInDatabase('payments', [
+ 'project_id' => $project->id,
+ 'amount' => 1000000,
+ 'in_out' => 0,
+ 'date' => '2015-05-01',
+ 'customer_id' => $vendor->id,
+ ]);
}
/** @test */
public function admin_can_edit_payment_data()
{
- $user = $this->adminUserSigningIn();
- $customer = $this->createUser('customer');
- $project = factory(Project::class)->create();
+ $user = $this->adminUserSigningIn();
+ $customer = factory(Customer::class)->create();
+ $project = factory(Project::class)->create();
- $payment = factory(Payment::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id, 'owner_id' => $user->id]);
+ $payment = factory(Payment::class)->create([
+ 'customer_id' => $customer->id,
+ 'project_id' => $project->id,
+ 'owner_id' => $user->id,
+ ]);
$this->visit(route('payments.edit', $payment->id));
$this->seePageIs(route('payments.edit', $payment->id));
@@ -83,9 +99,9 @@ class ManagePaymentsTest extends TestCase
$this->see(trans('payment.updated'));
$this->seeInDatabase('payments', [
'customer_id' => $customer->id,
- 'project_id' => $project->id,
- 'date' => '2016-05-20',
- 'amount' => 1234567890,
+ 'project_id' => $project->id,
+ 'date' => '2016-05-20',
+ 'amount' => 1234567890,
]);
}
@@ -109,7 +125,7 @@ class ManagePaymentsTest extends TestCase
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create(['owner_id' => $user->id]);
- $payment = factory(Payment::class)->create(['project_id' => $project->id,'owner_id' => $user->id]);
+ $payment = factory(Payment::class)->create(['project_id' => $project->id, 'owner_id' => $user->id]);
$this->visit(route('payments.index'));
$this->click(trans('app.show'));