Db interface invoices #179

Merged
JoaoTF03 merged 16 commits from db-interface-invoices into main 2026-01-18 13:58:30 +00:00
JoaoTF03 commented 2025-12-19 03:45:48 +00:00 (Migrated from github.com)

@GFMpt13 @AndreFerreira5

@GFMpt13 @AndreFerreira5
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-12-23 17:33:17 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR introduces a complete invoice management system with database interface, custom exception handling, and comprehensive test coverage. The implementation includes CRUD operations for invoices with proper snapshot functionality for client and vehicle details, atomic invoice numbering, and robust error handling.

Key changes:

  • Implemented InvoiceRepo with full CRUD operations including atomic invoice number generation
  • Added custom exception classes and handlers for invoice-specific error scenarios
  • Created comprehensive test suite covering success and failure paths for all repository methods

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_repos/test_invoices.py Comprehensive test suite for invoice repository with fixtures and test cases for all CRUD operations
tests/test_repos/test_appointments.py Minor formatting fix removing unnecessary line breaks in function signature
src/repository/invoices.py Complete invoice repository implementation with CRUD operations, snapshot logic, and atomic counter
src/exceptions/invoices_handlers.py Exception handlers for invoice-related errors with appropriate HTTP status codes
src/exceptions/invoices.py Custom exception classes for invoice operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This PR introduces a complete invoice management system with database interface, custom exception handling, and comprehensive test coverage. The implementation includes CRUD operations for invoices with proper snapshot functionality for client and vehicle details, atomic invoice numbering, and robust error handling. Key changes: - Implemented `InvoiceRepo` with full CRUD operations including atomic invoice number generation - Added custom exception classes and handlers for invoice-specific error scenarios - Created comprehensive test suite covering success and failure paths for all repository methods ### Reviewed changes Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | tests/test_repos/test_invoices.py | Comprehensive test suite for invoice repository with fixtures and test cases for all CRUD operations | | tests/test_repos/test_appointments.py | Minor formatting fix removing unnecessary line breaks in function signature | | src/repository/invoices.py | Complete invoice repository implementation with CRUD operations, snapshot logic, and atomic counter | | src/exceptions/invoices_handlers.py | Exception handlers for invoice-related errors with appropriate HTTP status codes | | src/exceptions/invoices.py | Custom exception classes for invoice operations | </details> --- 💡 <a href="/AndreFerreira5/starranja/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -0,0 +1,271 @@
import logging
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-12-23 17:33:16 +00:00

The invoice number format returned here (e.g., '0001') does not match the format used in the test fixture 'FT 2025/1'. This inconsistency will cause test failures. The format should include the 'FT YYYY/' prefix to match the expected pattern.

            return f"FT {datetime.now(UTC).year}/{seq}"
The invoice number format returned here (e.g., '0001') does not match the format used in the test fixture 'FT 2025/1'. This inconsistency will cause test failures. The format should include the 'FT YYYY/' prefix to match the expected pattern. ```suggestion return f"FT {datetime.now(UTC).year}/{seq}" ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-12-23 17:33:17 +00:00

The else block is unnecessary after raising an exception on line 86. The code after the exception raise is unreachable when the condition is false, so this else can be removed to improve readability and reduce nesting.

            # Assuming client.address matches InvoiceAddress structure or mapping is needed
            addr_snapshot = InvoiceAddress(
                street=client_address.street, city=client_address.city, zipCode=client_address.zip_code
            )
The else block is unnecessary after raising an exception on line 86. The code after the exception raise is unreachable when the condition is false, so this else can be removed to improve readability and reduce nesting. ```suggestion # Assuming client.address matches InvoiceAddress structure or mapping is needed addr_snapshot = InvoiceAddress( street=client_address.street, city=client_address.city, zipCode=client_address.zip_code ) ```
GFMpt13 commented 2025-12-23 17:36:30 +00:00 (Migrated from github.com)

@JoaoTF03 Update the code with the requests from copilot

@JoaoTF03 Update the code with the requests from copilot
GFMpt13 (Migrated from github.com) requested changes 2025-12-24 19:33:07 +00:00
GFMpt13 (Migrated from github.com) left a comment

Update the code with the requests from copilot

Update the code with the requests from copilot
AndreFerreira5 commented 2026-01-16 17:49:54 +00:00 (Migrated from github.com)

@JoaoTF03 one of the tests is not completing successfully, you must fix it before merging

@JoaoTF03 one of the tests is not completing successfully, you must fix it before merging
AndreFerreira5 (Migrated from github.com) approved these changes 2026-01-17 19:55:39 +00:00
JoaoTF03 commented 2026-01-17 22:37:25 +00:00 (Migrated from github.com)

The modifications recommended by Copilot have been fully integrated. The implementation is now complete and ready for final review.

The modifications recommended by Copilot have been fully integrated. The implementation is now complete and ready for final review.
Sign in to join this conversation.
No description provided.