-
Notifications
You must be signed in to change notification settings - Fork 0
Development #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #21
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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]