Skip to content

Conversation

@MTwomey1
Copy link

Forked repo to share

Hey @re-leased-hiring here is my pull request

I've created a comprehensive refactoring of the entire codebase, including updated tests. Here's an overview of what's included:

Refactored Domain Classes
Invoice Class: Now follows proper domain-driven design with rich behavior

Encapsulates payment processing logic
Provides clear property access control
Includes helpers for testing
Uses rich domain vocabulary with enums

Payment Class: Added with proper validation and constructors

Repository Pattern Implementation
IInvoiceRepository Interface: Creates a contract for repository operations
InvoiceRepository: Maintains backward compatibility while adding new features
ModernInvoiceRepository: A cleaner implementation for new code

Refactored Service Layer
InvoiceService: Now acts as a thin facade over domain operations

Maps domain results to user-friendly messages
Handles repository interactions
Validates inputs

Updated Tests
Fixed to work with the new domain model
Added a meaningful reference for better traceability
Includes setup method for better test organization
Added test for tax calculation on commercial invoices

Key Design Improvements

Proper Separation of Concerns

Domain logic moved to domain objects
Repository handles persistence concerns
Service layer handles orchestration

Improved Domain Model

Invoice now has rich behavior and enforces its own business rules
Payment results communicate outcomes clearly
Properties are properly encapsulated

Backward Compatibility

Repository maintains compatibility with old code
Helper methods support testing scenarios

Future-Proofing

Interface-based design supports dependency injection
Testable components with clear responsibilities
Support for multiple invoice storage

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