Skip to content

Commit

Permalink
Remove tenancy entity
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Jul 28, 2023
1 parent db96016 commit 70347c1
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 135 deletions.
32 changes: 1 addition & 31 deletions openfisca_aotearoa/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,6 @@
],
)

Tenancy = build_entity(
key = "tenancy",
plural = "tenancies",
label = "Tenancy",
doc = """
A tenancy represents, in relation to any residential premises, the
right to occupy the premises in consideration for rent.
""",
roles = [
{
"key": "applicant",
"label": "applicant",
"doc": """The one person who is the focus of the calculation""",
"max": 1,
},
{
"key": "tenant",
"plural": "tenants",
"label": "Tenants",
"doc": """The grantees of the tenancy""",
},
{
"key": "other",
"plural": "others",
"label": "Other",
"doc": """All other members of a tenancy""",
},
],
)

Ownership = build_entity(
key = "ownership",
plural = "ownerships",
Expand Down Expand Up @@ -225,4 +195,4 @@
],
)

entities = [Titled_Property, Ownership, Tenancy, Premise, Person, Family]
entities = [Titled_Property, Ownership, Premise, Person, Family]
40 changes: 29 additions & 11 deletions openfisca_aotearoa/tests/exegesis/housing_costs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
Scenario: single tenant #1
input:
persons:
Juana: {}
Juana:
residential_tenancies__tenant:
1987-W06: true
1987-W07: true
1987-W08: true
1987-W09: true
Abdul: {}
Pablo: {}
tenancy:
premise:
applicant: Juana
others: [Abdul, Pablo]
residential_tenancies__rent:
Expand All @@ -32,12 +37,16 @@
Scenario: single tenant #2
input:
persons:
Juana: {}
Juana:
residential_tenancies__tenant:
1987-W06: true
1987-W07: true
1987-W08: true
1987-W09: true
Abdul: {}
Pablo: {}
tenancy:
tenants: [Juana]
others: [Abdul, Pablo]
premise:
others: [Juana, Abdul, Pablo]
residential_tenancies__rent:
1987-W06: 0
1987-W07: 100
Expand All @@ -61,13 +70,22 @@
Scenario: joint tenants
input:
persons:
Juana: {}
Abdul: {}
Juana:
residential_tenancies__tenant:
1987-W06: true
1987-W07: true
1987-W08: true
1987-W09: true
Abdul:
residential_tenancies__tenant:
1987-W06: true
1987-W07: true
1987-W08: true
1987-W09: true
Pablo: {}
tenancy:
premise:
applicant: Juana
tenants: [Abdul]
others: [Pablo]
others: [Abdul, Pablo]
residential_tenancies__rent:
1987-W06: 0
1987-W07: 100
Expand Down
18 changes: 9 additions & 9 deletions openfisca_aotearoa/tests/rta/interpretation/bond.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
1987-W07: 100
1987-W08: 100
1987-W09: 100
tenancy:
tenants: [Juana] # Delegated to 'residential_tenancies__tenant'
premise:
applicant: Juana
residential_tenancies__rent:
1987-W05: 0
1987-W06: 0
Expand Down Expand Up @@ -79,8 +79,8 @@
1987-W07: 100
1987-W08: 100
1987-W09: 100
tenancy:
tenants: [Juana, Abdul, Pablo] # Delegated to 'residential_tenancies__tenant'
premise:
others: [Juana, Abdul, Pablo]
residential_tenancies__rent:
1987-W05: 0
1987-W06: 0
Expand Down Expand Up @@ -167,17 +167,17 @@
1987-W07: 100
1987-W08: 100
1987-W09: 100
tenancies:
tenancy1:
tenants: [Juana, Thorn, Jenny] # Delegated to 'residential_tenancies__tenant'
premises:
premise1:
others: [Juana, Thorn, Jenny]
residential_tenancies__rent:
1987-W05: 0
1987-W06: 0
1987-W07: 0
1987-W08: 50
1987-W09: 500
tenancy2:
tenants: [Abdul, Pablo] # Delegated to 'residential_tenancies__tenant'
premise2:
others: [Abdul, Pablo]
residential_tenancies__rent:
1987-W05: 0
1987-W06: 0
Expand Down
18 changes: 9 additions & 9 deletions openfisca_aotearoa/tests/rta/interpretation/rent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
1987-W07: 100
1987-W08: 100
1987-W09: 100
tenancy:
tenants: [Juana] # Delegated to 'residential_tenancies__tenant'
premise:
applicant: Juana
residential_tenancies__bond:
1987-W05: 0
1987-W06: 0
Expand Down Expand Up @@ -79,8 +79,8 @@
1987-W07: 100
1987-W08: 100
1987-W09: 100
tenancy:
tenants: [Juana, Abdul, Pablo] # Delegated to 'residential_tenancies__tenant'
premise:
others: [Juana, Abdul, Pablo]
residential_tenancies__bond:
1987-W05: 0
1987-W06: 0
Expand Down Expand Up @@ -167,17 +167,17 @@
1987-W07: 100
1987-W08: 100
1987-W09: 100
tenancies:
tenancy1:
tenants: [Juana, Thorn, Jenny] # Delegated to 'residential_tenancies__tenant'
premises:
premise1:
others: [Juana, Thorn, Jenny]
residential_tenancies__bond:
1987-W05: 0
1987-W06: 0
1987-W07: 0
1987-W08: 50
1987-W09: 500
tenancy2:
tenants: [Abdul, Pablo] # Delegated to 'residential_tenancies__tenant'
premise2:
others: [Abdul, Pablo]
residential_tenancies__bond:
1987-W05: 0
1987-W06: 0
Expand Down
47 changes: 0 additions & 47 deletions openfisca_aotearoa/tests/rta/interpretation/tenant.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions openfisca_aotearoa/variables/acts/rta/interpretation/bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ class residential_tenancies__bond(variables.Variable):
Any money, excluding rent, to be paid under a tenancy agreement by the
tenant, as security for the observance and performance of the tenancy.
"""
entity = entities.Tenancy
entity = entities.Premise
value_type = float
default_value = 0
definition_period = periods.DateUnit.WEEK

def formula_1987_02_01(tenancy, period, _params):
tenants = tenancy.members("residential_tenancies__tenant", period)
def formula_1987_02_01(premises, period, _params):
tenants = premises.members("residential_tenancies__tenant", period)

# bond means any sum of money payable or paid under a tenancy agreement
# as security for the observance and performance of the tenant’s
# obligations under the agreement and this Act;
housing_costs = tenancy.members("housing_costs", period)
rta1986_2_bond_a = tenancy.sum(housing_costs * tenants)
housing_costs = premises.members("housing_costs", period)
rta1986_2_bond_a = premises.sum(housing_costs * tenants)

# but does not include any sum payable or paid by way of rent
rent = tenancy("residential_tenancies__rent", period)
rent = premises("residential_tenancies__rent", period)
rta1986_2_bond_b = rent * tenants.any()

return numpy.maximum(rta1986_2_bond_a - rta1986_2_bond_b, 0)
12 changes: 6 additions & 6 deletions openfisca_aotearoa/variables/acts/rta/interpretation/rent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ class residential_tenancies__rent(variables.Variable):
Any valuable, including money, goods, services, and excluding bond, to
be paid under a tenancy agreement by the tenant.
"""
entity = entities.Tenancy
entity = entities.Premise
value_type = float
default_value = 0
definition_period = periods.DateUnit.WEEK

