fix: Update code generation of Vehicle/User/Company/Load to avoid collisions
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
const { ROOT_PATH, LIB_PATH } = process.env;
|
||||
const { getModel } = require( '../../../lib/Models' );
|
||||
const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
|
||||
const { getPagination, genKey } = require( '../../../lib/Misc.js' );
|
||||
const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler.js' );
|
||||
const Model = getModel('loads');
|
||||
const CompanyModel = getModel('companies');
|
||||
@@ -260,7 +259,7 @@ const postLoad = async(req, res) => {
|
||||
await load.save();
|
||||
|
||||
const id = "" + load._id;
|
||||
const shipment_code = "ETA-" + id.substring( 0 , 6 );
|
||||
const shipment_code = "ETA-" + genKey( 6, id );
|
||||
await Model.findByIdAndUpdate( id , {
|
||||
shipment_code
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user