Fix semester context, attendance rosters, and billing workflows
- load global semester helpers consistently and use date-based semester defaults - fix grading and daily attendance duplicate student/section rows - keep attendance violations scoped to the current semester by default - update invoice, refund, discount, payment, and financial aid flows - add configuration cleanup migrations for duplicate calendar/semester keys - refresh parent registration/report-card and print request handling - update related models, services, views, cron notes, and test coverage
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Database\ConnectionInterface;
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
use CodeIgniter\Validation\ValidationInterface;
|
||||
|
||||
class RefundModel extends Model
|
||||
{
|
||||
@@ -50,6 +52,39 @@ class RefundModel extends Model
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
private array $refundColumns = [];
|
||||
|
||||
public function __construct(?ConnectionInterface $db = null, ?ValidationInterface $validation = null)
|
||||
{
|
||||
parent::__construct($db, $validation);
|
||||
|
||||
$this->refundColumns = $this->getTableColumns($this->table);
|
||||
$this->allowedFields = array_values(array_filter(
|
||||
$this->allowedFields,
|
||||
fn (string $field): bool => in_array($field, $this->refundColumns, true)
|
||||
));
|
||||
|
||||
foreach (array_keys($this->validationRules) as $field) {
|
||||
if (!in_array($field, $this->allowedFields, true)) {
|
||||
unset($this->validationRules[$field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getTableColumns(string $table): array
|
||||
{
|
||||
try {
|
||||
return $this->db->getFieldNames($table);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', '[RefundModel] Could not read table columns for {table}: {error}', [
|
||||
'table' => $table,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total approved refund for a parent in a specific school year.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user