Example #1
0
    def test_include_countries(self):
        """ Test the IBAN model and form include_countries feature. """
        include_countries = ('NL', 'BE', 'LU')

        valid = {
            'NL02ABNA0123456789': 'NL02ABNA0123456789',
            'BE68539007547034': 'BE68539007547034',
            'LU280019400644750000': 'LU280019400644750000'
        }

        invalid = {
            # This IBAN is valid but not for the configured countries.
            'GB82WEST12345698765432':
            ['GB IBANs are not allowed in this field.']
        }

        self.assertFieldOutput(
            IBANFormField,
            field_kwargs={'include_countries': include_countries},
            valid=valid,
            invalid=invalid)

        # Test valid inputs for model field.
        iban_model_field = IBANField(include_countries=include_countries)
        for input, output in valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            # The error messages for models are in a different order.
            errors.reverse()
            self.assertEqual(context_manager.exception.messages, errors)
Example #2
0
 def test_model_field_deconstruct(self):
     # test_instance must be created with the non-default options.
     test_instance = IBANField(include_countries=('NL', 'BE'), use_nordea_extensions=True)
     name, path, args, kwargs = test_instance.deconstruct()
     new_instance = IBANField(*args, **kwargs)
     for attr in ('include_countries', 'use_nordea_extensions'):
         self.assertEqual(getattr(test_instance, attr), getattr(new_instance, attr))
    def test_include_countries(self):
        """ Test the IBAN model and form include_countries feature. """
        include_countries = ("NL", "BE", "LU")

        valid = {
            "NL02ABNA0123456789": "NL02ABNA0123456789",
            "BE68539007547034": "BE68539007547034",
            "LU280019400644750000": "LU280019400644750000",
        }

        invalid = {
            # This IBAN is valid but not for the configured countries.
            "GB82WEST12345698765432": ["GB IBANs are not allowed in this field."]
        }

        self.assertFieldOutput(
            IBANFormField, field_kwargs={"include_countries": include_countries}, valid=valid, invalid=invalid
        )

        # Test valid inputs for model field.
        iban_model_field = IBANField(include_countries=include_countries)
        for input, output in valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            # The error messages for models are in a different order.
            errors.reverse()
            self.assertEqual(context_manager.exception.messages, errors)
Example #4
0
    def test_iban_fields(self):
        """Test the IBAN model and form field."""
        valid = {
            'NL02ABNA0123456789': 'NL02ABNA0123456789',
            'Nl02aBNa0123456789': 'NL02ABNA0123456789',
            'NL02 ABNA 0123 4567 89': 'NL02ABNA0123456789',
            'NL02-ABNA-0123-4567-89': 'NL02ABNA0123456789',

            'NL91ABNA0417164300': 'NL91ABNA0417164300',
            'NL91 ABNA 0417 1643 00': 'NL91ABNA0417164300',
            'NL91-ABNA-0417-1643-00': 'NL91ABNA0417164300',

            'MU17BOMM0101101030300200000MUR': 'MU17BOMM0101101030300200000MUR',
            'MU17 BOMM 0101 1010 3030 0200 000M UR': 'MU17BOMM0101101030300200000MUR',
            'MU 17BO MM01011010 3030-02 000-00M UR': 'MU17BOMM0101101030300200000MUR',

            'BE68539007547034': 'BE68539007547034',
            'BE68 5390 0754 7034': 'BE68539007547034',
            'BE-685390075470 34': 'BE68539007547034',
        }

        invalid = {
            'NL02ABNA012345678999': ['NL IBANs must contain 18 characters.'],
            'NL02 ABNA 0123 4567 8999': ['NL IBANs must contain 18 characters.'],

            'NL91ABNB0417164300': ['Not a valid IBAN.'],
            'NL91 ABNB 0417 1643 00': ['Not a valid IBAN.'],

            'MU17BOMM0101101030300200000MUR12345': [
                'MU IBANs must contain 30 characters.',
                'Ensure this value has at most 34 characters (it has 35).'],
            'MU17 BOMM 0101 1010 3030 0200 000M UR12 345': [
                'MU IBANs must contain 30 characters.',
                'Ensure this value has at most 34 characters (it has 35).'],

            # This IBAN should only be valid only if the Nordea extensions are turned on.
            'EG1100006001880800100014553': ['EG is not a valid country code for IBAN.'],
            'EG11 0000 6001 8808 0010 0014 553': ['EG is not a valid country code for IBAN.']
        }

        self.assertFieldOutput(IBANFormField, valid=valid, invalid=invalid)

        # Test valid inputs for model field.
        iban_model_field = IBANField()
        for input, output in valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        self.assertIsNone(iban_model_field.to_python(None))

        # Invalid inputs for model field.
        for input, errors in invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            # The error messages for models are in a different order.
            errors.reverse()
            self.assertEqual(context_manager.exception.messages, errors)
