How to create a Sales Invoice using Web Service API

268 views
Skip to first unread message

Ankit

unread,
Apr 23, 2013, 9:37:44 PM4/23/13
to erpnext-dev...@googlegroups.com
Hello,

I can create customers using the API but creating an invoice involves a lot more and there is csv template that i can refer to.
Please provide an example.

regards
Ankit

Rushabh Mehta

unread,
Apr 23, 2013, 11:19:31 PM4/23/13
to erpnext-dev...@googlegroups.com
Ankit,

Had already given you a sample schema for invoice in the earlier example:


- Rushabh



Ankit

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/0n6gOwUfDBoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta

Ankit

unread,
Apr 23, 2013, 11:59:47 PM4/23/13
to erpnext-dev...@googlegroups.com
Thanks Rushabh,

My bad, I didn't check the link.


On Wednesday, April 24, 2013 3:19:31 PM UTC+12, rushabh wrote:
Ankit,

Had already given you a sample schema for invoice in the earlier example:


- Rushabh
On Wed, Apr 24, 2013 at 7:07 AM, Ankit <aps...@gmail.com> wrote:
Hello,

I can create customers using the API but creating an invoice involves a lot more and there is csv template that i can refer to.
Please provide an example.

regards

Ankit

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

To post to this group, send email to erpnext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/0n6gOwUfDBoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ankit

unread,
Apr 24, 2013, 3:35:29 AM4/24/13
to erpnext-dev...@googlegroups.com
Hello Rushabh,

Need your expert advice here.
I followed the example to create invoice.

Here is shat happens, if i send multiple  inserts for invoice like the example which sends invoice, taxes, items as branched doclists,
I get this error, even if there is just one doclist for sales invoice

"Traceback (innermost last):\n File \"../lib/webnotes/handler.py\", line 156, in handle\n execute_cmd(cmd)\n File \"../lib/webnotes/handler.py\", line 191, in execute_cmd\n ret = call(method, webnotes.form_dict)\n File \"../lib/webnotes/handler.py\", line 208, in call\n return fn(**newargs)\n File \"../lib/webnotes/client.py\", line 49, in insert\n doclist[0][\"__islocal\"] = 1\n TypeError: list indices must be integers, not unicode\n"
note: in php, just encoding multidimensional array to the json
Eg: json object that throws this error
string '[{"naming_series":"INV","company":"Company","conversion_rate":1,"currency":"RRR","debit_to":"ABCD EFGH - CMP","customer":"ABCD EFGH","customer_name":"ABCD EFGH","doctype":"Sales Invoice","posting_date":"2013-04-24","due_date":"2013-04-24","fiscal_year":"2013-2014","grand_total":0,"grand_total_export":0,"net_total":0,"is_pos":1,"plc_conversion_rate":1,"price_list_currency":"RRR","price_list_name":"Standard","territory":"Default"}]'


And i just send the sales invoice doclist to insert - not branched
It creates a blank invoice with the customer name on it.
note: in php, just encoding single dimensional array to the json
Eg: json object that works
string '{"naming_series":"INV","company":"Company","conversion_rate":1,"currency":"RRR","debit_to":"ABCD EFGH - CMP","customer":"ABCD EFGH","customer_name":"ABCD EFGH","doctype":"Sales Invoice","posting_date":"2013-04-24","due_date":"2013-04-24","fiscal_year":"2013-2014","grand_total":0,"grand_total_export":0,"net_total":0,"is_pos":1,"plc_conversion_rate":1,"price_list_currency":"RRR","price_list_name":"Standard","territory":"Default"'

I have tried various combinations with and withouts those multiple doclists with same error always.
What am I doing wrong.



Rushabh Mehta

unread,
Apr 24, 2013, 3:51:12 AM4/24/13
to erpnext-dev...@googlegroups.com
Ankit,

From the error, it seems that the object you are sending is a list of lists, not a list of dicts like "[{ doc }, { doc } ..]"

Check the json object sent in the request - maybe you are wrapping an extra list?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

To post to this group, send email to erpnext-dev...@googlegroups.com.

Ankit

unread,
Apr 25, 2013, 11:58:47 PM4/25/13
to erpnext-dev...@googlegroups.com
Hello Rushabh,

Two observations once I got it working.
1. The customer and debit to is selected, but when I check the contact, that is not selected. I was hoping that the primary contact gets selected by default.
2. If I set isPos via the webservice, It doens't populate the fields with default values for that Pos setting.

So I have to manually tick isPos which is fine, but I also have to reselect the customer to get the default contact.

How can I make sure the primary contact is selected when I set the customer?

regards
Ankit

Rushabh Mehta

unread,
Apr 26, 2013, 12:52:56 AM4/26/13
to erpnext-dev...@googlegroups.com
Ankit,

Thanks for identifying - we will add these in the server side validations and update you. We are already in the process of updating all our server side validations.

Should be done by end of day today.

best,
Rushabh


