Fix a few typos in python example scripts and align them with the latest api changes

This commit is contained in:
Geert Janssens 2014-11-17 17:45:40 +01:00
parent 22490a37ab
commit e59c3e0639
2 changed files with 9 additions and 10 deletions

View File

@ -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(), "", "")

View File

@ -22,11 +22,12 @@
# @author Mark Jenkins, ParIT Worker Co-operative <mark@parit.ca>
# 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()