Example #5
0
    def test_iban_fields(self):
        """ Test the IBAN model and form field. """
        valid = {
            'NL02ABNA0123456789': 'NL02ABNA0123456789',
            'Nl02aBNa0123456789': 'NL02ABNA0123456789',
            'NL02 ABNA 0123 4567 89': 'NL02ABNA0123456789',
            'NL02-ABNA-0123-4567-89': 'NL02ABNA0123456789',
            'NL91ABNA0417164300': 'NL91ABNA0417164300',
            'NL91 ABNA 0417 1643 00': 'NL91ABNA0417164300',
            'NL91-ABNA-0417-1643-00': 'NL91ABNA0417164300',
            'MU17BOMM0101101030300200000MUR': 'MU17BOMM0101101030300200000MUR',
            'MU17 BOMM 0101 1010 3030 0200 000M UR':
            'MU17BOMM0101101030300200000MUR',
            'MU 17BO MM01011010 3030-02 000-00M UR':
            'MU17BOMM0101101030300200000MUR',
            'BE68539007547034': 'BE68539007547034',
            'BE68 5390 0754 7034': 'BE68539007547034',
            'BE-685390075470 34': 'BE68539007547034',
        }

        invalid = {
            'NL02ABNA012345678999': ['NL IBANs must contain 18 characters.'],
            'NL02 ABNA 0123 4567 8999':
            ['NL IBANs must contain 18 characters.'],
            'NL91ABNB0417164300': ['Not a valid IBAN.'],
            'NL91 ABNB 0417 1643 00': ['Not a valid IBAN.'],
            'MU17BOMM0101101030300200000MUR12345': [
                'MU IBANs must contain 30 characters.',
                'Ensure this value has at most 34 characters (it has 35).'
            ],
            'MU17 BOMM 0101 1010 3030 0200 000M UR12 345': [
                'MU IBANs must contain 30 characters.',
                'Ensure this value has at most 34 characters (it has 35).'
            ],

            # This IBAN should only be valid only if the Nordea extensions are turned on.
            'EG1100006001880800100014553':
            ['EG is not a valid country code for IBAN.'],
            'EG11 0000 6001 8808 0010 0014 553':
            ['EG is not a valid country code for IBAN.']
        }

        self.assertFieldOutput(IBANFormField, valid=valid, invalid=invalid)

        # Test valid inputs for model field.
        iban_model_field = IBANField()
        for input, output in valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            # The error messages for models are in a different order.
            errors.reverse()
            self.assertEqual(context_manager.exception.messages, errors)
class User(models.Model):

    nameRegex = RegexValidator(
        regex=r'^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,.\'-]+$',
        message='Only characters from A to Z are allowed.'
    )

    creator = models.ForeignKey(AdminUser, on_delete=models.CASCADE)

    firstName = models.CharField(
        max_length=35,
        verbose_name='First Name',
        help_text='First Name',
        validators=[nameRegex],
        blank=False
    )

    lastName = models.CharField(
        max_length=50,
        verbose_name='Last Name',
        help_text="Last Name",
        validators=[nameRegex],
        blank=False
    )

    iban = IBANField(unique=True)

    def __str__(self):
        return 'First Name: {0}, Last Name: {1}'.format(self.firstName, self.lastName)
Example #7
0
class Application(models.Model):

    applicant = models.ForeignKey('Applicant')
    offer_year = models.ForeignKey('base.OfferYear')
    creation_date = models.DateTimeField(auto_now=True)
    application_type = models.CharField(
        max_length=20, choices=application_type.APPLICATION_TYPE_CHOICES)
    coverage_access_degree = models.CharField(
        max_length=30,
        blank=True,
        null=True,
        choices=coverage_access_degree.COVERAGE_ACCESS_DEGREE_CHOICES)
    valuation_possible = models.NullBooleanField(default=None)
    started_similar_studies = models.NullBooleanField(default=None)
    credits_to_value = models.NullBooleanField(default=None)
    applied_to_sameprogram = models.NullBooleanField(default=None)
    resident = models.NullBooleanField(default=None)
    raffle_number = models.CharField(max_length=50, blank=True, null=True)
    study_grant = models.BooleanField(default=False)
    study_grant_number = models.CharField(max_length=50, blank=True, null=True)
    deduction_children = models.BooleanField(default=False)
    scholarship = models.BooleanField(default=False)
    scholarship_organization = models.TextField(blank=True, null=True)
    sport_membership = models.BooleanField(default=False)
    culture_membership = models.BooleanField(default=False)
    solidarity_membership = models.BooleanField(default=False)
    bank_account_iban = IBANField(include_countries=IBAN_SEPA_COUNTRIES,
                                  blank=True,
                                  null=True)
    bank_account_bic = BICField(blank=True, null=True)
    bank_account_name = models.CharField(max_length=255, blank=True, null=True)

    def __str__(self):
        return u"%s %s" % (self.applicant, self.offer_year)
Example #8
0
class IBANAccount(AbstractBaseModel):
    """
    IBANAccount

    :first_name `CharField` required.

    :las_name `CharField` required.

    :active `BooleanField` required, with True as default,
             only superusers can activate or deactivate the account.

    :created_by `ForeignKey` required, User instance relation.

    :iban `IBANField` required.
    """
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    active = models.BooleanField(default=True)
    created_by = models.ForeignKey(User, on_delete=models.CASCADE)
    iban = IBANField(verbose_name='IBAN', use_nordea_extensions=True)

    objects = ActiveManager.as_manager()

    class Meta:
        ordering = ['-created_at']
        verbose_name_plural = 'IBAN accounts'

    def __str__(self):
        return '{first_name}, {last_name}'.format(
            first_name=self.first_name, last_name=self.last_name
        )

    def get_absolute_url(self):
        return reverse('iban:iban_detail', kwargs={'pk': self.id})
Example #9
0
class MemberSepa(Auditable, models.Model):

    member = AutoOneToOneField(
        to='members.Member',
        related_name='profile_sepa',
        on_delete=models.PROTECT,
    )

    iban = IBANField(null=True, blank=True, verbose_name="IBAN")
    bic = BICField(null=True, blank=True, verbose_name="BIC")

    institute = models.CharField(
        max_length=255,
        null=True, blank=True,
        verbose_name="IBAN Institute")

    issue_date = models.DateField(
        null=True, blank=True,
        verbose_name="IBAN Issue Date",
        help_text="The issue date of the direct debit mandate. (1970-01-01 means there is no issue date in the database )")

    fullname = models.CharField(
        null=True, blank=True,
        max_length=255, verbose_name="IBAN full name",
        help_text="Full name for IBAN account owner")

    address = models.CharField(
        null=True, blank=True,
        max_length=255, verbose_name="IBAN address",
        help_text="Address line (e.g. Street / House Number)")

    zip_code = models.CharField(
        null=True, blank=True,
        max_length=20, verbose_name="IBAN zip code",
        help_text="ZIP Code")

    city = models.CharField(
        null=True, blank=True,
        max_length=255, verbose_name="IBAN City",)

    country = models.CharField(
        null=True, blank=True,
        max_length=255, default="Deutschland",
        verbose_name="IBAN Country",)

    mandate_reference = models.CharField(
        null=True, blank=True,
        max_length=255,
        verbose_name="IBAN Mandate Reference",)

    mandate_reason = models.CharField(
        null=True, blank=True,
        max_length=255,
        verbose_name="IBAN Mandate Reason",)

    form_title = _('SEPA information')

    @property
    def is_usable(self):
        return bool(self.iban and self.bic and self.mandate_reference)
