summaryrefslogtreecommitdiff
path: root/src/administration_reader.cpp
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-10-19 17:12:59 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-10-19 17:12:59 +0200
commitb34be3482e4a322a1198873f4ba3265d8a82e58d (patch)
tree7f5145bbd3d69d1b53cc000afa1a7280aa899329 /src/administration_reader.cpp
parent1bfeb2751bf07cdc81ea9344ec941e671cb216a8 (diff)
fix issue with order of loading
Diffstat (limited to 'src/administration_reader.cpp')
-rw-r--r--src/administration_reader.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/administration_reader.cpp b/src/administration_reader.cpp
index afe2d4c..4edf501 100644
--- a/src/administration_reader.cpp
+++ b/src/administration_reader.cpp
@@ -115,6 +115,9 @@ bool administration_reader::open_existing(char* file_path)
zip_close(zip);
+ // Tax rates might be loaded after invoices so we need to recalculate all totals.
+ administration::invoice_recalculate_totals();
+
logger::info("Imported '%s' in %.3fms.", file_path, STOPWATCH_TIME);
return true;
@@ -229,12 +232,6 @@ bool administration_reader::read_invoice_from_xml(invoice* result, char* buffer,
bi.discount = xml_get_float_x(child, "cac:AllowanceCharge", "cbc:MultiplierFactorNumeric", 0);
}
- // Import service could set tax rate id to shorthandle.
- tax_rate tax_rate;
- if (administration::tax_rate_get_by_internal_code(&tax_rate, bi.tax_internal_code) == A_ERR_NOT_FOUND) {
- strops::copy(bi.tax_internal_code, "", MAX_LEN_SHORT_DESC);
- }
-
administration::billing_item_import_to_invoice(&data, bi);
}
@@ -369,7 +366,7 @@ bool administration_reader::import_tax_rate(char* buffer, size_t buffer_size)
struct xml_node* root = xml_document_root(document);
tax_rate data = {0};
- xml_get_str(root, data.internal_code, MAX_LEN_ID, "Id");
+ xml_get_str(root, data.internal_code, MAX_LEN_SHORT_DESC, "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"));