diff --git a/src/controllers/units.controller.js b/src/controllers/units.controller.js index e3d056eb..718986a9 100644 --- a/src/controllers/units.controller.js +++ b/src/controllers/units.controller.js @@ -82,6 +82,8 @@ export const create = async (req, res) => { if (newRecord.issuance.id) { // if we are reusing a record, make sure it exists await assertRecordExistance(Issuance, newRecord.issuance.id); + newRecord.issuanceId = newRecord.issuance.id; + delete newRecord.issuance; } else { newRecord.issuance.id = uuidv4(); newRecord.issuance.orgUid = orgUid; diff --git a/src/utils/data-assertions.js b/src/utils/data-assertions.js index 135e3e00..1b61f7ea 100644 --- a/src/utils/data-assertions.js +++ b/src/utils/data-assertions.js @@ -69,6 +69,8 @@ export const assertRecordExistance = async (Model, pk) => { if (!record) { throw new Error(`${Model.name} does not have a record for ${pk}`); } + + return record; }; export const assertHomeOrgExists = async () => {