2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00
books/backend/patches/addUOMs.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
708 B
TypeScript
Raw Normal View History

2022-07-08 17:51:21 +00:00
import { ModelNameEnum } from '../../models/types';
import { DatabaseManager } from '../database/manager';
import { getDefaultMetaFieldValueMap } from '../helpers';
2022-11-21 07:15:57 +00:00
const defaultUOMs = [
{
name: `Unit`,
isWhole: true,
},
{
name: `Kg`,
isWhole: false,
},
{
name: `Gram`,
isWhole: false,
},
{
name: `Meter`,
isWhole: false,
},
{
name: `Hour`,
isWhole: false,
},
{
name: `Day`,
isWhole: false,
},
];
2022-07-08 17:51:21 +00:00
async function execute(dm: DatabaseManager) {
for (const uom of defaultUOMs) {
const defaults = getDefaultMetaFieldValueMap();
await dm.db?.insert(ModelNameEnum.UOM, { ...uom, ...defaults });
}
}
export default { execute };