2.6 KiB
2.6 KiB
Fix: BadMethodCallException & PostgreSQL Compatibility Audit
I have resolved the BadMethodCallException reported in the AcnooSaleController and performed a final "automated" audit to fix remaining PostgreSQL compatibility issues.
Changes Made
1. Fixed Missing dueForBranch Method
- File: Party.php
- Fix: Implemented the
dueForBranch($branchId = null)method in thePartymodel. - Logic:
- For Suppliers: Sums
dueAmountfrom thepurchasestable for the specified branch. - For Customers: Sums
dueAmountfrom thesalestable for the specified branch. - This resolves the crash on the Sale and Purchase creation screens.
- For Suppliers: Sums
2. Automated PostgreSQL Audit & Fixes
I ran an audit script to find remaining MySQL-specific syntax or unquoted mixed-case identifiers.
- AcnooBranchController.php: Quoted
"lossProfit"inincomeExpensereports. - Admin/DashboardController.php:
- Updated
TO_CHARformat toFMMonthto avoid padded spaces. - Fixed
groupByto use the full expression instead of an alias for better PostgreSQL compatibility.
- Updated
- StatisticsController.php:
- Updated
groupBylogic to use theTO_CHARexpression directly, preventing "must appear in the GROUP BY clause" errors.
- Updated
Verification
Automated Audit
- The audit script was used to identify these locations.
- You can find the script here: audit_postgres.py.
Manual Verification Required
- Sale Creation: Open the "Create Sale" screen to verify that customer due amounts are now displayed correctly without error.
- Purchase Creation: Open the "Create Purchase" screen to verify supplier due amounts.
- Reports: Check the Branch Income/Expense report and Admin Dashboard to ensure charts are rendering correctly.
Note
I have committed these changes locally. Please run
git pushfrom your terminal to upload the fixes to your repository.