Conversation
… account loading, error diagnostics Agent-Logs-Url: https://github.com/moded12/acc3/sessions/8a7280b1-ac34-4071-b965-7e7c4c1479e7 Co-authored-by: moded12 <162719285+moded12@users.noreply.github.com>
Agent-Logs-Url: https://github.com/moded12/acc3/sessions/8a7280b1-ac34-4071-b965-7e7c4c1479e7 Co-authored-by: moded12 <162719285+moded12@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix journal entry save failures and improve application flow
Fix journal entry 500: PHP 8 method signature conflict in JournalController + business error handling
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POST /journal/store(and all journal write endpoints) always returned a generic 500 becauseJournalControllerfailed to load — itspost(array $params)method conflicted with the inheritedController::post(string $key)helper, which is a fatal error in PHP 8 (was only a warning in PHP 7). The error was caught exclusively by the global handler before any controller code ran.Critical fix
JournalController::post()→postEntry()— eliminates the PHP 8 fatal signature incompatibilityindex.phproute updated:JournalController@postEntryController hardening (
JournalController.php)requirePermission+verifyCsrfinside thetry/catchblock so DB errors during auth/CSRF checks are caught and return a structured 500 withdebug_idinstead of leaking to the global handlerBusiness errors → 422 instead of 500 (
JournalService.php)create()andupdate()moved before the transaction — returns['success' => false, 'errors' => [...]]instead of throwingRuntimeExceptioninside the transactionpost()/cancel()(double-post, closed period, imbalanced totals, etc.) converted fromthrow new \RuntimeExceptionto structured return arrays — no more 500s for expected business rule violationsGlobal error handler (
index.php)debug_id(e.g.SRV-A3F2C1D8), logs it, and includes it in JSON/HTML error responses — diagnosable without leaking sensitive details to end usersAccount dropdown fix (
main.php)openNewJournalInline()madeasync— fetches/accounts/leafwhenERP_DATA.accountsis empty (fixes empty dropdown when opening "New Journal" from the dashboard or any page other than/journal)Frontend resilience (
erp.js)submitJournalEntry: displays theerrors[]array from 422 responses; showsdebug_idon 500s; form is never closed on failure — state is preservedinitJournalForm: falls back toERP_DATA.accountsif the caller passes an empty arrayOriginal prompt
Create a comprehensive Pull Request in repository moded12/acc3 to fully resolve the journal entry failures and improve the application in two phases, based on the full debugging history below.
Repository:
Environment/context:
Primary business problem:
The “New Journal Entry” flow had multiple failures. Account dropdowns were previously empty, later fixed to display accounts. Now users can select accounts and balance the journal, but saving still fails with POST /20/acc3/journal/store returning HTTP 500. Current JSON response is a generic error like:
{"success":false,"message":"حدث خطأ غير متوقع في الخادم. يرجى المحاولة لاحقاً."}
Root-cause investigation history and verified facts:
PR goals
Phase 1 — Fix the journal flow from the roots
Please perform full root-cause analysis and implement the complete fix so that:
Specifically inspect and fix as needed:
Also explicitly verify these possible causes and fix whichever are real:
Implementation expectations for Phase 1:
This pull request was created from Copilot chat.