Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cheques Module with CRUD Operations and Tests (Integration & End-to-End) #31

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
19031ee
Update README.md
chandachewe10 Feb 24, 2024
8e437ed
Merge pull request #7 from chandachewe10/dev
chandachewe10 Feb 24, 2024
920aaac
Update README.md
chandachewe10 Feb 24, 2024
2d4c846
Merge pull request #8 from chandachewe10/main
chandachewe10 Feb 24, 2024
3ebe5e7
Update README.md
chandachewe10 Feb 25, 2024
d00b223
Merge pull request #9 from chandachewe10/dev
chandachewe10 Feb 25, 2024
482e56f
Updated README.md
chandachewe10 Feb 28, 2024
fd0f0ca
Merge pull request #10 from chandachewe10/dev
chandachewe10 Feb 28, 2024
ae40b98
Checking SWIFT-SMS using 1 and not using Active
chandachewe10 Apr 20, 2024
ea9e696
Merge pull request #11 from chandachewe10/dev
chandachewe10 Apr 20, 2024
7ba4599
Fixed Issue on Loan Settlement Forms
chandachewe10 May 12, 2024
237b18c
Merge pull request #15 from chandachewe10/dev
chandachewe10 May 16, 2024
62e1a5c
Fixed Issue on SMS
chandachewe10 May 17, 2024
0fbe78e
Modify Messeage for loan approval
chandachewe10 May 19, 2024
99c0442
Modify Messeage for loan approval
chandachewe10 May 19, 2024
adff7da
Add Loan Number on the tables list
chandachewe10 May 19, 2024
544fbd3
Fix Issue on Loan repayments
chandachewe10 May 19, 2024
060c81a
Merge pull request #16 from chandachewe10/dev
chandachewe10 May 20, 2024
0c9d0b9
Fixed Issue on token mismatch or token expires on log out
chandachewe10 May 21, 2024
7524bd0
Show correct deduction loan aduration for each successfull approval
chandachewe10 May 21, 2024
be9ff3d
Merge pull request #17 from chandachewe10/dev
chandachewe10 May 21, 2024
c438b85
Merge pull request #18 from chandachewe10/dev
chandachewe10 May 21, 2024
b8e72ba
Revert on Payments
chandachewe10 May 22, 2024
0bf6a9c
Show notification if the settlement form has not been set
chandachewe10 May 22, 2024
863f988
Update the balance on the loans table on each repaymens
chandachewe10 May 22, 2024
a769cab
Put correct url on loan settlement form
chandachewe10 May 22, 2024
90dc70b
Disable editing nd deleteing loan repayments
chandachewe10 May 22, 2024
c06dfec
If payment is fully or partially paid add the status
chandachewe10 May 22, 2024
432d81d
Fixed Issue on deducting funds on editing loans
chandachewe10 May 22, 2024
5ab455a
Add amount on status SMS@
chandachewe10 May 24, 2024
4607fd7
Fix Issue on expenses
chandachewe10 May 24, 2024
b5a556f
Fixed Issue on outstanding principal fees and amount disbursed
chandachewe10 May 24, 2024
dc4670b
Fixed Issue on outstanding principal fees and amount disbursed
chandachewe10 May 24, 2024
0ee63b0
Merge pull request #19 from chandachewe10/dev
chandachewe10 May 26, 2024
fdd1d6a
Fixed Issue on unhandled mistype
chandachewe10 May 27, 2024
8873e71
Fixed Issue on Expenses Graphs
chandachewe10 May 27, 2024
385dcfe
Merge pull request #20 from chandachewe10/dev
chandachewe10 May 27, 2024
2964a72
Add default to match expression in LoanResources :bug:
hsemix May 31, 2024
f07946a
Merge pull request #21 from hsemix/develop
chandachewe10 May 31, 2024
2870031
Exclude all documents files
chandachewe10 Jun 27, 2024
9e3d57a
Search borrowers when adding loans
chandachewe10 Aug 13, 2024
56f981e
This PR fixes #23
chandachewe10 Aug 13, 2024
27c68bd
Export Borrowers and LoanTypes
chandachewe10 Aug 14, 2024
f272305
Added Bulk Exports
chandachewe10 Aug 14, 2024
0ca5583
Disable editing an already approved loan
chandachewe10 Aug 14, 2024
6f5763b
Add transaction reference on transactions table
chandachewe10 Aug 14, 2024
17e9b1f
Add transaction reference on transactions table
chandachewe10 Aug 14, 2024
e891733
Notify borrowers via email on each loan stage status
chandachewe10 Aug 14, 2024
18c5d3b
Add font-size, spacing of 1.5 and font-style of arial to PHP Word
chandachewe10 Aug 15, 2024
d620186
Add company Logo
chandachewe10 Aug 15, 2024
629cbed
Add Favicon
chandachewe10 Aug 16, 2024
501a711
Fix Issue on picking wrong borrower
chandachewe10 Aug 16, 2024
c108a9e
Default if status not found
chandachewe10 Aug 16, 2024
49a177c
Fix Issue on image PHP Word
chandachewe10 Aug 16, 2024
91942f0
Fix Issue on image PHP Word
chandachewe10 Aug 16, 2024
aeeb1d8
Fix Corrupt Loan Word Files
chandachewe10 Aug 17, 2024
8ecc1e6
Fix Issue on sending emails if third party is not active
chandachewe10 Aug 17, 2024
7f89d4d
Send the data ASAP
chandachewe10 Sep 9, 2024
071061b
Changing Added By Input in Creating Borrower form from TextInput to S…
bereank Nov 6, 2024
bbb645e
Remove dd() on Create Borrower resource and changing added_by relatio…
bereank Nov 6, 2024
60229b8
Capturing borrow creator
bereank Nov 8, 2024
f434b19
Use Auth
chandachewe10 Nov 8, 2024
4df1b40
Merge pull request #29 from bereank/main
chandachewe10 Nov 8, 2024
b112de1
feat: add cheques model and table migration
alfiandri Nov 27, 2024
c096da2
chore: make check_number to unique
alfiandri Nov 27, 2024
af576c0
chore: rename actvity_logs to activity_logs
alfiandri Nov 28, 2024
b8b8bd2
chore: add fields required for activity_logs
alfiandri Nov 28, 2024
5f64460
chore: publish sweetalert config
alfiandri Nov 28, 2024
09d719d
fix: activity log
alfiandri Nov 28, 2024
124074f
feat: add cheques module
alfiandri Nov 28, 2024
30d8dc0
feat: add integration tests for cheque module
alfiandri Nov 28, 2024
83647b1
fix: menu index for cheque
alfiandri Nov 28, 2024
dd7c152
feat: add e2e test for cheque crud module using laravel dusk
alfiandri Nov 28, 2024
c82817b
Merge branch 'main' into development
alfiandri Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.env
.env.backup
.env.production
.env.testing
.phpunit.result.cache
Homestead.json
Homestead.yaml
Expand Down
155 changes: 155 additions & 0 deletions app/Http/Controllers/ChequeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?php

