Skip to content

Commit

Permalink
fix: issuances dont get overwritten when using existing issuance
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Mar 13, 2022
1 parent a1e2919 commit 185a56e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/controllers/units.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/data-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 185a56e

Please sign in to comment.