Last active
December 18, 2023 20:02
-
-
Save jasonleibowitz/0255846255e777cd4aa808ffc75d2a1e to your computer and use it in GitHub Desktop.
For FundTerms that have a country set to "US", but missing domicile_country, backfill the domicile_country to "US".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fund_admin.fund_admin.models import Fund | |
from fund_admin.fund_properties.amendable_properties.models import FundTerms | |
from fund_admin.fund_properties.amendable_properties.models import LPADocuments | |
terms = FundTerms.objects.filter(domicile_country__isnull=True, country__isnull=False, country="US").order_by('created_at') | |
print(f"Num Terms to Update: {terms.count()}") | |
if terms.count() > 0: | |
for term in terms: | |
lpa_document = LPADocuments.objects.get(pk=term.lpa_id) | |
fund_id = lpa_document.fund_id | |
fund = Fund.objects.get(pk=fund_id) | |
print(f"Setting domicile_country on fund ID: {fund.id} (Carta ID: {fund.carta_id}) - {fund.name} to {term.country}") | |
term.domicile_country = term.country | |
FundTerms.objects.bulk_update(terms, ["domicile_country"]) | |
updated_terms = FundTerms.objects.filter(domicile_country__isnull=True, country__isnull=False, country="US").order_by('created_at') | |
print(f"Num Terms Post Run: {updated_terms.count()}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lgtm