Example #10
0
class User(AbstractUser):

    # First Name and Last Name do not cover name patterns
    # around the globe.
    name = models.CharField(_('Name of User'), blank=True, max_length=255)
    created_by = models.ForeignKey('self', null=True, editable=False)
    iban = IBANField(null=True)

    def __str__(self):
        return self.get_full_name()

    def get_absolute_url(self):
        return reverse('users:detail', kwargs={'pk': self.pk})

    def can_modify(self, user):
        """

        :type user: regiohelden.users.models.User
        :param user: User to be modified
        :rtype: bool
        """
        return self.has_google_account() and (user.created_by == self
                                              or user == self)

    def has_google_account(self):
        return self.socialaccount_set.filter(provider="google").exists()
class CustomerUser(models.Model):
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    iban = IBANField(include_countries=IBAN_SEPA_COUNTRIES)
    user_created = models.ForeignKey(User, on_delete=models.CASCADE)  # admin who created this user

    def __str__(self):
        return '%s %s %s' % (self.first_name, self.last_name, self.iban)
Example #12
0
class User(models.Model):
    admin_id = models.ForeignKey(User, on_delete=models.CASCADE)
    first_name = models.CharField(max_length=64)
    last_name = models.CharField(max_length=64)
    iban = IBANField()

    def __str__(self):
        return self.first_name + ' ' + self.last_name
Example #13
0
class User(models.Model):
    creator = models.ForeignKey(AdminUser)
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    iban = IBANField()

    def __str__(self):
        return '{} {}'.format(self.first_name, self.last_name)
Example #14
0
class UserProfile(models.Model):
    owner = models.ForeignKey(User, on_delete=models.CASCADE)
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=200)
    iban = IBANField()

    def __str__(self):
        return f"{self.first_name}-{self.last_name}"
Example #15
0
class DirectDebitMandate(models.Model):
    customer = models.ForeignKey('customer.Customer',
                                 on_delete=models.CASCADE,
                                 verbose_name=_('customer'),
                                 related_name='direct_debit_mandate_set')
    reference = models.CharField(_('mandate reference'),
                                 max_length=35,
                                 unique=True,
                                 blank=True,
                                 null=True)
    name = models.CharField(max_length=100)
    street = models.CharField(max_length=100)
    postal_code = models.CharField(max_length=20)
    city = models.CharField(max_length=100)
    country = CountryField(default='DE')
    iban = IBANField('IBAN', help_text='International Bank Account Number')
    bic = BICField('BIC', help_text='Bank Identifier Code')
    bank_name = models.CharField(max_length=50, blank=True)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    updated = models.DateTimeField(_('updated'), auto_now=True)
    signed = models.DateField(blank=True, null=True)
    revoked = models.DateField(_('revoked'), blank=True, null=True)
    last_used = models.DateField(_('last_used'), blank=True, null=True)
    TYPE_CORE = 'CORE'
    TYPE_COR1 = 'COR1'
    TYPE_B2B = 'B2B'
    TYPE_CHOICES = (
        (TYPE_CORE, 'CORE'),
        (TYPE_COR1, 'COR1'),
        (TYPE_B2B, 'B2B'),
    )
    type = models.CharField(max_length=4, choices=TYPE_CHOICES)

    #document = models.ForeignKey('documents.Document',
    #        on_delete=models.CASCADE,
    #        verbose_name=_('signed document'),
    #        blank=True, null=True)

    class Meta:
        verbose_name = _('SEPA direct debit mandate')
        verbose_name_plural = _('SEPA direct debit mandates')

    def __str__(self):
        if self.reference:
            return self.reference
        else:
            return '<no reference>'

    @property
    def address_lines(self):
        return [
            self.name, self.street, self.postal_code + ' ' + self.city,
            self.get_country_display()
        ]

    @property
    def anonymized_iban(self):
        return anonymize_iban(self.iban)
