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:
baodev0
2026-10-19 16:37:56 +07:00
co-authored by Claude Sonnet 5.5
parent ea9a53f742
commit 25f23d541e
134 changed files with 4926 additions and 185 deletions
@@ -2,6 +2,8 @@
namespace App\Http\Resources\Api\Service;
use App\Support\BillingCycleCatalog;
use App\Support\ProductBillingCycles;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -77,15 +79,16 @@ class ServiceResource extends JsonResource
];
})->values(),
'pricing' => $this->pricings
->sortBy(fn($p) => $periodMonths[$p->billing_cycle] ?? 999)
->filter(fn($p) => ProductBillingCycles::allows($this->product_type, $p->billing_cycle))
->sortBy(fn($p) => $periodMonths[$p->billing_cycle] ?? BillingCycleCatalog::monthsFor($p->billing_cycle) ?? 999)
->values()
->map(fn($p) => [
'id' => $p->id,
'name' => $billingCycleLabels[$p->billing_cycle] ?? $p->billing_cycle,
'name' => $billingCycleLabels[$p->billing_cycle] ?? BillingCycleCatalog::labelForCode($p->billing_cycle) ?? $p->billing_cycle,
'price' => (int) $p->price,
'price_sale' => $p->price_sale ? (int) $p->price_sale : null,
'period' => $periodMonths[$p->billing_cycle] ?? 1,
'period_unit' => $periodUnits[$p->billing_cycle] ?? 'month',
'period' => $periodMonths[$p->billing_cycle] ?? BillingCycleCatalog::monthsFor($p->billing_cycle) ?? 1,
'period_unit' => $periodUnits[$p->billing_cycle] ?? (BillingCycleCatalog::monthsFor($p->billing_cycle) ? $p->billing_cycle : 'month'),
]),
$this->mergeWhen($this->product_type === 'hosting', fn () => [
'service_plan' => $this->servicePlan?->summary(),