fix enrollment, invoice, payment and financila aid
This commit is contained in:
@@ -753,8 +753,9 @@ final class SchoolYearClosingService
|
||||
];
|
||||
|
||||
if ($this->db->fieldExists('description', 'invoices')) {
|
||||
$label = $amount > 0 ? 'Balance carried over' : 'Credit carried over';
|
||||
$payload['description'] = "{$label} from previous school year {$sourceYear}.";
|
||||
$payload['description'] = $amount >= 0
|
||||
? "Carry over balance from last year {$sourceYear}"
|
||||
: "Credit carry over from last year {$sourceYear}";
|
||||
}
|
||||
|
||||
$invoiceModel = new InvoiceModel();
|
||||
@@ -763,7 +764,17 @@ final class SchoolYearClosingService
|
||||
throw new RuntimeException('Unable to create carry-forward invoice: ' . json_encode($invoiceModel->errors()));
|
||||
}
|
||||
|
||||
return (int) $invoiceId;
|
||||
$invoiceId = (int) $invoiceId;
|
||||
$description = (string) ($payload['description'] ?? "Carry over balance from last year {$sourceYear}");
|
||||
try {
|
||||
$ledgerService = new \App\Libraries\InvoiceLedgerService();
|
||||
$ledgerService->issueCarryForwardInvoiceLine($invoiceId, $amount, $description);
|
||||
$ledgerService->recalculateInvoice($invoiceId);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Carry-forward invoice line issuance failed for invoice ' . $invoiceId . ': ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $invoiceId;
|
||||
}
|
||||
|
||||
private function carryForwardInvoiceNumber(int $itemId, int $parentId, string $sourceYear, string $targetYear): string
|
||||
|
||||
Reference in New Issue
Block a user