Based on the bug https://issues.folio.org/browse/MODORDERS-368. After fixing it there are two unhandled cases were discovered that need to be clarified.
- create poline with values isPackage=true and instanceId=null (no titles were created)
- update poline with values isPackage=false and instanceId specified (title not exists, so nothing to update. Ignored for now)
- PUT to orders-storage/po-lines will create the title record but we need to make additional calls to get the title UUID of the title record, and then to update the title record with the instanceId.
- Is it planed to add restriction or additional logic for such transitions?
[CAM] I don't think so, but maybe Dennis Bridges disagrees
- Will it be enough to implement "create or update" in this case?
[CAM] Yes, in general, if a title exists update it. If it doesn't exist but should, create one. Remember, one role of the title record is to hold a reference to the instance(s) associated with a poLine. Since we're no longer storing the instanceId as part of poLine directly, We must create a title record if an instance is provided and a title does not already exist, otherwise we lose that information. The instanceId in a title record should be updated if the poLine's instance(s) are updated.
- create poline with values isPackage=false and instanceId=not null (title created with instanceId)
- update poline with values isPackage=true and instanceId=null (title still exists for package poline)
- it makes sense to delete title which points to package poline. Leaving it as is will affect search results at least.
[CAM] Yes, it should be deleted
Take into account that titles are also creating/updating transactionally with associated polines on storage level. https://issues.folio.org/browse/MODORDSTOR-127
- Title records are created/updated/deleted in reaction to updates in PoLine as described above
- API tests are updated
- Unit tests are updated