Delimiter //
/**
 * Accounts ref data normalization
 * 
 */

Drop Procedure If Exists LOADER_SUMMARIES_NORMALIZE//
Create Procedure LOADER_SUMMARIES_NORMALIZE (
    In batchnum Int
)
MAIN_SUMMARIES_NORMALIZE: Begin
    -- Mandatory checks
	call LOADER_SUMMARIES_NORMALIZE_ACCOUNT_REF_NOT_NULL(batchnum);
	call LOADER_SUMMARIES_NORMALIZE_DF_SUMM_CODE_NOT_NULL(batchnum);

	-- Mapping and linking
    Call LOADER_SUMMARIES_NORMALIZE_MAP_ACCOUNTS(batchnum);
    Call LOADER_SUMMARIES_NORMALIZE_MAP_ENTRIES(batchnum);
	Call LOADER_SUMMARIES_NORMALIZE_MAP_DF_SUMM_CODE(batchnum);
	Call LOADER_SUMMARIES_NORMALIZE_MAP_ALLOWED_UPDATE_CHECK(batchnum); --  doit être appelé après LOADER_SUMMARIES_NORMALIZE_MAP_DF_SUMM_CODE
	Call LOADER_SUMMARIES_NORMALIZE_MAP_CREATE_OR_UPDATE(batchnum); --  doit être appelé après LOADER_SUMMARIES_NORMALIZE_MAP_ALLOWED_UPDATE_CHECK
End//
Delimiter ;