Skip to content

Commit

Permalink
refactor the update payment function
Browse files Browse the repository at this point in the history
  • Loading branch information
hemant10yadav committed Nov 14, 2024
1 parent 02c5899 commit b411683
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion commcare_connect/opportunity/visit_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,18 @@ def _bulk_update_payments(opportunity: Opportunity, imported_data: Dataset) -> P
payment = Payment.objects.create(opportunity_access=access, amount=amount, amount_usd=amount_usd)
seen_users.add(username)
payment_ids.append(payment.pk)
update_work_payment_date(access)
process_work_payment_dates(users)
missing_users = set(usernames) - seen_users
send_payment_notification.delay(opportunity.id, payment_ids)
return PaymentImportStatus(seen_users, missing_users)


def process_work_payment_dates(accesses: list):
with transaction.atomic():
for oa in accesses:
update_work_payment_date(oa)


def _cache_key(currency_code, date=None):
return [currency_code, date.toordinal() if date else None]

Expand Down

0 comments on commit b411683

Please sign in to comment.