Example #16
0
class User(AbstractUser):
    iban = IBANField(include_countries=IBAN_SEPA_COUNTRIES,
                     blank=True,
                     null=True)
    creator = models.ForeignKey('User',
                                related_name="created",
                                on_delete=models.CASCADE,
                                blank=True,
                                null=True)
Example #17
0
class BankAccount(models.Model):
    STATUSES = Choices(
        (1, 'active', _('Active')),
        (2, 'suspended', _('Suspended')),
    )
    iban = IBANField(unique=True)
    owner = models.ForeignKey(User,
                              on_delete=models.CASCADE,
                              related_name='accounts')
    status = models.IntegerField(choices=STATUSES, default=STATUSES.active)
Example #18
0
class User(AbstractUser):
    iban = IBANField(_('IBAN'), null=True, unique=True)
    created_by = models.ForeignKey('self',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='owned_users')

    def __str__(self):
        return self.get_full_name() or self.get_username()
Example #19
0
class BillingProfile(BillingInfo):
    user = models.OneToOneField(settings.AUTH_USER_MODEL, models.CASCADE)
    bic = BICField(blank=True)
    iban = IBANField(blank=True)


    @receiver(post_save, sender=settings.AUTH_USER_MODEL)
    def create_profile(sender, instance, created=False, **kwargs):
        if created:
            BillingProfile.objects.create(user=instance)
Example #20
0
class IBAN(models.Model):
    user = models.ForeignKey(User,
                             related_name='ibans',
                             on_delete=models.CASCADE)
    number = IBANField(include_countries=IBAN_SEPA_COUNTRIES)
    creator = models.ForeignKey(User,
                                related_name='created_ibans',
                                on_delete=models.PROTECT)

    def __str__(self):
        return self.number
Example #21
0
class User(AbstractUser):
    """
    Custom user model
    """
    EURO = 0
    POUND = 1
    DOLLAR = 2
    YEN = 3
    FRANC = 4
    CROWN = 5

    CURRENCIES = ((EURO, 'Euro'), (POUND, 'Pound Sterling'),
                  (DOLLAR, 'US Dollar'), (YEN, 'Yen'), (FRANC, 'Swiss Franc'),
                  (CROWN, 'Swedish Crown'))

    first_name = models.CharField(max_length=30,
                                  blank=False,
                                  validators=[MinLengthValidator(1)],
                                  help_text="This user's first name.")
    last_name = models.CharField(max_length=150,
                                 blank=False,
                                 validators=[MinLengthValidator(1)],
                                 help_text="This user's last name.")
    iban = IBANField(unique=True,
                     null=True,
                     blank=True,
                     help_text='IBAN code to identify this account.')
    balance = models.FloatField(
        default=0,
        blank=True,
        help_text='Current amount of money in this account.')
    currency = models.IntegerField(choices=CURRENCIES,
                                   default=EURO,
                                   help_text='Currency of this account.')
    create_ts = models.DateTimeField(
        auto_now_add=True,
        blank=True,
        help_text='Time when this account was created.')
    update_ts = models.DateTimeField(
        auto_now=True,
        blank=True,
        help_text='Time when this account was last updated.')

    class Meta:
        db_table = DB_TABLE_PREFIX + 'user'

    def clean(self):
        if not self.iban:
            if not (self.is_staff or self.is_superuser):
                raise ValidationError('IBAN field is required.')

    def __str__(self):
        return f'{self.get_full_name()}: {self.iban}'
