Ejemplo n.º 1
0
    def test_invoice_currency_used_for_transaction_currency(self):
        customer = CustomerFactory.create(currency=None)
        invoice = InvoiceFactory.create(customer=customer,
                                        currency='EUR',
                                        transaction_currency=None)

        self.assertEqual(invoice.transaction_currency, 'EUR')
Ejemplo n.º 2
0
    def test_invoice_tax_value_decimal_places(self):
        invoice_entries = DocumentEntryFactory.create_batch(3)
        invoice = InvoiceFactory.create(invoice_entries=invoice_entries)

        invoice.sales_tax_percent = Decimal('20.00')

        assert self._get_decimal_places(invoice.tax_value) == 2
Ejemplo n.º 3
0
def test_cancel_invoice_with_provided_date(authenticated_api_client):
    provider = ProviderFactory.create()
    customer = CustomerFactory.create()
    invoice = InvoiceFactory.create(provider=provider, customer=customer)
    invoice.issue()

    url = reverse('invoice-state', kwargs={'pk': invoice.pk})
    data = {'state': 'canceled', 'cancel_date': '2014-10-10'}

    response = authenticated_api_client.put(url,
                                            data=json.dumps(data),
                                            content_type='application/json')

    assert response.status_code == status.HTTP_200_OK
    due_date = timezone.now().date() + timedelta(
        days=settings.SILVER_DEFAULT_DUE_DAYS)
    mandatory_content = {
        'issue_date': timezone.now().date().strftime('%Y-%m-%d'),
        'due_date': due_date.strftime('%Y-%m-%d'),
        'cancel_date': '2014-10-10',
        'state': 'canceled'
    }
    assert response.status_code == status.HTTP_200_OK
    assert all(item in list(response.data.items())
               for item in mandatory_content.items())
Ejemplo n.º 4
0
    def test_invoice_total_with_tax_integrity(self):
        invoice_entries = DocumentEntryFactory.create_batch(5)
        invoice = InvoiceFactory.create(invoice_entries=invoice_entries)

        invoice.sales_tax_percent = Decimal('20.00')

        self.assertEqual(invoice.total, invoice.total_before_tax + invoice.tax_value)
Ejemplo n.º 5
0
def test_issue_invoice_with_custom_issue_date_and_due_date(
        authenticated_api_client):
    provider = ProviderFactory.create()
    customer = CustomerFactory.create()
    invoice = InvoiceFactory.create(provider=provider, customer=customer)

    url = reverse('invoice-state', kwargs={'pk': invoice.pk})
    data = {
        'state': 'issued',
        'issue_date': '2014-01-01',
        'due_date': '2014-01-20'
    }

    response = authenticated_api_client.put(url,
                                            data=json.dumps(data),
                                            content_type='application/json')

    assert response.status_code == status.HTTP_200_OK
    mandatory_content = {
        'issue_date': '2014-01-01',
        'due_date': '2014-01-20',
        'state': 'issued'
    }
    assert response.status_code == status.HTTP_200_OK
    assert all(item in list(response.data.items())
               for item in mandatory_content.items())
    assert response.data.get('archived_provider', {}) != {}
    assert response.data.get('archived_customer', {}) != {}
Ejemplo n.º 6
0
def test_generate_pdf_task(settings, tmpdir, monkeypatch):
    settings.MEDIA_ROOT = tmpdir.strpath

    invoice = InvoiceFactory.create()
    invoice.issue()

    assert invoice.pdf.dirty

    pisa_document_mock = MagicMock(return_value=MagicMock(err=False))

    monkeypatch.setattr('silver.models.documents.pdf.pisa.pisaDocument',
                        pisa_document_mock)

    generate_pdf(invoice.id, invoice.kind)

    # pdf needs to be refreshed as the invoice reference in the test is not the same with the one
    # in the task
    invoice.pdf.refresh_from_db()

    assert not invoice.pdf.dirty

    assert invoice.pdf.url == settings.MEDIA_URL + invoice.get_pdf_upload_path(
    )

    assert pisa_document_mock.call_count == 1

    assert len(pisa_document_mock.mock_calls) == 1
