Skip to content

Commit b79bb43

Browse files
committed
MPT-10795 fix trial calculation and exchange rates client
1 parent c9b6747 commit b79bb43

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

ffc/billing/process_billing.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def generate_refunds(
567567
refund_lines = []
568568
trial_days: set[int] = set()
569569
trial_start_date, trial_end_date = get_trial_dates(agreement=agreement)
570-
if trial_start_date and trial_end_date:
570+
if trial_start_date and trial_end_date and trial_end_date >= self.billing_start_date.date():
571571
trial_info = self.get_trial_info(
572572
trial_start_date,
573573
trial_end_date,
@@ -664,18 +664,11 @@ async def generate_refund_lines(
664664
f"{linked_datasource_id}-{idx:02d}",
665665
datasource_id,
666666
organization_id,
667-
date(
668-
self.billing_start_date.year,
669-
self.billing_start_date.month,
670-
min(daily_expenses.keys()),
671-
),
672-
date(
673-
self.billing_start_date.year,
674-
self.billing_start_date.month,
675-
max(daily_expenses.keys()),
676-
),
667+
refund.start_date,
668+
refund.end_date,
677669
-refund_in_target_currency,
678670
datasource_name,
671+
refund.description,
679672
)
680673
)
681674

ffc/clients/exchage_rates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def fetch_exchange_rates(self, currency) -> dict[str, Any]:
2121
if currency in self.exchage_rates_cache:
2222
return self.exchage_rates_cache[currency]
2323
response = await self.httpx_client.get(
24-
f"{settings.EXTENSION_CONFIG["EXCHANGE_RATES_BASE_URL"]}/latest/{currency}"
24+
f"{settings.EXTENSION_CONFIG["EXCHANGE_RATES_API_TOKEN"]}/latest/{currency}"
2525
)
2626
response.raise_for_status()
2727
exchange_rates = response.json()

0 commit comments

Comments
 (0)