mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix: Set default index to transaction entries
This commit is contained in:
16
packages/server/src/services/Items/utils.ts
Normal file
16
packages/server/src/services/Items/utils.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { IItemEntry } from '@/interfaces';
|
||||
import { isNull, isUndefined } from 'lodash';
|
||||
|
||||
export function assocItemEntriesDefaultIndex<T>(
|
||||
entries: Array<T & { index?: number }>
|
||||
): Array<T & { index: number }> {
|
||||
return entries.map((entry, index) => {
|
||||
return {
|
||||
index:
|
||||
isUndefined(entry.index) || isNull(entry.index)
|
||||
? index + 1
|
||||
: entry.index,
|
||||
...entry,
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user