I'm trying to create an invoice programatically using the web services. I have time entry data for an employee working for a customer, so I want to enter that time then create an invoice. I can create the time entries. I can go into the UI and approve them after I create them programatically. But I get an invalid reference error when I try to save an invoice that refers to those time entries.
In studying the object model, I see that:
Invoice has a "timeList" field that accepts an InvoiceTimeList object.
InvoiceTimeList has a "time" field that accepts an array of InvoiceTime objects.
I start to get into trouble here. The InvoiceTime has required fields "doc" and "line". I think "doc" should hold the ID of a TimeBill object (that I successfully created), and I'm not sure what the "line" field is for, but in examples it is alwasy 0.
So, my program logic is this:
* Create a TimeBill object with details about the hours, employee, and customer; write it and get its internalId.
* Create an InvoiceTime object and set "doc" to the internalId above, and set the "line" to zero.
* Create the Invoice and set the "timeList" field to the InvoiceTime object. (Actually it is set to an array of InvoiceTime objects, but there is only one.)
When I write the Invoice I get "invalid reference key: doc, line" followed by the id of the TimeBill item I used and 0 respectively. "doc" is the id of a TimeBill item.
The "line" puzzles me, as I'm not sure what line the time entry is part of.
Thanks.