Hi Gurveen,
Agree, the OOTB entities ReturnOrderHeaderV2 and ReturnOrderLineV2 can only achieve your requirement partially as it can only handle return orders. Also, there are no composite entities in standard D365 FO to achieve the entire process of receipt and invoiced via integration.
A few questions:
1. Are there multiple LEs involved in this integration process?
2. Are you looking to process headers and lines together through one import?
3. Are you considering mapping Payment (Payment_Refunded) as a field in the data entity?
4. Are you considering posting these sales orders post import in D365 FO?
Suggestions:
You can extend the entity(If there are no existing processes running on this data entity) or create a new custom entity(if you are considering Multiple legal entities) with filters SalesType = Return (Available in Standard). You can add a filter on the data entity (extension or the custom one(if you are considering Multiple legal entities)) on the ReturnStatus field and consider Received, Invoiced as values (as an extension to the standard data entity). Would consider the line level entity in this case for the integration process. Header record can be created automatically through the line (if there are no custom fields to be considered at the header level).
Custom Fields at Header Level:
In case if you have any fields at the header level to be considered, you will have can leave the standard filter where SalesType = Return.
Composite Data Entities:
If you are considering usage of composite entities then you need to duplicate the SalesOrderV4Entity and add the above data entities (Both Header and Lines) under one composite entity and achieve the process as a whole.
After import (if you are considering posting the return sales orders in D365 FO):
If you are considering posting the sales order returns in D365 then you can use the SalesFormLetter_Invoice class in your batch and consider adding the following parameters highlighted in the screen clip below
We have setup this for a client using Order Type as Returned Order and set the Status for Received + Invoiced. Sharing the batch parameters that we setup for processing Return sales orders with status Delivered and Invoiced.
Hope this helps.