add refund logic and fix books inventory logic
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Failing after 1m20s

This commit is contained in:
root
2026-08-22 13:44:25 -04:00
parent 23d1cbb64c
commit d906a915d6
45 changed files with 4711 additions and 442 deletions
+5 -1
View File
@@ -30,7 +30,12 @@ protected $table = 'inventory_items';
'condition',
'isbn',
'edition',
'author',
'sku',
'is_active',
'retired_at',
'isbn_edition_key',
'sku_normalized',
'notes',
// audit
@@ -49,7 +54,6 @@ protected $table = 'inventory_items';
'type' => 'required|in_list[classroom,book,office,kitchen]',
'name' => 'required|min_length[2]',
'quantity' => 'permit_empty|integer',
'unit_price' => 'permit_empty|decimal',
'school_year' => 'required|string|max_length[16]',
];
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class InventoryItemYearModel extends Model
{
protected $table = 'inventory_item_years';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useTimestamps = true;
protected $allowedFields = [
'inventory_item_id',
'school_year_id',
'school_year',
'opening_quantity',
'charge_price_cents',
'currency',
'price_confirmed',
'system_closing_quantity',
'counted_closing_quantity',
'variance_quantity',
'status',
'source_item_year_id',
'closing_batch_id',
'created_by',
'updated_by',
];
protected $validationRules = [
'inventory_item_id' => 'required|integer',
'school_year' => 'required|string|max_length[16]',
'opening_quantity' => 'required|integer',
'charge_price_cents' => 'required|integer|greater_than_equal_to[0]',
'currency' => 'required|alpha|max_length[3]',
'price_confirmed' => 'required|in_list[0,1]',
'status' => 'required|in_list[open,reconciled,carried,closed]',
];
}
+3 -1
View File
@@ -15,9 +15,11 @@ class InventoryMovementModel extends Model
protected $useTimestamps = true;
protected $allowedFields = [
'item_id','qty_change','movement_type','reason','note',
'item_id','item_year_id','qty_change','movement_type','reason','note',
'semester','school_year',
'performed_by','teacher_id','student_id','class_section_id',
'idempotency_key','reversal_of_movement_id','status','reversed_at',
'reversed_by','source_type','source_id',
];
protected $validationRules = [
'school_year' => 'required|string|max_length[9]',
+5
View File
@@ -35,6 +35,9 @@ class SchoolYearModel extends Model
'registration_launch_approved_by',
'registration_email_template_version',
'fall_makeup_exam_on',
'total_instructional_weeks',
'annual_fee_includes_books',
'withdrawal_policy_version',
'previous_school_year_id',
'next_school_year_id',
'activated_at',
@@ -65,6 +68,8 @@ class SchoolYearModel extends Model
'registration_launch_approved_at' => 'permit_empty|valid_date[Y-m-d H:i:s]',
'registration_launch_approved_by' => 'permit_empty|integer',
'fall_makeup_exam_on' => 'permit_empty|valid_date[Y-m-d]',
'total_instructional_weeks' => 'permit_empty|integer|greater_than[0]',
'annual_fee_includes_books' => 'permit_empty|in_list[0,1]',
];
public function active(): ?array
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class StudentBookIssueModel extends Model
{
protected $table = 'student_book_issues';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useTimestamps = true;
protected $allowedFields = [
'student_id', 'enrollment_id', 'parent_id', 'inventory_item_id',
'inventory_item_year_id', 'school_year', 'class_section_id', 'quantity',
'unit_charge_price_cents', 'total_charge_cents', 'distribution_movement_id',
'idempotency_key', 'status', 'issued_at', 'issued_by', 'reversed_at',
'reversed_by', 'reversal_reason', 'reversal_quantity', 'reversal_movement_id',
];
protected $validationRules = [
'student_id' => 'required|integer',
'enrollment_id' => 'required|integer',
'parent_id' => 'required|integer',
'inventory_item_id' => 'required|integer',
'inventory_item_year_id' => 'required|integer',
'school_year' => 'required|string|max_length[16]',
'quantity' => 'required|integer|greater_than[0]',
'unit_charge_price_cents' => 'required|integer|greater_than[0]',
'total_charge_cents' => 'required|integer|greater_than[0]',
'idempotency_key' => 'required|string|max_length[160]',
'status' => 'required|in_list[issued,reversed]',
'issued_at' => 'required|valid_date[Y-m-d H:i:s]',
];
}
@@ -0,0 +1,42 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class WithdrawalFinancialCalculationModel extends Model
{
protected $table = 'withdrawal_financial_calculations';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useTimestamps = true;
protected $allowedFields = [
'version', 'enrollment_id', 'student_id', 'parent_id', 'invoice_id',
'school_year', 'policy_version', 'annual_fee_includes_books',
'school_year_start_date', 'enrollment_date', 'withdrawal_request_date',
'total_instructional_weeks', 'total_chargeable_days',
'studied_calendar_days', 'studied_weeks', 'annual_fee_allocation_cents',
'issued_book_charge_cents', 'annual_instruction_cents',
'earned_tuition_cents', 'other_charge_cents', 'retained_charge_cents',
'original_invoice_charge_cents', 'invoice_adjustment_cents',
'adjusted_invoice_charge_cents',
'valid_payment_cents', 'completed_payout_cents', 'open_reservation_cents',
'refundable_credit_cents', 'new_refund_request_cents', 'balance_due_cents',
'book_evidence_json', 'explanation_json', 'calculation_hash',
'active_posted_key', 'books_discount_eligible', 'status', 'superseded_by_id',
'override_reason', 'overridden_at', 'overridden_by',
'calculated_by', 'posted_by', 'calculated_at', 'posted_at',
];
protected $validationRules = [
'version' => 'required|integer|greater_than[0]',
'enrollment_id' => 'required|integer',
'student_id' => 'required|integer',
'parent_id' => 'required|integer',
'school_year' => 'required|string|max_length[16]',
'annual_fee_includes_books' => 'required|in_list[1]',
'total_instructional_weeks' => 'required|integer|greater_than[0]',
'status' => 'required|in_list[preview,posted,superseded,requires_review]',
];
}