2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 20:18:26 +00:00

feat: update number series with references

This commit is contained in:
18alantom 2022-03-08 12:16:18 +05:30
parent c9631c27a6
commit 454a2f5a95
4 changed files with 38 additions and 16 deletions

View File

@ -0,0 +1,16 @@
import { invertMap } from '@/utils';
import frappe from 'frappe';
import { DEFAULT_NUMBER_SERIES } from 'frappe/utils/consts';
async function setReferencesOnNumberSeries() {
const map = invertMap(DEFAULT_NUMBER_SERIES);
const rows = await frappe.db.knex('NumberSeries');
for (const row of rows) {
row.referenceType = map[row.name];
}
await frappe.db.prestigeTheTable('NumberSeries', rows);
}
export default async function execute() {
await setReferencesOnNumberSeries();
}

View File

@ -8,5 +8,10 @@
"version": "0.0.4", "version": "0.0.4",
"fileName": "convertCurrencyToStrings", "fileName": "convertCurrencyToStrings",
"beforeMigrate": true "beforeMigrate": true
},
{
"version": "0.3.2",
"fileName": "moveNumberSeriesFromSettings",
"beforeMigrate": false
} }
] ]

View File

@ -536,3 +536,14 @@ export function getCOAList() {
} }
return frappe.temp.coaList; return frappe.temp.coaList;
} }
export function invertMap(map) {
const keys = Object.keys(map);
const inverted = {};
for (const key of keys) {
const val = map[key];
inverted[val] = key;
}
return inverted;
}

View File

@ -12,20 +12,11 @@
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"types": [ "types": ["webpack-env"],
"webpack-env"
],
"paths": { "paths": {
"@/*": [ "@/*": ["src/*"]
"src/*"
]
}, },
"lib": [ "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}, },
"include": [ "include": [
"src/**/*.ts", "src/**/*.ts",
@ -38,11 +29,10 @@
"frappe/**/*.ts", "frappe/**/*.ts",
"models/**/*.ts", "models/**/*.ts",
"patches/**/*.ts", "patches/**/*.ts",
"patches/**/*.js",
"reports/**/*.ts", "reports/**/*.ts",
"accounting/**/*.ts", "accounting/**/*.ts",
"accounting/**/*.ts", "accounting/**/*.ts"
], ],
"exclude": [ "exclude": ["node_modules"]
"node_modules"
]
} }