summaryrefslogtreecommitdiff
path: root/src/administration_writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/administration_writer.cpp')
-rw-r--r--src/administration_writer.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp
index 6b28367..ee22022 100644
--- a/src/administration_writer.cpp
+++ b/src/administration_writer.cpp
@@ -669,14 +669,21 @@ bool administration_writer::save_tax_rate_blocking(tax_rate rate)
int buf_length = 0;
char* file_content = copy_template(file_template::taxrate_save_template, &buf_length);
- strops::replace(file_content, buf_length, "{{TAXBRACKET_ID}}", rate.id);
- strops::replace(file_content, buf_length, "{{TAXBRACKET_COUNTRY}}", rate.country_code);
+ 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(file_content, buf_length, "{{TAXBRACKET_CATEGORY}}", rate.category_code);
+ strops::replace_int32(file_content, buf_length, "{{TAXBRACKET_TYPE}}", static_cast<int>(rate.type));
+
+ char tax_sections_buffer[MAX_LEN_LONG_DESC];
+ char* write_cursor = tax_sections_buffer;
+ for (u32 i = 0; i < rate.tax_section_count; i++) {
+ write_cursor += strops::format(write_cursor, MAX_LEN_LONG_DESC, "%s##", rate.tax_sections[i]);
+ }
+
+ strops::replace(file_content, buf_length, "{{TAXBRACKET_SECTIONS}}", tax_sections_buffer);
//// Write to Disk.
char final_path[50];
- strops::format(final_path, 50, "%s.xml", rate.id);
+ strops::format(final_path, 50, "T/%s.xml", rate.internal_code);
int final_length = (int)strlen(file_content);
if (!xml_parse_document((uint8_t*)file_content, final_length)) result = 0;
@@ -684,8 +691,8 @@ bool administration_writer::save_tax_rate_blocking(tax_rate rate)
memops::unalloc(file_content);
- if (result) logger::info("Saved tax rate '%s/%.1f' in %.3fms.", rate.country_code, rate.rate, STOPWATCH_TIME);
- else logger::error("Failed to save tax rate '%s/%.1f'.", rate.country_code, rate.rate);
+ if (result) logger::info("Saved tax rate '%s' in %.3fms.", rate.internal_code, STOPWATCH_TIME);
+ else logger::error("Failed to save tax rate '%s'.", rate.internal_code);
return result;
}