diff --git a/hypha/apply/projects/migrations/0036_add_vendor.py b/hypha/apply/projects/migrations/0036_add_vendor.py index 2a7583005714e41c1410dd3d5919cfb32b416ca3..162e2249a9fce0a970494976bd976e698ac6b09e 100644 --- a/hypha/apply/projects/migrations/0036_add_vendor.py +++ b/hypha/apply/projects/migrations/0036_add_vendor.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.24 on 2021-06-14 07:09 +# Generated by Django 2.2.24 on 2021-06-14 11:33 from django.conf import settings import django.core.files.storage @@ -56,37 +56,37 @@ class Migration(migrations.Migration): ('contractor_name_label', models.TextField(default="2. What is the individual's name who is signing the contract?", verbose_name='label')), ('contractor_name_help_text', wagtail.core.fields.RichTextField(blank=True, default='This person is is authorised to sign contract on behalf of the person or organization named above.', verbose_name='help text')), ('type_label', models.TextField(default='3. Is the bank account owned by the person or organisation in the Question 1 above?', verbose_name='label')), - ('type_help_text', wagtail.core.fields.RichTextField(default='The name of the bank account must be the same as on the contract.', verbose_name='help_text')), + ('type_help_text', wagtail.core.fields.RichTextField(blank=True, default='The name of the bank account must be the same as on the contract.', verbose_name='help_text')), ('required_to_pay_taxes_label', models.TextField(default='Is the organisation required to pay US taxes?', verbose_name='label')), ('required_to_pay_taxes_help_text', wagtail.core.fields.RichTextField(blank=True, default='', verbose_name='help_text')), ('due_diligence_documents_label', models.TextField(default='Due Diligence Documents', verbose_name='label')), - ('due_diligence_documents_help_text', wagtail.core.fields.RichTextField(default='Upload Due Diligence Documents. E.g. w8/w9 forms.', verbose_name='help_text')), + ('due_diligence_documents_help_text', wagtail.core.fields.RichTextField(blank=True, default='Upload Due Diligence Documents. E.g. w8/w9 forms.', verbose_name='help_text')), ('account_holder_name_label', models.TextField(default='Bank Account Holder name', verbose_name='label')), - ('account_holder_name_help_text', wagtail.core.fields.RichTextField(default='This name must be same as the person or organisation that signed the contract. This person is authorised to sign contracts on behalf of the person or organisation named above.', verbose_name='help_text')), + ('account_holder_name_help_text', wagtail.core.fields.RichTextField(blank=True, default='This name must be same as the person or organisation that signed the contract. This person is authorised to sign contracts on behalf of the person or organisation named above.', verbose_name='help_text')), ('account_routing_number_label', models.TextField(default='Bank Account Routing number', verbose_name='label')), - ('account_routing_number_help_text', wagtail.core.fields.RichTextField(default='Depending on your country, this might be called the ACH, SWIFT, BIC or ABA number.', verbose_name='help_text')), + ('account_routing_number_help_text', wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called the ACH, SWIFT, BIC or ABA number.', verbose_name='help_text')), ('account_number_label', models.TextField(default='Bank Account Number', verbose_name='label')), - ('account_number_help_text', wagtail.core.fields.RichTextField(default='Depending on your country, this might be called the account number, IBAN, or BBAN number.', verbose_name='help_text')), + ('account_number_help_text', wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number.', verbose_name='help_text')), ('account_currency_label', models.TextField(default='Bank Account Currency', verbose_name='label')), - ('account_currency_help_text', wagtail.core.fields.RichTextField(default='This is the currency of this bank account.', verbose_name='label')), + ('account_currency_help_text', wagtail.core.fields.RichTextField(blank=True, default='This is the currency of this bank account.', verbose_name='label')), ('need_extra_info_label', models.TextField(default='Do you need to provide us with extra information?', verbose_name='label')), - ('need_extra_info_help_text', wagtail.core.fields.RichTextField(default='', verbose_name='help_text')), + ('need_extra_info_help_text', wagtail.core.fields.RichTextField(blank=True, default='', verbose_name='help_text')), ('branch_address_label', models.TextField(default='Bank Account Branch Address', verbose_name='label')), - ('branch_address_help_text', models.TextField(default='The address of the bank branch where you have the bank account located(not the bank account holder address)', verbose_name='help_text')), - ('ib_account_routing_number_label', models.TextField(default='Bank Account Routing Number', verbose_name='label')), - ('ib_account_routing_number_help_text', wagtail.core.fields.RichTextField(default='Depending on your country, this might be called ACH, SWIFT, BIC or ABA number', verbose_name='help_text')), - ('ib_account_number_label', models.TextField(default='Bank Account Number', verbose_name='label')), - ('ib_account_number_help_text', wagtail.core.fields.RichTextField(default='Depending on your country, this might be called the account number, IBAN, or BBAN number', verbose_name='help_text')), - ('ib_account_currency_label', models.TextField(default='Bank Account Currency', verbose_name='label')), - ('ib_account_currency_help_text', wagtail.core.fields.RichTextField(default='This is the currency of this bank account', verbose_name='help_text')), + ('branch_address_help_text', models.TextField(blank=True, default='The address of the bank branch where you have the bank account located(not the bank account holder address)', verbose_name='help_text')), + ('ib_account_routing_number_label', models.TextField(default='Intermediary Bank Account Routing Number', verbose_name='label')), + ('ib_account_routing_number_help_text', wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called ACH, SWIFT, BIC or ABA number', verbose_name='help_text')), + ('ib_account_number_label', models.TextField(default='Intermediary Bank Account Number', verbose_name='label')), + ('ib_account_number_help_text', wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number', verbose_name='help_text')), + ('ib_account_currency_label', models.TextField(default='Intermediary Bank Account Currency', verbose_name='label')), + ('ib_account_currency_help_text', wagtail.core.fields.RichTextField(blank=True, default='This is the currency of this bank account', verbose_name='help_text')), ('ib_branch_address_label', models.TextField(default='Intermediary Bank Branch Address', verbose_name='label')), - ('ib_branch_address_help_text', wagtail.core.fields.RichTextField(default='Bank branch address(not the bank account holder address)', verbose_name='help_text')), - ('nid_type_label', models.TextField(default='National Identity Document Type', verbose_name='label')), - ('nid_type_help_text', wagtail.core.fields.RichTextField(default='This could be a passport, a National Identity number, or other national identity document.', verbose_name='help_text')), - ('nid_number_label', models.TextField(default='National Identity Document Number', verbose_name='label')), - ('nid_number_help_text', wagtail.core.fields.RichTextField(default='', verbose_name='help_text')), + ('ib_branch_address_help_text', wagtail.core.fields.RichTextField(blank=True, default='Bank branch address(not the bank account holder address)', verbose_name='help_text')), + ('nid_type_label', models.TextField(default='Account Holder National Identity Document Type', verbose_name='label')), + ('nid_type_help_text', wagtail.core.fields.RichTextField(blank=True, default='This could be a passport, a National Identity number, or other national identity document.', verbose_name='help_text')), + ('nid_number_label', models.TextField(default='Account Holder National Identity Document Number', verbose_name='label')), + ('nid_number_help_text', wagtail.core.fields.RichTextField(blank=True, default='', verbose_name='help_text')), ('other_info_label', models.TextField(default='Other Information', verbose_name='label')), - ('other_info_help_text', wagtail.core.fields.RichTextField(default='If you need to include other information not listed above, provide it here.', verbose_name='help_text')), + ('other_info_help_text', wagtail.core.fields.RichTextField(blank=True, default='If you need to include other information not listed above, provide it here.', verbose_name='help_text')), ('site', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='wagtailcore.Site')), ], options={ diff --git a/hypha/apply/projects/models/vendor.py b/hypha/apply/projects/models/vendor.py index f33a11dac8c426072d537758990fc941725b2a16..43385b512ed02171d491461ad25c2d4e59082dc8 100644 --- a/hypha/apply/projects/models/vendor.py +++ b/hypha/apply/projects/models/vendor.py @@ -185,7 +185,7 @@ class VendorFormSettings(BaseSetting): ) ib_account_routing_number_label = models.TextField( 'label', - default='Bank Account Routing Number' + default='Intermediary Bank Account Routing Number' ) ib_account_routing_number_help_text = RichTextField( 'help_text', @@ -194,7 +194,7 @@ class VendorFormSettings(BaseSetting): ) ib_account_number_label = models.TextField( 'label', - default='Bank Account Number' + default='Intermediary Bank Account Number' ) ib_account_number_help_text = RichTextField( 'help_text', @@ -203,7 +203,7 @@ class VendorFormSettings(BaseSetting): ) ib_account_currency_label = models.TextField( 'label', - default='Bank Account Currency' + default='Intermediary Bank Account Currency' ) ib_account_currency_help_text = RichTextField( 'help_text', @@ -221,7 +221,7 @@ class VendorFormSettings(BaseSetting): ) nid_type_label = models.TextField( 'label', - default='National Identity Document Type' + default='Account Holder National Identity Document Type' ) nid_type_help_text = RichTextField( 'help_text', @@ -231,7 +231,7 @@ class VendorFormSettings(BaseSetting): ) nid_number_label = models.TextField( 'label', - default='National Identity Document Number' + default='Account Holder National Identity Document Number' ) nid_number_help_text = RichTextField( 'help_text', diff --git a/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html b/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html index f8b7a96c3538714b6236cc10af10b1118f07e37a..089df603a860c8aa1d8e8f58b35f9348bc7bf311 100644 --- a/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html +++ b/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html @@ -26,7 +26,7 @@ <p class="docs-block__title">Contractor Setup Form</p> </div> <div class="docs-block__row-inner"> - <a class="docs-block__link" href="{% url 'apply:projects:vendor' pk=project.pk %}">Add info</a> + <a class="docs-block__link" href="{% url 'apply:projects:vendor' pk=project.pk %}">Update info</a> </div> </li> diff --git a/hypha/apply/projects/views/vendor.py b/hypha/apply/projects/views/vendor.py index 41c835cc64a0d04bdac73a32a7e6ccad72cf113a..c2190699280e2c937fb3ea00f36e42afd6632f56 100644 --- a/hypha/apply/projects/views/vendor.py +++ b/hypha/apply/projects/views/vendor.py @@ -7,7 +7,7 @@ from wagtail.core.models import Site from formtools.wizard.views import SessionWizardView from hypha.apply.utils.storage import PrivateStorage -from ..models import Project, Vendor, DueDiligenceDocument, BankInformation +from ..models import Project, DueDiligenceDocument, BankInformation from ..forms import ( CreateVendorFormStep1, CreateVendorFormStep2, @@ -56,28 +56,50 @@ class CreateVendorView(VendorAccessMixin, SessionWizardView): cleaned_data = self.get_all_cleaned_data() vendor = vendor_project.vendor need_extra_info = cleaned_data['need_extra_info'] - bank_information = BankInformation.objects.create( - account_holder_name=cleaned_data['account_holder_name'], - account_routing_number=cleaned_data['account_routing_number'], - account_number=cleaned_data['account_number'], - account_currency=cleaned_data['account_currency'], - need_extra_info=need_extra_info, - ) - if need_extra_info: - intermediary_bank_information = BankInformation.objects.create( - account_routing_number=cleaned_data['ib_account_routing_number'], - account_number=cleaned_data['ib_account_number'], - account_currency=cleaned_data['ib_account_currency'], - # branch_address=cleaned_data['ib_branch_address'] + bank_info = vendor.bank_info + account_holder_name = cleaned_data['account_holder_name'] + account_routing_number = cleaned_data['account_routing_number'] + account_number = cleaned_data['account_number'] + account_currency = cleaned_data['account_currency'] + if not bank_info: + bank_info = BankInformation.objects.create( + account_holder_name=account_holder_name, + account_number=account_number, + account_routing_number=account_routing_number, + account_currency=account_currency, + need_extra_info=need_extra_info, ) - bank_information.branch_address = cleaned_data['branch_address'] - bank_information.nid_type = cleaned_data['nid_type'] - bank_information.nid_number = cleaned_data['nid_number'] - bank_information.iba_info = intermediary_bank_information - bank_information.save() - - vendor.bank_info = bank_information - vendor.other_info = cleaned_data['other_info'] + else: + bank_info.account_holder_name = account_holder_name + bank_info.account_number = account_number + bank_info.account_currency = account_currency + bank_info.need_extra_info = need_extra_info + if need_extra_info: + ib_account_routing_number = cleaned_data['ib_account_routing_number'] + ib_account_number = cleaned_data['ib_account_number'] + ib_account_currency = cleaned_data['ib_account_currency'] + # branch_address=cleaned_data['ib_branch_address'] + iba_info = bank_info.iba_info + if not iba_info: + iba_info = BankInformation.objects.create( + account_routing_number=ib_account_routing_number, + account_number=ib_account_number, + account_currency=ib_account_currency, + ) + else: + iba_info.account_routing_number = ib_account_routing_number + iba_info.account_number = ib_account_number + iba_info.account_currency = ib_account_currency + + bank_info.branch_address = cleaned_data['branch_address'] + bank_info.nid_type = cleaned_data['nid_type'] + bank_info.nid_number = cleaned_data['nid_number'] + bank_info.iba_info = iba_info + vendor.other_info = cleaned_data['other_info'] + + bank_info.save() + + vendor.bank_info = bank_info vendor.name = cleaned_data['name'] vendor.contractor_name = cleaned_data['contractor_name'] vendor.type = cleaned_data['type']