From e59c3e0639470bcdca39970ef8f7ff00849ec4e0 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 17 Nov 2014 17:45:40 +0100 Subject: [PATCH] Fix a few typos in python example scripts and align them with the latest api changes --- .../example_scripts/simple_business_create.py | 4 ++-- .../example_scripts/simple_invoice_insert.py | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/optional/python-bindings/example_scripts/simple_business_create.py b/src/optional/python-bindings/example_scripts/simple_business_create.py index adeb97aea9..40a2c3a02b 100644 --- a/src/optional/python-bindings/example_scripts/simple_business_create.py +++ b/src/optional/python-bindings/example_scripts/simple_business_create.py @@ -163,10 +163,10 @@ try: invoice_entry.SetDateEntered(datetime.datetime.now()) invoice_customer.PostToAccount(a2, datetime.date.today(), datetime.date.today(), - "the memo", True) + "the memo", True, False) new_customer.ApplyPayment(None, None, a2, a6, GncNumeric(100,100), - GncNumeric(1), datetime.date.today(), "", "") + GncNumeric(1), datetime.date.today(), "", "", True) invoice_customer.ApplyPayment(None, a6, GncNumeric(7,100), GncNumeric(1), datetime.date.today(), "", "") diff --git a/src/optional/python-bindings/example_scripts/simple_invoice_insert.py b/src/optional/python-bindings/example_scripts/simple_invoice_insert.py index ace1f57571..cab1769a1f 100644 --- a/src/optional/python-bindings/example_scripts/simple_invoice_insert.py +++ b/src/optional/python-bindings/example_scripts/simple_invoice_insert.py @@ -22,11 +22,12 @@ # @author Mark Jenkins, ParIT Worker Co-operative # Opens a GnuCash book file and adds an invoice to it for a particular -# customer (by GUID) with a specific ID and value +# customer (by ID) with a specific ID and value +# Optionally also adds a payment for the invoice as well # # The account tree and tax tables are assumed to be the same as the ones # created in simple_business_create.py, but you can edit that to adapt -# this to become an invoice imported for your own books +# this to become an invoice importer for your own books # # Syntax: # gnucash-env python simple_invoice_insert.py \ @@ -86,20 +87,18 @@ def gnc_numeric_from_decimal(decimal_value): s = Session(argv[1], is_new=False) -# this seems to make a difference in more complex cases -s.save() book = s.book root = book.get_root_account() commod_table = book.get_table() CAD = commod_table.lookup('CURRENCY', 'CAD') -my_customer = book.LookupByID(arg[2]) +my_customer = book.CustomerLookupByID(argv[2]) assert( my_customer != None ) assert( isinstance(my_customer, Customer) ) assets = root.lookup_by_name("Assets") -recievables = assets.lookup_by_name("Recievables") +receivables = assets.lookup_by_name("Receivables") income = root.lookup_by_name("Income") invoice = Invoice(book, argv[3], CAD, my_customer ) @@ -114,8 +113,8 @@ invoice_entry.SetQuantity( GncNumeric(1) ) invoice_entry.SetInvAccount(income) invoice_entry.SetInvPrice(invoice_value) -invoice.PostToAccount(recievables, datetime.date.today(), datetime.date.today(), - "", True) +invoice.PostToAccount(receivables, datetime.date.today(), datetime.date.today(), + "", True, False) s.save() s.end()