feat(invoices|receipts|estimates|payments): auto-increment backend logic based.

This commit is contained in:
a.bouhuolia
2021-03-07 16:14:59 +02:00
parent c245f4249d
commit 42ce791713
17 changed files with 482 additions and 201 deletions

View File

@@ -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,