diff options
Diffstat (limited to 'tests/peppol_write_tests.cpp')
| -rw-r--r-- | tests/peppol_write_tests.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tests/peppol_write_tests.cpp b/tests/peppol_write_tests.cpp index e77f128..c00b53b 100644 --- a/tests/peppol_write_tests.cpp +++ b/tests/peppol_write_tests.cpp @@ -10,25 +10,21 @@ char* extract_dir = "build\\extracted"; static contact _create_nl_business() { contact pw = administration_contact_create_empty(); - strops_copy(pw.name, "John Johnsson", sizeof(pw.name)); + strops_copy(pw.name, "Piet Pinda", sizeof(pw.name)); strops_copy(pw.address.address1, "Address 1", sizeof(pw.address.address1)); strops_copy(pw.address.country_code, "NL", sizeof(pw.address.country_code)); strops_copy(pw.address.city, "Amsterdam", sizeof(pw.address.city)); strops_copy(pw.address.postal, "1234AA", sizeof(pw.address.postal)); strops_copy(pw.taxid, "T123", sizeof(pw.taxid)); strops_copy(pw.businessid, "B321", sizeof(pw.businessid)); + strops_copy(pw.email, "test@test.com", sizeof(pw.email)); pw.type = contact_type::CONTACT_BUSINESS; return pw; } static contact _create_nl_consumer() { - contact pw = administration_contact_create_empty(); - strops_copy(pw.name, "Hans Klok", sizeof(pw.name)); - strops_copy(pw.address.address1, "Address 2", sizeof(pw.address.address1)); - strops_copy(pw.address.country_code, "NL", sizeof(pw.address.country_code)); - strops_copy(pw.address.city, "Amsterdam", sizeof(pw.address.city)); - strops_copy(pw.address.postal, "4321AA", sizeof(pw.address.postal)); + contact pw = _create_nl_business(); pw.type = contact_type::CONTACT_CONSUMER; return pw; } @@ -44,9 +40,28 @@ static billing_item _create_bi1(invoice *inv) item.discount_is_percentage = 0; tax_rate buffer[20]; - char* country_codes[2] = {inv->supplier.address.country_code, inv->customer.address.country_code}; - administration_tax_rate_get_by_country(buffer, 2, country_codes); - tax_rate rand_rate = buffer[0]; + char* _country_codes[2] = {inv->supplier.address.country_code, inv->customer.address.country_code}; + u32 tax_rate_count = administration_tax_rate_get_by_country(buffer, 2, _country_codes); + tax_rate rand_rate = buffer[tax_rate_count-1]; + strops_copy(item.tax_rate_id, rand_rate.id, MAX_LEN_ID); + + return item; +} + +static billing_item _create_bi2(invoice *inv) +{ + billing_item item = administration_billing_item_create_empty(); + item.amount = 2; + item.amount_is_percentage = 0; + strops_copy(item.description, "Soap", MAX_LEN_LONG_DESC); + item.net_per_item = 5.00f; + item.discount = 5.0f; + item.discount_is_percentage = 1; + + tax_rate buffer[20]; + char* _country_codes[2] = {inv->supplier.address.country_code, inv->customer.address.country_code}; + u32 tax_rate_count = administration_tax_rate_get_by_country(buffer, 2, _country_codes); + tax_rate rand_rate = buffer[tax_rate_count-1]; strops_copy(item.tax_rate_id, rand_rate.id, MAX_LEN_ID); return item; @@ -125,6 +140,7 @@ TEST _peppol_write_nl2nl_b2b(void) inv.expires_at = inv.issued_at + 1000; administration_billing_item_add_to_invoice(&inv, _create_bi1(&inv)); + administration_billing_item_add_to_invoice(&inv, _create_bi2(&inv)); ASSERT_EQ(administration_invoice_add(&inv), A_ERR_SUCCESS); if (_test_peppol_file(inv.id)) { PASS(); } else { FAIL(); } @@ -145,6 +161,7 @@ TEST _peppol_write_nl2nl_b2c(void) inv.expires_at = inv.issued_at + 1000; administration_billing_item_add_to_invoice(&inv, _create_bi1(&inv)); + administration_billing_item_add_to_invoice(&inv, _create_bi2(&inv)); ASSERT_EQ(administration_invoice_add(&inv), A_ERR_SUCCESS); if (_test_peppol_file(inv.id)) { PASS(); } else { FAIL(); } |
