fix: correct column/table names in daily_operations_report#14
Open
coder-contrib-bot wants to merge 1 commit into
Open
fix: correct column/table names in daily_operations_report#14coder-contrib-bot wants to merge 1 commit into
coder-contrib-bot wants to merge 1 commit into
Conversation
The daily_operations_report endpoint was using incorrect column and table names that don't match the actual database schema, causing a 500 error. Fixes: - sales_invoices: id → invoice_id, created_at → invoice_date - sale_items → sales_invoice_items, quantity → sold_quantity - purchase_invoices: id → purchase_invoice_id, created_at → purchase_date - expenses: id → expense_id, category → expense_category - payments table → customer_payments/supplier_payments (separate tables) - customers: id → customer_id, created_at → created_date - products: id → product_id, name → product_name - returns: use sales_returns table instead of cancelled sales_invoices Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary\n\nFixes the
GET /api/reports/daily-operationsendpoint which was returning a 500 Internal Server Error due to SQL queries referencing non-existent columns and tables.\n\nRoot cause: The raw SQL queries indaily_operations_reportused generic column names (id,created_at,category) and table names (sale_items,payments) that don't match the actual database schema.\n\nFixes applied:\n-sales_invoices:id→invoice_id,created_at→invoice_date\n-sale_items→sales_invoice_items,quantity→sold_quantity\n-purchase_invoices:id→purchase_invoice_id,created_at→purchase_date\n-expenses:id→expense_id,category→expense_category\n-payments(non-existent table) →customer_payments/supplier_payments\n-customers:id→customer_id,created_at→created_date\n-products:id→product_id,name→product_name\n- Returns query: usesales_returnstable instead of filteringsales_invoicesby a non-existentstatuscolumn\n\n## Test plan\n\n- [ ] Restart the backend container and hitGET /api/reports/daily-operations\n- [ ] Verify the endpoint returns a 200 with the expected JSON structure\n- [ ] Verify sales, purchases, expenses, returns, payments, and top products data is populated correctly from the database\n\n---\n\nAuthor:GIT_AUTHOR_NAME=Contrib,GIT_AUTHOR_EMAIL=coder.github.robot@gmail.com\n\nThis PR was generated by an AI Agent (Claude Code, Opus 4.7).\n\n🤖 Generated with Claude Code"