Preserve legacy draft shape when no compatible context is inherited
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -57,6 +57,8 @@ export function inheritSimulatorFields<T extends Record<string,unknown>>(draft:T
|
||||
if(/^\d{4}-\d{2}-\d{2}$/.test(start)) source.monthly_iva_start=start.slice(0,7);
|
||||
else if(/^\d{4}$/.test(String(draft.fiscal_period)) && draft.fiscal_periodicity==='monthly' && /^(0?[1-9]|1[0-2])$/.test(String(draft.fiscal_month))) source.monthly_iva_start=`${draft.fiscal_period}-${String(draft.fiscal_month).padStart(2,'0')}`;
|
||||
if(!settingsValid) delete source.monthly_iva_start;
|
||||
// Legacy drafts without a compatible source need no inheritance marker or autosave churn.
|
||||
if (!Object.keys(source).length && !draft.compatible_fields_snapshot) return draft;
|
||||
const values={...draft,monthly_iva_start:settings.start ?? ''};
|
||||
const patch=inheritCompatibleFields('simulator-compatible-fields',values,source,draft.compatible_fields_snapshot);
|
||||
const next:Record<string,unknown>={...draft,...patch.patch,compatible_fields_snapshot:patch.metadata};
|
||||
|
||||
Reference in New Issue
Block a user