Deleting checkouts command and item deletion fix #45
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 enhancements to checkout management, focusing on cleanup operations, reactivation of abandoned checkouts, and improved repository functionality. It also includes updates to the documentation and adds comprehensive tests for checkout behaviors. The most important changes are grouped into themes below.
Cleanup Operations
force-delete-checkoutscommand in theMakefileto perform aggressive cleanup of expired, abandoned, and old completed checkouts. This complements the existingexpire-checkoutscommand. (Makefile, MakefileR132-R134)ForceDeleteAllExpiredCheckoutsmethod inCheckoutUseCase, which forcefully deletes expired checkouts using the repository's newGetAllExpiredCheckoutsForDeletionmethod. (internal/application/usecase/checkout_usecase.go, [1] [2]Reactivation of Abandoned Checkouts
GetOrCreateCheckoutBySessionIDWithCurrencyto reactivate abandoned checkouts when no active checkout is found. This includes updating the checkout's status and optionally changing its currency. (internal/application/usecase/checkout_usecase.go, internal/application/usecase/checkout_usecase.goR805-R824)Reactivatemethod to theCheckoutentity, allowing abandoned checkouts to be marked as active again. (internal/domain/entity/checkout.go, internal/domain/entity/checkout.goR370-R375)Repository Enhancements
CheckoutRepositoryinterface to include methods for retrieving abandoned checkouts by session ID and expired checkouts for deletion. (internal/domain/repository/checkout_repository.go, [1] [2]Updatemethod in the GORM-basedCheckoutRepositoryto handle item deletions more robustly, ensuring removed items are deleted from the database. (internal/infrastructure/repository/gorm/checkout_repository.go, internal/infrastructure/repository/gorm/checkout_repository.goL210-R271)Documentation Updates
readme.mdwith detailed instructions for using and scheduling the new cleanup commands. This includes examples for regular and force cleanup operations. (readme.md, readme.mdR484-R543)Testing Improvements
CheckoutRepositoryto verify item removal behavior during updates and the handling of abandoned checkouts. (internal/infrastructure/repository/gorm/checkout_repository_test.go, internal/infrastructure/repository/gorm/checkout_repository_test.goR1-R219)Reactivatemethod in theCheckoutentity to ensure abandoned checkouts can be successfully reactivated. (internal/domain/entity/checkout_test.go, internal/domain/entity/checkout_test.goR326-R356)