|
@@ -1,16 +1,22 @@
|
|
|
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'
|
|
|
+import { SET_MOVES, SET_SELECTED_MOVE_LINE, SET_SELECTED_MOVE_PAYMENTS, REMOVE_MOVE_LINE, REMOVE_PAYMENTS_MOVE, SET_TOTAL_MOVE_PAYMENTS } from '@/constants/mutationTypes'
|
|
|
|
|
|
const initialState = {
|
|
|
moves : null,
|
|
|
selectedMoveLine: null,
|
|
|
- movesPayments: []
|
|
|
+ movesPayments: [],
|
|
|
+ movesPaymentsTotal: 0,
|
|
|
+ movesPaymentsBalance: 0,
|
|
|
+ paymentTotal: 0
|
|
|
}
|
|
|
|
|
|
const state = {
|
|
|
moves: initialState.moves,
|
|
|
selectedMoveLine: initialState.selectedMoveLine,
|
|
|
- movesPayments: initialState.movesPayments
|
|
|
+ movesPayments: initialState.movesPayments,
|
|
|
+ movesPaymentsTotal: initialState.movesPaymentsTotal,
|
|
|
+ movesPaymentsBalance: initialState.movesPaymentsBalance,
|
|
|
+ paymentTotal: initialState.paymentTotal
|
|
|
}
|
|
|
|
|
|
const getters = {
|
|
@@ -19,7 +25,7 @@ const getters = {
|
|
|
* @param {[type]} state [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
- moves(state) {
|
|
|
+ moves (state) {
|
|
|
return state.moves
|
|
|
},
|
|
|
/**
|
|
@@ -27,7 +33,7 @@ const getters = {
|
|
|
* @param {[type]} state [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
- selectedMoveLine(state){
|
|
|
+ selectedMoveLine (state){
|
|
|
return state.selectedMoveLine
|
|
|
},
|
|
|
/**
|
|
@@ -35,8 +41,33 @@ const getters = {
|
|
|
* @param {[type]} state [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
- movesPayments(state) {
|
|
|
+ movesPayments (state) {
|
|
|
return state.movesPayments
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [movesPaymentsTotal description]
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
+ movesPaymentsTotal (state) {
|
|
|
+ return state.movesPaymentsTotal
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [movesPaymentsBalance description]
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
+ movesPaymentsBalance (state) {
|
|
|
+ return state.movesPaymentsBalance
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [paymentTotal description]
|
|
|
+ * @method paymentTotal
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
+ paymentTotal (state) {
|
|
|
+ return state.paymentTotal
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -103,6 +134,19 @@ const mutations = {
|
|
|
let movesFoundIndex = state.movesPayments.findIndex(item => item.id === payload.moveLine.id)
|
|
|
state.movesPayments.splice(movesFoundIndex, 1)
|
|
|
}
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [total description]
|
|
|
+ * @type {[type]}
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @param {[type]} payload [description]
|
|
|
+ */
|
|
|
+ [SET_TOTAL_MOVE_PAYMENTS] (state) {
|
|
|
+ let total =0
|
|
|
+ state.movesPayments.forEach(item => {
|
|
|
+ total = total + item.amountResidual
|
|
|
+ })
|
|
|
+ state.movesPaymentsTotal = total
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -125,19 +169,25 @@ const actions = {
|
|
|
commit(SET_SELECTED_MOVE_LINE, payload)
|
|
|
/* Remover Move Line */
|
|
|
commit(REMOVE_MOVE_LINE, payload)
|
|
|
+ commit(SET_TOTAL_MOVE_PAYMENTS)
|
|
|
},
|
|
|
/**
|
|
|
*
|
|
|
+ * @param {*} param0
|
|
|
+ * @param {*} payload
|
|
|
*/
|
|
|
[REMOVE_MOVE_PAYMENTS] ({ commit, dispatch }, payload) {
|
|
|
- commit(REMOVE_PAYMENTS_MOVE, {
|
|
|
+ dispatch(ADD_MOVE_IN_INVOICE, {
|
|
|
moveLine: payload,
|
|
|
mode: 'partial'
|
|
|
})
|
|
|
- dispatch(ADD_MOVE_IN_INVOICE, {
|
|
|
+
|
|
|
+ commit(REMOVE_PAYMENTS_MOVE, {
|
|
|
moveLine: payload,
|
|
|
mode: 'partial'
|
|
|
})
|
|
|
+
|
|
|
+ commit(SET_TOTAL_MOVE_PAYMENTS)
|
|
|
},
|
|
|
/**
|
|
|
* [length description]
|
|
@@ -161,6 +211,8 @@ const actions = {
|
|
|
}),
|
|
|
mode: 'full'
|
|
|
})
|
|
|
+
|
|
|
+ commit(SET_TOTAL_MOVE_PAYMENTS)
|
|
|
}
|
|
|
}
|
|
|
|