Skip to content

Commit

Permalink
fix: allow import if ct not required
Browse files Browse the repository at this point in the history
  • Loading branch information
18alantom committed Sep 4, 2023
1 parent 9558350 commit 62db99b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,16 @@ function getTemplateFields(
];
const fields: TemplateField[] = [];

const targetSchemaFieldMap =
fyo.schemaMap[importer.schemaName]?.fields.reduce((acc, f) => {
if (!(f as TargetField).target) {
return acc;
}

acc[f.fieldname] = f;
return acc;
}, {} as Record<string, Field>) ?? {};

while (schemas.length) {
const { schema, parentSchemaChildField } = schemas.pop() ?? {};
if (!schema) {
Expand Down Expand Up @@ -608,6 +618,14 @@ function getTemplateFields(
tf.required = false;
}

if (
schema.isChild &&
tf.required &&
!targetSchemaFieldMap[tf.schemaName ?? '']?.required
) {
tf.required = false;
}

const schemaName = schema.name;
const schemaLabel = schema.label;
const fieldKey = `${schema.name}.${field.fieldname}`;
Expand Down

0 comments on commit 62db99b

Please sign in to comment.