From d0ad95fe927ae93abf85f617e7d8db2e1c4a2dec Mon Sep 17 00:00:00 2001 From: Alex Aycinena Date: Thu, 6 Feb 2025 15:06:09 -0800 Subject: [PATCH] Correct bug introduced in commit 63deaad. affecting Edit->Tax Report Options and the US Income Tax Report --- libgnucash/engine/Account.cpp | 8 ++++++-- libgnucash/engine/Account.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index c3bc18f7fc..438a0d8d04 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -4006,13 +4006,17 @@ gint64 xaccAccountGetTaxUSCopyNumber (const Account *acc) { auto copy_number = get_kvp_int64_path (acc, {"tax-US", "copy-number"}); - return copy_number ? *copy_number : 1; + return (copy_number && (*copy_number != 0)) ? *copy_number : 1; } void xaccAccountSetTaxUSCopyNumber (Account *acc, gint64 copy_number) { - set_kvp_int64_path (acc, {"tax-US", "copy-number"}, copy_number); + if (copy_number != 0) + set_kvp_int64_path (acc, {"tax-US", "copy-number"}, copy_number); + else + /* deletes KVP if it exists */ + set_kvp_int64_path (acc, {"tax-US", "copy-number"}, std::nullopt); } /*********************************************************************\ diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h index 842db88486..eea91ac018 100644 --- a/libgnucash/engine/Account.h +++ b/libgnucash/engine/Account.h @@ -1406,9 +1406,9 @@ typedef enum const char * xaccAccountGetTaxUSPayerNameSource (const Account *account); /** DOCUMENT ME! */ void xaccAccountSetTaxUSPayerNameSource (Account *account, const char *source); - /** DOCUMENT ME! */ + /** Returns copy_number stored in KVP; if KVP doesn't exist or copy_number is zero, returns 1 */ gint64 xaccAccountGetTaxUSCopyNumber (const Account *account); - /** DOCUMENT ME! */ + /** Saves copy_number in KVP if it is greater than 1; if copy_number is zero, deletes KVP */ void xaccAccountSetTaxUSCopyNumber (Account *account, gint64 copy_number); /** @} */