I created Taxi module and after finishing it, I will suggest on ERPNext to contribute it to be part of the source.
In this taxi application, there is trip order and it contains the below table which calculates the price for each trip and the total price.
I need to add Make button to be able to create Invoice, the question is:
How I can create invoice that is related to the trip order and contains (automatically) the items (which will be the trips and its prices)?
I am sure there should be a method that enable us to be able to determine what to fill in the invoice item table.
Or I have to make the needed fields to be the same name? This is the only way?
OK, what about if I need to do some manipulation: For example: If I need to manipulate the items that are existed in the order and place it in the invoice in different quantities or names?
That is why I am thinking on a method (script) that enable me to play in this and pass the proper data to appear in the invoice.
I haven’t looked for the right method, but I can tell you the principle. You need to create/submit a ‘Sales Invoice’ using frappe.new_doc(), which means you need to fill all the essential attributes like customer, item , price etc. In order to do that, you need to have all those documents already created. You item creation could be trickier if you want separate items for every distinct trip(from-to ). If not, you could just create one item, set the rate and change the quantity based on the distance.
I resolved this by considering the Trip Order doctype is the invoice. So when the user submitting it, then it will fill the needed debit and credit records in the GL at the account module.
Generally speaking: from business to business, there will be a different need for doctype to be the invoice. So you can not consider the sales invoice to be valid for all kind of businesses.
Same thing happened for education, they used Fees doctype to be the sales invoice for the student.