Skip to content

Commit a5fbb0d

Browse files
committed
Migrating HH, Payment and PaymentPlan
1 parent 6b48e7d commit a5fbb0d

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/hope/models/household.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from sorl.thumbnail import ImageField
1818

1919
from hope.apps.activity_log.utils import create_mapping_dict
20-
from hope.apps.core.currencies import CURRENCY_CHOICES
2120
from hope.apps.household.field_validators import validate_originating_id
2221
from hope.apps.household.mixins import (
2322
HouseholdDeliveryDataMixin,
@@ -648,10 +647,17 @@ class CollectType(models.TextChoices):
648647
fchild_hoh = models.BooleanField(null=True, help_text="Female child headed household flag")
649648
child_hoh = models.BooleanField(null=True, help_text="Child headed household flag")
650649
village = models.CharField(max_length=250, blank=True, default=BLANK, help_text="Household village")
651-
currency = models.CharField(
650+
currency_old = models.CharField(
652651
max_length=250,
653-
choices=CURRENCY_CHOICES,
654652
default=BLANK,
653+
help_text="Household currency (legacy, pending removal)",
654+
)
655+
currency = models.ForeignKey(
656+
"core.Currency",
657+
on_delete=models.SET_NULL,
658+
null=True,
659+
blank=True,
660+
related_name="households",
655661
help_text="Household currency",
656662
)
657663
unhcr_id = models.CharField(

src/hope/models/payment.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,19 @@ class Payment(
121121
default=STATUS_PENDING,
122122
)
123123
status_date = models.DateTimeField()
124-
currency = models.CharField(
124+
currency_old = models.CharField(
125125
max_length=5,
126126
null=True,
127127
blank=True,
128128
)
129+
currency = models.ForeignKey(
130+
"core.Currency",
131+
on_delete=models.SET_NULL,
132+
null=True,
133+
blank=True,
134+
related_name="payments",
135+
help_text="Currency",
136+
)
129137
entitlement_quantity = models.DecimalField(
130138
decimal_places=2, max_digits=15, validators=[MinValueValidator(Decimal("0.00"))], null=True, blank=True
131139
)

src/hope/models/payment_plan.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from psycopg2._range import NumericRange
2525

2626
from hope.apps.activity_log.utils import create_mapping_dict
27-
from hope.apps.core.currencies import CURRENCY_CHOICES, USDC
27+
from hope.apps.core.currencies import USDC
2828
from hope.apps.core.exchange_rates import ExchangeRates
2929
from hope.apps.core.utils import map_unicef_ids_to_households_unicef_ids
3030
from hope.apps.targeting.services.targeting_service import TargetingCriteriaQueryingBase
@@ -365,11 +365,18 @@ class Action(models.TextChoices):
365365
null=True,
366366
help_text="Payment Plan end date",
367367
)
368-
currency = models.CharField(
368+
currency_old = models.CharField(
369369
max_length=5,
370-
choices=CURRENCY_CHOICES,
371370
blank=True,
372371
null=True,
372+
help_text="Currency (legacy, pending removal)",
373+
)
374+
currency = models.ForeignKey(
375+
"core.Currency",
376+
on_delete=models.SET_NULL,
377+
null=True,
378+
blank=True,
379+
related_name="payment_plans",
373380
help_text="Currency",
374381
)
375382
dispersion_start_date = models.DateField(blank=True, null=True, help_text="Dispersion Start Date")

0 commit comments

Comments
 (0)