def test_validation(self): with self.assertRaises(ValidationError): validate_vatin("XX123456") with self.assertRaises(ValidationError): validate_vatin("CZ123456") with self.assertRaises(ValidationError): validate_vatin("CZ8003280317") validate_vatin("CZ8003280318")
def test_validation(self): with self.assertRaises(ValidationError): validate_vatin('XX123456') with self.assertRaises(ValidationError): validate_vatin('CZ123456') with self.assertRaises(ValidationError): validate_vatin('CZ8003280317') validate_vatin('CZ8003280318')
def validate_customer(self, customer): if not self.check_customer: return None if customer.is_empty: messages.info( self.request, _('Please provide your billing information to ' 'complete the payment.')) return redirect('payment-customer', pk=self.object.pk) if customer.vat: try: validate_vatin(customer.vat) except ValidationError: messages.warning( self.request, _('The VAT ID is no longer valid, please update it.')) return redirect('payment-customer', pk=self.object.pk) return None
def validate_customer(self, customer): if not self.check_customer: return None if customer.is_empty: messages.info( self.request, gettext('Please provide your billing information to ' 'complete the payment.'), ) return redirect('payment-customer', pk=self.object.pk) # This should not happen, but apparently validation service is # often broken, so whitelist repeating payments if customer.vat and not self.object.repeat: try: validate_vatin(customer.vat) except ValidationError: messages.warning( self.request, gettext( 'The VAT ID is no longer valid, please update it.'), ) return redirect('payment-customer', pk=self.object.pk) return None