Skip to content

Conversation

@jbpenrath
Copy link
Collaborator

Purpose

Currently only orders with inactive states (canceled, draft, assigned) were ignored in the organization assignation logic. But orders pending for signature or without payment method are take in account but most of time this kind of orders are abandoned. So it has been ask to ignore this kind of order during assignation. Furthermore, we did not ignore refunded and refunding orders.

Resolve #1081

Copy link

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 pull request updates the organization assignation logic to ignore orders with pending signature, orders without a payment method, and refunded/refunding orders. Key changes include updating the test to randomly select non-binding order states, modifying the client API filtering logic, and updating the changelog.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/backend/joanie/tests/core/api/order/test_create.py Updated order creation tests to randomly choose ignored order states for first organization and batch creation for the second organization.
src/backend/joanie/core/api/client/init.py Modified the organization selection filter and updated the related docstring to reflect new binding order criteria.
CHANGELOG.md Documented changes in organization assignation logic regarding order states to ignore.

product=relation.product,
course=relation.course,
state=enums.ORDER_STATE_DRAFT,
state=lazy(lambda: random.choice(ignored_states), str)(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep deterministic states, without random.choice.
I will add a fixup.

@kernicPanel kernicPanel force-pushed the improve/order-organization-assignation-logic branch from 01a1cae to 6bda6bc Compare April 4, 2025 16:29
@kernicPanel kernicPanel requested a review from wilbrdt April 4, 2025 16:31
@kernicPanel
Copy link
Member

I just added tests, as current one doesn't cover the code.

Copy link

@wilbrdt wilbrdt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being nitpicky but looks good to me!

@kernicPanel kernicPanel assigned kernicPanel and unassigned jbpenrath Apr 8, 2025
@kernicPanel kernicPanel force-pushed the improve/order-organization-assignation-logic branch 2 times, most recently from 19ced06 to c2f3fda Compare April 8, 2025 12:53
Currently only orders with inactive states (canceled, draft, assigned) were
ignored in the organization assignation logic. But orders pending for signature
or without payment method  are take in account but most of time this kind of
orders are abandoned. So it has been ask to ignore this kind of order during
assignation. Furthermore, we did not ignore refunded and refunding orders.

Resolve #1081
@kernicPanel kernicPanel force-pushed the improve/order-organization-assignation-logic branch from c2f3fda to 4642af7 Compare April 8, 2025 13:58
@kernicPanel kernicPanel enabled auto-merge (rebase) April 8, 2025 14:00
@kernicPanel kernicPanel merged commit f8c70e8 into main Apr 8, 2025
17 checks passed
@kernicPanel kernicPanel deleted the improve/order-organization-assignation-logic branch April 8, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore order in state to_save_payment_method into the organization assignation

5 participants