Change date format

/** * @description To format the Date Object into the given type/format * @param {Date} dateObj * @param {String} type * @returns {boolean|String} */ function formatDate(dateObj, type) { let dateAsKeys = splitDate(dateObj); if (dateAsKeys) switch (type) { case ‘MM/DD/YYYY’: ; case ‘M/D/YYYY’: return dateLogic.changeDateFormat(dateAsKeys, type, ‘/’); case ‘D/M/YYYY’: ; case ‘DD/MM/YYYY’: return changeDateFormat(dateAsKeys, type, ‘/’);… Continue reading Change date format

Generate date object with the given date

/** * To generate Date Object with the given data * @param {[Number,Number,Number]} dataArray * @returns {Date} */ function generateDate(dataArray) { if (dateLogic.checkDateFormat(dataArray)) return new Date(Number(dataArray[0]), Math.abs(Number(dataArray[1]) – 1) % 12, dataArray[2]); return new Date(‘false’); } /** * @description To check whether the given date is in format of [Number,Number,Number]. ie, [YYYY,MM,DD] * @param {dateArray}… Continue reading Generate date object with the given date

Convert Array to CSV

/** * Converts a value to a string appropriate for entry into a CSV table. E.g., a string value will be surrounded by quotes. * @param {string|number|object} theValue * @param {string} sDelimiter The string delimiter. Defaults to a double quote (“) if omitted. */function toCsvValue(theValue, sDelimiter) { try { var t = typeof (theValue), output;… Continue reading Convert Array to CSV

Divide Array to Chunks

/** * Dividing into array of arrays. * @param array Array to be divided * @param size length of trimmed array * */ function chunkArray(array, size) { try { let result = [] for (let i = 0; i < array.length; i += size) { let chunk = array.slice(i, i + size) result.push(chunk) } log.debug(‘result’,… Continue reading Divide Array to Chunks

Item search for getting available Bins for an item

/** *@description Available bin search – This function will return object of bin name and their quantity * @param itemName Name of the item * @return {Object} */function availableBinSearch(itemName) { try { var itemSearchObj = search.create({ type: “item”, filters: [ [“name”, “is”, itemName.toString()], “AND”, [“inventorydetail.binnumber”, “noneof”, “@NONE@”], “AND”, [“binonhand.quantityavailable”, “greaterthan”, “0”] ], columns: [ search.createColumn({… Continue reading Item search for getting available Bins for an item