Skip to content

Commit

Permalink
Enable gnc_register_owner_option to handle the three types that GncOw…
Browse files Browse the repository at this point in the history
…ner aliases.
  • Loading branch information
jralls committed Aug 1, 2021
1 parent d8f83d6 commit 4a4e5d3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
34 changes: 27 additions & 7 deletions libgnucash/app-utils/gnc-optiondb.cpp
Expand Up @@ -896,23 +896,43 @@ gnc_register_internal_option(GncOptionDB* db, const char* section,
db->register_option(section, std::move(option));
}

static inline GncOptionUIType
owner_type_to_ui_type(GncOwnerType type)
{
switch (type)
{
case GNC_OWNER_NONE:
case GNC_OWNER_UNDEFINED:
case GNC_OWNER_JOB:
return GncOptionUIType::INTERNAL;
case GNC_OWNER_CUSTOMER:
return GncOptionUIType::CUSTOMER;
case GNC_OWNER_VENDOR:
return GncOptionUIType::VENDOR;
case GNC_OWNER_EMPLOYEE:
return GncOptionUIType::EMPLOYEE;
}
}

void
gnc_register_owner_option(GncOptionDB* db, const char* section,
const char* name, const char* key,
const char* doc_string, GncOwner* value)
const char* name, const char* key,
const char* doc_string, GncOwner* value,
GncOwnerType type)
{
GncOption option{section, name, key, doc_string, (const QofInstance*)value,
GncOptionUIType::INVOICE};
GncOption option{section, name, key, doc_string,
(const QofInstance*)value->owner.undefined,
owner_type_to_ui_type(type)};
db->register_option(section, std::move(option));
}

void
gnc_register_invoice_option(GncOptionDB* db, const char* section,
const char* name, const char* key,
const char* doc_string, GncInvoice* value)
const char* name, const char* key,
const char* doc_string, GncInvoice* value)
{
GncOption option{section, name, key, doc_string, (const QofInstance*)value,
GncOptionUIType::OWNER};
GncOptionUIType::INVOICE};
db->register_option(section, std::move(option));
}

Expand Down
3 changes: 2 additions & 1 deletion libgnucash/app-utils/gnc-optiondb.hpp
Expand Up @@ -174,7 +174,8 @@ void gnc_register_invoice_option(GncOptionDB* db, const char* section,

void gnc_register_owner_option(GncOptionDB* db, const char* section,
const char* name, const char* key,
const char* doc_string, GncOwner* value);
const char* doc_string, GncOwner* value,
GncOwnerType type);

void gnc_register_taxtable_option(GncOptionDB* db, const char* section,
const char* name, const char* key,
Expand Down

0 comments on commit 4a4e5d3

Please sign in to comment.