def formula_1987_02_01(tenancy, period, _params):
tenants = tenancy.members("residential_tenancies__tenant", period)
def formula_1987_02_01(premises, period, _params):
tenants = premises.members("residential_tenancies__tenant", period)

# rent means any money, goods, services, or other valuable
# consideration in the nature of rent to be paid or supplied under a
# tenancy agreement by the tenant;
housing_costs = tenancy.members("housing_costs", period)
rta1986_2_rent_a = tenancy.sum(housing_costs * tenants)
housing_costs = premises.members("housing_costs", period)
rta1986_2_rent_a = premises.sum(housing_costs * tenants)

# but does not include any sum of money payable or paid by way of bond
bond = tenancy("residential_tenancies__bond", period)
bond = premises("residential_tenancies__bond", period)
rta1986_2_rent_b = bond * tenants.any()

return numpy.maximum(rta1986_2_rent_a - rta1986_2_rent_b, 0)
14 changes: 0 additions & 14 deletions openfisca_aotearoa/variables/acts/rta/interpretation/tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,3 @@ class residential_tenancies__tenant(variables.Variable):
value_type = bool
default_value = False
definition_period = periods.DateUnit.WEEK

def formula_1987_02_01(people, _period, _params):
# tenant, in relation to any residential premises that are the subject
# of a tenancy agreement, means the grantee of a tenancy of the
# premises under the agreement; and, where appropriate, includes—
# (a) a prospective tenant; and
# (b) a former tenant; and
# (c) a lawful successor in title of a tenant to the premises; and
# (d) the personal representative of a deceased tenant; and
# (e) an agent of a tenant
return (
+ people.has_role(entities.Tenancy.APPLICANT)
+ people.has_role(entities.Tenancy.TENANT)
)
4 changes: 2 additions & 2 deletions openfisca_aotearoa/variables/exegesis/housing_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class housing_costs(variables.Variable):

def formula(people, period, _params):
tenants = people("residential_tenancies__tenant", period)
rent = people.tenancy("residential_tenancies__rent", period)
bond = people.tenancy("residential_tenancies__bond", period)
rent = people.premise("residential_tenancies__rent", period)
bond = people.premise("residential_tenancies__bond", period)

return (rent + bond) * tenants / numpy.add.reduce(tenants)

0 comments on commit 70347c1

Please sign in to comment.