|
@@ -17,8 +17,24 @@ import {
|
|
|
CHECK_CUSTOMER,
|
|
|
CHECK_INVOICE,
|
|
|
CHECK_MOVE,
|
|
|
- CHECK_PAYMENTS
|
|
|
+ CHECK_PAYMENTS,
|
|
|
+ COMPLETED_PAYMENTS,
|
|
|
+ RESET_PAYMENT_CUSTOMER,
|
|
|
+ RESET_DATE,
|
|
|
+ RESET_USER,
|
|
|
+ RESET_COMPANY,
|
|
|
+ RESET_CUSTOMERS,
|
|
|
+ RESET_INVOICES,
|
|
|
+ RESET_MOVE_LINES,
|
|
|
+ RESET_JOURNALS,
|
|
|
+ RESET_CURRENCY,
|
|
|
+ RESET_PAYMENTS
|
|
|
} from '@/constants/actionTypes'
|
|
|
+// Mutations
|
|
|
+import {
|
|
|
+ SET_PROCESSING_PAYMENTS,
|
|
|
+ SET_COMPLETED_PAYMENTS
|
|
|
+} from '@/constants/mutationTypes'
|
|
|
|
|
|
const actions = {
|
|
|
/**
|
|
@@ -35,6 +51,7 @@ const actions = {
|
|
|
*/
|
|
|
[INIT_PAYMENTS] ({ dispatch }) {
|
|
|
return axios.get(INIT_PAYMENTS_URL).then(response => {
|
|
|
+ dispatch(COMPLETED_PAYMENTS, false)
|
|
|
dispatch('explodeData', response.data)
|
|
|
}).catch(error => {
|
|
|
console.log(error);
|
|
@@ -50,12 +67,43 @@ const actions = {
|
|
|
dispatch(`initPayments${value[0].toUpperCase()}${value.slice(1)}`,payload[value])
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ [CHECK_CUSTOMER] ({ getters, dispatch }) {
|
|
|
+ return !!getters.selectedCustomer ||dispatch(PAYMENTS_NOTIFY,'Necesitas seleccionar un cliente para continuar.')
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ [CHECK_INVOICE] ({ getters, dispatch }) {
|
|
|
+ return !!getters.selectedInvoice ||dispatch(PAYMENTS_NOTIFY, 'Necesitas seleccionar una factura para continuar.')
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ [CHECK_MOVE] ({ getters, dispatch }) {
|
|
|
+ return !!getters.movesPayments.length || dispatch(PAYMENTS_NOTIFY,'Necesitas seleccionar al menos una cuota para continuar.')
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ [CHECK_PAYMENTS] ({ getters, dispatch }) {
|
|
|
+ if (!getters.selectedJournal) {
|
|
|
+ return dispatch(PAYMENTS_NOTIFY, 'Necesitas seleccionar un método de pago')
|
|
|
+ }
|
|
|
+ if (getters.paidTotal <= 0){
|
|
|
+ return dispatch(PAYMENTS_NOTIFY, 'Necesitas ingresar un monto a pagar')
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
/**
|
|
|
* [PAYMENTS_PROCESS]
|
|
|
* @param {*} param0
|
|
|
* @param {*} payload
|
|
|
*/
|
|
|
[PAYMENTS_PROCESS] ({ getters, commit, dispatch }, payload ) {
|
|
|
+ commit(SET_PROCESSING_PAYMENTS, true)
|
|
|
const data = {
|
|
|
jsonrpc: '2.0',
|
|
|
method: 'call',
|
|
@@ -71,31 +119,41 @@ const actions = {
|
|
|
}
|
|
|
|
|
|
return axios.post(PAYMENTS_PROCESS_URL, data).then(response => {
|
|
|
- console.log(response);
|
|
|
+ commit(SET_PROCESSING_PAYMENTS, !response.data.result)
|
|
|
+ dispatch(COMPLETED_PAYMENTS, response.data.result)
|
|
|
}).catch(error => {
|
|
|
console.log(error);
|
|
|
+ commit(SET_PROCESSING_PAYMENTS, false)
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
+ * [COMPLETED_PAYMENTS]
|
|
|
*
|
|
|
*/
|
|
|
- [CHECK_CUSTOMER] ({ getters, dispatch }) {
|
|
|
- return !!getters.selectedCustomer ||dispatch(PAYMENTS_NOTIFY,'Necesitas seleccionar un cliente para continuar.')
|
|
|
- },
|
|
|
- [CHECK_INVOICE] ({ getters, dispatch }) {
|
|
|
- return !!getters.selectedInvoice ||dispatch(PAYMENTS_NOTIFY, 'Necesitas seleccionar una factura para continuar.')
|
|
|
- },
|
|
|
- [CHECK_MOVE] ({ getters, dispatch }) {
|
|
|
- return !!getters.movesPayments.length || dispatch(PAYMENTS_NOTIFY,'Necesitas seleccionar al menos una cuota para continuar.')
|
|
|
+ [COMPLETED_PAYMENTS] ({ commit }, payload) {
|
|
|
+ commit(SET_COMPLETED_PAYMENTS, !!payload)
|
|
|
},
|
|
|
- [CHECK_PAYMENTS] ({ getters, dispatch }) {
|
|
|
- if (!getters.selectedJournal) {
|
|
|
- return dispatch(PAYMENTS_NOTIFY, 'Necesitas seleccionar un método de pago')
|
|
|
- }
|
|
|
- if (getters.paidTotal <= 0){
|
|
|
- return dispatch(PAYMENTS_NOTIFY, 'Necesitas ingresar un monto a pagar')
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ [RESET_PAYMENT_CUSTOMER] ({ rootState, commit, dispatch }){
|
|
|
+ for (let key in rootState) {
|
|
|
+ if (!(rootState[key] instanceof Object)){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ dispatch(`reset${key[0].toUpperCase()}${key.slice(1)}`)
|
|
|
}
|
|
|
- return true
|
|
|
+ // dispatch(RESET_DATE)
|
|
|
+ // dispatch(RESET_USER)
|
|
|
+ // dispatch(RESET_COMPANY)
|
|
|
+ // dispatch(RESET_CUSTOMERS)
|
|
|
+ // dispatch(RESET_INVOICES)
|
|
|
+ // dispatch(RESET_MOVE_LINES)
|
|
|
+ // dispatch(RESET_JOURNALS)
|
|
|
+ // dispatch(RESET_CURRENCY)
|
|
|
+ // dispatch(RESET_PAYMENTS)
|
|
|
+
|
|
|
+ dispatch(INIT_PAYMENTS)
|
|
|
}
|
|
|
}
|
|
|
|