update api and add more features

This commit is contained in:
root
2026-06-04 02:24:41 -04:00
parent fa6c9519a0
commit 4e33882ac7
131 changed files with 34596 additions and 340 deletions
@@ -0,0 +1,33 @@
<?php
namespace App\Http\Resources\Fees;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ChargeActionResource extends JsonResource
{
public function toArray(Request $request): array
{
return array_filter([
'ok' => (bool) ($this->resource['ok'] ?? false),
'charge_type' => $this->resource['charge_type'] ?? null,
'id' => isset($this->resource['id']) ? (int) $this->resource['id'] : null,
'parent_id' => isset($this->resource['parent_id']) ? (int) $this->resource['parent_id'] : null,
'student_id' => isset($this->resource['student_id']) ? (int) $this->resource['student_id'] : null,
'invoice_id' => isset($this->resource['invoice_id']) ? (int) $this->resource['invoice_id'] : null,
'event_id' => isset($this->resource['event_id']) ? (int) $this->resource['event_id'] : null,
'event_name' => $this->resource['event_name'] ?? null,
'amount' => isset($this->resource['amount']) ? (float) $this->resource['amount'] : null,
'status' => $this->resource['status'] ?? null,
'payment_status' => $this->resource['payment_status'] ?? null,
'participation_status' => $this->resource['participation_status'] ?? null,
'cancellation_status' => $this->resource['cancellation_status'] ?? null,
'account_credit_charge_id' => isset($this->resource['account_credit_charge_id'])
? (int) $this->resource['account_credit_charge_id']
: null,
'message' => $this->resource['message'] ?? null,
'error' => $this->resource['error'] ?? null,
], fn ($value) => $value !== null);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Resources\Fees;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ChargeListResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'parent_id' => (int) ($this->resource['parent_id'] ?? 0),
'school_year' => $this->resource['school_year'] ?? null,
'extra_charges' => $this->resource['extra_charges'] ?? [],
'event_charges' => $this->resource['event_charges'] ?? [],
];
}
}
@@ -0,0 +1,53 @@
<?php
namespace App\Http\Resources\Fees;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class FeeFamilyBalanceResource extends JsonResource
{
public function toArray(Request $request): array
{
$charges = $this->resource['charges'] ?? [];
$credits = $this->resource['credits'] ?? [];
$students = $this->resource['students'] ?? [];
return [
'parent_id' => (int) ($this->resource['parent_id'] ?? 0),
'school_year' => $this->resource['school_year'] ?? null,
'charges' => [
'tuition' => (float) ($charges['tuition'] ?? 0),
'extra_charges' => (float) ($charges['extra_charges'] ?? 0),
'event_charges' => (float) ($charges['event_charges'] ?? 0),
'late_fees' => (float) ($charges['late_fees'] ?? 0),
'total' => (float) ($charges['total'] ?? 0),
],
'credits' => [
'discounts' => (float) ($credits['discounts'] ?? 0),
'total' => (float) ($credits['total'] ?? 0),
],
'payments' => (float) ($this->resource['payments'] ?? 0),
'refunds_applied' => (float) ($this->resource['refunds_applied'] ?? 0),
'remaining_balance' => (float) ($this->resource['remaining_balance'] ?? 0),
'account_credit' => (float) ($this->resource['account_credit'] ?? 0),
'students' => array_map(function (array $row): array {
return [
'student_id' => $row['student_id'] ?? null,
'student_name' => $row['student_name'] ?? null,
'grade' => $row['grade'] ?? null,
'enrollment_status' => $row['enrollment_status'] ?? null,
'tuition' => (float) ($row['tuition'] ?? 0),
'extra_charges' => (float) ($row['extra_charges'] ?? 0),
'event_charges' => (float) ($row['event_charges'] ?? 0),
'total_charges' => (float) ($row['total_charges'] ?? 0),
'payments_applied' => (float) ($row['payments_applied'] ?? 0),
'credits_applied' => (float) ($row['credits_applied'] ?? 0),
'refunds_applied' => (float) ($row['refunds_applied'] ?? 0),
'remaining_balance' => (float) ($row['remaining_balance'] ?? 0),
'account_credit' => (float) ($row['account_credit'] ?? 0),
];
}, $students),
];
}
}
@@ -9,6 +9,8 @@ class FeeRefundResource extends JsonResource
{
public function toArray(Request $request): array
{
$students = $this->resource['students'] ?? [];
return [
'refund_amount' => (float) ($this->resource['refund_amount'] ?? 0),
'total_paid' => (float) ($this->resource['total_paid'] ?? 0),
@@ -16,6 +18,20 @@ class FeeRefundResource extends JsonResource
'school_end_date' => $this->resource['school_end_date'] ?? null,
'weeks_of_study' => (float) ($this->resource['weeks_of_study'] ?? 0),
'withdrawn_students' => (int) ($this->resource['withdrawn_students'] ?? 0),
'students' => array_map(function (array $row): array {
return [
'student_id' => $row['student_id'] ?? null,
'grade' => $row['grade'] ?? null,
'grade_level' => $row['grade_level'] ?? null,
'fee_category' => $row['fee_category'] ?? null,
'tuition_fee' => (float) ($row['tuition_fee'] ?? 0),
'withdrawal_date' => $row['withdrawal_date'] ?? null,
'weeks_remaining' => (int) ($row['weeks_remaining'] ?? 0),
'refund_amount' => (float) ($row['refund_amount'] ?? 0),
'eligible' => (bool) ($row['eligible'] ?? false),
'reason' => $row['reason'] ?? null,
];
}, $students),
];
}
}
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Resources\Fees;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class FeeTuitionBreakdownResource extends JsonResource
{
public function toArray(Request $request): array
{
$students = $this->resource['students'] ?? [];
$fees = $this->resource['fees'] ?? [];
return [
'school_year' => $this->resource['school_year'] ?? null,
'family_total' => (float) ($this->resource['family_total'] ?? 0),
'billable_count' => (int) ($this->resource['billable_count'] ?? 0),
'non_billable_count' => (int) ($this->resource['non_billable_count'] ?? 0),
'fees' => [
'first_student_fee' => (float) ($fees['first_student_fee'] ?? 0),
'second_student_fee' => (float) ($fees['second_student_fee'] ?? 0),
'youth_fee' => (float) ($fees['youth_fee'] ?? 0),
],
'students' => array_map(function (array $row): array {
return [
'student_id' => $row['student_id'] ?? null,
'student_name' => $row['student_name'] ?? null,
'grade' => $row['grade'] ?? null,
'grade_level' => $row['grade_level'] ?? null,
'enrollment_status' => $row['enrollment_status'] ?? null,
'admission_status' => $row['admission_status'] ?? null,
'fee_category' => $row['fee_category'] ?? null,
'tuition_fee' => (float) ($row['tuition_fee'] ?? 0),
'discount_amount' => (float) ($row['discount_amount'] ?? 0),
'final_tuition_amount' => (float) ($row['final_tuition_amount'] ?? 0),
];
}, $students),
];
}
}