Org Web Adapter

hungryroot/jira/be_7350_add_auto_refund_support_to_createtestcustomerview_test_endpoint.org

ID
b868881e-f2ca-4d62-90c3-92e83af34a7e

BE-7350 Add auto_refund support to CreateTestCustomerView test endpoint

- source :: https://hungryroot.atlassian.net/browse/BE-7350

- tags :: Hungryroot API Project

- epic :: EP-411 Eng Parking Lot

- sprint :: HR BE Sprint 106

- status :: Status - Code Review

Tasks

DONE Add auto_refund support to the CreateTestCustomerView

projectworkhungryrootcursorep411sprint106be7350
ID
5691383b-424a-2ac0-0965-e8f5a04f5a09

Description

Background

The CreateTestCustomerView in test_automation/views/create_test_customer.py is

used to create test customers with configurable settings for QA and testing

purposes. Currently, there is no way to control whether an order's

can_auto_refund property returns true or false through the test endpoint.

Problem

Testers need the ability to force auto_refund to return true or false when

creating test customers through the test automation endpoint, so they can test

flows that depend on auto-refund eligibility without manually manipulating the

underlying data.

How can_auto_refund Works

The Order.can_auto_refund property (in app/models/order.py) evaluates to True

when ALL of the following conditions are met:

Order status is in OrderStatus.SubmittedStatuses

customer.no_auto_credit is False

The order has no refunds (refund == 0)

The number of issue-credit log events is below the dynamic config threshold

(AUTO_ISSUE_CREDIT_EVENTS_RESTRICTION)

Proposed Implementation

Add an auto_refund boolean field to TestCustomerCreationSerializer that controls

whether can_auto_refund will return True or False for the customer's orders:

auto_refund=true (or omitted/default): Ensure customer.no_auto_credit = False

(default behavior, auto-refund eligible)

auto_refund=false: Set customer.no_auto_credit = True on the created customer,

which causes can_auto_refund to return False for all of their orders

This maps to the existing Customer.no_auto_credit boolean field, which is the

most direct and reliable way to control auto-refund eligibility at the customer

level.

Acceptance Criteria

[ ] New optional auto_refund boolean field added to

TestCustomerCreationSerializer

[ ] When auto_refund=false, the created customer has no_auto_credit=True

[ ] When auto_refund=true or omitted, the created customer has

no_auto_credit=False (default)

[ ] The field is documented in the API schema via help_text

[ ] Unit tests cover both auto_refund=true and auto_refund=false scenarios