diff options
Diffstat (limited to 'tests/test_helper.cpp')
| -rw-r--r-- | tests/test_helper.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/tests/test_helper.cpp b/tests/test_helper.cpp index 85d228a..fc09fd6 100644 --- a/tests/test_helper.cpp +++ b/tests/test_helper.cpp @@ -5,6 +5,7 @@ #include "memops.hpp" #include "strops.hpp" +#include "countries.hpp" #include "administration.hpp" #include "administration_reader.hpp" #include "administration_writer.hpp" @@ -48,7 +49,7 @@ static contact _create_nl_consumer() } -static billing_item _create_bi1(invoice *inv) +static billing_item _create_bi1() { billing_item item = administration::billing_item_create_empty(); item.amount = 1; @@ -58,16 +59,14 @@ static billing_item _create_bi1(invoice *inv) item.discount = 2.0f; item.discount_is_percentage = 0; - 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_internal_code, rand_rate.id, MAX_LEN_ID); + tax_rate rate; + administration::tax_rate_get_by_internal_code(&rate, "NL/21"); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } -static billing_item _create_bi2(invoice *inv) +static billing_item _create_bi2() { billing_item item = administration::billing_item_create_empty(); item.amount = 2; @@ -77,16 +76,14 @@ static billing_item _create_bi2(invoice *inv) 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_internal_code, rand_rate.id, MAX_LEN_ID); + tax_rate rate; + administration::tax_rate_get_by_internal_code(&rate, "NL/21"); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } -static billing_item _create_bi3(invoice *inv) +static billing_item _create_bi3() { billing_item item = administration::billing_item_create_empty(); item.amount = 1; @@ -96,16 +93,14 @@ static billing_item _create_bi3(invoice *inv) item.discount = 2.0f; item.discount_is_percentage = 0; - 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_internal_code, rand_rate.id, MAX_LEN_ID); + tax_rate rate; + administration::tax_rate_get_by_internal_code(&rate, "NL/21"); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } -static billing_item _create_bi4(invoice *inv) +static billing_item _create_bi4() { billing_item item = administration::billing_item_create_empty(); item.amount = 3; @@ -115,16 +110,14 @@ static billing_item _create_bi4(invoice *inv) item.discount = 0.0f; item.discount_is_percentage = 0; - 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_internal_code, rand_rate.id, MAX_LEN_ID); + tax_rate rate; + administration::tax_rate_get_by_internal_code(&rate, "NL/21"); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } -static billing_item _create_bi5(invoice *inv) +static billing_item _create_bi5() { billing_item item = administration::billing_item_create_empty(); item.amount = 5; @@ -134,16 +127,14 @@ static billing_item _create_bi5(invoice *inv) 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_internal_code, rand_rate.id, MAX_LEN_ID); + tax_rate rate; + administration::tax_rate_get_by_internal_code(&rate, "NL/21"); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } -static billing_item _create_bi6(invoice *inv) +static billing_item _create_bi6() { billing_item item = administration::billing_item_create_empty(); item.amount = 10; @@ -153,11 +144,9 @@ static billing_item _create_bi6(invoice *inv) item.discount = 0.0f; item.discount_is_percentage = 0; - 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_internal_code, rand_rate.id, MAX_LEN_ID); + tax_rate rate; + administration::tax_rate_get_by_internal_code(&rate, "NL/21"); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } @@ -172,8 +161,8 @@ static billing_item _create_bi(float amount, float npi, char* taxrate) item.discount = 0.0f; item.discount_is_percentage = 0; tax_rate rate; - //administration::tax_rate_get_by_shorthandle(&rate, taxrate); - strops::copy(item.tax_internal_code, rate.id, MAX_LEN_ID); + administration::tax_rate_get_by_internal_code(&rate, taxrate); + strops::copy(item.tax_internal_code, rate.internal_code, MAX_LEN_SHORT_DESC); return item; } @@ -243,4 +232,15 @@ static bool _test_peppol_file(char* id) } return result; -}
\ No newline at end of file +} + +static void add_default_nl_tax_rates() +{ + tax_rate* tr_buffer = (tax_rate*)memops::alloc(sizeof(tax_rate) * 500); + country::get_available_tax_rates("NL", tr_buffer, 500); + + for (u32 i = 0; i < 10; i++) { + administration::tax_rate_add(tr_buffer[i]); + } + memops::unalloc(tr_buffer); +} |
