Skip to content

Commit

Permalink
EDA-1195: Not remembering EB Entity to bill when editing Taxpayer Inf…
Browse files Browse the repository at this point in the history
…ormation (#374)

EDA-1195: Not remembering EB Entity to bill when editing Taxpayer Information
  • Loading branch information
sarias-eb authored Jun 17, 2020
1 parent dda6d26 commit 89868b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion supplier_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class TaxPayerArgentinaBaseForm(ModelForm):
widget=forms.RadioSelect(attrs={"class": "form-check-input"}),
choices=get_eb_entities(),
label=_("Eventbrite entities to bill"),
initial=1,

)

Expand Down
6 changes: 4 additions & 2 deletions supplier_app/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ def tearDown(self):
rmtree('file')

def test_get_success_url_should_redirect_to_details_view_when_click_in_update_button(self):
TaxPayerEBEntityFactory(taxpayer=self.taxpayer)
response = self.client.get(
reverse(
self.taxpayer_edit_url,
Expand Down Expand Up @@ -1179,7 +1180,7 @@ def test_post_edit_active_taxpayer_as_ap_dont_chang_state(self):
status_approved
)

def test_taxpayer_edit_view_should_render_eb_entities_related(self):
def test_taxpayer_edit_view_should_render_last_eb_entities(self):
taxpayer = TaxPayerArgentinaFactory(
company=self.taxpayer.company,
)
Expand All @@ -1194,7 +1195,7 @@ def test_taxpayer_edit_view_should_render_eb_entities_related(self):
),
)
self.assertEqual(
[taxpayer_eb_entity_1.eb_entity, taxpayer_eb_entity_2.eb_entity],
taxpayer_eb_entity_2.eb_entity.id,
response.context_data['form'].fields['eb_entities'].initial)

def test_form_valid_method_should_update_eb_entities(self):
Expand Down Expand Up @@ -1232,6 +1233,7 @@ def test_edit_taxpayer_view_should_populate_file_fields_with_existing_files(self
self.taxpayer.iibb_no_retention_taxes_file = self.file_mock
self.taxpayer.iibb_registration_file = self.file_mock
self.taxpayer.save()
TaxPayerEBEntityFactory(taxpayer=self.taxpayer)

response = self.client.get(
reverse(
Expand Down
3 changes: 2 additions & 1 deletion supplier_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ def get_context_data(self, **kwargs):

form.fields['afip_registration_file'].initial = taxpayer.afip_registration_file
form.fields['witholding_taxes_file'].initial = taxpayer.witholding_taxes_file
form.fields['eb_entities'].initial = taxpayer.eb_entities
# Todo: migrate relation to OneToOne
form.fields['eb_entities'].initial = taxpayer.eb_entities.pop().id
return context

def handle_no_permission(self):
Expand Down

0 comments on commit 89868b0

Please sign in to comment.