--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To post to this group, send email to erpnext-dev...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ankit Parikh

unread,
Apr 26, 2013, 1:05:11 AM4/26/13
to erpnext-dev...@googlegroups.com
Thank you Rushabh.


You received this message because you are subscribed to a topic in the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/erpnext-developer-forum/2TM0Tr_RILg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to erpnext-developer...@googlegroups.com.

To post to this group, send email to erpnext-dev...@googlegroups.com.

Anand Doshi

unread,
Apr 26, 2013, 2:11:12 AM4/26/13
to erpnext-dev...@googlegroups.com
Hi Ankit,

We will shift the fetching of values to server side, as you requested.

However, at this point, most calculations are done on the client side. We have started work on shifting them to server side. 

Hence, for now, you will need to specify values and totals when you pass the doclist.

Thanks,
Anand.

Ankit Parikh

unread,
Apr 26, 2013, 2:14:38 AM4/26/13
to erpnext-dev...@googlegroups.com
Hello Anand,

Calculations are not an issue.
We just the fields to be populated with the default values
like, primary contact for the customer should be selected automatically, when we send the customer.

We are checking all calculations before submitting the invoice.

regards
Ankit

Anand Doshi

unread,
Apr 26, 2013, 8:14:04 AM4/26/13
to erpnext-dev...@googlegroups.com
Hi Ankit,

We will release these changes on Monday, since we can provide better support then.

Thanks,
Anand.

Ankit Parikh

unread,
Apr 29, 2013, 8:25:38 PM4/29/13
to erpnext-dev...@googlegroups.com
Hello Anand,

I still can't see the changes. Now I am passing the item code as I start populating the items, and it should fetch the name and description from the database.

Are you going to implement what we discussed last week.
Setting customer, pos defaults, item details - all depend on this feature.

regards
Ankit

Anand Doshi

unread,
Apr 29, 2013, 10:12:27 PM4/29/13
to erpnext-dev...@googlegroups.com, erpnext-dev...@googlegroups.com
Hi Ankit

As per your last mail I had implemented fetching of customer data an post settings. 

Item details fetching was not mentioned. Will try to get this done. In the mean time, pass the item name and description. 

Sent from my phone

Ankit Parikh

unread,
Apr 29, 2013, 10:17:26 PM4/29/13
to erpnext-dev...@googlegroups.com
Hello Anand,

Just verified and the customer contact is not fetched when I set the customer.So it is still not working.

I cannot provide item name and description exactly to match the database hence the preferred option would be fetch it from erpnext like a normal flow of events when creating an invoice manually.


Anand Doshi

unread,
Apr 30, 2013, 1:50:17 AM4/30/13
to erpnext-dev...@googlegroups.com
Oops. Since this was a sensitive release, we were supposed to release it after some testing. But due to heave support load yesterday, we couldn't make it live.

We will do it today and also try to get the item fetching done.

Thanks,
Anand.

Ankit Parikh

unread,
Apr 30, 2013, 10:29:47 PM4/30/13
to erpnext-dev...@googlegroups.com
Hello Anand,

The changes are not there yet. Please email me when you have done those changes.
Very crucial to fetch the details for customers and items to automate the process otherwise it defeats the purpose of automatic invoice generation.

regards
Ankit

Ankit Parikh

unread,
May 3, 2013, 2:28:04 AM5/3/13
to erpnext-dev...@googlegroups.com
Hello Anand,

Another week has ended here.
Still waiting for those changes to kick in.

Haven't heard from you.

Ankit

Anand Doshi

unread,
May 3, 2013, 2:31:29 AM5/3/13
to erpnext-dev...@googlegroups.com
Hi Ankit,

We have had a heavy support load this week along with our usual development. Hence, we were unable to release it. I am testing it. We will release it on monday.

Thanks,
Anand.

Anand Doshi

unread,
May 3, 2013, 3:30:19 AM5/3/13
to erpnext-dev...@googlegroups.com
Hi Ankit,

This change required some other related changes and hence, it could introduce bugs.

I hope that you don't get the idea that I am stalling the release. 

The coding has been done and I am doing some tests on it.

We don't release any major changes on our server on a Friday. Hence, we will release it on Monday.

Thanks,
Anand. 

Ankit Parikh

unread,
May 3, 2013, 3:40:56 AM5/3/13
to erpnext-dev...@googlegroups.com
Thanks Anand

Anand Doshi

unread,
May 3, 2013, 5:24:31 AM5/3/13
to erpnext-dev...@googlegroups.com
Dear Ankit,

We have shifted your account to the cutting edge branch, in which we have released these changes. 

So you can now check if your api code works.

Let me know if you get stuck.

Thanks,
Anand.

Ankit Parikh

unread,
May 3, 2013, 8:56:47 PM5/3/13
to erpnext-dev...@googlegroups.com
Hello Anand,

That is working now. Thank you very much.

regards
Ankit
Reply all
Reply to author
Forward
0 new messages