UAT Notes / Quick Documentation
This is the upload screen + backend processor used to load Newspaper Branch GL actuals into the database from a CSV.
The front-end page is only the UI. The backend does the validation, duplicate checks, inserts, and logging.
| Frontend (UI only) |
/admin/newspaper/newspaper_branch_gl_upload.php
Shows the upload form, handles the progress bar, calls the backend via AJAX,
and prints the result message (success/warning/error).
|
|---|---|
| Backend (upload + processing) |
/admin/newspaper/newspaper_branch_gl_upload_backend.php
Accepts the CSV, checks if the same data was uploaded before, reads each row,
validates it, inserts into DB, and logs the upload batch.
|
Screen behavior
Validation (UI side)
If no file is selected and the user submits, the field is marked invalid and the message is shown: “Please choose a CSV file.”
The UI expects JSON but reads the response as text first, then runs:
JSON.parse(resp.trim())
If parsing fails (for example BOM/whitespace or a PHP warning), it shows the raw response as an error message.
Database tables used
Endpoint requirements
Duplicate upload protection important
The backend prevents uploading the same information twice by using two hashes:
The duplicate check uses normalized_hash, not file_hash. That means it still blocks duplicates even if: row order changes, extra spaces exist, or debit formatting changes (like 1,000 vs 1000.00).
If a duplicate is found
Batch ID
Each upload creates a batch id like: BYYYYMMDDHHMMSS_xxxxxxxx
Example: B20260128101530_a1b2c3d4
Header handling (flexible)
The backend reads the first row as headers and maps columns by name (case/space insensitive). It also uses fallback indexes if headers don’t match exactly.
| GL CODE | Header “GL CODE” or fallback index 0 |
|---|---|
| ENTERD_BRN | Header “ENTERD_BRN” or fallback index 2 |
| DATEOFTRAN | Header “DATEOFTRAN” or fallback index 5 |
Note for UAT
If someone uploads a CSV with missing/renamed headers, it may still process using fallback indexes, as long as the column order matches what the code expects.
Required fields per row
If any of these are empty, the row is skipped and counted as invalid.
Date parsing supported
If the date can’t be parsed, the row is skipped as invalid.
GL Description override forced
Even if the CSV contains a description, the backend forces: gl_description = "NEWSPAPER".
Month field creation
Debit cleanup
DEBITS is cleaned (commas/spaces removed) and cast to float. For the normalized hash, debits are normalized to 2 decimals so duplicates are detected reliably.
The backend tracks:
At the end it writes a record into tbl_admin_actual_branch_gl_newspaper_upload_log including the batch id, hashes, filename, file size, and totals.
{
"status": "success",
"batch_id": "...",
"total_rows": 123,
"inserted": 120,
"invalid": 2,
"failed": 1
}
Status can also be info (duplicate blocked) or error (upload/validation issue).