Ejemplo n.º 7
0
    def handle(self, *args, **options):
        proforma = ProformaFactory.create(
            proforma_entries=[DocumentEntryFactory.create()],
            state=Proforma.STATES.ISSUED)
        proforma.create_invoice()

        invoice = InvoiceFactory.create(
            invoice_entries=[DocumentEntryFactory.create()],
            state=Invoice.STATES.ISSUED,
            related_document=None)
        TransactionFactory.create(state=Transaction.States.Settled,
                                  invoice=invoice,
                                  payment_method__customer=invoice.customer,
                                  proforma=None)
        InvoiceFactory.create_batch(
            size=3,
            invoice_entries=[DocumentEntryFactory.create()],
            state=Invoice.STATES.PAID,
            related_document=None)
        InvoiceFactory.create_batch(
            size=3,
            invoice_entries=[DocumentEntryFactory.create()],
            state=Invoice.STATES.DRAFT,
            related_document=None)

        InvoiceFactory.create_batch(
            size=3,
            invoice_entries=[DocumentEntryFactory.create()],
            state=Invoice.STATES.CANCELED,
            related_document=None)
Ejemplo n.º 8
0
    def test_invoice_create_storno_from_unallowed_states(self):
        invoice = InvoiceFactory.create()
        assert invoice.state == invoice.STATES.DRAFT
        self.assertRaises(ValueError, invoice.create_storno)

        invoice.issue()
        self.assertRaises(ValueError, invoice.create_storno)
Ejemplo n.º 9
0
    def test_actions_failed_no_log_entries(self):
        invoice = InvoiceFactory.create()

        url = reverse('admin:silver_invoice_changelist')

        mock_log_entry = MagicMock()
        mock_log_action = MagicMock()
        mock_log_entry.objects.log_action = mock_log_action

        exceptions = cycle([ValueError, TransitionNotAllowed])

        def _exception_thrower(*args):
            raise next(exceptions)

        mock_action = MagicMock(side_effect=_exception_thrower)

        mock_invoice = MagicMock()
        mock_invoice.issue = mock_action
        mock_invoice.cancel = mock_action
        mock_invoice.pay = mock_action
        mock_invoice.clone_into_draft = mock_action
        mock_invoice.create_invoice = mock_action

        with patch.multiple('silver.admin',
                            LogEntry=mock_log_entry,
                            Invoice=mock_invoice):
            actions = ['issue', 'pay', 'cancel', 'clone']

            for action in actions:
                self.admin.post(url, {
                    'action': action,
                    '_selected_action': [str(invoice.pk)]
                })

                assert not mock_log_action.call_count
Ejemplo n.º 10
0
    def test_documents_list_case_1(self):
        """
            One proforma, one invoice, without related documents
        """
        proforma = ProformaFactory.create()
        invoice_entries = DocumentEntryFactory.create_batch(3)
        invoice = InvoiceFactory.create(invoice_entries=invoice_entries)
        invoice.issue()
        payment_method = PaymentMethodFactory.create(customer=invoice.customer)
        transaction = TransactionFactory.create(payment_method=payment_method,
                                                invoice=invoice)

        url = reverse('document-list')

        with patch('silver.utils.payments._get_jwt_token',
                   new=self._jwt_token):
            response = self.client.get(url)

        # ^ there's a bug where specifying format='json' doesn't work
        response_data = response.data

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response_data), 2)

        self.assertIn(self._get_expected_data(invoice, [transaction]),
                      response_data)

        self.assertIn(self._get_expected_data(proforma), response_data)
Ejemplo n.º 11
0
    def test_add_transaction_with_unrelated_documents(self):
        customer = CustomerFactory.create()
        payment_method = PaymentMethodFactory.create(customer=customer)

        invoice = InvoiceFactory.create(customer=customer)
        invoice.issue()

        proforma = ProformaFactory.create(customer=customer)
        proforma.issue()

        valid_until = datetime.now().replace(microsecond=0)
        url = reverse('payment-method-transaction-list',
                      kwargs={'customer_pk': customer.pk,
                              'payment_method_id': payment_method.pk})

        invoice_url = reverse('invoice-detail', args=[invoice.pk])
        proforma_url = reverse('proforma-detail', args=[proforma.pk])
        data = {
            'payment_method': reverse('payment-method-detail',
                                      kwargs={'customer_pk': customer.pk,
                                              'payment_method_id': payment_method.id}),
            'valid_until': valid_until,
            'amount': 200.0,
            'invoice': invoice_url,
            'proforma': proforma_url
        }

        response = self.client.post(url, format='json', data=data)

        expected_data = {
            'non_field_errors': [u'Invoice and proforma are not related.']
        }
        self.assertEqual(response.data, expected_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 12
0
def test_delete_invoice_entry(authenticated_api_client):
    invoice = InvoiceFactory.create()

    url = reverse('invoice-entry-create', kwargs={'document_pk': invoice.pk})
    request_data = {
        "description": "Page views",
        "unit_price": 10.0,
        "quantity": 20
    }
    entries_count = 10
    for cnt in range(entries_count):
        authenticated_api_client.post(url,
                                      data=json.dumps(request_data),
                                      content_type='application/json')

    url = reverse('invoice-entry-update',
                  kwargs={
                      'document_pk': invoice.pk,
                      'entry_pk': list(invoice._entries)[0].pk
                  })
    response = authenticated_api_client.delete(url)
    assert response.status_code == status.HTTP_204_NO_CONTENT

    url = reverse('invoice-detail', kwargs={'pk': invoice.pk})
    response = authenticated_api_client.get(url)
    invoice_entries = response.data.get('invoice_entries', None)
    assert len(invoice_entries) == entries_count - 1
Ejemplo n.º 13
0
    def test_filter_min_max_amount(self):
        payment_method = PaymentMethodFactory.create(
            payment_processor=triggered_processor, )
        customer = payment_method.customer

        entry = DocumentEntryFactory(quantity=1, unit_price=100)
        invoice = InvoiceFactory.create(invoice_entries=[entry],
                                        customer=customer)
        invoice.issue()

        transaction = TransactionFactory.create(payment_method=payment_method,
                                                invoice=invoice)

        transaction_data = self._transaction_data(transaction)

        urls = [
            reverse('payment-method-transaction-list',
                    kwargs={
                        'customer_pk': customer.pk,
                        'payment_method_id': payment_method.pk
                    }),
            reverse('transaction-list', kwargs={'customer_pk': customer.pk})
        ]

        for url in urls:
            url_with_filterable_data = url + '?min_amount=10'
            url_no_output = url + '?min_amount=150'

            with patch('silver.utils.payments._get_jwt_token') as mocked_token:
                mocked_token.return_value = 'token'

                response = self.client.get(url_with_filterable_data,
                                           format='json')

                transaction.refresh_from_db()
                transaction_data['updated_at'] = response.data[0]['updated_at']

                self.assertEqual(response.status_code, status.HTTP_200_OK)
                self.assertEqual(response.data[0], transaction_data)

                response = self.client.get(url_no_output, format='json')
                self.assertEqual(response.status_code, status.HTTP_200_OK)
                self.assertEqual(response.data, [])

                url_with_filterable_data = url + '?max_amount=1050'
                url_no_output = url + '?max_amount=10'

                response = self.client.get(url_with_filterable_data,
                                           format='json')

                transaction.refresh_from_db()
                transaction_data['updated_at'] = response.data[0]['updated_at']

                self.assertEqual(response.status_code, status.HTTP_200_OK)
                self.assertEqual(response.data[0], transaction_data)

                response = self.client.get(url_no_output, format='json')
                self.assertEqual(response.status_code, status.HTTP_200_OK)
                self.assertEqual(response.data, [])
Ejemplo n.º 14
0
    def test_invoice_create_storno_from_paid_state(self):
        invoice = InvoiceFactory.create(invoice_entries=[DocumentEntryFactory.create()])
        invoice.issue()
        invoice.pay()
        storno = invoice.create_storno()

        assert -invoice.total == storno.total != 0
        assert storno.related_document == invoice
        assert invoice.customer == storno.customer
        assert invoice.provider == storno.provider
Ejemplo n.º 15
0
    def test_invoice_storno_issue(self):
        invoice = InvoiceFactory.create()
        invoice.issue()
        invoice.pay()
        storno = invoice.create_storno()

        storno.issue()
        assert storno.state == storno.STATES.ISSUED
        assert storno.issue_date == date.today()
        assert not storno.due_date
Ejemplo n.º 16
0
    def test_draft_invoice_series_number(self):
        invoice = InvoiceFactory.create()
        invoice.number = None

        assert invoice.series_number == '%s-draft-id:%d' % (invoice.series,
                                                            invoice.pk)

        invoice.series = None

        assert invoice.series_number == 'draft-id:%d' % invoice.pk
Ejemplo n.º 17
0
def test_pay_invoice_when_in_draft_state(authenticated_api_client):
    provider = ProviderFactory.create()
    customer = CustomerFactory.create()
    invoice = InvoiceFactory.create(provider=provider, customer=customer)

    url = reverse('invoice-state', kwargs={'pk': invoice.pk})
    data = {'state': 'paid'}
    response = authenticated_api_client.put(url, data=json.dumps(data),
                                            content_type='application/json')
    assert response.status_code == status.HTTP_403_FORBIDDEN
    assert response.data == {
        'detail': 'An invoice can be paid only if it is in issued state.'
    }
Ejemplo n.º 18
0
def test_generate_pdfs_task(monkeypatch):
    issued_invoice = InvoiceFactory.create()
    issued_invoice.issue()

    paid_invoice = InvoiceFactory.create()
    paid_invoice.issue()
    paid_invoice.pay()

    canceled_invoice = InvoiceFactory.create()
    canceled_invoice.issue()
    canceled_invoice.cancel()

    issued_invoice_already_generated = InvoiceFactory.create()
    issued_invoice_already_generated.issue()
    issued_invoice_already_generated.pdf.dirty = False
    issued_invoice_already_generated.pdf.save()

    issued_proforma = ProformaFactory.create()
    issued_proforma.issue()

    issued_proforma_already_generated = ProformaFactory.create()
    issued_proforma_already_generated.issue()
    issued_proforma_already_generated.pdf.dirty = False
    issued_proforma_already_generated.pdf.save()

    documents_to_generate = [
        issued_invoice, canceled_invoice, paid_invoice, issued_proforma
    ]

    for document in documents_to_generate:
        assert document.pdf.dirty

    lock_mock = MagicMock()
    monkeypatch.setattr('silver.tasks.redis.lock', lock_mock)

    with patch('silver.tasks.group') as group_mock:
        generate_pdfs()

        assert group_mock.call_count
Ejemplo n.º 19
0
def test_illegal_state_change_when_in_draft_state(authenticated_api_client):
    provider = ProviderFactory.create()
    customer = CustomerFactory.create()
    invoice = InvoiceFactory.create(provider=provider, customer=customer)

    url = reverse('invoice-state', kwargs={'pk': invoice.pk})
    data = {'state': 'illegal-state'}

    response = authenticated_api_client.put(url, data=json.dumps(data),
                                            content_type='application/json')

    assert response.status_code == status.HTTP_403_FORBIDDEN
    assert response.data == {'detail': 'Illegal state value.'}
Ejemplo n.º 20
0
def test_edit_invoice_in_issued_state(authenticated_api_client):
    invoice = InvoiceFactory.create()
    invoice.issue()

    url = reverse('invoice-detail', kwargs={'pk': invoice.pk})
    data = {"description": "New Page views"}
    response = authenticated_api_client.patch(url, data=json.dumps(data),
                                              content_type='application/json')

    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert response.data == {
        'non_field_errors': ['You cannot edit the document once it is in issued state.']
    }
Ejemplo n.º 21
0
    def test_documents_list_case_2(self):
        """
            One proforma with a related invoice, one invoice
        """
        proforma = ProformaFactory.create()
        invoice1 = InvoiceFactory.create(related_document=proforma)
        proforma.related_document = invoice1
        proforma.save()

        invoice2 = InvoiceFactory.create()

        url = reverse('document-list')
        response = self.client.get(url)

        # ^ there's a bug where specifying format='json' doesn't work
        response_data = json.loads(json.dumps(response.data))

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response_data), 2)

        self.assertIn(self._get_expected_data(invoice1), response_data)

        self.assertIn(self._get_expected_data(invoice2), response_data)
Ejemplo n.º 22
0
    def test_patch_transaction_not_allowed_fields(self):
        payment_method = PaymentMethodFactory.create(
            payment_processor=triggered_processor)
        customer = payment_method.customer
        transaction = TransactionFactory.create(payment_method=payment_method)

        proforma = ProformaFactory.create(state='issued', customer=customer)
        invoice = InvoiceFactory.create(state='issued',
                                        customer=customer,
                                        related_document=proforma)
        proforma.related_document = invoice
        proforma.save()

        invoice_url = reverse('invoice-detail', args=[invoice.pk])
        proforma_url = reverse('proforma-detail', args=[proforma.pk])
        url = reverse('transaction-detail',
                      args=[transaction.customer.pk, transaction.uuid])

        new_payment_method = PaymentMethodFactory.create(
            payment_processor=triggered_processor, customer=customer)

        new_payment_method_url = reverse('payment-method-detail',
                                         kwargs={
                                             'customer_pk':
                                             new_payment_method.customer.pk,
                                             'payment_method_id':
                                             new_payment_method.pk
                                         })

        data = {
            'proforma': proforma_url,
            'invoice': invoice_url,
            'currency': 'EUR',
            'amount': 1234,
            'payment_method': new_payment_method_url
        }

        response = self.client.patch(url, format='json', data=data)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        self.assertEqual(
            response.data, {
                'proforma': [u'This field may not be modified.'],
                'invoice': [u'This field may not be modified.'],
                'currency': [u'This field may not be modified.'],
                'amount': [u'This field may not be modified.'],
                'payment_method': [u'This field may not be modified.']
            })
