2
0
mirror of https://github.com/frappe/books.git synced 2025-01-26 16:48:28 +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,
};
export function getSchemas(countryCode = '-'): Readonly<SchemaMap> {
export function getSchemas(
countryCode = '-',
pluginSchemaList: SchemaStub[] = []
): Readonly<SchemaMap> {
const builtCoreSchemas = getCoreSchemas();
const builtAppSchemas = getAppSchemas(countryCode);
const builtAppSchemas = getAppSchemas(countryCode, pluginSchemaList);
let schemaMap = Object.assign({}, builtAppSchemas, builtCoreSchemas);
schemaMap = addMetaFields(schemaMap);
@ -137,8 +140,12 @@ function getCoreSchemas(): SchemaMap {
return cleanSchemas(coreSchemaMap);
}
function getAppSchemas(countryCode: string): SchemaMap {
const appSchemaMap = getMapFromList(cloneDeep(appSchemas), 'name');
function getAppSchemas(
countryCode: string,
pluginSchemaList: SchemaStub[]
): SchemaMap {
const schemaList = cloneDeep([appSchemas, pluginSchemaList].flat());
const appSchemaMap = getMapFromList(schemaList, 'name');
const regionalSchemaMap = getRegionalSchemaMap(countryCode);
const combinedSchemas = getRegionalCombinedSchemas(
appSchemaMap,