feat: Inventory item details report.

feat: Cash flow statement report.
This commit is contained in:
a.bouhuolia
2021-05-31 13:17:02 +02:00
parent 256d915f06
commit d47633b8ea
80 changed files with 5474 additions and 376 deletions

View File

@@ -0,0 +1,52 @@
import _ from 'lodash';
import deepdash from 'deepdash';
const {
condense,
condenseDeep,
eachDeep,
exists,
filterDeep,
findDeep,
findPathDeep,
findValueDeep,
forEachDeep,
index,
keysDeep,
mapDeep,
mapKeysDeep,
mapValuesDeep,
omitDeep,
pathMatches,
pathToString,
paths,
pickDeep,
reduceDeep,
someDeep,
iteratee,
} = deepdash(_);
export {
iteratee,
condense,
condenseDeep,
eachDeep,
exists,
filterDeep,
findDeep,
findPathDeep,
findValueDeep,
forEachDeep,
index,
keysDeep,
mapDeep,
mapKeysDeep,
mapValuesDeep,
omitDeep,
pathMatches,
pathToString,
paths,
pickDeep,
reduceDeep,
someDeep,
};

View File

@@ -51,6 +51,30 @@ const dateRangeCollection = (
return collection;
};
const dateRangeFromToCollection = (
fromDate,
toDate,
addType = 'day',
increment = 1
) => {
const collection = [];
const momentFromDate = moment(fromDate);
const dateFormat = 'YYYY-MM-DD';
for (
let i = momentFromDate;
i.isBefore(toDate, addType) || i.isSame(toDate, addType);
i.add(increment, `${addType}s`)
) {
collection.push({
fromDate: i.startOf(addType).format(dateFormat),
toDate: i.endOf(addType).format(dateFormat),
});
}
return collection;
};
const dateRangeFormat = (rangeType) => {
switch (rangeType) {
case 'year':
@@ -329,8 +353,28 @@ var increment = (n) => {
};
};
const transformToMapBy = (collection, key) => {
return new Map(
Object.entries(_.groupBy(collection, key)),
);
}
const transformToMapKeyValue = (collection, key) => {
return new Map(
collection.map((item) => [item[key], item]),
);
};
const accumSum = (data, callback) => {
return data.reduce((acc, _data) => {
const amount = callback(_data);
return acc + amount;
}, 0)
}
export {
accumSum,
increment,
hashPassword,
origin,
@@ -354,4 +398,7 @@ export {
defaultToTransform,
transformToMap,
transactionIncrement,
transformToMapBy,
dateRangeFromToCollection,
transformToMapKeyValue
};