feat(billing): renewals, coupons, VAT numbering, billing cycles and invoice payment tracking
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ea9a53f742
commit
25f23d541e
@@ -14,6 +14,7 @@ use App\Models\Invoice;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceAddon;
|
||||
use App\Services\ActivityLogger;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -92,6 +93,7 @@ trait ActivatesPaidInvoices
|
||||
? $service->expires_at
|
||||
: now();
|
||||
$expiresAt = Carbon::parse($baseDate)->addMonths($months);
|
||||
$previousExpiresAt = $service->expires_at;
|
||||
|
||||
$service->update([
|
||||
'status' => 'active',
|
||||
@@ -99,6 +101,21 @@ trait ActivatesPaidInvoices
|
||||
'suspended_at' => null,
|
||||
]);
|
||||
|
||||
app(ActivityLogger::class)->log(
|
||||
event: 'renewed',
|
||||
logName: 'Service',
|
||||
description: "Gia hạn dịch vụ #{$service->id} thêm {$months} tháng (hóa đơn #{$invoice->invoice_number})",
|
||||
subject: $service,
|
||||
oldValues: ['expires_at' => $previousExpiresAt?->toDateTimeString()],
|
||||
newValues: [
|
||||
'expires_at' => $expiresAt->toDateTimeString(),
|
||||
'months' => $months,
|
||||
'invoice_number' => $invoice->invoice_number,
|
||||
'amount' => (int) $invoice->total,
|
||||
'payment_method' => $invoice->payment_method,
|
||||
],
|
||||
);
|
||||
|
||||
if ($service->vm_id) {
|
||||
dispatch(new VMJobs((int) $service->vm_id, 'Start', false))->delay(now()->addSeconds(5));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user