adrielso 7 лет назад
Родитель
Сommit
08ee9f79f9

+ 18 - 13
src/Payments.vue

@@ -1,6 +1,6 @@
 <template lang="pug">
 	.payments
-		form-wizard(title="" subtitle="" finishButtonText="Finalizar" color="#7c7bad" backButtonText="Volver" nextButtonText="Continuar" transition="fade" @on-complete="paymentProcess()" @on-change="(prev, next) => removeMovePaymentsAll(prev > next && next < 2)")
+		form-wizard(title="" subtitle="" finishButtonText="Finalizar" color="#7c7bad" backButtonText="Volver" :hideButtons='processingPayments' nextButtonText="Continuar" transition="fade" @on-complete="paymentProcess()" ref='wizard' @on-change="(prev, next) => removeMovePaymentsAll(prev > next && next < 2)")
 			tab-content(title="Quien es el cliente?" :beforeChange="checkCustomer")
 				customers
 			tab-content(title="Cual es la factura?" :beforeChange="checkInvoice")
@@ -12,15 +12,15 @@
 </template>
 
 <script>
-
-	import { mapActions } from 'vuex'
+	import { mapActions, mapGetters } from 'vuex'
 	import {
 		REMOVE_MOVE_PAYMENTS_ALL,
 		PAYMENTS_PROCESS,
 		CHECK_CUSTOMER,
 		CHECK_INVOICE,
 		CHECK_MOVE,
-		CHECK_PAYMENTS
+		CHECK_PAYMENTS,
+		RESET_PAYMENT_CUSTOMER
 	} from '@/constants/actionTypes'
 
 	import { FormWizard, TabContent } from 'vue-form-wizard'
@@ -40,7 +40,10 @@
 			MoveLine,
 			Payments
 		},
-
+		computed: mapGetters([
+			'processingPayments',
+			'completedPayments'
+		]),
 		methods: mapActions([
 			'initPayments',
 			REMOVE_MOVE_PAYMENTS_ALL,
@@ -48,15 +51,17 @@
 			CHECK_CUSTOMER,
 			CHECK_INVOICE,
 			CHECK_MOVE,
-			CHECK_PAYMENTS
-			// 'notify',
-			// 'completePayment',
-			// 'removeLineAll',
-			// 'checkMoveLine',
-			// 'chekPaymentAmount',
-			// 'checkPartner',
-			// 'checkInvoice'
+			CHECK_PAYMENTS,
+			RESET_PAYMENT_CUSTOMER
 		]),
+		watch: {
+			completedPayments(value) {
+				if (value ){
+					this.$refs.wizard.changeTab(3, 0, false)
+					this.resetPaymentCustomer()
+				}
+			}
+		},
 		mounted() {
 			this.initPayments()
 		}

+ 3 - 4
src/components/filters/dateFormat.js

@@ -1,12 +1,11 @@
 /**
  * [dateFormat description]
  * @type {[type]}
- *
- *
  */
 const dateFormat = (date) => {
-    date = date.toString()
-    
+    if (!date)
+        return
+    // date = date.toString()
     date = date.replace(/(\d{4})([/\-])(\d{2})[/\-](\d{2})/,'$4$2$3$2$1')
     return date
 }

+ 1 - 1
src/components/froms/CustomerDetails.vue

@@ -6,7 +6,7 @@
                 hr
             .form-item-payments
                 label.form-label Nombre
-                input.form-input(:value="customer.name || ''" readonly)
+                //- input.form-input(:value="customer.name || ''" readonly)
             .form-item-payments
                 label.form-label R.U.C/C.I.Nº
                 input.form-input(:value="customer.ruc || ''" readonly)

+ 25 - 1
src/components/steps/MethodPayment.vue

@@ -1,6 +1,9 @@
 <template lang="pug">
     .payments-step
-        //- .method-payment-step
+        .from-loading-payments(v-show='processingPayments')
+            .form-overlay-payments
+            .form-spinner-payments
+                spinner(type='wave')
         ticket(v-if="!!selectedMoveLine" :items="movesPayments" :customer='selectedCustomer' :invoice='selectedInvoice' :paymentBalance='paymentsResidual' :paymentTotal='paidTotal' :totalPayments='movesPaymentsTotal' :currencyCompany='currencyCompany')
         form.method-payment
             .method-form-separator
