fix gitlab tests
This commit is contained in:
@@ -5,12 +5,15 @@ namespace App\Services\Invoices;
|
||||
use App\Models\Enrollment;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Student;
|
||||
use App\Models\StudentClass;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InvoiceManagementService
|
||||
{
|
||||
public function __construct(private InvoiceConfigService $config) {}
|
||||
public function __construct(private InvoiceConfigService $config)
|
||||
{
|
||||
}
|
||||
|
||||
public function getManagementData(?string $schoolYear): array
|
||||
{
|
||||
@@ -44,7 +47,7 @@ class InvoiceManagementService
|
||||
->all();
|
||||
|
||||
$parentData = [
|
||||
'parent_name' => trim(($parent['firstname'] ?? '').' '.($parent['lastname'] ?? '')),
|
||||
'parent_name' => trim(($parent['firstname'] ?? '') . ' ' . ($parent['lastname'] ?? '')),
|
||||
'parent_id' => (int) $parent['id'],
|
||||
'enrolledKids' => [],
|
||||
'withdrawnKids' => [],
|
||||
@@ -57,7 +60,7 @@ class InvoiceManagementService
|
||||
|
||||
$invoices = Invoice::getInvoicesByParentId((int) $parent['id'], $schoolYear);
|
||||
foreach ($invoices as $invoice) {
|
||||
if (! $invoice) {
|
||||
if (!$invoice) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -65,13 +68,13 @@ class InvoiceManagementService
|
||||
$parentData['last_updated'] = $invoice['updated_at'] ?? null;
|
||||
$parentData['invoice_id'] = $invoice['id'] ?? null;
|
||||
|
||||
if (! empty($invoice['issue_date'])) {
|
||||
if (!empty($invoice['issue_date'])) {
|
||||
$tzName = $this->config->getTimezone();
|
||||
$parentData['invoice_date'] = (new \DateTimeImmutable($invoice['issue_date'], new \DateTimeZone('UTC')))
|
||||
->setTimezone(new \DateTimeZone($tzName))
|
||||
->format('Y-m-d H:i:s');
|
||||
} else {
|
||||
$parentData['invoice_date'] = ! empty($invoice['updated_at'])
|
||||
$parentData['invoice_date'] = !empty($invoice['updated_at'])
|
||||
? date('Y-m-d H:i:s', strtotime($invoice['updated_at']))
|
||||
: null;
|
||||
}
|
||||
@@ -112,7 +115,7 @@ class InvoiceManagementService
|
||||
|
||||
foreach ($enrollments as $enrollment) {
|
||||
$kid = [
|
||||
'name' => trim(($student['firstname'] ?? '').' '.($student['lastname'] ?? '')),
|
||||
'name' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
|
||||
'grade' => $grade,
|
||||
'tuition_fee' => (float) ($enrollment['tuition_fee'] ?? 0),
|
||||
];
|
||||
@@ -133,7 +136,7 @@ class InvoiceManagementService
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($parentData['enrolledKids']) || ! empty($parentData['withdrawnKids'])) {
|
||||
if (!empty($parentData['enrolledKids']) || !empty($parentData['withdrawnKids'])) {
|
||||
$invoiceData[] = $parentData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user