|  | @@ -1,5 +1,5 @@
 | 
	
		
			
				|  |  | -import { SELECT_MOVE_INVOICE, SELECT_MOVE } from '@/constants/actionTypes'
 | 
	
		
			
				|  |  | -import { SET_MOVES, SET_SELECTED_MOVE_LINE, SET_SELECTED_MOVE_PAYMENTS } from '@/constants/mutationTypes'
 | 
	
		
			
				|  |  | +import { SELECT_MOVE_INVOICE, SELECT_MOVE, REMOVE_MOVE_PAYMENTS, ADD_MOVE_IN_INVOICE, REMOVE_MOVE_PAYMENTS_ALL } from '@/constants/actionTypes'
 | 
	
		
			
				|  |  | +import { SET_MOVES, SET_SELECTED_MOVE_LINE, SET_SELECTED_MOVE_PAYMENTS, REMOVE_MOVE_LINE, REMOVE_PAYMENTS_MOVE } from '@/constants/mutationTypes'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const initialState = {
 | 
	
		
			
				|  |  |      moves : null,
 | 
	
	
		
			
				|  | @@ -67,6 +67,42 @@ const mutations = {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      [SET_SELECTED_MOVE_PAYMENTS] (state, payload) {
 | 
	
		
			
				|  |  |          state.movesPayments = [payload, ...state.movesPayments]
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * [actions description]
 | 
	
		
			
				|  |  | +     * @type {Object}
 | 
	
		
			
				|  |  | +     * @param  {[type]} state [description]
 | 
	
		
			
				|  |  | +     * @param  {[type]} payload [description]
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    [REMOVE_MOVE_LINE] (state, payload) {
 | 
	
		
			
				|  |  | +        let moveFoundIndex = state.moves.findIndex(item => item.id === payload.id)
 | 
	
		
			
				|  |  | +        state.moves.splice(moveFoundIndex, 1)
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * [actions description]
 | 
	
		
			
				|  |  | +     * @type {Object}
 | 
	
		
			
				|  |  | +     * @param  {[type]} state [description]
 | 
	
		
			
				|  |  | +     * @param  {[type]} payload [description]
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    [REMOVE_PAYMENTS_MOVE]( state, payload) {
 | 
	
		
			
				|  |  | +        if (payload.mode ==='full') {
 | 
	
		
			
				|  |  | +            payload.moveLine.forEach(moves => {
 | 
	
		
			
				|  |  | +                let movesFoundIndex = state.moves.find(item => item.id === moves.id)
 | 
	
		
			
				|  |  | +                if (movesFoundIndex) return
 | 
	
		
			
				|  |  | +                /*ADD MOVE LINE*/
 | 
	
		
			
				|  |  | +                state.moves = [moves, ...state.moves]
 | 
	
		
			
				|  |  | +                /* REMOVE MOVE CARD*/
 | 
	
		
			
				|  |  | +                let movesPaymentsFoundIndex = state.movesPayments.findIndex(item => item.id === moves.id)
 | 
	
		
			
				|  |  | +                state.movesPayments.splice(movesPaymentsFoundIndex, 1)
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            let movesFound = state.moves.find(item => item.id === payload.moveLine.id)
 | 
	
		
			
				|  |  | +            if (movesFound) return
 | 
	
		
			
				|  |  | +            state.moves = [payload.moveLine, ...state.moves]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            let movesFoundIndex = state.movesPayments.findIndex(item => item.id === payload.moveLine.id)
 | 
	
		
			
				|  |  | +            state.movesPayments.splice(movesFoundIndex, 1)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -87,6 +123,44 @@ const actions = {
 | 
	
		
			
				|  |  |      [SELECT_MOVE] ({ commit }, payload) {
 | 
	
		
			
				|  |  |          commit(SET_SELECTED_MOVE_PAYMENTS, payload)
 | 
	
		
			
				|  |  |          commit(SET_SELECTED_MOVE_LINE, payload)
 | 
	
		
			
				|  |  | +        /* Remover Move Line */
 | 
	
		
			
				|  |  | +        commit(REMOVE_MOVE_LINE, payload)
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    [REMOVE_MOVE_PAYMENTS] ({ commit, dispatch }, payload) {
 | 
	
		
			
				|  |  | +        commit(REMOVE_PAYMENTS_MOVE, {
 | 
	
		
			
				|  |  | +            moveLine: payload,
 | 
	
		
			
				|  |  | +            mode: 'partial'
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        dispatch(ADD_MOVE_IN_INVOICE, {
 | 
	
		
			
				|  |  | +            moveLine: payload,
 | 
	
		
			
				|  |  | +            mode: 'partial'
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * [length description]
 | 
	
		
			
				|  |  | +     * @type {[type]}
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    [REMOVE_MOVE_PAYMENTS_ALL] ({commit, dispatch, state}, payload) {
 | 
	
		
			
				|  |  | +        if (!payload) return
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (state.movesPayments.length === 0 ) return
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        dispatch(ADD_MOVE_IN_INVOICE,{
 | 
	
		
			
				|  |  | +            moveLine: state.movesPayments.map(item => {
 | 
	
		
			
				|  |  | +                return item
 | 
	
		
			
				|  |  | +            }),
 | 
	
		
			
				|  |  | +            mode: 'full'
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        commit(REMOVE_PAYMENTS_MOVE, {
 | 
	
		
			
				|  |  | +            moveLine: state.movesPayments.map(item => {
 | 
	
		
			
				|  |  | +                return item
 | 
	
		
			
				|  |  | +            }),
 | 
	
		
			
				|  |  | +            mode: 'full'
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |