コード例 #1
0
ファイル: test_invoice.py プロジェクト: DocTocToc/silver
def test_add_single_invoice_entry(authenticated_api_client, invoice):
    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')

    invoice = Invoice.objects.all()[0]
    total = Decimal(200.0) * Decimal(1 + invoice.sales_tax_percent / 100)

    assert response.status_code == status.HTTP_201_CREATED, response.data
    entry = DocumentEntry.objects.get(id=response.data['id'])
    document_entry_definition.check_response(entry, response.data, request_data)

    url = reverse('invoice-detail', kwargs={'pk': invoice.pk})
    response = authenticated_api_client.get(url)

    invoice_entries = response.data['invoice_entries']
    assert invoice_entries == [spec_document_entry(entry)]
コード例 #2
0
ファイル: invoice.py プロジェクト: silverapp/silver
     'output': lambda invoice: invoice.sales_tax_name,
     'assertions': [
         lambda input, invoice, output: input == output if input else output == 'VAT'
     ]
 },
 'transactions': {
     'read_only': True,
     'output': lambda invoice: [
         spec_transaction(t) for t in invoice.transactions
     ]
 },
 'invoice_entries': {
     'required': False,
     'expected_input_types': list,
     'output': lambda invoice: [
         spec_document_entry(entry) for entry in invoice.entries
     ],
     'assertions': [
         lambda input, invoice, output: (
             len(input) == len(invoice.entries) == len(output) if input else
             len(invoice.entries) == len(output)
         ),
         # TODO
         # lambda input, invoice, output: (
         #     document_entry_definition.check_response(input, invoice.entries, output)
         # )
     ]
 },
 'pdf_url': {
     'read_only': True,
     'output': lambda invoice: (