While it took me two days to get sorted out, I got the Sales Invoice API to work (if you are struggling with this, dowload the frappe-client library, swap out StringIO for io and save yourself some headache).
I’m submitting payment invoices successfully, but the payment information is not being recognized. Can anyone either:
- Recommend a modification to the JSON below, or
- Point me to the source code so I can see the logic for validating payment entries upon submission of Sales Invoices.
JSON Is here:
{"doctype":"Sales Invoice",
"docstatus":1,
"special_order_no":transaction.order_id,
"naming_series":"SINV-",
"posting_date":convert_to_date(transaction.date),
"company":"AnyCompany USA",
"currency":"USD",
"conversion_rate":1,
"selling_price_list":"Standard Selling",
"price_list_currency":"USD",
"plc_conversion_rate":1,
"base_net_total":transaction.total,
"base_grand_total":transaction.total,
"grand_total":transaction.total,
"debit_to":"Debtors - DFL",
"customer":"BroomHilda Co",
"customer_name":"BroomHilda",
"due_date":convert_to_date(transaction.date),
"base_paid_amount":transaction.total,
"paid_amount":transaction.total,
"status":"Paid",
"submit_on_creation":1,
"update_stock":1,
"items":
[{"doctype":"Sales Invoice Item",
"item_name":transaction.item_name,
"description":transaction.item_name,
"uom":"Nos",
"conversation_factor":1,
"rate":transaction.rate,
"amount":transaction.rate,
"base_rate":transaction.rate,
"base_amount":transaction.rate,
"income_account":"Sales - DFL",
"cost_center":"Main - DFL",
"item_code":transaction.sku,
"qty":float(transaction.qty),
"warehouse":"Finished Goods - DFL"}],
"payments":
[{"mode_of_payment":"Cash",
"amount":transaction.total,
"clearance_date":convert_to_date(transaction.date),
"account":"Cash - DFL",
"base_amount":transaction.total}]}
Any guidance is much appreciated.