summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/administration.cpp1
-rw-r--r--src/administration_reader.cpp1
-rw-r--r--src/administration_writer.cpp10
-rw-r--r--src/countries/nl.cpp44
4 files changed, 40 insertions, 16 deletions
diff --git a/src/administration.cpp b/src/administration.cpp
index 7a10ac0..e77dfdb 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -184,7 +184,6 @@ void administration::create_default(char* save_file)
{
administration::create_empty(save_file);
create_default_cost_centers();
- //administration::create_debug_data();
}
// Other functions.
diff --git a/src/administration_reader.cpp b/src/administration_reader.cpp
index 6a79b57..afe2d4c 100644
--- a/src/administration_reader.cpp
+++ b/src/administration_reader.cpp
@@ -370,6 +370,7 @@ bool administration_reader::import_tax_rate(char* buffer, size_t buffer_size)
tax_rate data = {0};
xml_get_str(root, data.internal_code, MAX_LEN_ID, "Id");
+ xml_get_str(root, data.category_code, MAX_LEN_CODE, "Category");
data.rate = xml_get_float(root, "Rate");
data.type = static_cast<tax_rate_type>(xml_get_s32(root, "Type"));
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp
index ebc0056..aae264b 100644
--- a/src/administration_writer.cpp
+++ b/src/administration_writer.cpp
@@ -427,10 +427,7 @@ bool administration_writer::save_invoice_blocking(invoice inv)
strops::replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAXABLE_AMOUNT}}", subtotal.net, 2);
strops::replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAX_AMOUNT}}", subtotal.tax, 2);
- char tax_category[10];
- tax_category[0] = 0; // TODO get tax category
-
- strops::replace(tax_entry_file_content, tax_entry_buf_length, "{{TAX_CATEGORY}}", tax_category);
+ strops::replace(tax_entry_file_content, tax_entry_buf_length, "{{TAX_CATEGORY}}", tax_rate_buffer[i].category_code);
strops::replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAX_PERCENT}}", tax_rate_buffer[i].rate, 2);
u32 content_len = (u32)strlen(tax_entry_file_content);
@@ -475,7 +472,7 @@ bool administration_writer::save_invoice_blocking(invoice inv)
strops::replace(billing_item_file_content, billing_item_buf_length, "{{LINE_ID}}", bi.id);
strops::replace(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_ID}}", bi.tax_internal_code);
strops::replace(billing_item_file_content, billing_item_buf_length, "{{ITEM_NAME}}", bi.description);
- strops::replace(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_CATEGORY}}", "S"); // TODO get from tax code
+ strops::replace(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_CATEGORY}}", rate.category_code);
strops::replace_float(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_PERCENT}}", rate.rate, 2);
strops::replace_float(billing_item_file_content, billing_item_buf_length, "{{LINE_AMOUNT}}", bi.net, 2); // line amount = net_per_item * items_count - discount
strops::replace_float(billing_item_file_content, billing_item_buf_length, "{{QUANTITY}}", bi.amount, 2);
@@ -670,7 +667,8 @@ bool administration_writer::save_tax_rate_blocking(tax_rate rate)
strops::replace(file_content, buf_length, "{{TAXBRACKET_INTERNAL_CODE}}", rate.internal_code);
strops::replace_float(file_content, buf_length, "{{TAXBRACKET_RATE}}", rate.rate, 2);
- strops::replace_int32(file_content, buf_length, "{{TAXBRACKET_TYPE}}", static_cast<int>(rate.type));
+ strops::replace_int32(file_content, buf_length, "{{TAXBRACKET_TYPE}}", static_cast<int>(rate.type));
+ strops::replace(file_content, buf_length, "{{TAXBRACKET_CATEGORY}}", rate.category_code);
char tax_sections_buffer[MAX_LEN_LONG_DESC];
char* write_cursor = tax_sections_buffer;
diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp
index 22a4ee2..8fe3c7f 100644
--- a/src/countries/nl.cpp
+++ b/src/countries/nl.cpp
@@ -139,6 +139,31 @@ time_t _nl_get_invoice_date_to_use_for_tax_report(invoice* inv)
return inv->issued_at;
}
+static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, char* category_code, float rate, ...)
+{
+ tax_rate result;
+ result.type = type;
+ result.tax_section_count = 0;
+ result.rate = rate;
+ strops::copy(result.internal_code, internal_code, sizeof(result.internal_code));
+ strops::copy(result.category_code, category_code, sizeof(result.category_code));
+
+ va_list args;
+ va_start(args, rate);
+
+ char* tax_category = 0;
+ do
+ {
+ tax_category = va_arg(args, char*);
+ if (tax_category) strops::copy(result.tax_sections[result.tax_section_count++], tax_category, MAX_LEN_SHORT_DESC);
+ else break;
+ } while (1);
+
+ va_end(args);
+
+ return result;
+}
+
static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, float rate, ...)
{
tax_rate result;
@@ -146,6 +171,7 @@ static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, float
result.tax_section_count = 0;
result.rate = rate;
strops::copy(result.internal_code, internal_code, sizeof(result.internal_code));
+ strops::copy(result.category_code, "S", sizeof(result.category_code));
va_list args;
va_start(args, rate);
@@ -171,15 +197,15 @@ u32 _nl_get_available_tax_rates(tax_rate* buffer, u32 buffer_size)
#define ADD(_line) if (cc < buffer_size) buffer[cc++] = _line; else assert(0);
// Outgoing
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/21", 21.00, "NL/1a", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/9", 9.00, "NL/1b", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/0", 0.00, "NL/1e", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/BTV", 0.00, "", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/BVB", 0.00, "NL/1e", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/PBEU", 0.00, "NL/3a", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/PIEU", 0.00, "NL/3b", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/DIEU", 0.00, "NL/3b", 0));
- ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/NBTW", 0.00, "", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/21", "S", 21.00, "NL/1a", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/9", "AA", 9.00, "NL/1b", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/0", "Z", 0.00, "NL/1e", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/BTV", "E", 0.00, "", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/BVB", "AE", 0.00, "NL/1e", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/PBEU", "G", 0.00, "NL/3a", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/PIEU", "G", 0.00, "NL/3b", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/DIEU", "G", 0.00, "NL/3b", 0));
+ ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/NBTW", "O", 0.00, "", 0));
// Unieregeling diensten
ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/MT/18/D", 18.00, "OBU", 0));