I have experimented with both DMF (data management framework) as well as the the OData API, in an attempt to import a Journal Header, and its lines, atomically (single transaction).
OData API attempts
- /data/LedgerJournalHeaders allows me to post a header only. Attempting to include its "Lines" in the same call results in a "cannot patch " error for the lines I am attempting to send.
- Tried to use the /data/batch endpoint to leverage OData's support for batch operations. However you cannot send a header and its lines in the same change set, because the payload for a line (/data/LedgerJournalLines) has a property that has to refer to the ID of the header. This means the header must be created first to get its ID, and only then can you create the lines. This is in line with how the "General journals" UI works in Finance.
DMF Attempts
There is a data entity called "General journal" that contains both the header level and line level in a single entity. This seems to be the recommended entity to use for batch import scenarios. I created a data project in Finance, and exported an sample package which contained the csv, and the manifest files. I then edited the CSV file to contain a journal with 2 lines, the first line I used an invalid account. I imported this package into dynamics finance. It picked up an error for the invalid line as i'd expect, however the valid line was imported. The end result is a partial journal in dynamics, with one line - this is what I am trying to prevent.
Am I missing something?