Skip to content

feat: complete product actions & fix sales returns#5

Open
coder-contrib-bot wants to merge 6 commits into
mainfrom
claude-code/product-actions-sales-fix/r8k2m5w1
Open

feat: complete product actions & fix sales returns#5
coder-contrib-bot wants to merge 6 commits into
mainfrom
claude-code/product-actions-sales-fix/r8k2m5w1

Conversation

@coder-contrib-bot
Copy link
Copy Markdown
Collaborator

Summary

  • Product Screen Actions: Implement all button actions in product detail drawer:

    • Adjust Stock (IN/OUT with warehouse selection)
    • Transfer Stock between warehouses (waste OUT + opening_stock IN)
    • Update Price with live profit margin preview
    • View Analytics with AI demand forecast
    • Low Stock Alerts dialog (notification icon)
  • Sales Returns Backend: Add returned_quantity tracking per invoice item via subquery aggregation on sales_return_items. Full return flow with inventory restoration, cash refund, and ledger entries.

  • Sales Frontend: Add InvoiceItemModel.returnedQuantity and returnableQuantity getter. Sales repository updated with return and items endpoints.

  • Database: Add migration for mixed invoice type constraint.

Files Changed

Backend

  • backend/app/routers/sales.py — returned_quantity subquery in items endpoint
  • backend/app/schemas/sales.py — SalesReturnCreate/Response schemas
  • backend/app/repositories/sales_repo.py — return CRUD methods
  • backend/app/services/sales_service.py — process_return with full accounting
  • backend/app/services/inventory_service.py — record_return method
  • backend/app/services/ledger_service.py — record_sales_return entries
  • database/fix_mixed_invoice_type.sql — constraint migration

Frontend

  • frontend/lib/features/products/data/products_repository.dart — adjustStock method
  • frontend/lib/features/products/presentation/product_detail_drawer.dart — all action implementations
  • frontend/lib/features/products/presentation/products_page.dart — low stock alerts
  • frontend/lib/features/sales/data/sales_repository.dart — returnedQuantity, returns API

Note

The sale_detail_drawer.dart changes (didUpdateWidget refresh, operations history in print) are implemented locally but exceeded the push size limit. Those changes include:

  • Auto-refresh drawer on invoice changes via didUpdateWidget
  • Prevent returning already-returned quantities
  • Operations history and return operations in invoice print

Author

🤖 Generated with Claude Code

coder-contrib-bot and others added 6 commits May 26, 2026 00:57
- Add subquery to aggregate returned quantities per invoice item
- Add SalesReturnCreate/Response schemas for return flow
- Add sales return repository methods
- Implement process_return in SalesService with inventory/ledger integration
- Add record_return to InventoryService
- Add record_sales_return to LedgerService
- Add fix for mixed invoice type constraint

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>
…sales

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Adjust Stock (IN/OUT with warehouse selection)
- Transfer Stock between warehouses
- Update Price with live margin preview
- View Analytics with AI demand forecast

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