Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: part of program refund with single transaction #349

Open
wants to merge 9 commits into
base: program-migration
Choose a base branch
from

Conversation

abdullahwaheed
Copy link
Contributor

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  commerce_coordinator/apps/commercetools
  clients.py
  filters.py
  pipeline.py 279-280
  serializers.py
  views.py
  commerce_coordinator/apps/commercetools/catalog_info
  edx_utils.py 128-133, 136
  commerce_coordinator/apps/commercetools/sub_messages
  tasks.py 329-351
  commerce_coordinator/apps/commercetools/tests
  test_pipeline.py
  commerce_coordinator/apps/paypal
  clients.py 43
  pipeline.py 75
  commerce_coordinator/apps/rollout
  utils.py
  commerce_coordinator/apps/rollout/tests
  test_util_functions.py
Project Total  

This report was generated by python-coverage-comment-action

Comment on lines +486 to +505
return_payment_state_actions = []
update_transaction_id_actions = []
for return_line_item_return_id in return_line_item_return_ids:
return_payment_state_actions.append(OrderSetReturnPaymentStateAction(
return_item_id=return_line_item_return_id,
payment_state=ReturnPaymentState.REFUNDED,
))
custom_fields = {
"transactionId": transaction_id,
}
entitlement_id = return_line_entitlement_ids.get(return_line_item_return_id)
if entitlement_id:
custom_fields[TwoUKeys.LINE_ITEM_LMS_ENTITLEMENT_ID] = entitlement_id
update_transaction_id_actions.append(OrderSetReturnItemCustomTypeAction(
return_item_id=return_line_item_return_id,
type=CTTypeResourceIdentifier(
key="returnItemCustomType",
),
fields=CTFieldContainer(custom_fields),
))
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: some logical separation

Suggested change
return_payment_state_actions = []
update_transaction_id_actions = []
for return_line_item_return_id in return_line_item_return_ids:
return_payment_state_actions.append(OrderSetReturnPaymentStateAction(
return_item_id=return_line_item_return_id,
payment_state=ReturnPaymentState.REFUNDED,
))
custom_fields = {
"transactionId": transaction_id,
}
entitlement_id = return_line_entitlement_ids.get(return_line_item_return_id)
if entitlement_id:
custom_fields[TwoUKeys.LINE_ITEM_LMS_ENTITLEMENT_ID] = entitlement_id
update_transaction_id_actions.append(OrderSetReturnItemCustomTypeAction(
return_item_id=return_line_item_return_id,
type=CTTypeResourceIdentifier(
key="returnItemCustomType",
),
fields=CTFieldContainer(custom_fields),
))
return_payment_state_actions = []
update_transaction_id_actions = []
for item_id in return_line_item_return_ids:
return_payment_state_actions.append(OrderSetReturnPaymentStateAction(
return_item_id=item_id,
payment_state=ReturnPaymentState.REFUNDED,
))
custom_fields = {"transactionId": transaction_id}
if entitlement_id := return_line_entitlement_ids.get(item_id):
custom_fields[TwoUKeys.LINE_ITEM_LMS_ENTITLEMENT_ID] = entitlement_id
update_transaction_id_actions.append(OrderSetReturnItemCustomTypeAction(
return_item_id=item_id,
type=CTTypeResourceIdentifier(key="returnItemCustomType"),
fields=CTFieldContainer(custom_fields),
))

Copy link
Member

@NawfalAhmed NawfalAhmed left a comment

Choose a reason for hiding this comment

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

LGTM, added minor comments

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.

3 participants