Skip to content

Commit

Permalink
fix: add inclusive serial number block count
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Mar 13, 2022
1 parent 5e11312 commit dd522c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/models/units/units.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ const virtualFields = {
}

const serialNumberPattern = this.getDataValue('serialNumberPattern');
const [unitBlockStart, unitBlockEnd] = transformSerialNumberBlock(
const [, , unitCount] = transformSerialNumberBlock(
serialNumberBlock,
serialNumberPattern,
);

return Number(unitBlockEnd) - Number(unitBlockStart);
return unitCount;
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const transformSerialNumberBlock = (
return [null, null, null];
}

const blockStart = Number(unitBlocks[1]);
const blockStart = Number(unitBlocks[1]) - 1; // Unit blocks are inclusive bound
const blockEnd = Number(unitBlocks[2]);
return [blockStart, blockEnd, blockEnd - blockStart];
};
Expand Down

0 comments on commit dd522c6

Please sign in to comment.