Ejemplo n.º 23
0
    def test_actions_log_entries(self):
        invoice = InvoiceFactory.create()

        url = reverse('admin:silver_invoice_changelist')

        mock_log_entry = MagicMock()
        mock_log_action = MagicMock()
        mock_log_entry.objects.log_action = mock_log_action

        mock_action = Mock(return_value=Mock(series_number='aaa', admin_change_url="result_url"))

        mock_invoice = MagicMock()
        mock_invoice.issue = mock_action
        mock_invoice.cancel = mock_action
        mock_invoice.pay = mock_action
        mock_invoice.clone_into_draft = mock_action
        mock_invoice.create_storno = mock_action

        with patch.multiple('silver.admin',
                            LogEntry=mock_log_entry,
                            Invoice=mock_invoice):
            actions = ['issue', 'pay', 'cancel', 'clone', 'create_storno']

            for action in actions:
                self.admin.post(url, {
                    'action': action,
                    '_selected_action': [str(invoice.pk)]
                })

                assert mock_action.call_count

                mock_action.reset_mock()

                if action == 'clone':
                    action = 'clone_into_draft'

                mock_log_action.assert_called_with(
                    user_id=self.user.pk,
                    content_type_id=ContentType.objects.get_for_model(invoice).pk,
                    object_id=invoice.pk,
                    object_repr=force_text(invoice),
                    action_flag=CHANGE,
                    change_message='{action} action initiated by user.'.format(
                        action=action.capitalize().replace('_', ' ')
                    )
                )
Ejemplo n.º 24
0
    def test_no_transaction_creation_for_issued_documents_case3(self):
        """
            There are 1 pending and 1 settled transactions that together cover the document amount.
        """
        entry = DocumentEntryFactory(quantity=1, unit_price=100)
        invoice = InvoiceFactory.create(invoice_entries=[entry])
        invoice.issue()

        customer = invoice.customer
        payment_method = PaymentMethodFactory.create(
            payment_processor=triggered_processor, customer=customer,
            canceled=False,
            verified=False,
        )

        TransactionFactory.create(invoice=invoice,
                                  payment_method=payment_method,
                                  amount=invoice.total_in_transaction_currency / 2,
                                  state=Transaction.States.Settled)

        TransactionFactory.create(invoice=invoice,
                                  payment_method=payment_method,
                                  amount=invoice.total_in_transaction_currency / 2,
                                  state=Transaction.States.Pending)

        mock_execute = MagicMock()
        with patch.multiple(TriggeredProcessor, execute_transaction=mock_execute):
            expected_exception = ValidationError
            expected_message = "Amount is greater than the amount that should be " \
                               "charged in order to pay the billing document."
            try:
                TransactionFactory.create(invoice=invoice,
                                          payment_method=payment_method,
                                          amount=1)

                self.fail('{} not raised.'.format(str(expected_exception)))
            except expected_exception as e:
                self.assertTrue(expected_message in str(e))

            transactions = Transaction.objects.filter(
                payment_method=payment_method, invoice=invoice,
            )
            self.assertEqual(len(transactions), 2)

            self.assertEqual(mock_execute.call_count, 0)
