def test_create_with_minimal_data(self, netvisor, responses): responses.add(method='POST', url='http://koulutus.netvisor.fi/Customer.nv?method=add', body=get_response_content('CustomerCreate.xml'), content_type='text/html; charset=utf-8', match_querystring=True) netvisor_id = netvisor.customers.create( {'customer_base_information': { 'name': u'Matti Meikäläinen' }}) request = responses.calls[0].request assert netvisor_id == 8 assert request.body == get_request_content('CustomerMinimal.xml')
def test_create_product(self, netvisor, responses): responses.add(method='POST', url='http://koulutus.netvisor.fi/Product.nv?method=add', body=get_response_content('ProductCreate.xml'), content_type='text/html; charset=utf-8', match_querystring=True) netvisor_id = netvisor.products.create({ 'product_base_information': { 'product_code': u'CC', 'product_group': u'Kirjat', 'name': u'Code Complete', 'description': u'Toinen painos', 'unit_price': { 'amount': decimal.Decimal('42.5'), 'type': u'gross' }, 'unit': u'kpl', 'purchase_price': decimal.Decimal('25.00'), 'tariff_heading': u'Code Complete', 'comission_percentage': decimal.Decimal('11'), 'is_active': True, 'is_sales_product': False, 'inventory_enabled': False, 'country_of_origin': u'FI', }, 'product_book_keeping_details': { 'default_vat_percentage': decimal.Decimal('22'), }, 'product_additional_information': { 'product_net_weight': decimal.Decimal('11.2'), 'product_gross_weight': decimal.Decimal('12.6'), 'product_weight_unit': u'kg' }, 'product_package_information': { 'package_width': decimal.Decimal('7.3'), 'package_height': decimal.Decimal('15.0'), 'package_length': decimal.Decimal('36.1') } }) request = responses.calls[0].request assert netvisor_id == 8 assert request.body == get_request_content('Product.xml')
def test_create_minimal(self, netvisor, responses): responses.add( method='POST', url='http://koulutus.netvisor.fi/salesinvoice.nv?method=add', body=get_response_content('SalesInvoiceCreate.xml'), content_type='text/html; charset=utf-8', match_querystring=True) netvisor_id = netvisor.sales_invoices.create({ 'date': date(2008, 12, 12), 'amount': decimal.Decimal('244.00'), 'status': 'unsent', 'invoicing_customer_identifier': u'1', 'payment_term_net_days': 14, 'payment_term_cash_discount_days': 5, 'payment_term_cash_discount': decimal.Decimal('9'), 'invoice_lines': [{ 'identifier': dict(identifier="1697", type="netvisor"), 'name': 'Omena', 'unit_price': { 'amount': decimal.Decimal('6.90'), 'type': 'net' }, 'vat_percentage': { 'percentage': decimal.Decimal('22'), 'code': 'KOMY', }, 'quantity': decimal.Decimal('2'), }] }) request = responses.calls[0].request assert netvisor_id == 8 assert xmltodict.parse(request.body) == xmltodict.parse( get_request_content('SalesInvoiceMinimal.xml'))
def test_create_dimension(self, netvisor, responses): responses.add( method='POST', url='http://koulutus.netvisor.fi/DimensionItem.nv?method=add', body=get_response_content('DimensionCreate.xml'), content_type='text/html; charset=utf-8', match_querystring=True) netvisor.dimensions.create({ "name": "Example Dimension", "item": "Example Dimension Item Sub-Item 1", "father_id": "0", "father_item": "Example Dimension Item 2", "is_hidden": False }) request = responses.calls[0].request assert xmltodict.parse(request.body) == xmltodict.parse( get_request_content('Dimension.xml'))
def test_create_minimal_product(self, netvisor, responses): responses.add(method='POST', url='http://koulutus.netvisor.fi/Product.nv?method=add', body=get_response_content('ProductCreate.xml'), content_type='text/html; charset=utf-8', match_querystring=True) netvisor_id = netvisor.products.create({ 'product_base_information': { 'product_group': u'Kirjat', 'name': u'Code Complete', 'unit_price': { 'amount': decimal.Decimal('42.5'), 'type': u'gross' }, 'is_active': True, 'is_sales_product': False, } }) request = responses.calls[0].request assert netvisor_id == 8 assert request.body == get_request_content('ProductMinimal.xml')
def test_create_voucher(self, netvisor, responses): responses.add(method='POST', url='http://koulutus.netvisor.fi/Accounting.nv', body=get_response_content('AccountingCreateVoucher.xml'), content_type='text/html; charset=utf-8', match_querystring=True) netvisor_id = netvisor.accounting.create({ "mode": "net", "date": date(2018, 6, 11), "description": "Test Company Oy, invoice 1", "class": "Myyntilasku", "voucher_line": [{ "line_sum": { "sum": Decimal("-10000.00"), "type": "net" }, "description": u"Test Company Oy, invoice 1", "account_number": 3000, "vat_percent": dict(percentage=Decimal("24"), code="KOMY"), "account_dimension": { "dimension": "Test account", "type": "name" }, "dimension": { "name": "Projects", "item": "Project X" } }, { "line_sum": { "sum": Decimal("-5000"), "type": "net" }, "description": u"Test Company Oy, invoice 1", "account_number": 2939, "vat_percent": dict(percentage=Decimal(0), code=u"NONE"), }, { "line_sum": { "sum": Decimal("20000"), "type": "net" }, "description": u"Test Company Oy, invoice 1", "account_number": 1701, "vat_percent": dict(percentage=Decimal(0), code=u"NONE"), }], "attachments": [{ "mime_type": "application/pdf", "description": "Test attachment", "filename": "attachment.pdf", "data": "JVBERi0xLjQNJeLjz9MNCjYgMCB" }], }) request = responses.calls[0].request assert netvisor_id == 8 assert xmltodict.parse(request.body) == xmltodict.parse( get_request_content('Voucher.xml'))
def test_update(self, netvisor, responses): responses.add( method='POST', url='http://koulutus.netvisor.fi/Customer.nv?method=edit&id=8', body=get_response_content('CustomerEdit.xml'), content_type='text/html; charset=utf-8', match_querystring=True) data = { 'customer_base_information': { 'internal_identifier': u'MM', 'external_identifier': u'1967543-8', 'name': u'Matti Meikäläinen', 'name_extension': u'Toimitusjohtaja', 'street_address': u'c/o Yritys Oy', 'additional_address_line': u'Pajukuja 1', 'city': u'Lappeenranta', 'post_number': u'53100', 'country': u'FI', 'customer_group_name': u'Alennusasiakkaat', 'phone_number': u'040 123456', 'fax_number': u'05 123456', 'email': u'*****@*****.**', 'email_invoicing_address': u'*****@*****.**', 'home_page_uri': u'www.firma.fi', 'is_active': True, }, 'customer_finvoice_details': { 'finvoice_address': u'FI109700021497', 'finvoice_router_code': 'NDEAFIHH' }, 'customer_delivery_details': { 'delivery_name': u'Maija Mehiläinen', 'delivery_street_address': u'Pajukuja 2', 'delivery_city': u'Lappeenranta', 'delivery_post_number': u'53900', 'delivery_country': u'FI', }, 'customer_contact_details': { 'contact_person': u'Matti Meikäläinen', 'contact_person_email': u'*****@*****.**', 'contact_person_phone': u'040 987 254', }, 'customer_additional_information': { 'comment': u'Kommentti', 'customer_reference_number': u'1070', 'invoicing_language': u'FI', 'invoice_print_channel_format': u'1', 'your_default_reference': 'Default reference', 'default_text_before_invoice_lines': 'Default text before invoice lines', 'default_text_after_invoice_lines': 'Default text after invoice lines', } } assert netvisor.customers.update(id=8, data=data) is None request = responses.calls[0].request assert request.body == get_request_content('Customer.xml')
def test_update(self, netvisor, responses): responses.add( method='POST', url='http://koulutus.netvisor.fi/salesinvoice.nv?method=edit&id=8', body=get_response_content('SalesInvoiceEdit.xml'), content_type='text/html; charset=utf-8', match_querystring=True) data = { 'number': '107', 'date': date(2008, 12, 12), 'value_date': date(2008, 11, 30), 'delivery_date': date(2008, 7, 25), 'reference_number': '1070', 'amount': decimal.Decimal('244.00'), 'currency': 'EUR', 'seller_identifier': 32, 'status': 'unsent', 'invoicing_customer_identifier': u'1', 'invoicing_customer_name': u'Matti Mallikas', 'invoicing_customer_name_extension': u'Masa', 'invoicing_customer_address_line': u'Pajukuja 1', 'invoicing_customer_additional_address_line': None, 'invoicing_customer_post_number': u'53100', 'invoicing_customer_town': u'Lappeenranta', 'invoicing_customer_country_code': u'FI', 'delivery_address_name': u'Netvisor Oy', 'delivery_address_name_extension': u'Ohjelmistokehitys ja tuotanto', 'delivery_address_line': u'Snelmanninkatu 12', 'delivery_address_post_number': u'53100', 'delivery_address_town': u'LPR', 'delivery_address_country_code': u'FI', 'payment_term_net_days': 14, 'payment_term_cash_discount_days': 5, 'payment_term_cash_discount': decimal.Decimal('9'), 'invoice_lines': [{ 'identifier': dict(identifier="1697", type="netvisor"), 'name': 'Omena', 'unit_price': { 'amount': decimal.Decimal('6.90'), 'type': 'net' }, 'vat_percentage': { 'percentage': decimal.Decimal('22'), 'code': 'KOMY', }, 'quantity': decimal.Decimal('2'), 'discount_percentage': decimal.Decimal('0'), 'free_text': 'Punainen', 'accounting_account_suggestion': '3000' }, { 'identifier': dict(identifier="1697", type="netvisor"), 'name': 'Banaani', 'unit_price': { 'amount': decimal.Decimal('100.00'), 'type': 'net' }, 'vat_percentage': { 'percentage': decimal.Decimal('22'), 'code': 'KOMY', }, 'quantity': decimal.Decimal('1'), 'free_text': 'Keltainen', 'accounting_account_suggestion': '3200' }], 'attachments': [{ 'mime_type': "application/pdf", 'description': 'This is a file', 'filename': 'invoice-attachment.pdf', 'data': 'SSdtIG5vdCBtYWRlIGJ5IGRlc2lnbg==', 'type': 'pdf', }] } assert netvisor.sales_invoices.update(id=8, data=data) is None request = responses.calls[0].request assert request.body == get_request_content('SalesInvoice.xml')