Skip to content

Vendor

hypha.apply.projects.forms.vendor

BaseVendorForm

BaseVendorForm(site=None, *args, **kwargs)
Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, site=None, *args, **kwargs):
    if site:
        self.form_settings = VendorFormSettings.for_site(site)
    super().__init__(*args, **kwargs)

form_settings instance-attribute

form_settings = for_site(site)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

CreateVendorFormStep1

CreateVendorFormStep1(*args, **kwargs)

Bases: BaseVendorForm, Form

Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, *args, **kwargs):
    super(CreateVendorFormStep1, self).__init__(*args, **kwargs)
    self.fields = self.apply_form_settings(self.fields)

form_settings instance-attribute

form_settings = for_site(site)

TYPE_CHOICES class-attribute instance-attribute

TYPE_CHOICES = [('organization', gettext_lazy('Yes, the account belongs to the organisation above')), ('personal', gettext_lazy('No, it is a personal bank account'))]

name class-attribute instance-attribute

name = CharField(required=True)

contractor_name class-attribute instance-attribute

contractor_name = CharField(required=True)

type class-attribute instance-attribute

type = ChoiceField(choices=TYPE_CHOICES, required=True, widget=RadioSelect)

fields instance-attribute

fields = apply_form_settings(fields)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

CreateVendorFormStep2

CreateVendorFormStep2(*args, **kwargs)

Bases: BaseVendorForm, Form

Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, *args, **kwargs):
    super(CreateVendorFormStep2, self).__init__(*args, **kwargs)
    self.fields = self.apply_form_settings(self.fields)

form_settings instance-attribute

form_settings = for_site(site)

required_to_pay_taxes class-attribute instance-attribute

required_to_pay_taxes = TypedChoiceField(choices=((False, 'No'), (True, 'Yes')), coerce=lambda : x == 'True', widget=RadioSelect, required=True)

fields instance-attribute

fields = apply_form_settings(fields)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

CreateVendorFormStep3

CreateVendorFormStep3(*args, **kwargs)

Bases: FileFormMixin, BaseVendorForm, Form

Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, *args, **kwargs):
    super(CreateVendorFormStep3, self).__init__(*args, **kwargs)
    self.fields = self.apply_form_settings(self.fields)

form_settings instance-attribute

form_settings = for_site(site)

due_diligence_documents class-attribute instance-attribute

due_diligence_documents = MultiFileField(required=True)

fields instance-attribute

fields = apply_form_settings(fields)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

CreateVendorFormStep4

CreateVendorFormStep4(*args, **kwargs)

Bases: BaseVendorForm, Form

Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, *args, **kwargs):
    super(CreateVendorFormStep4, self).__init__(*args, **kwargs)
    self.fields = self.apply_form_settings(self.fields)

form_settings instance-attribute

form_settings = for_site(site)

CURRENCY_CHOICES class-attribute instance-attribute

CURRENCY_CHOICES = [(currency, f'{get_currency_name(currency, locale=CURRENCY_LOCALE)} - {currency}') for currency in get_active_currencies()]

account_holder_name class-attribute instance-attribute

account_holder_name = CharField(required=True)

account_routing_number class-attribute instance-attribute

account_routing_number = CharField(required=True)

account_number class-attribute instance-attribute

account_number = CharField(required=True)

account_currency class-attribute instance-attribute

account_currency = ChoiceField(choices=sorted(CURRENCY_CHOICES, key=itemgetter(1)), required=True, initial='USD')

fields instance-attribute

fields = apply_form_settings(fields)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

CreateVendorFormStep5

CreateVendorFormStep5(*args, **kwargs)

Bases: BaseVendorForm, Form

Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, *args, **kwargs):
    super(CreateVendorFormStep5, self).__init__(*args, **kwargs)
    self.fields = self.apply_form_settings(self.fields)

form_settings instance-attribute

form_settings = for_site(site)

need_extra_info class-attribute instance-attribute

need_extra_info = TypedChoiceField(choices=((False, gettext_lazy('No')), (True, gettext_lazy('Yes'))), coerce=lambda : x == 'True', widget=RadioSelect, required=True)

fields instance-attribute

fields = apply_form_settings(fields)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

CreateVendorFormStep6

CreateVendorFormStep6(*args, **kwargs)

Bases: BaseVendorForm, Form

Source code in hypha/apply/projects/forms/vendor.py
def __init__(self, *args, **kwargs):
    super(CreateVendorFormStep6, self).__init__(*args, **kwargs)
    self.fields = self.apply_form_settings(self.fields)

form_settings instance-attribute

form_settings = for_site(site)

CURRENCY_CHOICES class-attribute instance-attribute

CURRENCY_CHOICES = [(currency, f'{get_currency_name(currency, locale=CURRENCY_LOCALE)} - {currency}') for currency in get_active_currencies()]

branch_address class-attribute instance-attribute

branch_address = AddressField()

ib_account_routing_number class-attribute instance-attribute

ib_account_routing_number = CharField(required=False)

ib_account_number class-attribute instance-attribute

ib_account_number = CharField(required=False)

ib_account_currency class-attribute instance-attribute

ib_account_currency = ChoiceField(choices=sorted(CURRENCY_CHOICES, key=itemgetter(1)), required=False, initial='USD')

ib_branch_address class-attribute instance-attribute

ib_branch_address = AddressField()

nid_type class-attribute instance-attribute

nid_type = CharField(required=False)

nid_number class-attribute instance-attribute

nid_number = CharField(required=False)

other_info class-attribute instance-attribute

other_info = CharField(required=False, widget=Textarea)

fields instance-attribute

fields = apply_form_settings(fields)

apply_form_settings

apply_form_settings(fields)
Source code in hypha/apply/projects/forms/vendor.py
def apply_form_settings(self, fields):
    for field in fields:
        try:
            self.fields[field].label = getattr(self.form_settings, f"{field}_label")
        except AttributeError:
            pass
        try:
            self.fields[field].help_text = getattr(
                self.form_settings, f"{field}_help_text"
            )
        except AttributeError:
            pass
    return fields

get_active_currencies

get_active_currencies()
Source code in hypha/apply/projects/forms/vendor.py
def get_active_currencies():
    active_currencies = []
    territories = get_global("territory_currencies").keys()
    for territory in territories:
        currencies = get_territory_currencies(territory, datetime.date.today())
        if currencies:
            for currency in currencies:
                if currency not in active_currencies:
                    active_currencies.append(currencies[0])
    return active_currencies