Skip to content

✨ allow custom voucher discount on admin order creation#1318

Open
kernicPanel wants to merge 2 commits intomainfrom
custom-voucher-discount-order-create
Open

✨ allow custom voucher discount on admin order creation#1318
kernicPanel wants to merge 2 commits intomainfrom
custom-voucher-discount-order-create

Conversation

@kernicPanel
Copy link
Copy Markdown
Member

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

  • Backend: AdminOrderCreateSerializer accepts optional
    discount_type (rate/amount) and discount_value fields.
    perform_create uses them to create the appropriate discount,
    defaulting to 100% when omitted.
  • Frontend: A checkbox "Full discount (100%)" is checked by
    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%.
  • All messages are translated via defineMessages/intl.

Copilot AI review requested due to automatic review settings April 2, 2026 10:17
Copy link
Copy Markdown

Copilot AI left a 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 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_value to AdminOrderCreateSerializer and uses them in OrderViewSet.perform_create to create the right Discount.
  • 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.

@kernicPanel kernicPanel force-pushed the custom-voucher-discount-order-create branch 3 times, most recently from f8f809e to 733ba27 Compare April 2, 2026 13:05
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.
@kernicPanel kernicPanel force-pushed the custom-voucher-discount-order-create branch from 733ba27 to 2d867b5 Compare April 2, 2026 14:46
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