@@ -30,11 +33,14 @@
 <script>
     import { mapGetters, mapActions } from 'vuex'
     import Ticket from '@@/payments/VoucherTicket'
+    // import Spinner from '@/components/common/Spinner'
+    import Spinner from '@@/common/Spinner'
     import { SELECT_JOURNAL, CHANGE_INITIAL_PAID }from '@/constants/actionTypes'
 
     export default {
         components: {
             Ticket,
+            Spinner
         },
         computed:{
             paymentJournals: {
@@ -71,6 +77,7 @@
                 'paidTotal',
                 'paymentsReturned',
                 'paymentsResidual',
+                'processingPayments'
             ]),
         },
         methods: {
@@ -99,6 +106,7 @@
         height: calc(100% - 50px)
         padding-bottom: 50px
         display: flex
+        // position: relative
         .method-payment
             width: calc(100% - 450px)
             height: 100%
@@ -126,4 +134,20 @@
                     border-radius: 0
                 .method-form-input-number
                     text-align: right
+        .from-loading-payments
+            width: 90%
+            height: 90%
+            position: absolute
+            .form-overlay-payments
+                width: 100%
+                height: 100%
+                background: $app-bg-color
+                opacity: 0.5
+                position: absolute
+            .form-spinner-payments
+                width: 100%
+                height: 100%
+                display: flex
+                justify-content: center
+                align-items: center
 </style>

+ 21 - 3
src/constants/actionTypes.js

@@ -1,7 +1,10 @@
 const PAYMENTS_NOTIFY = 'paymentsNotify'
 const INIT_PAYMENTS = 'initPayments'
 const EXPLODE_DATA = 'explodeData'
+//Processar Pagos
 const PAYMENTS_PROCESS = 'paymentProcess'
+const COMPLETED_PAYMENTS = 'completedPayments'
+const RESET_PAYMENT_CUSTOMER = 'resetPaymentCustomer'
 /**
  * [DATE]
  */
@@ -28,6 +31,7 @@ const SELECT_MOVE_INVOICE = 'selectMoveInvoice'
 const SELECT_MOVE = 'selectMove'
 const REMOVE_MOVE_PAYMENTS = 'removeMovePayments'
 const REMOVE_MOVE_PAYMENTS_ALL = 'removeMovePaymentsAll'
+const SET_MOVE_PAYMENTS = 'setMovePayments'
 /**
  * [JOURNALS]
  */
@@ -45,14 +49,28 @@ const INIT_PAYMENTS_CURRENCIES = 'initPaymentsCurrencies'
  const CHECK_INVOICE = 'checkInvoice'
  const CHECK_MOVE = 'checkMove'
  const CHECK_PAYMENTS = 'checkPayments'
+ /**
+  * Reset
+  */
+const RESET_DATE = 'resetDate'
+const RESET_USER = 'resetUser'
+const RESET_COMPANY = 'resetCompany'
+const RESET_CUSTOMERS = 'resetCustomers'
+const RESET_INVOICES = 'resetInvoices'
+const RESET_MOVE_LINES = 'resetMoveLines'
+const RESET_JOURNALS = 'resetJournals'
+const RESET_CURRENCY = 'resetCurrency'
+const RESET_PAYMENTS = 'resetPayments'
+
 export {
-    PAYMENTS_NOTIFY, INIT_PAYMENTS, EXPLODE_DATA, PAYMENTS_PROCESS, //initial
+    PAYMENTS_NOTIFY, INIT_PAYMENTS, EXPLODE_DATA, PAYMENTS_PROCESS, COMPLETED_PAYMENTS, //initial
     INIT_PAYMENTS_DATE, //date
     INIT_PAYMENTS_USER, INIT_PAYMENTS_COMPANY, //user
     INIT_PAYMENTS_CUSTOMERS, SELECT_PAYMENTS_CUSTOMER, FILTER_PAYMENTS_CUSTOMERS, //customer
     SELECT_CUSTOMER_INVOICES, SELECT_INVOICE, ADD_MOVE_IN_INVOICE,FILTER_PAYMENTS_INVOICE, //Customer -invoice
-    SELECT_MOVE_INVOICE, SELECT_MOVE,REMOVE_MOVE_PAYMENTS, REMOVE_MOVE_PAYMENTS_ALL, //Customer -Move
+    SELECT_MOVE_INVOICE, SELECT_MOVE,REMOVE_MOVE_PAYMENTS, REMOVE_MOVE_PAYMENTS_ALL, SET_MOVE_PAYMENTS, //Customer -Move
     INIT_PAYMENTS_JOURNALS, SELECT_JOURNAL, CHANGE_INITIAL_PAID,//Journal
     INIT_PAYMENTS_CURRENCIES, //currency
-    CHECK_CUSTOMER, CHECK_INVOICE, CHECK_MOVE, CHECK_PAYMENTS //Check
+    CHECK_CUSTOMER, CHECK_INVOICE, CHECK_MOVE, CHECK_PAYMENTS, //Check
+    RESET_PAYMENT_CUSTOMER, RESET_DATE, RESET_USER, RESET_COMPANY, RESET_CUSTOMERS, RESET_INVOICES, RESET_MOVE_LINES, RESET_JOURNALS, RESET_CURRENCY, RESET_PAYMENTS //RESET STATE
 }

+ 22 - 2
src/constants/mutationTypes.js

@@ -4,6 +4,12 @@
  */
 const SET_DATE = 'setDate'
 const SET_LOADING_DATE = 'setLoadingDate'
+/**
+ * [SET_PROCESSING_PAYMENTS description]
+ * @type {String}
+ */
+const SET_PROCESSING_PAYMENTS ='setProcessingPayments'
+const SET_COMPLETED_PAYMENTS = 'setCompletedPayments'
 /**
  * [USER]
  * @type {String}
@@ -50,13 +56,27 @@ const SET_PAID_TOTAL = 'setPaidTotal'
  */
 const SET_CURRENCIES = 'setCurrencies'
 const SET_LOADING_CURRENCIES = 'setLoadingCurrencies'
-
+/**
+ * Reset
+ */
+/*const SET_RESET_DATE = 'setResetDate'
+const SET_RESET_USER = 'setResetUser'
+const SET_RESET_COMPANY = 'setResetCompany'
+const SET_RESET_CUSTOMERS = 'setResetCustomers'
+const SET_RESET_INVOICES = 'setResetInvoices'
+const SET_RESET_MOVE_LINES = 'setResetMoveLines'
+const SET_RESET_JOURNALS = 'setResetJournals'
+const SET_RESET_CURRENCY = 'setResetCurrency'
+const SET_RESET_PAYMENTS = 'setResetPayments'
+*/
 export {
+    SET_PROCESSING_PAYMENTS, SET_COMPLETED_PAYMENTS,
     SET_DATE, SET_LOADING_DATE, //Date
     SET_USER, SET_LOADING_USER, SET_SELECTED_COMPANY, SET_SELECTED_CURRENCY_COMPANY, //User
     SET_CUSTOMERS, SET_LOADING_CUSTOMERS, SET_SELECTED_CUSTOMER, SET_FILTER_PAYMENTS_CUSTOMERS, //customer
     SET_INVOICES, SET_SELECTED_INVOICE, SET_SELECTED_CURRENCY_INVOICE, SET_MOVE_IN_INVOICE,SET_FILTER_PAYMENTS_INVOICE, //customer - invoice
     SET_MOVES, SET_SELECTED_MOVE_LINE, SET_SELECTED_MOVE_PAYMENTS, REMOVE_MOVE_LINE, REMOVE_PAYMENTS_MOVE, SET_TOTAL_MOVE_PAYMENTS,SET_ORDER_MOVE_LINE ,SET_ORDER_PAYMENTS_MOVE, //customer -Move
     SET_JOURNALS, SET_LOADING_JOURNALS, SET_SELECTED_JOURNAL, SET_PAID_TOTAL,//Journal
-    SET_CURRENCIES, SET_LOADING_CURRENCIES //Currency
+    SET_CURRENCIES, SET_LOADING_CURRENCIES//Currency
+//    SET_RESET_DATE, SET_RESET_USER, SET_RESET_COMPANY, SET_RESET_CUSTOMERS, SET_RESET_INVOICES, SET_RESET_MOVE_LINES, SET_RESET_JOURNALS, SET_RESET_CURRENCY, SET_RESET_PAYMENTS //RESET
 }

+ 75 - 17
src/store/actions.js

@@ -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)
     }
 }
 

