Skip to content

Commit f9c162e

Browse files
committed
Rename compute_costs_utilized_euros_millicents
1 parent 1c4506d commit f9c162e

3 files changed

Lines changed: 51 additions & 30 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 5.2.14 on 2026-05-29 06:43
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
(
10+
"invoices",
11+
"0015_invoice_follow_up_on_required_for_initialized_post_paid",
12+
),
13+
]
14+
15+
operations = [
16+
migrations.RenameField(
17+
model_name="invoice",
18+
old_name="compute_costs_utilized_euros_millicents",
19+
new_name="compute_cost_euro_millicents",
20+
),
21+
]

app/grandchallenge/invoices/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Invoice(models.Model, FieldChangeMixin):
150150
compute_costs_euros = models.PositiveIntegerField(
151151
help_text="The capacity reservation in Euros"
152152
)
153-
compute_costs_utilized_euros_millicents = models.PositiveIntegerField(
153+
compute_cost_euro_millicents = models.PositiveIntegerField(
154154
help_text="The utilized compute costs in Euro millicents (cached from utilizations)",
155155
default=0,
156156
)
@@ -351,7 +351,7 @@ def is_budget_authorized(self):
351351

352352
@cached_property
353353
def compute_costs_balance_euros_millicents(self):
354-
utilized = self.compute_costs_utilized_euros_millicents
354+
utilized = self.compute_cost_euro_millicents
355355
diff = self.compute_costs_euros * 1000 * 100 - utilized
356356

357357
if not self.is_budget_authorized:

app/tests/invoices_tests/test_compute_costs_balance.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_prepaid_no_utilization_positive_balance():
2121
invoice = InvoiceFactory(
2222
challenge=challenge,
2323
compute_costs_euros=2,
24-
compute_costs_utilized_euros_millicents=0,
24+
compute_cost_euro_millicents=0,
2525
payment_type=PaymentTypeChoices.PREPAID,
2626
payment_status=Invoice.PaymentStatusChoices.PAID,
2727
)
@@ -34,7 +34,7 @@ def test_prepaid_utilization_positive_balance():
3434
invoice = InvoiceFactory(
3535
challenge=challenge,
3636
compute_costs_euros=2,
37-
compute_costs_utilized_euros_millicents=1 * 1000 * 100,
37+
compute_cost_euro_millicents=1 * 1000 * 100,
3838
payment_type=PaymentTypeChoices.PREPAID,
3939
payment_status=Invoice.PaymentStatusChoices.PAID,
4040
)
@@ -63,7 +63,7 @@ def test_prepaid_no_utilization_zero_balance(payment_status, expires_on):
6363
invoice = InvoiceFactory(
6464
challenge=challenge,
6565
compute_costs_euros=1,
66-
compute_costs_utilized_euros_millicents=0,
66+
compute_cost_euro_millicents=0,
6767
payment_type=PaymentTypeChoices.PREPAID,
6868
payment_status=payment_status,
6969
expires_on=expires_on,
@@ -86,7 +86,7 @@ def test_prepaid_overutilization_negative_balance(payment_status):
8686
invoice = InvoiceFactory(
8787
challenge=challenge,
8888
compute_costs_euros=1,
89-
compute_costs_utilized_euros_millicents=3 * 1000 * 100,
89+
compute_cost_euro_millicents=3 * 1000 * 100,
9090
payment_type=PaymentTypeChoices.PREPAID,
9191
payment_status=payment_status,
9292
)
@@ -99,7 +99,7 @@ def test_prepaid_utilization_expired_zero_balance():
9999
invoice = InvoiceFactory(
100100
challenge=challenge,
101101
compute_costs_euros=4,
102-
compute_costs_utilized_euros_millicents=1 * 1000 * 100,
102+
compute_cost_euro_millicents=1 * 1000 * 100,
103103
payment_type=PaymentTypeChoices.PREPAID,
104104
payment_status=Invoice.PaymentStatusChoices.PAID,
105105
expires_on=now().date() - timedelta(days=2),
@@ -113,7 +113,7 @@ def test_prepaid_overutilization_expired_negative_balance():
113113
invoice = InvoiceFactory(
114114
challenge=challenge,
115115
compute_costs_euros=1,
116-
compute_costs_utilized_euros_millicents=3 * 1000 * 100,
116+
compute_cost_euro_millicents=3 * 1000 * 100,
117117
payment_type=PaymentTypeChoices.PREPAID,
118118
payment_status=Invoice.PaymentStatusChoices.PAID,
119119
expires_on=now().date() - timedelta(days=2), # Expired
@@ -146,14 +146,14 @@ def test_postpaid_no_utilization(
146146
InvoiceFactory(
147147
challenge=challenge,
148148
compute_costs_euros=1,
149-
compute_costs_utilized_euros_millicents=0,
149+
compute_cost_euro_millicents=0,
150150
payment_type=PaymentTypeChoices.PREPAID,
151151
payment_status=prepaid_payment_status,
152152
)
153153
postpaid_invoice = InvoiceFactory(
154154
challenge=challenge,
155155
compute_costs_euros=2,
156-
compute_costs_utilized_euros_millicents=0,
156+
compute_cost_euro_millicents=0,
157157
payment_type=PaymentTypeChoices.POSTPAID,
158158
payment_status=postpaid_payment_status,
159159
)
@@ -246,14 +246,14 @@ def test_postpaid_postpaid_status_interaction_zero_balance(
246246
InvoiceFactory(
247247
challenge=challenge,
248248
compute_costs_euros=1,
249-
compute_costs_utilized_euros_millicents=0,
249+
compute_cost_euro_millicents=0,
250250
payment_type=PaymentTypeChoices.PREPAID,
251251
payment_status=prepaid_payment_status,
252252
)
253253
postpaid_invoice = InvoiceFactory(
254254
challenge=challenge,
255255
compute_costs_euros=2,
256-
compute_costs_utilized_euros_millicents=0,
256+
compute_cost_euro_millicents=0,
257257
payment_type=PaymentTypeChoices.POSTPAID,
258258
payment_status=postpaid_payment_status,
259259
)
@@ -267,15 +267,15 @@ def test_postpaid_with_expired_paid_prepaid():
267267
InvoiceFactory(
268268
challenge=challenge,
269269
compute_costs_euros=1,
270-
compute_costs_utilized_euros_millicents=0,
270+
compute_cost_euro_millicents=0,
271271
payment_type=PaymentTypeChoices.PREPAID,
272272
payment_status=Invoice.PaymentStatusChoices.PAID,
273273
expires_on=now().date() - timedelta(days=2),
274274
)
275275
postpaid_invoice = InvoiceFactory(
276276
challenge=challenge,
277277
compute_costs_euros=2,
278-
compute_costs_utilized_euros_millicents=0,
278+
compute_cost_euro_millicents=0,
279279
payment_type=PaymentTypeChoices.POSTPAID,
280280
payment_status=PaymentStatusChoices.INITIALIZED,
281281
)
@@ -292,14 +292,14 @@ def test_postpaid_utilized():
292292
InvoiceFactory(
293293
challenge=challenge,
294294
compute_costs_euros=1,
295-
compute_costs_utilized_euros_millicents=0,
295+
compute_cost_euro_millicents=0,
296296
payment_type=PaymentTypeChoices.PREPAID,
297297
payment_status=Invoice.PaymentStatusChoices.PAID,
298298
)
299299
postpaid_invoice = InvoiceFactory(
300300
challenge=challenge,
301301
compute_costs_euros=4,
302-
compute_costs_utilized_euros_millicents=1 * 1000 * 100,
302+
compute_cost_euro_millicents=1 * 1000 * 100,
303303
payment_type=PaymentTypeChoices.POSTPAID,
304304
payment_status=Invoice.PaymentStatusChoices.PAID,
305305
)
@@ -316,14 +316,14 @@ def test_postpaid_utilized_but_expired():
316316
InvoiceFactory(
317317
challenge=challenge,
318318
compute_costs_euros=1,
319-
compute_costs_utilized_euros_millicents=0,
319+
compute_cost_euro_millicents=0,
320320
payment_type=PaymentTypeChoices.PREPAID,
321321
payment_status=Invoice.PaymentStatusChoices.PAID,
322322
)
323323
postpaid_invoice = InvoiceFactory(
324324
challenge=challenge,
325325
compute_costs_euros=4,
326-
compute_costs_utilized_euros_millicents=1 * 1000 * 100,
326+
compute_cost_euro_millicents=1 * 1000 * 100,
327327
payment_type=PaymentTypeChoices.POSTPAID,
328328
payment_status=Invoice.PaymentStatusChoices.PAID,
329329
expires_on=now().date() - timedelta(days=2),
@@ -339,14 +339,14 @@ def test_postpaid_overutilized():
339339
InvoiceFactory(
340340
challenge=challenge,
341341
compute_costs_euros=1,
342-
compute_costs_utilized_euros_millicents=0,
342+
compute_cost_euro_millicents=0,
343343
payment_type=PaymentTypeChoices.PREPAID,
344344
payment_status=Invoice.PaymentStatusChoices.PAID,
345345
)
346346
postpaid_invoice = InvoiceFactory(
347347
challenge=challenge,
348348
compute_costs_euros=1,
349-
compute_costs_utilized_euros_millicents=3 * 1000 * 100,
349+
compute_cost_euro_millicents=3 * 1000 * 100,
350350
payment_type=PaymentTypeChoices.POSTPAID,
351351
payment_status=Invoice.PaymentStatusChoices.PAID,
352352
)
@@ -363,14 +363,14 @@ def test_postpaid_overutilized_but_expired():
363363
InvoiceFactory(
364364
challenge=challenge,
365365
compute_costs_euros=1,
366-
compute_costs_utilized_euros_millicents=0,
366+
compute_cost_euro_millicents=0,
367367
payment_type=PaymentTypeChoices.PREPAID,
368368
payment_status=Invoice.PaymentStatusChoices.PAID,
369369
)
370370
postpaid_invoice = InvoiceFactory(
371371
challenge=challenge,
372372
compute_costs_euros=1,
373-
compute_costs_utilized_euros_millicents=3 * 1000 * 100,
373+
compute_cost_euro_millicents=3 * 1000 * 100,
374374
payment_type=PaymentTypeChoices.POSTPAID,
375375
payment_status=Invoice.PaymentStatusChoices.PAID,
376376
expires_on=now().date() - timedelta(days=2),
@@ -402,7 +402,7 @@ def test_complimentary_no_utilization_positive_balance(payment_status):
402402
invoice = InvoiceFactory(
403403
challenge=challenge,
404404
compute_costs_euros=1,
405-
compute_costs_utilized_euros_millicents=0,
405+
compute_cost_euro_millicents=0,
406406
payment_type=PaymentTypeChoices.COMPLIMENTARY,
407407
payment_status=payment_status,
408408
)
@@ -415,7 +415,7 @@ def test_complimentary_cancelled():
415415
invoice = InvoiceFactory(
416416
challenge=challenge,
417417
compute_costs_euros=1,
418-
compute_costs_utilized_euros_millicents=0,
418+
compute_cost_euro_millicents=0,
419419
payment_type=PaymentTypeChoices.COMPLIMENTARY,
420420
payment_status=PaymentStatusChoices.CANCELLED,
421421
)
@@ -437,7 +437,7 @@ def test_complimentary_utilized(payment_status):
437437
invoice = InvoiceFactory(
438438
challenge=challenge,
439439
compute_costs_euros=4,
440-
compute_costs_utilized_euros_millicents=1 * 1000 * 100,
440+
compute_cost_euro_millicents=1 * 1000 * 100,
441441
payment_type=PaymentTypeChoices.COMPLIMENTARY,
442442
payment_status=payment_status,
443443
)
@@ -459,7 +459,7 @@ def test_complimentary_utilized_but_expired(payment_status):
459459
invoice = InvoiceFactory(
460460
challenge=challenge,
461461
compute_costs_euros=4,
462-
compute_costs_utilized_euros_millicents=1 * 1000 * 100,
462+
compute_cost_euro_millicents=1 * 1000 * 100,
463463
payment_type=PaymentTypeChoices.COMPLIMENTARY,
464464
payment_status=payment_status,
465465
expires_on=now().date() - timedelta(days=2),
@@ -473,7 +473,7 @@ def test_complimentary_overutilized_but_expired():
473473
invoice = InvoiceFactory(
474474
challenge=challenge,
475475
compute_costs_euros=1,
476-
compute_costs_utilized_euros_millicents=3 * 1000 * 100,
476+
compute_cost_euro_millicents=3 * 1000 * 100,
477477
payment_type=PaymentTypeChoices.COMPLIMENTARY,
478478
payment_status=PaymentStatusChoices.PAID,
479479
expires_on=now().date() - timedelta(days=2),
@@ -487,15 +487,15 @@ def test_multiple_challenges_do_not_mix_prepaid():
487487
InvoiceFactory(
488488
challenge=challenge_with_prepaid,
489489
compute_costs_euros=2,
490-
compute_costs_utilized_euros_millicents=0,
490+
compute_cost_euro_millicents=0,
491491
payment_type=PaymentTypeChoices.PREPAID,
492492
payment_status=Invoice.PaymentStatusChoices.PAID,
493493
)
494494
challenge_without_prepaid = ChallengeFactory()
495495
postpaid_invoice = InvoiceFactory(
496496
challenge=challenge_without_prepaid,
497497
compute_costs_euros=1,
498-
compute_costs_utilized_euros_millicents=0,
498+
compute_cost_euro_millicents=0,
499499
payment_type=PaymentTypeChoices.POSTPAID,
500500
payment_status=Invoice.PaymentStatusChoices.INITIALIZED,
501501
follow_up_on=now() - timedelta(days=3),
@@ -506,7 +506,7 @@ def test_multiple_challenges_do_not_mix_prepaid():
506506
InvoiceFactory(
507507
challenge=challenge_without_prepaid,
508508
compute_costs_euros=2,
509-
compute_costs_utilized_euros_millicents=0,
509+
compute_cost_euro_millicents=0,
510510
payment_type=PaymentTypeChoices.PREPAID,
511511
payment_status=Invoice.PaymentStatusChoices.PAID,
512512
)

0 commit comments

Comments
 (0)