PHP code example of 3mad / fee-collection
1. Go to this page and download the library: Download 3mad/fee-collection library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
3mad / fee-collection example snippets
Emad\FeeCollection\Providers\FeeCollectionServiceProvider::class
use Emad\FeeCollection\Traits\UseFeeable;
class User extends Model
{
use UseFeeable;
}
return [
'invoice_prefix' => 'I-',
'invoice_suffix' => '',
'receipt_prefix' => 'R-',
'receipt_suffix' => '',
'credit_note_prefix' => 'CN-',
'credit_note_suffix' => '',
'auto_invoice_on_receipt' => true,
'invoice_view' => 'fee-collection::pdf.invoice',
'receipt_view' => 'fee-collection::pdf.receipt',
'credit_note_view' => 'fee-collection::pdf.invoice',
'pdf' => [
'enabled' => env('FEE_COLLECTION_PDF_ENABLED', true),
'paper' => 'a4',
'orientation' => 'portrait',
'disk' => env('FEE_COLLECTION_PDF_DISK', 'public'),
'path' => env('FEE_COLLECTION_PDF_PATH', 'fee-collection/documents'),
],
];
$balance = $user->balance();
$user = User::factory()->create();
$user->createReceipt(1000, 'Initial credit', now());
$user->registerPayment(100, now()->addDays(1));
$user->registerPayment(100, now()->addDays(2));
$user->registerPayment(100, now()->addDays(3));
$user->createReceipt(1000, 'Initial credit', now(), autoInvoice: false);
$payment = $user->registerPayment(100, now()->addDays(10));
$payment->createInvoice('Test Invoice', now());
$payment->createReceipt('Test Receipt', now());
$payment = $user->registerPayment(1000, now()->addDays(1));
$children = $payment->split([
['amount' => 100, 'due_date' => now()->addDays(2)],
['amount' => 100, 'due_date' => now()->addDays(3)],
['amount' => 800, 'due_date' => now()->addDays(4)],
]);
$invoice = $payment->invoice;
$children = $payment->split([
['amount' => 500, 'due_date' => now()->addMonth()],
['amount' => 500, 'due_date' => now()->addMonths(2)],
]);
$invoice->createCreditNote('Customer requested installment split', now());
$payment = $user->registerPayment(1000, now()->addDay());
$invoice = $payment->createInvoice('Original invoice', now());
$creditNote = $invoice->createCreditNote('Invoice cancelled', now());
$payment = $user->registerPayment(1000, now()->addDay());
$invoice = $payment->createInvoice('Draft invoice', now());
$invoice->void('Created by mistake');
if ($payment->isOverdue()) {
// notify the customer
}
$overduePayments = $user->overduePayments();
$invoices = $user->generateDueInvoices();
use App\Models\User;
$schedule->call(function () {
User::each(fn (User $user) => $user->generateDueInvoices());
})->daily();
$paidStatements = $user->accountStatements()->where('status', 'paid')->get();
$creditedStatements = $user->accountStatements()->where('status', 'credited')->get();
$statements = $user->accountStatements()->orderByDesc('date')->get();
$balance = $user->balance();
'pdf' => [
'enabled' => env('FEE_COLLECTION_PDF_ENABLED', true),
'paper' => 'a4',
'orientation' => 'portrait',
'disk' => env('FEE_COLLECTION_PDF_DISK', 'public'),
'path' => env('FEE_COLLECTION_PDF_PATH', 'fee-collection/documents'),
],
'invoice_view' => 'fee-collection::pdf.invoice',
'receipt_view' => 'fee-collection::pdf.receipt',
'credit_note_view' => 'fee-collection::pdf.invoice',
$statement = $user->accountStatements()->latest('id')->first();
$pdf = $statement->toPdf();
return $pdf->download($statement->formatted_number . '.pdf');
$user->createReceipt(1000, 'Initial credit', now());
$user->createReceipt(1000, 'Initial credit', now(), autoInvoice: false);
$payment = $user->registerPayment(100, now()->addDays(10));
$overduePayments = $user->overduePayments();
$invoices = $user->generateDueInvoices();
$statements = $user->accountStatements()->orderByDesc('date')->get();
$balance = $user->balance();
$invoice = $payment->createInvoice('Original invoice', now());
$payment->createReceipt('Test Receipt', now());
$children = $payment->split([
['amount' => 500, 'due_date' => now()->addMonth()],
['amount' => 500, 'due_date' => now()->addMonths(2)],
]);
if ($payment->isOverdue()) {
// notify the customer
}
$creditNote = $invoice->createCreditNote('Invoice cancelled', now());
$invoice->void('Created by mistake');
$pdf = $statement->toPdf();
bash
php artisan vendor:publish --provider="Emad\FeeCollection\Providers\FeeCollectionServiceProvider" --tag=config
bash
php artisan vendor:publish --provider="Emad\FeeCollection\Providers\FeeCollectionServiceProvider" --tag=views
bash
php artisan migrate