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.
Show a Coupon: Retrieves a specific coupon by ID and returns its details in JSON format.
Index Coupons: Lists all coupons for a specific merchant, returning an array of coupon objects.
Create a Coupon: Allows the creation of a new coupon linked to a merchant. Validations ensure unique codes and required attributes.
Model Updates:
Coupon Model: Added validations for uniqueness of coupon codes scoped to merchants, along with necessary associations.
Invoice Model: Updated to optionally associate with a coupon.
Merchant Model: Established a relationship with coupons.
Serializer: A CouponSerializer has been added to format coupon data for API responses.
Database Migrations:
Created a coupons table with necessary fields and validations.
Added a reference to coupons in the invoices table.
Tests: Comprehensive request specs ensure the functionality works as intended, covering all CRUD operations for coupons and handling edge cases.
This update enhances the functionality of the merchant management system by allowing the creation and retrieval of coupons, facilitating promotional offers for merchants.