✨ allow custom voucher discount on admin order creation#1318
Open
kernicPanel wants to merge 2 commits intomainfrom
Open
✨ allow custom voucher discount on admin order creation#1318kernicPanel wants to merge 2 commits intomainfrom
kernicPanel wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the admin standalone order creation flow to optionally create vouchers with a custom discount (percentage or fixed amount), instead of always forcing a 100% discount.
Changes:
- Backend: adds
discount_type/discount_valuetoAdminOrderCreateSerializerand uses them inOrderViewSet.perform_createto create the rightDiscount. - Frontend: extends the order creation form with a “Full discount (100%)” toggle that reveals discount inputs when unchecked, and sends the optional fields to the API.
- Tests: adds backend API tests plus frontend unit and Playwright E2E coverage for the new UI and payload behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/backend/joanie/core/serializers/admin.py |
Accepts optional discount_type/discount_value and enforces “both or none” presence. |
src/backend/joanie/core/api/admin/__init__.py |
Creates Discount as rate/amount based on the optional fields, otherwise defaults to full (rate=1). |
src/backend/joanie/tests/core/api/admin/orders/test_create.py |
Adds API tests for custom rate and amount discounts on order creation. |
src/frontend/admin/src/services/api/models/Order.ts |
Extends DTOOrderCreate with optional discount fields. |
src/frontend/admin/src/components/templates/orders/form/OrderCreateForm.tsx |
Adds UI and payload logic for full vs custom discounts, including translated labels/messages. |
src/frontend/admin/src/components/templates/orders/form/OrderCreateForm.spec.tsx |
Adds unit tests for toggling/visibility and request payload behavior. |
src/frontend/admin/src/tests/orders/orders.test.e2e.ts |
Adds Playwright E2E tests validating UI behavior and posted JSON payload fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/frontend/admin/src/components/templates/orders/form/OrderCreateForm.tsx
Outdated
Show resolved
Hide resolved
f8f809e to
733ba27
Compare
The admin order create endpoint previously always created a 100% discount voucher. It now accepts optional discount_type (rate or amount) and discount_value fields so admins can choose the voucher discount when creating standalone orders.
A checkbox (checked by default) lets admins keep the 100% discount. Unchecking it reveals a value input and a type selector (percentage or fixed amount) to configure a custom voucher discount.
733ba27 to
2d867b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
The admin order creation form always attached a 100% discount voucher.
Admins need the ability to specify a custom discount (percentage or
fixed amount) when creating standalone orders.
Proposal
AdminOrderCreateSerializeraccepts optionaldiscount_type(rate/amount) anddiscount_valuefields.perform_createuses them to create the appropriate discount,defaulting to 100% when omitted.
default. Unchecking it reveals a value input and a type selector
(fixed amount by default, or percentage). Re-checking hides the
fields and reverts to 100%.
defineMessages/intl.