From 929a3bcd9ec5704fc4998376ae827d0d6f7338a1 Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Sun, 11 Nov 2018 18:12:32 +0100 Subject: [PATCH 1/4] pass additional args and document function --- bindings/python/gnucash_core.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index c1863bd1b9..b268503ebb 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -435,12 +435,22 @@ class Transaction(GnuCashCoreClass): gncInvoiceGetInvoiceFromTxn, Transaction ) def decorate_monetary_list_returning_function(orig_function): - def new_function(self): + def new_function(self, *args): + """decorate function that returns list of gnc_monetary to return tuples of GncCommodity and GncNumeric + + Args: + *args: Variable length argument list. Will get passed to orig_function + + Returns: + array of tuples: (GncCommodity, GncNumeric) + + ToDo: + Maybe this function should better reside in module function_class (?)""" # warning, item.commodity has been shown to be None # when the transaction doesn't have a currency return [(GncCommodity(instance=item.commodity), GncNumeric(instance=item.value)) - for item in orig_function(self) ] + for item in orig_function(self, *args) ] return new_function class Split(GnuCashCoreClass): From b431d471e0af0484642a2e97079499a1591c6e16 Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Sun, 11 Nov 2018 18:11:11 +0100 Subject: [PATCH 2/4] decorate monetary list to access GncCommodity and GncNumeric --- bindings/python/gnucash_business.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/python/gnucash_business.py b/bindings/python/gnucash_business.py index f2e47e677e..53b8e1b345 100644 --- a/bindings/python/gnucash_business.py +++ b/bindings/python/gnucash_business.py @@ -374,3 +374,6 @@ methods_return_instance(Entry, entry_dict) Entry.decorate_functions( decorate_to_return_instance_instead_of_owner, 'GetBillTo' ) + +from gnucash.gnucash_core import decorate_monetary_list_returning_function +Entry.decorate_functions(decorate_monetary_list_returning_function, 'GetBalTaxValues') From 8fe0b14213a81419ee6808b270773ebd46fb6844 Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Sun, 11 Nov 2018 18:58:46 +0100 Subject: [PATCH 3/4] Question about GncMonetary class instead of tuple --- bindings/python/gnucash_core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index b268503ebb..05306cab9d 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -445,7 +445,8 @@ def decorate_monetary_list_returning_function(orig_function): array of tuples: (GncCommodity, GncNumeric) ToDo: - Maybe this function should better reside in module function_class (?)""" + * Maybe this function should better reside in module function_class ? + * Should it be tuples anyway ? Wouldn't it be better to have GncMonetary to reflect gnc_monetary in c ?""" # warning, item.commodity has been shown to be None # when the transaction doesn't have a currency return [(GncCommodity(instance=item.commodity), From ff660a873e4738a3b694dd64cfc949573d90a20f Mon Sep 17 00:00:00 2001 From: Christoph Holtermann Date: Tue, 4 Dec 2018 12:17:56 +0100 Subject: [PATCH 4/4] Revert "Question about GncMonetary class instead of tuple" This reverts commit 8fe0b14213a81419ee6808b270773ebd46fb6844. Question has been discussed in pull request. --- bindings/python/gnucash_core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index 05306cab9d..b268503ebb 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -445,8 +445,7 @@ def decorate_monetary_list_returning_function(orig_function): array of tuples: (GncCommodity, GncNumeric) ToDo: - * Maybe this function should better reside in module function_class ? - * Should it be tuples anyway ? Wouldn't it be better to have GncMonetary to reflect gnc_monetary in c ?""" + Maybe this function should better reside in module function_class (?)""" # warning, item.commodity has been shown to be None # when the transaction doesn't have a currency return [(GncCommodity(instance=item.commodity),