Expose reversal information in Journal endpoint
Problem: if a Journal is reversed, Journal.SourceId may point to an invoice whose LineItems do not correspond to JournalLines.
Proposed Solution: If a Journal is a reversal, expose the number of reversed journal via API, e.g.
<Journal>
<IsReversalOf>originalJournalNumber</IsReversalOf>
...
</Journal>
When it is useful: in the simplest scenario, when Invoice's LineItem is edited, the original Journal corresponding to the Invoice is reverted and new one is created. We end up with three Journals: Journal1 and Journal2 cancel each other, Journal3 reflects (the new version of) the invoice. Unfortunately, all three Journals have SourceID pointing to the (now modified) invoice. Consequently, JournalLine of Journal1 and Journal2 that corresponds to the LineItem that has been edited on the invoice, does not correspond to any LineItem on the invoice, so e.g. it cannot be matched with invoice's ItemCode.
With an existing API to determine whether a Journal has been reversed one needs to go back possibly very deep in the sequence of Journals (perhaps it is sufficient to go back to the the current lock date, which still may be a year worth of journals).
-
Gonzalo commented
I think the solution I wrote below would be better:
<Journal>
<IsReversalOf>originalJournalNumber</IsReversalOf>
<IsReversedBy>newlJournalNumber</IsReversedBy>
...
</Journal>