Delimiter //
/**
 * Author:  armen
 * Created: 24 janv. 2018
 * #8718
 * après tous les traitements sur les montants, les procédure LOADER_ENTRIES_MAP_CALCULATE_BALANCE  
 * et LOADER_ENTRIES_NORMALIZE_MAP_ENTRY_CREATE_OR_UPDATE
 *  => ne s'applique que sur les nouvelles écritures
 */
Drop Procedure If Exists LOADER_ENTRIES_MAP_EMPTY_TRANSACTION_AMOUNTS//
Create Procedure LOADER_ENTRIES_MAP_EMPTY_TRANSACTION_AMOUNTS(
    In batchnum Int
)
Begin
    
    Update
        LOADER_ENTRIES SRC
        Inner Join LOADER_STATUS LST
            On LST.ID_LOADER_STATUS = SRC.LOADER_STATUS_ID_LOADER_STATUS
    Set
        SRC.ENTRIES_DEBIT = SRC.ENTRIES_ENT_DEBIT
		, SRC.ENTRIES_CREDIT = SRC.ENTRIES_ENT_CREDIT
    Where
        LST.LOADER_STATUS_BATCH_NUM = batchnum
		And SRC.ENTRIES_DEBIT Is Null
		And SRC.ENTRIES_CREDIT Is Null
		AND LST.LOADER_STATUS_ERRCOUNT = 0
		-- uniquement pour les écriture en création
		And SRC.ID_ENTRIES_NEW Is Not Null
		And SRC.ID_ENTRIES Is Null
		
    ;

End//
Delimiter ;
