Exemple #1
0
 def test_recalculate_order_no_connection(self):
     # VAT is right, but with no internet connection
     with no_connection():
         with patch('plans.taxation.eu.logger') as mock_logger:
             o = self.create_view.recalculate(
                 10, BillingInfo(tax_number='48136450', country='CZ'))
             self.assertEqual(o.tax, 21)
             mock_logger.exception.assert_called_with("TAX_ID=CZ48136450")
Exemple #2
0
    def clean(self):
        cleaned_data = super(BillingInfoForm, self).clean()

        try:
            cleaned_data['tax_number'] = BillingInfo.clean_tax_number(
                cleaned_data['tax_number'], cleaned_data.get('country', None))
        except ValidationError, e:
            self._errors['tax_number'] = e.messages
Exemple #3
0
    def test_recalculate_order(self):
        # BE 0203.201.340 is VAT ID of Belgium national bank.
        # It is used, because national provider for VIES seems to be stable enough
        c = self.create_view
        o = c.recalculate(
            10, BillingInfo(tax_number='BE 0203 201 340', country='BE'))
        self.assertEqual(o.tax, None)

        o = c.recalculate(10,
                          BillingInfo(tax_number='0203 201 340', country='BE'))
        self.assertEqual(o.tax, None)

        o = c.recalculate(10, BillingInfo(tax_number='1234565', country='BE'))
        self.assertEqual(o.tax, 21)

        o = c.recalculate(10, BillingInfo(tax_number='1234567', country='GR'))
        self.assertEqual(o.tax, 24)

        o = c.recalculate(10, BillingInfo(tax_number='090145420',
                                          country='GR'))
        self.assertEqual(o.tax, None)
Exemple #4
0
 def _create_premium_subscription(self, user, plan_pricing):
     user.radiususergroup_set.all().delete()
     organization = self.context['view'].organization
     group = get_or_create_temporary_radius_group(organization)
     rug = RadiusUserGroup(user=user,
                           group=group)
     rug.full_clean()
     rug.save()
     # billing info
     billing_info_data = self.validated_data['billing_info']
     billing_info_data['user'] = user
     billing_info = BillingInfo(**billing_info_data)
     billing_info.full_clean()
     billing_info.save()
     payment = create_order(user,
                            plan_pricing,
                            self.context['request'].META['REMOTE_ADDR'],
                            organization)
     # will be used in TokenSerializer.get_payment_url
     self.context['view'].payment = payment
Exemple #5
0
 def test_clean_tax_number_country_code_does_not_equal_as_country(self):
     with self.assertRaisesRegex(
             ValidationError,
             'VAT ID country code doesn\'t corespond with country'):
         BillingInfo.clean_tax_number('AT48136450', 'CZ')
Exemple #6
0
 def test_clean_tax_number_vat_id_is_not_correct(self):
     with self.assertRaisesRegex(ValidationError, 'VAT ID is not correct'):
         BillingInfo.clean_tax_number('GR48136450', 'GR')
Exemple #7
0
 def test_clean_tax_number_valid_with_country(self):
     self.assertEqual(BillingInfo.clean_tax_number('CZ48136450', 'CZ'),
                      'CZ48136450')
Exemple #8
0
 def test_clean_tax_number_valid_space(self):
     self.assertEqual(BillingInfo.clean_tax_number('48 136 450', 'CZ'),
                      'CZ48136450')
Exemple #9
0
 def test_clean_tax_number(self):
     with self.assertRaises(ValidationError):
         BillingInfo.clean_tax_number('123456', 'CZ')