Example #22
0
class User(models.Model):
    creator = models.ForeignKey(to=SystemUser, on_delete=models.CASCADE)
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    iban = IBANField()

    def __str__(self):
        return '{} {} ({})'.format(self.first_name, self.last_name, self.iban)

    class Meta:
        verbose_name = 'Bank account user'
        verbose_name_plural = 'Bank account users'
Example #23
0
class Account(models.Model):
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    iban = IBANField()

    manager = models.ForeignKey(settings.AUTH_USER_MODEL)

    class Meta:
        ordering = ['first_name']

    def __str__(self):
        return str('{} {}'.format(self.first_name, self.last_name))
Example #24
0
class Expense(models.Model):
  name = models.CharField(ugettext_lazy('Name'), max_length=255, validators=validators['name'])
  email = models.EmailField(ugettext_lazy('Email address'), validators=validators['email'])
  cc_email = models.EmailField(ugettext_lazy('CC email address'), blank=True, null=True, help_text=ugettext_lazy('Copy of the expense will be sent to the email.'), validators=validators['email'])
  phone = models.CharField(ugettext_lazy('Phone'), max_length=255, validators=validators['phoneno'])
  address = models.CharField(ugettext_lazy('Address'), max_length=255, validators=validators['address'])
  iban = IBANField(ugettext_lazy('Bank account no'))
  swift_bic = BICField(ugettext_lazy('BIC no'), blank=True, null=True)
  personno = models.CharField(ugettext_lazy('Person number'), max_length=11, validators=validators['hetu_or_businessid'], help_text=ugettext_lazy('If you apply for an expense reimbursement for a local group, enter the group’s business ID here. Kilometric allowances and daily subsistence allowances can not be applied for with a business ID.'))
  user = models.ForeignKey(User,on_delete=models.PROTECT)

  description = models.CharField(ugettext_lazy('Purpose'), max_length=255)
  memo = models.TextField(ugettext_lazy('Info'), help_text=ugettext_lazy('Eg. Names of the additional passengers, people in the meeting, cost centre or activity sector.'), blank=True, null=True)
  organisation = models.ForeignKey(Organisation, on_delete=models.PROTECT)
  status = models.IntegerField(ugettext_lazy('Status'), choices=APPLICATION_STATUSES, default=0)
  katre_status = models.IntegerField(ugettext_lazy('Katre status'), choices=KATRE_STATUSES, default=0)

  created_at = models.DateTimeField(ugettext_lazy('Sent'), auto_now_add=True)
  updated_at = models.DateTimeField(ugettext_lazy('Edited'), auto_now=True)

  def amount(self):
    sum = 0
    lines = ExpenseLine.objects.filter(expense=self)
    for line in lines:
      sum+= line.sum()
    return sum

  def __unicode__(self):
    return self.name + ': ' + self.description + ' (' + str(self.amount()) + ' e)'

  def finvoice(self):
    expense = self
    expenselines = ExpenseLine.objects.filter(expense=expense)

    return createFinvoice(expense, expenselines)

  def needsKatre(self):
    expense = self
    expenselines = ExpenseLine.objects.filter(expense=expense)

    for line in expenselines:
      if line.expensetype_type in ['FPD', 'PPD', 'FOPD', 'MA', 'T']:
        return True
    
    return False

  def katre(self):
    expense = self
    expenselines = ExpenseLine.objects.filter(expense=expense)

    return createKatreReport(expense, expenselines)
