Adding solution for day 19#12
Open
yanncourtel wants to merge 39 commits into
Open
Conversation
Solution/day03 - Try at day02 in Kotlin
Restructure documentation into two focused files: - 01-tax-calculation-overview.md: Business requirements and feature scope - 02-tax-calculation-roadmap.md: Analysis, gaps, and implementation strategy Refs: Phase 1 - Analysis Complete
Add PrintWithTaxes method to support regional tax calculation while maintaining backwards compatibility with existing Print method.
The refactoring map has two primary goals. 1) Identify missing domain concepts 2) Prioritize the refactoring tasks in phases with the lesser risks first.
… a static readonly field Ref: Docs/03-tax-calculation-refactoringmap.md Part of Phase 1: Extract Helpers
Extract tax rate lookup logic into GetTaxInfo helper. Centralizes error handling for unknown regions and provides consistent access to tax information. Ref: Docs/03-tax-calculation-refactoringmap.md Part of Phase 1: Extract Helpers (Complete)
Create EnrichedDelivery class to encapsulate delivery with its company, eliminating manual relationship resolution in business logic.
Add EnrichedInvoice domain model and new Print methods that accept it, eliminating dictionary parameter from core printing logic. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 1.5: Domain Model Coherence (Complete)
Handle money formatting and value calculation. Add public factory from cents or dollar amount. Add EnrichedInvoice domain model and new Print methods that accept it, eliminating dictionary parameter from core printing logic. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 2: Create Money struct with AmountInCents property (complete).
Create Tax value object to encapsulate tax region, rate, and amount. Replaces scattered tax data with cohesive domain object. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 2: Tax Value Object (complete)
…ggregate Add InvoiceLine object for better encapsulation. Create CalculatedInvoice to represent fully calculated invoice data. Completes separation between calculation and formatting. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 3: Created InvoiceLine and CalculatedInvoice (phase 3: complete)
Enhance domain model with better encapsulation following Law of Demeter and C# conventions for string representation. Post phase 3 refactoring
Extract all formatting logic into dedicated formatter classes implementing IInvoiceFormatter interface. InvoicePrinter now focuses purely on business logic (enrichment and calculation). Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 4: Extract Formatters
… default one. Simplified the injection of formatters. Added factory for service under test
Split package strategy for calculation cost. Add extensions for enriched delivery for better syntax in invoice printer. Add unit tests for calculation. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 5: Extract Pricing.
Extract tax calculation logic into dedicated TaxCalculator class. Moves tax rates and calculation logic out of InvoicePrinter. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 5: Extract Tax Calculation.
Add extensions in each node of the domain model. Simplify the invoice printer. Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 5: Extract Tax Calculation.
Extract class for loyalty calculation Add extensions for bridge Simplify the call from InvoicePrinter Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 5: Extract Loyalty Calculation.
Moving factory method into the InvoiceLine Simplify InvoicePrinter
Add InvoiceCalculator class and inject all calculation service Adjust the InvoicePrinter Remove all extensions that was holding business logic Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 5: Create Domain Service.
Add Loyalty calculation tests Add Tax calculation test Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 5: Added calculation unit tests (complete).
Replace string by Region enum Remove TaxRate Model Remove all methods not used Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 6: Adjust TaxRate object (remove unused TaxRate).
Add Invoice extensions to enrich it Add EnrichInvoice extensions to allow calculation Add CalculatedInvoice extensions to allow formatting Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 6: Add Extension Methods for Declarative Syntax.
…ctics. Move files into 3 folders: Domain, Formating and Calculation Move extensions to be on the consumer side to bridge domains Ref: Docs/03-tax-calculation-refactoringmap Part of Phase 6: Package Organization (DDD Tactical Patterns).
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.
The idea here was to add taxes to the invoice statement.
I added in the unit test solution a refactoring map with all steps I used.