Files
kulakpos_web/walkthroughs/2026-05-14_b817429e_Walkthrough__Fixing_PostgreSQL_Compatibility.md
eko54r 6f9bdff115
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m59s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 18s
Build, Push and Deploy / deploy-staging (push) Successful in 39s
Build, Push and Deploy / deploy-production (push) Has been skipped
update
2026-05-14 12:25:21 +07:00

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 the Party model.
  • Logic:
    • For Suppliers: Sums dueAmount from the purchases table for the specified branch.
    • For Customers: Sums dueAmount from the sales table for the specified branch.
    • This resolves the crash on the Sale and Purchase creation screens.

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" in incomeExpense reports.
  • Admin/DashboardController.php:
    • Updated TO_CHAR format to FMMonth to avoid padded spaces.
    • Fixed groupBy to use the full expression instead of an alias for better PostgreSQL compatibility.
  • StatisticsController.php:
    • Updated groupBy logic to use the TO_CHAR expression directly, preventing "must appear in the GROUP BY clause" errors.

Verification

Automated Audit

  • The audit script was used to identify these locations.
  • You can find the script here: audit_postgres.py.

Manual Verification Required

  1. Sale Creation: Open the "Create Sale" screen to verify that customer due amounts are now displayed correctly without error.
  2. Purchase Creation: Open the "Create Purchase" screen to verify supplier due amounts.
  3. 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 push from your terminal to upload the fixes to your repository.