Correct bug introduced in commit 63deaad. affecting Edit->Tax Report Options and the US Income Tax Report

This commit is contained in:
Alex Aycinena 2025-02-06 15:06:09 -08:00
parent b5c1937702
commit d0ad95fe92
2 changed files with 8 additions and 4 deletions

View File

@ -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);
}
/*********************************************************************\

View File

@ -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);
/** @} */