namespace App\Http\Controllers;

use App\Http\Requests\ChequeRequest;
use App\Models\ActivityLog;
use App\Models\Cheque;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;

class ChequeController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$cheques = Cheque::all();
return view('cheques.index', compact('cheques'));
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('cheques.create');
}

/**
* Store a newly created resource in storage.
*/
public function store(ChequeRequest $request)
{
try {
DB::beginTransaction();

$cheque = Cheque::create($request->validated());
// Log the activity
$user = auth()->user();
$ipAddress = $request->ip();
$userAgent = $request->header('User-Agent');
$action = 'Cheque Created Successfully';
ActivityLog::create([
'user_id' => $user ? $user->id : null,
'ip_address' => $ipAddress,
'user_agent' => $userAgent,
'action' => $action,
'details' => 'Cheque ' . $cheque->check_number . ' Created Successfully by ' . $user->name
]);

DB::commit();

toast('Cheque ' . $cheque->check_number . ' added successfully', 'success');
return redirect()->route('cheque.index');
} catch (\Exception $e) {
DB::rollback();
dd($e);
toast('Whoops!!! Something went wrong ' . $e->getMessage(), 'error');
return redirect()->back();
}
}

/**
* Display the specified resource.
*/
public function show(string $cheque)
{
return view('cheques.show', [
'cheque' => Cheque::findOrFail($cheque)
]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(string $cheque)
{
return view('cheques.edit', [
'cheque' => Cheque::findOrFail($cheque)
]);
}

/**
* Update the specified resource in storage.
*/
public function update(ChequeRequest $request, Cheque $cheque)
{
try {
DB::beginTransaction();
$cheque->update($request->validated());
// Log the activity
$user = auth()->user();
$ipAddress = $request->ip();
$userAgent = $request->header('User-Agent');
$action = 'Cheque Updated Successfully';
ActivityLog::create([
'user_id' => $user ? $user->id : null,
'ip_address' => $ipAddress,
'user_agent' => $userAgent,
'action' => $action,
'details' => 'Cheque ' . $cheque->check_number . ' Updated Successfully by ' . $user->name
]);
DB::commit();

toast('Cheque ' . $cheque->check_number . ' updated successfully', 'success');
return redirect()->route('cheque.index');
} catch (\Exception $e) {
DB::rollBack();
toast('Whoops!!! Something went wrong ' . $e->getMessage(), 'error');
return redirect()->back();
}
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Cheque $cheque, Request $request)
{
try {
$check_password = Hash::check($request->password, auth()->user()->password);
if (!$check_password) {
toast('These credentials do not match our records', 'error');

return redirect()->back();
}
DB::beginTransaction();
$chequeNumber = $cheque->check_number;
$cheque->delete();

// Log the activity
$user = auth()->user();
$ipAddress = $request->ip();
$userAgent = $request->header('User-Agent');
$action = 'Cheque Deleted Successfully';
ActivityLog::create([
'user_id' => $user ? $user->id : null,
'ip_address' => $ipAddress,
'user_agent' => $userAgent,
'action' => $action,
'details' => 'Cheque ' . $chequeNumber . ' Deleted Successfully by ' . $user->name
]);
DB::commit();

toast('Cheque deleted successfully', 'success');
return redirect()->route('cheque.index');
} catch (\Exception $e) {
DB::rollBack();
toast('Whoops!!! Something went wrong ' . $e->getMessage(), 'error');
return redirect()->back();
}
}
}
49 changes: 49 additions & 0 deletions app/Http/Requests/ChequeRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ChequeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$chequeId = $this->cheque ? $this->cheque->id : null;

return [
'check_number' => 'required|string|unique:cheques,check_number,' . $chequeId,
'amount' => 'required|numeric|min:1',
'beneficiary' => 'required|string|max:255',
];
}

public function messages(): array
{
return [
'check_number.required' => 'Check number is required.',
'check_number.string' => 'Check number must be a valid string.',
'check_number.unique' => 'This check number is already in use. Please use a different one.',

'amount.required' => 'Amount is required.',
'amount.numeric' => 'Amount must be a numeric value.',
'amount.min' => 'Amount must be at least 1.',

'beneficiary.required' => 'Beneficiary is required.',
'beneficiary.string' => 'Beneficiary must be a valid string.',
'beneficiary.max' => 'Beneficiary cannot exceed 255 characters.',
];
}
}
6 changes: 1 addition & 5 deletions app/Models/ActvityLog.php → app/Models/ActivityLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class ActivityLog extends Model
'user_agent',
'action',
'details',

];




];
}
18 changes: 18 additions & 0 deletions app/Models/Cheque.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Cheque extends Model
{
use HasFactory, SoftDeletes;

protected $fillable = [
'check_number',
'amount',
'beneficiary',
];
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/dusk": "^8.2",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
Expand Down
Loading