Skip to content

Conversation

@gustaavik
Copy link
Member

@gustaavik gustaavik commented Jun 19, 2025

This pull request introduces significant refactoring and enhancements to the product and discount use cases, focusing on simplifying currency management, improving stock calculation, and enhancing product lifecycle operations. Key changes include removing currency-specific price handling, introducing stock recalculation logic, and refining discount application methods.

Product Use Case Changes:

Currency Management Simplification:

  • Removed CurrencyPriceInput and all related logic for handling currency-specific prices in CreateProductInput, CreateVariantInput, UpdateVariantInput, and AddVariantInput. Products and variants now use a single currency specified during creation. ([[1]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L48-R56), [[2]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L75), [[3]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L312), [[4]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L407))

Stock Management Enhancements:

  • Introduced CalculateStock method to automatically recalculate product stock after operations like adding, updating, or deleting variants. ([[1]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777R174), [[2]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777R297-R306), [[3]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L506-R400))
  • Updated logic to persist recalculated stock in the repository after variant operations. ([internal/application/usecase/product_usecase.goL479-R367](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L479-R367))

Lifecycle Improvements:

  • Added an Active flag to CreateProductInput and UpdateProductInput to manage product activation status. Removed default variant creation logic and simplified variant handling. ([[1]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L184-R139), [[2]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L258))

Search and Listing Updates:

  • Replaced SearchProducts with ListProducts to streamline product listing with pagination and filtering by active status. ([[1]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L541-R469), [[2]](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-c590c807754d06047fffec1aba0a62b2b7a9a4addfa29b6261f94bda1cf51777L598-L682))

Discount Use Case Changes:

Discount Application Refinement:

  • Updated product repository method from Search to List for improved filtering capabilities. ([internal/application/usecase/discount_usecase.goL303-R303](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-9e8bf920baed4c5d4fd9ba5fc752d75135c3613d636feab41bda8cda59aac496L303-R303))
  • Refactored discount application logic to use switch statements for better readability and maintainability. ([internal/application/usecase/discount_usecase.goL319-R324](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-9e8bf920baed4c5d4fd9ba5fc752d75135c3613d636feab41bda8cda59aac496L319-R324))

Entity Changes:

Date Handling Adjustments:

  • Modified IsValid method in Discount entity to ensure date comparisons are performed in local time. ([internal/domain/entity/discount.goL107-R110](https://github.com/Zenfulcode/CommercifyGO/pull/37/files#diff-b9542e31b8777a66fb2801254847a19bc444d36daf2e1d3f96842df8bce9c009L107-R110))

@gustaavik gustaavik merged commit 97caf99 into main Jun 20, 2025
5 checks passed
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.

2 participants