Ejemplo n.º 25
0
    def test_transaction_creation_for_issued_documents(self):
        """
            The happy case.
        """
        invoice = InvoiceFactory.create()
        customer = invoice.customer

        PaymentMethodFactory.create(
            payment_processor=triggered_processor, customer=customer,
            canceled=False,
            verified=True,
        )

        invoice.issue()

        transactions = Transaction.objects.filter(
            invoice=invoice, proforma=invoice.related_document
        )
        self.assertEqual(len(transactions), 1)
Ejemplo n.º 26
0
    def test_no_transaction_creation_for_issued_documents_case2(self):
        """
            The payment method is not usable
        """
        invoice = InvoiceFactory.create()
        customer = invoice.customer
        PaymentMethodFactory.create(
            payment_processor=triggered_processor, customer=customer,
            canceled=False
        )

        mock_execute = MagicMock()
        with patch.multiple(TriggeredProcessor, execute_transaction=mock_execute):
            invoice.issue()

            transactions = Transaction.objects.filter(
                invoice=invoice, proforma=invoice.related_document
            )
            self.assertEqual(len(transactions), 0)
Ejemplo n.º 27
0
    def test_clone_invoice_into_draft(self):
        invoice = InvoiceFactory.create()
        invoice.issue()
        invoice.pay()

        entries = DocumentEntryFactory.create_batch(3)
        invoice.invoice_entries.add(*entries)

        clone = invoice.clone_into_draft()

        assert clone.state == Invoice.STATES.DRAFT
        assert clone.paid_date is None
        assert clone.issue_date is None
        assert clone.related_document is None
        assert (clone.series != invoice.series
                or clone.number != invoice.number)
        assert clone.sales_tax_percent == invoice.sales_tax_percent
        assert clone.sales_tax_name == invoice.sales_tax_name

        assert not clone.archived_customer
        assert not clone.archived_provider
        assert clone.customer == invoice.customer
        assert clone.provider == invoice.provider

        assert clone.currency == invoice.currency
        assert clone.pk != invoice.pk
        assert clone.id != invoice.id
        assert not clone.pdf

        assert clone.invoice_entries.count() == 3
        assert invoice.invoice_entries.count() == 3

        entry_fields = [
            entry.name for entry in DocumentEntry._meta.get_fields()
        ]
        for clone_entry, original_entry in zip(clone.invoice_entries.all(),
                                               invoice.invoice_entries.all()):
            for entry in entry_fields:
                if entry not in ('id', 'proforma', 'invoice'):
                    assert getattr(clone_entry, entry) == \
                        getattr(original_entry, entry)
        assert invoice.state == Invoice.STATES.PAID
Ejemplo n.º 28
0
def test_add_invoice_entry_in_issued_state(authenticated_api_client):
    invoice = InvoiceFactory.create()
    invoice.issue()

    url = reverse('invoice-entry-create', kwargs={'document_pk': invoice.pk})
    request_data = {
        "description": "Page views",
        "unit_price": 10.0,
        "quantity": 20
    }
    response = authenticated_api_client.post(url, data=json.dumps(request_data),
                                             content_type='application/json')

    assert response.status_code == status.HTTP_403_FORBIDDEN
    msg = 'Invoice entries can be added only when the invoice is in draft state.'
    assert response.data == {'detail': msg}

    url = reverse('invoice-detail', kwargs={'pk': invoice.pk})
    response = authenticated_api_client.get(url)
    invoice_entries = response.data['invoice_entries']
    assert invoice_entries == []
Ejemplo n.º 29
0
    def test_invoice_total_decimal_points(self):
        invoice_entries = DocumentEntryFactory.create_batch(3)
        invoice = InvoiceFactory.create(invoice_entries=invoice_entries)

        assert self._get_decimal_places(invoice.total) == 2
Ejemplo n.º 30
0
    def test_issues_invoice_series_number(self):
        invoice = InvoiceFactory.create(state=Invoice.STATES.ISSUED)

        assert invoice.series_number == '%s-%s' % (invoice.series,
                                                   invoice.number)