Ejemplo n.º 1
0
    def build_submission(self, **kwargs):
        # Override the build_submission method so we can apply taxes to the
        # submission dict

        submission = super(PaymentDetailsView, self).build_submission(**kwargs)

        # Fetch and apply taxes to submission dict
        try:
            avalara.apply_taxes_to_submission(submission)
        except avalara.InvalidAddress, e:
            msg = loader.render_to_string(
                'avalara/messages/invalid_address.html', {'error': e.message})
            messages.error(self.request, msg, extra_tags="safe noicon")
Ejemplo n.º 2
0
    def build_submission(self, **kwargs):
        # Override the build_submission method so we can apply taxes to the
        # submission dict

        submission = super(PaymentDetailsView, self).build_submission(**kwargs)

        # Fetch and apply taxes to submission dict
        try:
            avalara.apply_taxes_to_submission(submission)
        except avalara.InvalidAddress, e:
            msg = loader.render_to_string(
                'avalara/messages/invalid_address.html',
                {'error': e.message})
            messages.error(self.request, msg, extra_tags="safe noicon")
Ejemplo n.º 3
0
    def test_sets_taxes_on_basket_and_shipping_method(self):
        submission = build_submission()
        self.assertFalse(submission['basket'].is_tax_known)
        self.assertFalse(submission['shipping_charge'].is_tax_known)

        with mock.patch('requests.request') as mocked_request:
            mocked_response = mock.Mock()
            mocked_response.status_code = 200
            mocked_response.json = mock.Mock(
                return_value=responses.SUCCESS)
            mocked_request.return_value = mocked_response

            avalara.apply_taxes_to_submission(submission)

        self.assertTrue(submission['basket'].is_tax_known)
        self.assertTrue(submission['shipping_charge'].is_tax_known)