This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates a SHA-256 hash for a string. | |
* In case of an exception, it will return the original string value back | |
* | |
* @param hashable - the string to be hashed | |
* @return - the hashed string/ the original string in case of an exception | |
*/ | |
String generateHashValue(String hashable) { | |
MessageDigest digest; | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Will return an object which contains all the elements from the `items` array grouped according to the `key` field | |
* Eg. items = [{name: "ABC", age:2},{name: "DEF", age:2},{name: "GHI", age:2},{name: "JKL", age:3},{name: "MNO", age:3}] | |
* key = "age" | |
* result = {2: [{name: "ABC", age:2},{name: "DEF", age:2},{name: "GHI", age:2}], 3: [{name: "JKL", age:3},{name: "MNO", age:3}]} | |
* @param {Array} items - array of items that needs to be grouped | |
* @param {String} key - key in the object inside the items array for which the grouping is to be performed | |
* @returns {*} - resulting object with grouped elements | |
*/ | |
const groupBy = (items, key) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getLastFourQuarters = (date = moment()) => { | |
const momentObject = moment(date); | |
const quarters = {}; | |
for (let i = 0; i <= 3; i++) { | |
const quarterDate = momentObject.clone().subtract(i * 3, 'month'); | |
const number = quarterDate.quarter(); | |
const year = quarterDate.year(); | |
quarters['Q' + number + ' ' + year] = quarterDate.startOf('quarter'); | |
} | |
return quarters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getFiscalYearToDate = () => { | |
const thisYearMarch = moment().month('March').startOf('month'); | |
if (moment().isAfter(, 'day')){ | |
// new fiscal year has started | |
return { | |
startDate : thisYearMarch.clone(), | |
endDate: moment() | |
} | |
} else { | |
// take the last fiscal year |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eu Basque | |
hr_BA Croatian (Bosnia & Herzegovina) | |
en_CM English (Cameroon) | |
en_BI English (Burundi) | |
rw_RW Kinyarwanda (Rwanda) | |
ast Asturian | |
en_SZ English (Swaziland) | |
he_IL Hebrew (Israel) | |
ar Arabic | |
uz_Arab Uzbek (Arabic) |