示例#1
0
    def test_get_proforma(self):
        ProformaFactory.reset_sequence(1)
        proforma = ProformaFactory.create()

        url = reverse('proforma-detail', kwargs={'pk': proforma.pk})
        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, {
            "id": proforma.pk,
            "series": "ProformaSeries",
            "number": 1,
            "provider": "http://testserver/providers/%s/" % proforma.provider.pk,
            "customer": "http://testserver/customers/%s/" % proforma.customer.pk,
            "archived_provider": {},
            "archived_customer": {},
            "due_date": None,
            "issue_date": None,
            "paid_date": None,
            "cancel_date": None,
            "sales_tax_name": "VAT",
            "sales_tax_percent": '1.00',
            "currency": "RON",
            "transaction_currency": proforma.transaction_currency,
            "transaction_xe_rate": ("%.4f" % proforma.transaction_xe_rate
                                    if proforma.transaction_xe_rate else None),
            "transaction_xe_date": proforma.transaction_xe_date,
            "pdf_url": None,
            "state": "draft",
            "invoice": None,
            "proforma_entries": [],
            "total": Decimal('0.00'),
            "total_in_transaction_currency": Decimal('0.00'),
            "transactions": []
        })
示例#2
0
    def test_get_proforma(self):
        ProformaFactory.reset_sequence(1)
        proforma = ProformaFactory.create()

        url = reverse('proforma-detail', kwargs={'pk': proforma.pk})
        response = self.client.get(url)

        assert response.status_code == status.HTTP_200_OK
        assert response.data == {
            "id": proforma.pk,
            "series": "ProformaSeries",
            "number": 1,
            "provider": "http://testserver/providers/%s/" % proforma.provider.pk,
            "customer": "http://testserver/customers/%s/" % proforma.customer.pk,
            "archived_provider": {},
            "archived_customer": {},
            "due_date": None,
            "issue_date": None,
            "paid_date": None,
            "cancel_date": None,
            "sales_tax_name": "VAT",
            "sales_tax_percent": '1.00',
            "currency": "RON",
            'pdf_url': None,
            "state": "draft",
            "invoice": None,
            "proforma_entries": [],
            'total': Decimal('0.00'),
        }
示例#3
0
    def test_get_proforma(self):
        ProformaFactory.reset_sequence(1)
        ProformaFactory.create()

        url = reverse('proforma-detail', kwargs={'pk': 1})
        response = self.client.get(url)

        assert response.status_code == status.HTTP_200_OK
        assert response.data == {
            "id": 1,
            "series": "ProformaSeries",
            "number": 1,
            "provider": "http://testserver/providers/1/",
            "customer": "http://testserver/customers/1/",
            "archived_provider": {},
            "archived_customer": {},
            "due_date": None,
            "issue_date": None,
            "paid_date": None,
            "cancel_date": None,
            "sales_tax_name": "VAT",
            "sales_tax_percent": '1.00',
            "currency": "RON",
            'pdf_url': None,
            "state": "draft",
            "invoice": None,
            "proforma_entries": [],
            'total': Decimal('0.00'),
        }
示例#4
0
    def test_get_proforma(self, mocked_settings):
        ProformaFactory.reset_sequence(1)

        upload_path = '%s/documents/' % settings.MEDIA_ROOT
        proforma = ProformaFactory.create(pdf=PDF.objects.create(upload_path=upload_path))
        proforma.generate_pdf()

        url = reverse('proforma-detail', kwargs={'pk': proforma.pk})

        for show_pdf_storage_url, pdf_url in [
            (True, build_absolute_test_url(proforma.pdf.url)),
            (False, build_absolute_test_url(reverse('pdf', args=[proforma.pdf.pk])))
        ]:
            mocked_settings.SILVER_SHOW_PDF_STORAGE_URL = show_pdf_storage_url
            response = self.client.get(url)

            provider_url = build_absolute_test_url(reverse('provider-detail',
                                                           [proforma.provider.pk]))
            customer_url = build_absolute_test_url(reverse('customer-detail',
                                                           [proforma.customer.pk]))

            self.assertEqual(response.status_code, status.HTTP_200_OK)
            self.assertEqual(response.data, {
                "id": proforma.pk,
                "series": "ProformaSeries",
                "number": proforma.number,
                "provider": provider_url,
                "customer": customer_url,
                "archived_provider": '{}',
                "archived_customer": '{}',
                "due_date": None,
                "issue_date": None,
                "paid_date": None,
                "cancel_date": None,
                "sales_tax_name": "VAT",
                "sales_tax_percent": '1.00',
                "currency": "RON",
                "transaction_currency": proforma.transaction_currency,
                "transaction_xe_rate": ("%.4f" % proforma.transaction_xe_rate
                                        if proforma.transaction_xe_rate else None),
                "transaction_xe_date": proforma.transaction_xe_date,
                "pdf_url": pdf_url,
                "state": "draft",
                "invoice": None,
                "proforma_entries": [],
                "total": 0,
                "total_in_transaction_currency": 0,
                "transactions": []
            })
示例#5
0
    def test_get_proforma(self, mocked_settings):
        ProformaFactory.reset_sequence(1)

        upload_path = '%s/documents/' % settings.MEDIA_ROOT
        proforma = ProformaFactory.create(pdf=PDF.objects.create(
            upload_path=upload_path))
        proforma.generate_pdf()

        url = reverse('proforma-detail', kwargs={'pk': proforma.pk})

        for show_pdf_storage_url, pdf_url in [
            (True, "http://testserver%s" % proforma.pdf.url),
            (False, "http://testserver/pdfs/%s/" % proforma.pk)
        ]:
            mocked_settings.SILVER_SHOW_PDF_STORAGE_URL = show_pdf_storage_url
            response = self.client.get(url)

            provider_url = build_absolute_test_url(
                reverse('provider-detail', [proforma.provider.pk]))
            customer_url = build_absolute_test_url(
                reverse('customer-detail', [proforma.customer.pk]))

            self.assertEqual(response.status_code, status.HTTP_200_OK)
            self.assertEqual(
                response.data, {
                    "id":
                    proforma.pk,
                    "series":
                    "ProformaSeries",
                    "number":
                    proforma.number,
                    "provider":
                    provider_url,
                    "customer":
                    customer_url,
                    "archived_provider":
                    '{}',
                    "archived_customer":
                    '{}',
                    "due_date":
                    None,
                    "issue_date":
                    None,
                    "paid_date":
                    None,
                    "cancel_date":
                    None,
                    "sales_tax_name":
                    "VAT",
                    "sales_tax_percent":
                    '1.00',
                    "currency":
                    "RON",
                    "transaction_currency":
                    proforma.transaction_currency,
                    "transaction_xe_rate":
                    ("%.4f" % proforma.transaction_xe_rate
                     if proforma.transaction_xe_rate else None),
                    "transaction_xe_date":
                    proforma.transaction_xe_date,
                    "pdf_url":
                    pdf_url,
                    "state":
                    "draft",
                    "invoice":
                    None,
                    "proforma_entries": [],
                    "total":
                    0,
                    "total_in_transaction_currency":
                    0,
                    "transactions": []
                })