diff --git a/src/models/units/units.model.js b/src/models/units/units.model.js index 1d762351..acd3f0d2 100644 --- a/src/models/units/units.model.js +++ b/src/models/units/units.model.js @@ -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; }, }, }; diff --git a/src/utils/helpers.js b/src/utils/helpers.js index a1121e15..48a24bc1 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -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]; };