Example #25
0
class Debtor(models.Model):
    created_by = models.ForeignKey(User,
                                   on_delete=models.CASCADE,
                                   related_name='debtor_creator')
    first_name = models.CharField(_('first name'), max_length=30)
    last_name = models.CharField(_('last name'), max_length=30)
    email = models.EmailField(_('email address'), unique=True)
    iban = IBANField()

    invoice_count_objects = DebtorInvoiceManager()
    objects = models.Manager()

    def __str__(self):
        return f"{self.first_name} {self.last_name}: {self.iban}"
Example #26
0
class MangoPayBankAccount(models.Model):
    mangopay_user = models.ForeignKey(MangoPayUser,
                                      related_name="mangopay_bank_accounts")
    mangopay_id = models.PositiveIntegerField(null=True, blank=True)

    address = models.CharField(max_length=254)
    account_type = models.CharField(max_length=2,
                                    choices=BANK_ACCOUNT_TYPE_CHOICES,
                                    default=BANK_ACCOUNT_TYPE_CHOICES.iban)
    iban = IBANField(blank=True, null=True)

    bic = BICField(blank=True, null=True)
    country = CountryField(null=True, blank=True)
    account_number = models.CharField(max_length=15, null=True, blank=True)

    # BA_US type only fields
    aba = models.CharField(max_length=9, null=True, blank=True)
    deposit_account_type = models.CharField(max_length=8,
                                            choices=DEPOSIT_CHOICES,
                                            default=DEPOSIT_CHOICES.checking)

    def get_bank_account(self):
        bank_account = BankAccount(
            id=self.mangopay_id,
            owner_name=self.mangopay_user.user.get_full_name(),
            owner_address=Address(address_line_1=self.address),
            user=self.mangopay_user.get_user(),
            type=self.account_type)

        if self.account_type == BANK_ACCOUNT_TYPE_CHOICES.iban:
            bank_account.iban = self.iban
        elif self.account_type == BANK_ACCOUNT_TYPE_CHOICES.us:
            bank_account.aba = self.aba
            bank_account.deposit_account_type = self.deposit_account_type
            bank_account.account_number = self.account_number
        elif self.account_type == BANK_ACCOUNT_TYPE_CHOICES.other:
            bank_account.account_number = self.account_number
        else:
            raise NotImplementedError(
                "Bank Account Type ({0}) not implemented.".format(
                    self.account_type))

        return bank_account

    def create(self):
        bank_account = self.get_bank_account()
        bank_account.save()
        self.mangopay_id = bank_account.get_pk()
        self.save()
Example #27
0
class Iban(GenericClass):
    company = models.ForeignKey(Company, on_delete=models.CASCADE)
    iban = IBANField(
        _("Iban"),
        max_length=20,
        blank=True,
        null=True,
    )
    default = models.BooleanField(_("par défaut"), default=False)

    def __str__(self):
        return '%s' % self.iban

    class Meta:
        verbose_name = _('Iban')
Example #28
0
class Account(models.Model):
    first_name = models.CharField(max_length=200)
    last_name = models.CharField(max_length=200)
    iban_number = IBANField()
    author = models.ForeignKey(settings.AUTH_USER_MODEL)
    created_at = models.DateTimeField(auto_now_add=True)
    created_at.editable = True

    class Meta:
        verbose_name_plural = "accounts"

    def __str__(self):
        return self.first_name

    def get_absolute_url(self):
        return reverse('main:account_edit', kwargs={'pk': self.pk})