+ 22 - 0
src/store/getters.js

@@ -0,0 +1,22 @@
+const getters = {
+    /**
+     * [processingPayments description]
+     * @method processingPayments
+     * @param  {[type]}           state [description]
+     * @return {[type]}                 [description]
+     */
+    processingPayments (state) {
+        return state.processingPayments
+    },
+    /**
+     * [completedPayments description]
+     * @method completedPayments
+     * @param  {[type]}          state [description]
+     * @return {[type]}                [description]
+     */
+    completedPayments (state) {
+        return state.completedPayments
+    }
+}
+
+export default getters

+ 7 - 0
src/store/index.js

@@ -2,6 +2,10 @@ import Vue from 'vue'
 import Vuex from 'vuex'
 
 import actions from '@/store/actions'
+import getters from '@/store/getters'
+import mutations from '@/store/mutations'
+import state from '@/store/state'
+
 /* date*/
 import date from '@/store/modules/date'
 /* user - company*/
@@ -22,6 +26,9 @@ import payments  from '@/store/modules/payments'
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
+    state,
+    getters,
+    mutations,
     actions,
     modules: {
         date,

+ 11 - 1
src/store/modules/company.js

@@ -1,4 +1,4 @@
-import { INIT_PAYMENTS_COMPANY } from '@/constants/actionTypes'
+import { INIT_PAYMENTS_COMPANY, RESET_COMPANY } from '@/constants/actionTypes'
 import { SET_SELECTED_COMPANY, SET_SELECTED_CURRENCY_COMPANY } from '@/constants/mutationTypes'
 
 const initialState = {
@@ -49,9 +49,19 @@ const mutations = {
     }
 }
 const actions = {
+    /**
+     *
+     */
     [INIT_PAYMENTS_COMPANY] ({commit}, payload) {
         commit(SET_SELECTED_COMPANY,payload.company)
         commit(SET_SELECTED_CURRENCY_COMPANY, payload.currency)
+    },
+    /**
+     *
+     */
+    [RESET_COMPANY] ({ commit}) {
+        commit(SET_SELECTED_COMPANY, [])
+        commit(SET_SELECTED_CURRENCY_COMPANY, [])
     }
 }
 

+ 5 - 2
src/store/modules/currency.js

@@ -1,8 +1,8 @@
-import { INIT_PAYMENTS_CURRENCIES } from '@/constants/actionTypes'
+import { INIT_PAYMENTS_CURRENCIES, RESET_CURRENCY } from '@/constants/actionTypes'
 import { SET_CURRENCIES, SET_LOADING_CURRENCIES } from '@/constants/mutationTypes'
 
 const initialState = {
-    currency: null,
+    currency: [],
     loadingCurrency: false
 }
 
@@ -59,6 +59,9 @@ const actions = {
     [INIT_PAYMENTS_CURRENCIES] ({commit}, payload) {
         commit(SET_CURRENCIES, payload)
         commit(SET_LOADING_CURRENCIES, payload)
+    },
+    [RESET_CURRENCY] ({ commit }) {
+        commit(SET_CURRENCIES, [] )
     }
 }
 

+ 13 - 4
src/store/modules/customers.js

@@ -2,7 +2,8 @@ import {
     INIT_PAYMENTS_CUSTOMERS,
     SELECT_PAYMENTS_CUSTOMER,
     SELECT_CUSTOMER_INVOICES,
-    FILTER_PAYMENTS_CUSTOMERS
+    FILTER_PAYMENTS_CUSTOMERS,
+    RESET_CUSTOMERS
 } from '@/constants/actionTypes'
 
 import {
@@ -15,9 +16,8 @@ import {
 const initialState = {
     customers: [],
     filterCustomers: [],
+    selectedCustomer: null,
     loadingCustomers: false,
-    selectedCustomer: null
-
 }
 
 const state = {
@@ -111,8 +111,17 @@ const actions = {
      */
     [FILTER_PAYMENTS_CUSTOMERS] ({ commit }, payload) {
         commit(SET_FILTER_PAYMENTS_CUSTOMERS, payload)
+    },
+    /**
+     * [RESET_CUSTOMERS]
+     * @param {*} param0
+     */
+    [RESET_CUSTOMERS] ({ commit }) {
+        commit(SET_CUSTOMERS, [])
+        commit(SET_SELECTED_CUSTOMER, null)
+        commit(SET_FILTER_PAYMENTS_CUSTOMERS, [])
+        commit(SET_LOADING_CUSTOMERS, true)
     }
-
 }
 
 export default {

+ 9 - 1
src/store/modules/date.js

@@ -1,4 +1,4 @@
-import { INIT_PAYMENTS_DATE } from '@/constants/actionTypes'
+import { INIT_PAYMENTS_DATE, RESET_DATE } from '@/constants/actionTypes'
 import { SET_DATE, SET_LOADING_DATE } from '@/constants/mutationTypes'
 
 const initialState = {
@@ -58,6 +58,14 @@ const actions = {
     [INIT_PAYMENTS_DATE] ({ commit}, payload) {
         commit(SET_DATE, payload)
         commit(SET_LOADING_DATE, payload)
+    },
+    /**
+     *
+     * @param {*} param0
+     * @param {*} payload
+     */
+    [RESET_DATE] ({ commit }) {
+        commit(SET_DATE, [])
     }
 }
 

+ 10 - 3
src/store/modules/invoices.js

@@ -3,7 +3,8 @@ import {
     SELECT_INVOICE,
     SELECT_MOVE_INVOICE,
     ADD_MOVE_IN_INVOICE,
-    FILTER_PAYMENTS_INVOICE
+    FILTER_PAYMENTS_INVOICE,
+    RESET_INVOICES
 } from '@/constants/actionTypes'
 
 import {
@@ -17,7 +18,7 @@ import {
 const initialState = {
     invoices: [],
     filterPaymentsInvoice: [],
-    currencyInvoice: null,
+    currencyInvoice: [],
     selectedInvoice : null
 }
 
@@ -157,8 +158,14 @@ const actions = {
      */
     [FILTER_PAYMENTS_INVOICE] ({ commit }, payload ){
         commit(SET_FILTER_PAYMENTS_INVOICE, payload)
+    },
+    [RESET_INVOICES] ({ commit }) {
+        commit(SET_INVOICES, [] )
+        commit(SET_SELECTED_INVOICE, null)
+        commit(SET_SELECTED_CURRENCY_INVOICE, [] )
+        commit(SET_FILTER_PAYMENTS_INVOICE, [] )
     }
-}
+ }
 
 export default {
     state,

+ 7 - 2
src/store/modules/journals.js

@@ -1,8 +1,8 @@
-import { INIT_PAYMENTS_JOURNALS, SELECT_JOURNAL } from '@/constants/actionTypes'
+import { INIT_PAYMENTS_JOURNALS, SELECT_JOURNAL, RESET_JOURNALS } from '@/constants/actionTypes'
 import { SET_JOURNALS, SET_LOADING_JOURNALS, SET_SELECTED_JOURNAL } from '@/constants/mutationTypes'
 
 const initialState ={
-    journals: null,
+    journals: [],
     loadingJournal: false,
     selectedJournal: null
 }
@@ -85,6 +85,11 @@ const actions = {
      */
     [SELECT_JOURNAL] ({ commit },payload ) {
         commit(SET_SELECTED_JOURNAL, payload)
+    },
+    [RESET_JOURNALS] ({ commit }) {
+        commit(SET_JOURNALS, [] )
+        commit(SET_SELECTED_JOURNAL, null )
+
     }
 
 }

+ 17 - 3
src/store/modules/moveLines.js

@@ -3,7 +3,9 @@ import {
     SELECT_MOVE,
     REMOVE_MOVE_PAYMENTS,
     ADD_MOVE_IN_INVOICE,
-    REMOVE_MOVE_PAYMENTS_ALL
+    REMOVE_MOVE_PAYMENTS_ALL,
+    RESET_MOVE_LINES,
+    SET_MOVE_PAYMENTS
 } from '@/constants/actionTypes'
 
 import {
@@ -32,7 +34,6 @@ const state = {
     movesPayments: initialState.movesPayments,
     movesPaymentsTotal: initialState.movesPaymentsTotal,
     movesPaymentsBalance: initialState.movesPaymentsBalance,
-
 }
 
 const getters = {
@@ -88,6 +89,9 @@ const mutations = {
     [SET_MOVES] (state, payload) {
         state.moves =  payload
     },
+    [SET_MOVE_PAYMENTS] (state, payload) {
+        state.movesPayments = payload
+    },
     /**
      * [selectedMoveLine description]
      * @type {[type]}
@@ -149,9 +153,10 @@ const mutations = {
      * @param  {[type]} payload [description]
      */
     [SET_TOTAL_MOVE_PAYMENTS] (state) {
-        let total =0
+        let total = 0
         state.movesPayments.forEach(item => {
             total = total + item.amountResidual
+            // total = total + !!item.amountResidual ? item.amountResidual : 0
         })
         state.movesPaymentsTotal = total
     },
@@ -244,6 +249,15 @@ const actions = {
 
         commit(SET_ORDER_MOVE_LINE)
         commit(SET_TOTAL_MOVE_PAYMENTS)
+    },
+    /**
+     *
+     */
+    [RESET_MOVE_LINES] ({ commit }) {
+        commit(SET_MOVES, [] )
+        commit(SET_SELECTED_MOVE_LINE, null )
+        commit(SET_MOVE_PAYMENTS, [] )
+        commit(SET_TOTAL_MOVE_PAYMENTS)
     }
 }
 

+ 4 - 1
src/store/modules/payments.js

@@ -1,4 +1,4 @@
-import { CHANGE_INITIAL_PAID } from '@/constants/actionTypes'
+import { CHANGE_INITIAL_PAID, RESET_PAYMENTS } from '@/constants/actionTypes'
 import { SET_PAID_TOTAL } from '@/constants/mutationTypes'
 
 const initialState = {
@@ -56,6 +56,9 @@ const actions = {
      */
     [CHANGE_INITIAL_PAID] ({ commit },payload) {
         commit(SET_PAID_TOTAL, payload)
+    },
+    [RESET_PAYMENTS] ({ commit }) {
+        commit(SET_PAID_TOTAL, 0)
     }
 }
 

+ 7 - 1
src/store/modules/user.js

@@ -1,4 +1,4 @@
-import { INIT_PAYMENTS_USER, INIT_PAYMENTS_COMPANY } from '@/constants/actionTypes'
+import { INIT_PAYMENTS_USER, INIT_PAYMENTS_COMPANY, RESET_USER} from '@/constants/actionTypes'
 import { SET_USER, SET_LOADING_USER } from '@/constants/mutationTypes'
 
 const initialState ={
@@ -60,6 +60,12 @@ const actions ={
 
         dispatch(INIT_PAYMENTS_COMPANY, payload)
 
+    },
+    /**
+     *
+     */
+    [RESET_USER] ({ commit }) {
+        commit(SET_USER, [])
     }
 }
 

+ 23 - 0
src/store/mutations.js

@@ -0,0 +1,23 @@
+import {
+    SET_PROCESSING_PAYMENTS,
+    SET_COMPLETED_PAYMENTS
+} from '@/constants/mutationTypes'
+
+const mutations = {
+    /**
+     * [processingPayments description]
+     * @type {[type]}
+     */
+    [SET_PROCESSING_PAYMENTS] (state, payload) {
+        state.processingPayments = payload
+    },
+    /**
+     * [completedPayments description]
+     * @type {[type]}
+     */
+    [SET_COMPLETED_PAYMENTS] (state, payload) {
+        state.completedPayments = payload
+    }
+}
+
+export default mutations

+ 6 - 0
src/store/state.js

@@ -0,0 +1,6 @@
+const state = {
+    processingPayments: false,
+    completedPayments: false
+}
+
+export default state