summaryrefslogtreecommitdiff
path: root/src/administration_writer.cpp
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-09-21 20:37:34 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-09-21 20:37:34 +0200
commit051666a90b2c4779efdc8cfb49ab7316c94b58b0 (patch)
tree041ad949685731db2b824f502f0a7a8e64715517 /src/administration_writer.cpp
parent946a0c939c0cb7c28c9af9b7e4e2b20c45dd3702 (diff)
peppol file importing + invoice rw tests
Diffstat (limited to 'src/administration_writer.cpp')
-rw-r--r--src/administration_writer.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp
index e02d476..75f5daf 100644
--- a/src/administration_writer.cpp
+++ b/src/administration_writer.cpp
@@ -298,13 +298,8 @@ bool administration_writer_save_invoice_blocking(invoice inv)
struct tm *tm_info = 0;
char date_buffer[11]; // "YYYY-MM-DD" + null terminator
- // properties not stored from invoice:
- // - id (can be retrieved from filename)
- // - invoice allowance (can be recalculated from billing items)
-
// properties not stored from supplier/customer/addressee:
// - type
- // - bank account
// These can all be retrieved from existing contacts.
// properties not stored from billing item:
@@ -312,11 +307,13 @@ bool administration_writer_save_invoice_blocking(invoice inv)
// - tax (can be recalculated)
// - total (can be recalculated)
- strops_replace(file_content, buf_length, "{{INVOICE_ID}}", inv.sequential_number);
+ strops_replace(file_content, buf_length, "{{INVOICE_ID}}", inv.id);
+ strops_replace(file_content, buf_length, "{{INVOICE_SEQUENCE_ID}}", inv.sequential_number);
strops_replace(file_content, buf_length, "{{CURRENCY}}", inv.currency);
strops_replace(file_content, buf_length, "{{PROJECT_ID}}", inv.project_id);
- strops_replace(file_content, buf_length, "{{COST_CENTER_CODE}}", inv.cost_center_id);
+ strops_replace(file_content, buf_length, "{{COST_CENTER_ID}}", inv.cost_center_id);
strops_replace(file_content, buf_length, "{{INVOICE_DOCUMENT}}", inv.document);
+ strops_replace_int32(file_content, buf_length, "{{INVOICE_STATUS}}", (s32)inv.status);
// Supplier data
strops_replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_SCHEME}}", administration_writer_get_eas_scheme_for_contact(inv.supplier));
@@ -366,9 +363,11 @@ bool administration_writer_save_invoice_blocking(invoice inv)
// Payment means
strops_replace_int32(file_content, buf_length, "{{PAYMENT_TYPE}}", inv.payment_means.payment_method);
- strops_replace(file_content, buf_length, "{{SUPPLIER_IBAN}}", inv.payment_means.payee_bank_account);
- strops_replace(file_content, buf_length, "{{SUPPLIER_BIC}}", inv.payment_means.service_provider_id);
-
+ strops_replace(file_content, buf_length, "{{RECIPIENT_IBAN}}", inv.payment_means.payee_bank_account);
+ strops_replace(file_content, buf_length, "{{RECIPIENT_NAME}}", inv.payment_means.payee_account_name);
+ strops_replace(file_content, buf_length, "{{RECIPIENT_BIC}}", inv.payment_means.service_provider_id);
+ strops_replace(file_content, buf_length, "{{SENDER_IBAN}}", inv.payment_means.payer_bank_account);
+
// Tax breakdown
strops_replace_float(file_content, buf_length, "{{TOTAL_TAX_AMOUNT}}", inv.tax, 2);
{ // Create tax subtotal list.
@@ -431,9 +430,10 @@ bool administration_writer_save_invoice_blocking(invoice inv)
billing_item bi = billing_item_buffer[i];
tax_rate rate;
administration_tax_rate_get_by_id(&rate, bi.tax_rate_id);
-
+
strops_replace(billing_item_file_content, billing_item_buf_length, "{{CURRENCY}}", bi.currency);
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_rate_id);
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}}", rate.category_code);
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_PERCENT}}", rate.rate, 2);
@@ -441,10 +441,9 @@ bool administration_writer_save_invoice_blocking(invoice inv)
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{QUANTITY}}", bi.amount, 2);
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{UNIT_PRICE}}", bi.net_per_item, 2); // unit price before discount
strops_replace(billing_item_file_content, billing_item_buf_length, "{{UNIT_CODE}}", bi.amount_is_percentage ? "%" : "X");
- //strops_replace(billing_item_file_content, billing_item_buf_length, "{{TAX_BRACKET_ID}}", bi.tax_rate_id);
if (bi.discount_is_percentage) {
- strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL_PERCENTAGE}}", (bi.allowance / (bi.net + bi.allowance)) * 100.0f, 2);
+ strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL_PERCENTAGE}}", bi.discount, 2);
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_BASE_AMOUNT}}", bi.net + bi.allowance, 2); // Total net before discount.
}
else {