2
0
mirror of https://github.com/frappe/books.git synced 2025-01-27 09:08:24 +00:00

incr: update schema builder to accept plugin schema lists

This commit is contained in:
18alantom 2023-07-19 11:46:17 +05:30
parent 45bc8c48fd
commit 511ac9a943

View File

@ -12,9 +12,12 @@ const NAME_FIELD = {
readOnly: true, readOnly: true,
}; };
export function getSchemas(countryCode = '-'): Readonly<SchemaMap> { export function getSchemas(
countryCode = '-',
pluginSchemaList: SchemaStub[] = []
): Readonly<SchemaMap> {
const builtCoreSchemas = getCoreSchemas(); const builtCoreSchemas = getCoreSchemas();
const builtAppSchemas = getAppSchemas(countryCode); const builtAppSchemas = getAppSchemas(countryCode, pluginSchemaList);
let schemaMap = Object.assign({}, builtAppSchemas, builtCoreSchemas); let schemaMap = Object.assign({}, builtAppSchemas, builtCoreSchemas);
schemaMap = addMetaFields(schemaMap); schemaMap = addMetaFields(schemaMap);
@ -137,8 +140,12 @@ function getCoreSchemas(): SchemaMap {
return cleanSchemas(coreSchemaMap); return cleanSchemas(coreSchemaMap);
} }
function getAppSchemas(countryCode: string): SchemaMap { function getAppSchemas(
const appSchemaMap = getMapFromList(cloneDeep(appSchemas), 'name'); countryCode: string,
pluginSchemaList: SchemaStub[]
): SchemaMap {
const schemaList = cloneDeep([appSchemas, pluginSchemaList].flat());
const appSchemaMap = getMapFromList(schemaList, 'name');
const regionalSchemaMap = getRegionalSchemaMap(countryCode); const regionalSchemaMap = getRegionalSchemaMap(countryCode);
const combinedSchemas = getRegionalCombinedSchemas( const combinedSchemas = getRegionalCombinedSchemas(
appSchemaMap, appSchemaMap,