示例#1
0
    def test_basket_with_vatin(self):
        basket = Mock()
        line = Mock()
        line.line_price_excl_tax_incl_discounts = D('100.00')
        line.purchase_info = Mock()
        line.purchase_info.price = Mock()
        line.quantity = 1
        basket.all_lines = Mock(return_value=[line])
        address = Mock()
        address.country = Mock()
        address.country.code = 'AT'
        address.line4 = 'Vienna'
        address.postcode = '1010'
        address.phone_number = '+43 1 234 5678'
        address.line1 = 'hastexo Professional Services GmbH'
        address.vatin = 'ATU66688202'
        shipping_charge = Mock()
        shipping_charge.excl_tax = D('10.00')

        submission = {
            'basket': basket,
            'shipping_address': address,
            'shipping_charge': shipping_charge
        }

        vat.apply_to(submission)
        self.assertEqual(shipping_charge.tax, D('0.00'))
        self.assertEqual(line.purchase_info.price.tax, D('0.00'))
示例#2
0
    def test_basket_with_vatin_reverse_charge(self):
        basket = Mock()
        line = Mock()
        line.line_price_excl_tax_incl_discounts = D('100.00')
        line.purchase_info = Mock()
        line.purchase_info.price = Mock()
        line.quantity = 1
        basket.all_lines = Mock(return_value=[line])
        address = Mock()
        address.country = Mock()
        address.country.code = 'AT'
        address.line4 = 'Vienna'
        address.postcode = '1010'
        address.phone_number = '+43 1 234 5678'
        address.line1 = 'hastexo Professional Services GmbH'
        address.vatin = 'ATU66688202'
        shipping_charge = Mock()
        shipping_charge.excl_tax = D('10.00')

        submission = { 'basket': basket,
                       'shipping_address': address,
                       'shipping_charge': shipping_charge }

        # We're pretending we're a store in Germany. Then we can do
        # reverse charge.
        vat.apply_to(submission)
        self.assertEqual(shipping_charge.tax, D('0.00'))
        self.assertEqual(line.purchase_info.price.tax, D('0.00'))
示例#3
0
    def test_basket_with_vatin_no_reverse_charge(self):
        basket = Mock()
        line = Mock()
        line.line_price_excl_tax_incl_discounts = D('100.00')
        line.purchase_info = Mock()
        line.purchase_info.price = Mock()
        line.quantity = 1
        basket.all_lines = Mock(return_value=[line])
        address = Mock()
        address.country = Mock()
        address.country.code = 'AT'
        address.line4 = 'Vienna'
        address.postcode = '1010'
        address.phone_number = '+43 1 234 5678'
        address.line1 = 'hastexo Professional Services GmbH'
        address.vatin = 'ATU66688202'
        shipping_charge = Mock()
        shipping_charge.excl_tax = D('10.00')

        submission = { 'basket': basket,
                       'shipping_address': address,
                       'shipping_charge': shipping_charge }

        # Even if they've given us a VATIN, if they're in the same
        # country as the store, VAT still applies.
        vat.apply_to(submission)
        self.assertEqual(shipping_charge.tax, D('2.00'))
        self.assertEqual(line.purchase_info.price.tax, D('20.00'))
示例#4
0
    def test_basket_with_tax(self):
        basket = Mock()
        line = Mock()
        line.line_price_excl_tax_incl_discounts = D('100.00')
        line.purchase_info = Mock()
        line.purchase_info.price = Mock()
        line.quantity = 1
        basket.all_lines = Mock(return_value=[line])
        address = Mock()
        address.country = Mock()
        address.country.code = 'AT'
        address.line4 = 'Vienna'
        address.postcode = '1010'
        address.phone_number = '+43 1 234 5678'
        address.vatin = ''
        shipping_charge = Mock()
        shipping_charge.excl_tax = D('10.00')

        submission = { 'basket': basket,
                       'shipping_address': address,
                       'shipping_charge': shipping_charge }

        vat.apply_to(submission)
        self.assertEqual(shipping_charge.tax, D('2.00'))
        self.assertEqual(line.purchase_info.price.tax, D('20.00'))
示例#5
0
 def build_submission(self, **kwargs):
     submission = super(PaymentDetailsView, self).build_submission(**kwargs)
     try:
         vat.apply_to(submission)
         # Recalculate order total to ensure we have a
         # tax-inclusive total
         submission['order_total'] = self.get_order_totals(
             submission['basket'], submission['shipping_charge'])
     except vat.VATAssessmentException as e:
         message = str(e)
         messages.error(self.request, message)
     return submission
示例#6
0
 def build_submission(self, **kwargs):
     submission = super(PaymentDetailsView, self).build_submission(**kwargs)
     try:
         vat.apply_to(submission)
         # Recalculate order total to ensure we have a
         # tax-inclusive total
         submission['order_total'] = self.get_order_totals(
             submission['basket'], submission['shipping_charge'])
     except vat.VATAssessmentException as e:
         message = str(e)
         messages.error(self.request, message)
     return submission
示例#7
0
    def build_submission(self, **kwargs):
        submission = super(DeferredVATCheckoutSessionMixin,
                           self).build_submission(**kwargs)

        assess_tax = (submission['shipping_method'] and
                      submission['shipping_address'] and
                      submission['shipping_address'].phone_number)
        if assess_tax:
            try:
                vat.apply_to(submission)
                # Recalculate order total to ensure we have a
                # tax-inclusive total
                submission['order_total'] = self.get_order_totals(
                    submission['basket'], submission['shipping_charge'])
            except vat.VATAssessmentException:
                pass
        return submission
示例#8
0
    def build_submission(self, **kwargs):
        submission = super(DeferredVATCheckoutSessionMixin,
                           self).build_submission(**kwargs)

        assess_tax = (submission['shipping_method']
                      and submission['shipping_address']
                      and submission['shipping_address'].phone_number)
        if assess_tax:
            try:
                vat.apply_to(submission)
                # Recalculate order total to ensure we have a
                # tax-inclusive total
                submission['order_total'] = self.get_order_totals(
                    submission['basket'], submission['shipping_charge'])
            except vat.VATAssessmentException:
                pass
        return submission