Add line item to expense

21 views
Skip to first unread message

guid...@interactar.com

unread,
Feb 23, 2016, 9:30:59 AM2/23/16
to Less Accounting API
Hi there I can't find in API documents how to POST an expense with an amount splited in 2 or more items. Could you pleas post an example?

Thank you!

Guido 


Eugen Minciu

unread,
Feb 23, 2016, 10:54:24 AM2/23/16
to less-acco...@googlegroups.com
Sure thing. 
Your form encoded parameters should look something like this:

expense[amount]=12.00&expense[bank_account_id]=16695&expense[check_number]=&expense[due_date]=01/15/14&expense[expense_items_attributes][0][_destroy]=false&expense[expense_items_attributes][0][amount]=8.00&expense[expense_items_attributes][0][contractor_id]=&expense[expense_items_attributes][0][employee_id]=&expense[expense_items_attributes][0][expense_category_id]=83096&expense[expense_items_attributes][0][notes]=notes+A&expense[expense_items_attributes][0][payee_id]=13183&expense[expense_items_attributes][0][tag_list]=a,b&expense[expense_items_attributes][0][title]=split+1+title&expense[expense_items_attributes][0][years_holding_value]=0&expense[expense_items_attributes][1][_destroy]=false&expense[expense_items_attributes][1][amount]=4.00&expense[expense_items_attributes][1][contractor_id]=13183&expense[expense_items_attributes][1][employee_id]=&expense[expense_items_attributes][1][expense_category_id]=83098&expense[expense_items_attributes][1][notes]=notes+B&expense[expense_items_attributes][1][payee_id]=&expense[expense_items_attributes][1][tag_list]=c&expense[expense_items_attributes][1][title]=title+for+split+2&expense[expense_items_attributes][1][years_holding_value]=3&expense[ignore_parent_attrs]=true&expense[is_paid]=1&expense[paid_date]=01/15/14&expense[title]=main+title

If one of the expense items (aka lines) you’re using already exists in the system, say with an id of 12345, you should set its id in the brackets like this:

expense[amount]=12.00&expense[bank_account_id]=16695&expense[check_number]=&expense[due_date]=01/15/14&expense[expense_items_attributes][0][_destroy]=false&expense[expense_items_attributes][0][amount]=8.00&expense[expense_items_attributes][0][contractor_id]=&expense[expense_items_attributes][0][employee_id]=&expense[expense_items_attributes][0][expense_category_id]=83096&expense[expense_items_attributes][0][notes]=notes+A&expense[expense_items_attributes][0][payee_id]=13183&expense[expense_items_attributes][0][tag_list]=a,b&expense[expense_items_attributes][0][title]=split+1+title&expense[expense_items_attributes][0][years_holding_value]=0&expense[expense_items_attributes][1234567][_destroy]=false&expense[expense_items_attributes][1234567][amount]=4.00&expense[expense_items_attributes][1234567][contractor_id]=13183&expense[expense_items_attributes][1234567][employee_id]=&expense[expense_items_attributes][1234567][expense_category_id]=83098&expense[expense_items_attributes][1234567][notes]=notes+B&expense[expense_items_attributes][1234567][payee_id]=&expense[expense_items_attributes][1234567][tag_list]=c&expense[expense_items_attributes][1234567][title]=title+for+split+2&expense[expense_items_attributes][1234567][years_holding_value]=3&expense[ignore_parent_attrs]=true&expense[is_paid]=1&expense[paid_date]=01/15/14&expense[title]=main+title

Sorry if the examples are a bit messy. Do let me know if you need any more help.

Eugen.

--
You received this message because you are subscribed to the Google Groups "Less Accounting API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to less-accounting...@googlegroups.com.
To post to this group, send email to less-acco...@googlegroups.com.
Visit this group at https://groups.google.com/group/less-accounting-api.
For more options, visit https://groups.google.com/d/optout.

guid...@interactar.com

unread,
Feb 23, 2016, 2:16:18 PM2/23/16
to Less Accounting API
Thanks a lot Eugen! Right now I was trying with the POST parameters from the lessaccounting frontend too. This worked perfect!

Best regards!


Guido

To unsubscribe from this group and stop receiving emails from it, send an email to less-accounting-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages