diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm index 9961a6a378..10cee27df1 100644 --- a/gnucash/report/report-system/report-utilities.scm +++ b/gnucash/report/report-system/report-utilities.scm @@ -1200,15 +1200,8 @@ flawed. see report-utilities.scm. please update reports.") (format #f "[~a]" (gnc:monetary->string mon))) (define (owner->str owner) - (define owner-alist - (list (cons GNC-OWNER-NONE "None") - (cons GNC-OWNER-UNDEFINED "Undefined") - (cons GNC-OWNER-JOB "Job") - (cons GNC-OWNER-CUSTOMER "Cust") - (cons GNC-OWNER-VENDOR "Vend") - (cons GNC-OWNER-EMPLOYEE "Emp"))) (format #f "[~a:~a]" - (or (assv-ref owner-alist (gncOwnerGetType owner)) "Owner") + (gncOwnerGetTypeString owner) (gncOwnerGetName owner))) (define (invoice->str inv) (format #f "~a" diff --git a/libgnucash/engine/gncOwner.c b/libgnucash/engine/gncOwner.c index 53e648edb9..93a8211e57 100644 --- a/libgnucash/engine/gncOwner.c +++ b/libgnucash/engine/gncOwner.c @@ -204,6 +204,29 @@ GncOwnerType gncOwnerGetType (const GncOwner *owner) return owner->type; } +const char * gncOwnerGetTypeString (const GncOwner *owner) +{ + GncOwnerType type = gncOwnerGetType(owner); + switch (type) + { + case GNC_OWNER_NONE: + return "None"; + case GNC_OWNER_UNDEFINED: + return "Undefined"; + case GNC_OWNER_CUSTOMER: + return "Customer"; + case GNC_OWNER_JOB: + return "Job"; + case GNC_OWNER_VENDOR: + return "Vendor"; + case GNC_OWNER_EMPLOYEE: + return "Employee"; + default: + PWARN ("Unknown owner type"); + return NULL; + } +} + QofIdTypeConst qofOwnerGetType(const GncOwner *owner) { diff --git a/libgnucash/engine/gncOwner.h b/libgnucash/engine/gncOwner.h index 28251ac335..c66d60fe5a 100644 --- a/libgnucash/engine/gncOwner.h +++ b/libgnucash/engine/gncOwner.h @@ -65,6 +65,8 @@ to QOF as they can be used by objects like GncInvoice. */ /** return the type for the collection. */ QofIdTypeConst qofOwnerGetType(const GncOwner *owner); +/** return the type for the owner as an untranslated string. */ +const char * gncOwnerGetTypeString (const GncOwner *owner); /** return the owner itself as an entity. */ QofInstance* qofOwnerGetOwner (const GncOwner *owner); /** set the owner from the entity. */