-
Notifications
You must be signed in to change notification settings - Fork 0
Development #13
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 #13
Conversation
- Implemented PaymentTransaction entity with necessary fields and methods. - Created PaymentTransactionRepository interface for payment transaction persistence. - Developed PostgreSQL implementation of PaymentTransactionRepository. - Added PaymentTransactionRepository to the RepositoryProvider interface. - Updated use case provider to include PaymentTransactionRepository. - Created migration scripts for payment_transactions table with backfill logic. - Added mock implementation of PaymentTransactionRepository for testing. - Updated todo list to reflect new payment repository feature.
- Added ShippingZone entity with methods for creation, updating, and address validation. - Introduced ShippingMethod and ShippingRate repositories for data access. - Implemented PostgreSQL repositories for shipping methods, zones, and rates with CRUD operations. - Created migrations for shipping methods, zones, and rates tables, including weight and value-based rates. - Developed mock shipping use case for testing, including methods for retrieving shipping options and calculating costs.
…alize timestamps for shipping rates
…lculation - Updated the IsApplicableToOrder method in the Discount entity to clarify category checks and their handling in the use case layer. - Changed the ApplyDiscount method in the Order entity to use the discount method directly and simplified the discount amount calculation. - Fixed parameter formatting in the ShippingRateRepository to ensure correct SQL parameter binding. - Added a chore to the todo list for refactoring the final amount calculation in the Order entity.
…, zones, and rates
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add payment transactions
Add shipping system
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
feat: add comprehensive development guidelines document
- Updated product use case tests to convert prices to cents using money.ToCents. - Modified shipping use case to handle monetary values in cents. - Adjusted discount entity to store min order value and max discount value as int64 (cents). - Changed order entity to store total amount, shipping cost, discount amount, and final amount as int64 (cents). - Updated payment transaction entity to use int64 for transaction amounts. - Refactored shipping rate entity to store base rate, min order value, and free shipping threshold as int64 (cents). - Enhanced money utility functions to apply percentages to cents values. - Adjusted payment services and repositories to handle int64 amounts. - Updated API handlers to convert monetary values to and from cents. - Modified mock repositories to reflect changes in monetary value handling.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Refactor money data type
…ing methods, zones, rates, webhooks, and payment transactions
… transaction types
Refactor seed command
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 pull request makes significant updates to the Commercify backend by standardizing monetary values as cents instead of floating-point dollars, integrating shipping functionality and related repository interfaces, and enhancing discount logic to support category‐based discounts and precise payment transaction recording.
- Standardizes monetary types across payment, product, order, and discount modules.
- Introduces new shipping repositories and methods along with API documentation updates.
- Updates order and discount use cases to integrate shipping cost and multi-provider payment transaction handling.
Reviewed Changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/domain/service/payment_service.go | Updated payment amount types from float64 to int64. |
| internal/domain/repository/shipping_repository.go | Added interfaces for shipping methods, zones, and rates. |
| internal/domain/repository/product_repository.go | Modified Search parameters to use cents for price comparisons. |
| internal/domain/money/money.go | Introduced utility functions for converting between dollars and cents. |
| internal/domain/entity/* | Updated product, order, discount, and shipping entities to store money in cents and added weight fields. |
| internal/application/usecase/* | Updated use cases for products, orders, discounts, and payments to convert input prices from dollars to cents and integrate shipping, payment transaction, and discount enhancements. |
| docs/shipping_api_examples.md & .github/copilot-instructions.md | Added comprehensive API examples and development guidelines. |
Comments suppressed due to low confidence (2)
internal/application/usecase/order_usecase.go:115
- For products with variants, matching 'variant.ID' against 'cartItem.ProductID' may be incorrect since the cart item likely should reference a variant identifier rather than the product ID. Consider verifying and using the correct identifier (e.g., a dedicated variant ID) to accurately retrieve the variant's weight.
if product.HasVariants { for _, variant := range product.Variants { if variant.ID == cartItem.ProductID { itemWeight = variant.Weight
internal/domain/entity/order.go:266
- [nitpick] Ensure that the FinalAmount calculation, which now adds ShippingCost to TotalAmount before subtracting DiscountAmount, aligns with the business rules for order pricing.
o.FinalAmount = o.TotalAmount + o.ShippingCost - discountAmount
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces significant updates to the Commercify backend, including new development guidelines, enhanced shipping API examples, and improvements to discount and order use cases. These changes aim to improve code quality, maintainability, and functionality.
Documentation Updates
.github/copilot-instructions.md, outlining architectural principles, coding standards, API design, database practices, testing, and deployment processes. This document serves as a reference for maintaining code consistency and adhering to best practices.docs/shipping_api_examples.mdfile with detailed examples for public and admin shipping API endpoints, including request/response formats for calculating shipping options, creating shipping methods, and managing shipping zones and rates.Discount Use Case Enhancements
money.ToCentsutility to standardize monetary values in theDiscountUseCasemethods, ensuring consistent handling of minimum order values and maximum discount values. [1] [2] [3]ApplyDiscountToOrderto support category-based discounts by dynamically determining eligible products and calculating discounts accordingly. Added safeguards for maximum discount caps and order total limits.Order Use Case Enhancements
OrderUseCaseby integratingShippingUseCaseand calculating shipping costs based on total weight and selected shipping method. UpdatedCreateOrderInputto includeShippingMethodID. [1] [2] [3] [4]These updates collectively improve the backend's robustness, scalability, and developer experience.