mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat(invoices|receipts|estimates|payments): auto-increment backend logic based.
This commit is contained in:
@@ -289,6 +289,30 @@ const transformToMap = (objects, key) => {
|
||||
|
||||
const transactionIncrement = (s) => s.replace(/([0-8]|\d?9+)?$/, (e) => ++e);
|
||||
|
||||
const booleanValuesRepresentingTrue: string[] = [
|
||||
'true',
|
||||
'1',
|
||||
];
|
||||
const booleanValuesRepresentingFalse: string[] = [
|
||||
'false',
|
||||
'0',
|
||||
];
|
||||
|
||||
const normalizeValue = (value: any): string => value.toString().trim().toLowerCase();
|
||||
|
||||
const booleanValues: string[] = [
|
||||
...booleanValuesRepresentingTrue,
|
||||
...booleanValuesRepresentingFalse,
|
||||
].map((value) => normalizeValue(value));
|
||||
|
||||
export const parseBoolean = <T>(value: any, defaultValue: T): T | boolean => {
|
||||
const normalizedValue = normalizeValue(value);
|
||||
if (booleanValues.indexOf(normalizedValue) === -1) {
|
||||
return defaultValue;
|
||||
}
|
||||
return booleanValuesRepresentingTrue.indexOf(normalizedValue) !== -1;
|
||||
};
|
||||
|
||||
export {
|
||||
hashPassword,
|
||||
origin,
|
||||
Reference in New Issue
Block a user