Hello folk, i didnt find a required parameter in Sales Invoices API to create sales invoice from Sales Order ID, while in the business documentation at erpnext knowledge it shows a clear relation between sales order and sales invoice. can you please advice what API to use to create sales invoice from sales order id. thank you
The sales invoice uses a custom button to show orders from the customer you can bill:
cur_frm.meta._default_print_format = null;
}
}
}
sales_order_btn() {
var me = this;
this.$sales_order_btn = this.frm.add_custom_button(__('Sales Order'),
function() {
erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
target: me.frm,
setters: {
customer: me.frm.doc.customer || undefined,
},
get_query_filters: {
docstatus: 1,
status: ["not in", ["Closed", "On Hold"]],
per_billed: ["<", 99.99],
company: me.frm.doc.company
It uses this method:
}
target_doc = get_mapped_doc("Sales Order", source_name, mapper, target_doc, set_missing_values)
target_doc.set_onload("ignore_price_list", True)
return target_doc
@frappe.whitelist()
def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
def postprocess(source, target):
set_missing_values(source, target)
# Get the advance paid Journal Entries in Sales Invoice Advance
if target.get("allocate_advances_automatically"):
target.set_advances()
def set_missing_values(source, target):
target.flags.ignore_permissions = True
target.run_method("set_missing_values")
target.run_method("set_po_nos")
Since the method is whitelisted, you can use it via API.
https://frappeframework.com/docs/v14/user/en/api/rest#remote-method-calls
thank you Kenneth for your help.