in src/app/accounting/store/cheques/cheques.reducer.ts [39:87]
export function reducer(state = initialState, action: Actions<FimsCheque> | cheque.Actions): ResourceState {
switch (action.type) {
case cheque.ChequeCRUDActions.LOAD_ALL: {
return initialState;
}
case cheque.ChequeCRUDActions.LOAD_ALL_COMPLETE: {
const ranges: FimsCheque[] = action.payload.resources;
const ids = ranges.map(chargeDefinition => chargeDefinition.identifier);
const entities = resourcesToHash(ranges);
const loadedAt = idsToHashWithCurrentTimestamp(ids);
return {
ids: [ ...ids ],
entities: entities,
loadedAt: loadedAt,
selectedId: state.selectedId
};
}
case cheque.PROCESS_SUCCESS: {
const chequeIdentifier = action.payload.chequeIdentifier;
const command: ChequeProcessingCommand = action.payload.command;
const cheque = state.entities[chequeIdentifier];
if (command.action === 'APPROVE') {
cheque.state = 'PROCESSED';
} else {
cheque.state = 'CANCELED';
}
return Object.assign({}, state, {
entities: Object.assign({}, state.entities, {
[cheque.identifier]: cheque
}),
});
}
default: {
return state;
}
}
}