Example #29
0
class Person(models.Model):
  user = models.OneToOneField(User, on_delete=models.PROTECT)

  phone = models.CharField(ugettext_lazy('Phone'), max_length=255, blank=True, null=True, validators=validators['phoneno'])
  address = models.CharField(ugettext_lazy('Address'), max_length=255, blank=True, null=True, validators=validators['address'])
  iban = IBANField(ugettext_lazy('Bank account no'), blank=True, null=True)
  swift_bic = BICField(ugettext_lazy('BIC no'), blank=True, null=True)
  personno = models.CharField(ugettext_lazy('Person number'), max_length=11, blank=True, null=True, validators=validators['hetu_or_businessid'], help_text=ugettext_lazy('Person number is required for every expense application for annual announcements to the tax authority. If you don\'t want to save it here, you can enter it to each expense application separately.'))
  type = models.IntegerField(ugettext_lazy('Type'), choices=PERSONTYPE_CHOICES, default=1)
  language = models.CharField(ugettext_lazy('Site language'), max_length=6, blank=True, null=True, choices=settings.LANGUAGES)

  def name(self):
    return self.user.first_name + ' ' + self.user.last_name

  def __unicode__(self):
    return self.name()
class Account(models.Model):
    """
    Account model that holds the name fields and IBAN no of the accounts
    """
    first_name = models.CharField(_("First Name"), max_length=30)
    last_name = models.CharField(_("Last Name"), max_length=30)
    IBAN = IBANField(_("IBAN NO"), use_nordea_extensions=True)

    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   on_delete=models.PROTECT)

    class Meta:
        verbose_name = _("Account")

    def __str__(self):
        return "{} {}".format(self.first_name, self.last_name)
Example #31
0
class Lid(models.Model):
    club_id = models.AutoField(primary_key=True)
    voornaam = models.CharField(max_length=20)
    familienaam = models.CharField(max_length=50)
    geslacht = models.CharField(max_length=1,
                                choices=LID_GESLACHT_CHOICES,
                                default=MAN)
    sportief_lid = models.BooleanField(default=False)
    betalend_lid = models.BooleanField(default=False)
    straatnaam_en_huisnummer = models.CharField(max_length=50)
    postcode = models.IntegerField()
    gemeente = models.CharField(max_length=50)
    geboortedatum = models.DateField(null=True)
    gsmnummer = PhoneNumberField(null=True, blank=True)
    moeder = models.ForeignKey('management.Ouder',
                               related_name='moeder',
                               on_delete=models.SET_NULL,
                               null=True,
                               blank=True)
    vader = models.ForeignKey('management.Ouder',
                              related_name='vader',
                              on_delete=models.SET_NULL,
                              null=True,
                              blank=True)
    email = models.EmailField(max_length=254, null=True, blank=True)
    gescheiden_ouders = models.BooleanField(default=False)
    extra_informatie = models.CharField(default="", max_length=500, blank=True)
    rekeningnummer = IBANField(null=True, blank=True)
    lidnummer_vbl = models.IntegerField(null=True, blank=True)
    updated_at = models.DateTimeField(auto_now=True)
    created_at = models.DateTimeField(auto_now_add=True)
    functies = models.ManyToManyField(Functie, blank=True)
    familieleden = models.ManyToManyField("self", blank=True)
    facturatie = models.BooleanField(default=False)
    afbetaling = models.BooleanField(default=False)
    uid = models.DecimalField(
        max_digits=10,
        decimal_places=0,
        unique=True,
        blank=True,
        null=True,
    )
    objects = models.Manager()

    def __str__(self):
        return "{} {}".format(self.voornaam, self.familienaam,
                              self.lidnummer_vbl)
class Debtor(models.Model):
    first_name = models.CharField(max_length=30, blank=False)
    last_name = models.CharField(max_length=30, blank=False)
    email = models.EmailField(blank=False)
    iban = IBANField()

    admin_creator = models.ForeignKey(User,
                                      on_delete=models.CASCADE,
                                      related_name='created_debtors')

    objects = DebtorQuerySet.as_manager()

    def is_created_by_admin(self, admin):
        return self.admin_creator == admin

    def __str__(self):
        return f'{self.first_name} {self.last_name} IBAN: {self.iban}'
 def test_default_form(self):
     iban_model_field = IBANField()
     self.assertEqual(type(iban_model_field.formfield()), type(IBANFormField()))