Check digit logic in CRN for aramax
1. Objective (Problems and Goals)
UI to add CRN series and option to add check digit logic there and delete the series
save the check digit logic and whenever fetched during consignment creation need to use that logic
2. Initiation
Title | Check digit logic in CRN |
Author(s) | Titunath |
Team (POD) | Brahmos |
Reviewer(s) | Suraj |
Last Updated On | 8-8-24 |
Epic, ticket, issue, or LPP reference link |
3. Solution
while fetching the virtual CRN we will add the suffix using check digit logic
1. Frontend to be made.
2.Same api will be called which is used for reference number and series type would. be added to that
3.2 Approach and Components
Approach:
while fetching the CRN through this function
fetchAndCommitValidSeries
we will add the suffix ( Using check digit logic if required ) in the fetched number and return it.Current Logic
const { prefix, length, end, start, numberOfUsed } = result; const digits = length - (prefix || '').length; virtualNumber = prefix + this.padDigits(digits, result.numberOfUsed + result.start)+ newSuffix; if (seriesType === 'CUSTOMER_REFERENCE_NUMBER') { params.prefilledCustomerReferenceNumber = virtualNumber; const response = await this.checkConsignmentInProjectx(clientId, organisationId, params); if (end - start + 1 === numberOfUsed + 1) { await this.setExhausted(result._id); } if (response?.isConsignmentFound) { continue; // consignment with virtual generated cust ref no. already exist so continue generate again next } else { break; // virtual generated number is new so break and return } } else { break; // for series type != CUSTOMER_REFERENCE_NUMBER }
In the current logic we append the prefix and pad digits in the number combine them and assign the virtual number
Here , now we will check if the enableCheckDigitCalculation key is on then ,
we will append a suffix which will be created through the logic checkDigitLogic-
const { prefix, length, end, start, numberOfUsed, enableCheckDigitCalculation, checkDigitLogic } = result;
After fetching these info from the mongo collection we will write a function to create a suffix
const createCheckDigitSuffix = (..) => { .... return suffix; }
This will be appended with the crn and then it will be checked in the projectx whether consignment is already created with the same customer reference number before then increment the counter otherwise return this number as done in the old flow .
It will be backward compatible also for the customers already using the crn before this dev - through this key (enableCheckDigitCalculation) we will maintain the backward compatability here and will nt hamper the already running flows.
2. In this file/DTDCVirtualSeriesStrategy.ts
we will add logic to saveenableCheckDigitCalculation
, checkDigitLogic in db for customer reference number.
3. Make a UI in CRM to take the start , end and check digit logic .
Database Migration and Index Changes:
Org Config:
Code Writing Style:
API Documentation:
Endpoint:
Method:
Fields/Payload:
Response:
Logic:
Assumptions:
3.2 Dev Test Cases
Function/Feature | Scenario | Expected Outcome |
---|---|---|
|
|
|
|
|
|