-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from liberu-billing/sweep/Add-Late-Fee-Config…
…uration-and-Automated-Late-Fee-Calculation-for-Invoices Add Late Fee Configuration and Automated Late Fee Calculation for Invoices
- Loading branch information
Showing
5 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
|
||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use App\Traits\HasTeam; | ||
|
||
class LateFeeConfiguration extends Model | ||
{ | ||
use HasFactory; | ||
use HasTeam; | ||
|
||
protected $fillable = [ | ||
'team_id', | ||
'fee_type', | ||
'fee_amount', | ||
'grace_period_days', | ||
'max_fee_amount', | ||
'is_compound', | ||
'frequency', | ||
]; | ||
|
||
protected $casts = [ | ||
'is_compound' => 'boolean', | ||
'fee_amount' => 'decimal:2', | ||
'max_fee_amount' => 'decimal:2', | ||
'grace_period_days' => 'integer', | ||
]; | ||
|
||
public static function getFrequencyOptions() | ||
{ | ||
return [ | ||
'one-time' => 'One Time', | ||
'daily' => 'Daily', | ||
'weekly' => 'Weekly', | ||
'monthly' => 'Monthly' | ||
]; | ||
} | ||
|
||
public static function getFeeTypeOptions() | ||
{ | ||
return [ | ||
'percentage' => 'Percentage', | ||
'fixed' => 'Fixed Amount' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
database/migrations/2024_01_10_000001_create_late_fee_configurations_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
|
||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('late_fee_configurations', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('team_id')->constrained()->onDelete('cascade'); | ||
$table->enum('fee_type', ['percentage', 'fixed']); | ||
$table->decimal('fee_amount', 10, 2); | ||
$table->integer('grace_period_days')->default(0); | ||
$table->decimal('max_fee_amount', 10, 2)->nullable(); | ||
$table->boolean('is_compound')->default(false); | ||
$table->enum('frequency', ['one-time', 'daily', 'weekly', 'monthly'])->default('one-time'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('late_fee_configurations'); | ||
} | ||
}; |
25 changes: 25 additions & 0 deletions
25
database/migrations/2024_01_10_000002_add_late_fee_fields_to_invoices.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
|
||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::table('invoices', function (Blueprint $table) { | ||
$table->decimal('late_fee_amount', 10, 2)->default(0); | ||
$table->timestamp('last_late_fee_date')->nullable(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table('invoices', function (Blueprint $table) { | ||
$table->dropColumn(['late_fee_amount', 'last_late_fee_date']); | ||
}); | ||
} | ||
}; |