Skip to content

fix: allow 'mixed' invoice type in DB constraint#4

Open
coder-contrib-bot wants to merge 3 commits into
mainfrom
claude-code/fix-mixed-invoice-type/b9e2f7a1
Open

fix: allow 'mixed' invoice type in DB constraint#4
coder-contrib-bot wants to merge 3 commits into
mainfrom
claude-code/fix-mixed-invoice-type/b9e2f7a1

Conversation

@coder-contrib-bot
Copy link
Copy Markdown
Collaborator

Summary

  • Fix chk_credit_requires_customer DB constraint to allow 'mixed' invoice type (part cash, part credit)
  • Update backend validation, credit limit check, ledger recording, and customer balance tracking to handle 'mixed' like 'credit'
  • Add migration SQL (database/fix_mixed_invoice_type.sql) for live databases

Root Cause

The frontend supports a "Mixed" invoice type (part cash, part credit), but the database check constraint only accepted 'cash' or 'credit'. When a user created a mixed invoice, PostgreSQL rejected the insert with:

CHECK constraint "chk_credit_requires_customer" violated

Changes

File Change
database/schema.sql Updated constraint to include 'mixed'
database/fix_mixed_invoice_type.sql Migration for live DB
backend/app/services/sales_service.py Handle 'mixed' in validation, credit limit, ledger, and balance updates

Author


🤖 Generated with Claude Code

coder-contrib-bot and others added 3 commits May 25, 2026 14:59
The frontend supports 'mixed' invoices (part cash, part credit) but the
database check constraint `chk_credit_requires_customer` only accepted
'cash' or 'credit', causing 500 errors on mixed invoice creation.

Changes:
- Update DB constraint to allow 'mixed' type (requires customer_id)
- Update backend validation to handle 'mixed' like 'credit'
- Update credit limit check to apply to mixed invoices
- Update customer balance tracking for mixed invoices
- Update ledger recording for mixed invoices
- Add migration SQL for live databases

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant