Development#21
Merged
Merged
Conversation
…onality - Implemented CurrencyUseCase for managing currencies, including creation, updating, deletion, and retrieval of currencies. - Added CurrencyHandler for handling HTTP requests related to currencies. - Introduced new database tables for currencies, product prices, and product variant prices. - Updated product handler to support fetching products with specific currency prices. - Added routes for currency management in the API server. - Created migrations for adding currency support to the database. - Developed mock repository for testing currency-related functionalities.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
feat: Add currency support with CRUD operations
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces multi-currency support by adding a default currency configuration in the system, expanding currency-related use cases and handlers, and updating API documentation and tests. Key changes include configuration updates to load and validate a default currency; new currency API endpoints and a dedicated CurrencyUseCase; and extending product and variant use cases to handle multiple currency prices.
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| migrations/000014_add_currency_support.down.sql | SQL script to remove currency tables, indexes, and constraints for rollback purposes |
| internal/interfaces/api/server.go | Adds public and admin currency routes to the API server |
| internal/interfaces/api/handler/{product,currency}_handler.go | Extends product and creates currency HTTP handlers for multi-currency operations |
| internal/infrastructure/container/* | Updates dependency injection to include the new CurrencyUseCase and CurrencyHandler |
| internal/domain/* | Adds new currency and price entity definitions |
| internal/application/usecase/* | Updates product and currency use cases to process currency prices and support multi-currency queries |
| docs/* | Updates API examples to include multi-currency parameters and payloads |
| config/config.go | Adds a new DefaultCurrency field and loads it from the environment |
Comments suppressed due to low confidence (2)
internal/infrastructure/container/usecase_provider.go:18
- [nitpick] Consider renaming 'CurrencyUsecase' to 'CurrencyUseCase' for consistency with other method names and common CamelCase conventions.
CurrencyUsecase() *usecase.CurrencyUseCase
internal/application/usecase/product_usecase.go:667
- [nitpick] Verify that the rounding and conversion logic for min/max prices—when converting from a non-default currency to the default currency—is performing as expected, ensuring no unintended precision loss in search filtering.
if input.CurrencyCode != "" && input.CurrencyCode != defaultCurr.Code {
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.
This pull request introduces multi-currency support to the system, enabling products, variants, and prices to be managed in multiple currencies. It includes updates to configuration, documentation, and use cases to support this functionality. The most significant changes include adding a default currency configuration, extending the product and currency use cases, and updating the API documentation to reflect the new features.
Configuration Updates
DefaultCurrencyfield to theConfigstruct inconfig/config.goand updated theLoadConfigfunction to load this value from the environment. A validation ensures thatDEFAULT_CURRENCYis provided. [1] [2] [3]API Documentation Updates
docs/currency_api_examples.mdfile with detailed examples for currency-related API endpoints, including listing, creating, updating, and deleting currencies, as well as converting amounts.docs/product_api_examples.mdto include multi-currency support, such as specifyingcurrency_priceswhen creating or updating products and variants, and usingcurrencyquery parameters to retrieve prices in specific currencies. [1] [2] [3] [4] [5] [6] [7]Use Case Enhancements
CurrencyUseCaseininternal/application/usecase/currency_usecase.goto handle currency-related operations, such as creating, updating, deleting, and converting currencies.ProductUseCaseininternal/application/usecase/product_usecase.goto support multi-currency prices for products and variants. This includes validating currencies and processingcurrency_pricesduring product creation. [1] [2]