Skip to content

Fixed Transaction.GetInvoiceFromTxn to convert to the right type of Python object #2074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindings/python/gnucash_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,9 @@ def GetNthSplit(self, n):
return self.GetSplitList().pop(n)

def GetInvoiceFromTxn(self):
from gnucash.gnucash_business import Transaction
from gnucash.gnucash_business import Invoice
return self.do_lookup_create_oo_instance(
gncInvoiceGetInvoiceFromTxn, Transaction )
gncInvoiceGetInvoiceFromTxn, Invoice )

def __eq__(self, other):
return self.Equal(other, True, False, False, False)
Expand Down
9 changes: 9 additions & 0 deletions bindings/python/tests/test_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,14 @@ def test_owner(self):
def test_commodities(self):
self.assertTrue( self.currency.equal( self.customer.GetCommoditiesList()[0] ) )

def test_invoice_transaction(self):
"""
Test that you can get the posted transaction from a posted invoice and that you can get the invoice back from the transaction.
"""
posted_transaction = self.invoice.GetPostedTxn()
self.assertTrue( posted_transaction != None )
invoice_from_transaction = posted_transaction.GetInvoiceFromTxn()
self.assertTrue( invoice_from_transaction != None and invoice_from_transaction.GetID() == self.invoice.GetID() )

if __name__ == '__main__':
main()