I am developing a customize app and I have two doctype A and B. A is the where transactions are stored during the day and the end of the day I want to move all data in A to B. This is a daily event, B is more like a history of A.
Check the method get_mapped_doc it will map the fields in the source (in your case it’s A) document and create a new target (in your case it’s A) document.
You will need to write the fieldmap if the fields name’s in the Document A and Document B are not same. Please check the how the sales invoice is created from sales order using method make_sales_invoice