Skip to content

Commit

Permalink
refactor: sent to financial manager returns bool
Browse files Browse the repository at this point in the history
  • Loading branch information
igobranco committed Apr 12, 2024
1 parent 291b080 commit 240862c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions nau_extensions/financial_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _convert_order_lines(order):

def send_to_financial_manager_if_enabled(
basket_transaction_integration: BasketTransactionIntegration,
):
) -> bool:
"""
The service that calls the nau-financial-manager with the request data pre saved on the
`BasketTransactionIntegration` instance, then save the response data.
Expand Down Expand Up @@ -170,7 +170,8 @@ def send_to_financial_manager_if_enabled(

basket_transaction_integration.response = response_json
basket_transaction_integration.save()
return basket_transaction_integration
return True
return False


def get_receipt_link(order):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def add_arguments(self, parser):

def handle(self, *args, **kwargs):
"""
Synchronize courses to the Richie marketing site, print to console its sync progress.
Synchronize Basket Transaction Integrations to Financial Manager system,
print to console its sync progress.
"""
btis: list = None

Expand Down Expand Up @@ -83,8 +84,8 @@ def handle(self, *args, **kwargs):
seconds=delta_to_be_sent_in_seconds
):
log.info("Sending to financial manager basket_id=%d", bti.basket.id)
bti_updated = send_to_financial_manager_if_enabled(bti)
if bti_updated.is_sent_with_success:
sent = send_to_financial_manager_if_enabled(bti)
if sent:
retry_success_count += 1
else:
log.error("Error sending basket_id=%d", bti.basket.id)
Expand Down

0 comments on commit 240862c

Please sign in to comment.