|
@@ -0,0 +1,99 @@
|
|
|
+import { SELECT_CUSTOMER_INVOICES, SELECT_INVOICE, SELECT_MOVE_INVOICE } from '@/constants/actionTypes'
|
|
|
+import { SET_INVOICES, SET_SELECTED_INVOICE, SET_SELECTED_CURRENCY_INVOICE } from '@/constants/mutationTypes'
|
|
|
+
|
|
|
+const initialState = {
|
|
|
+ invoices: null,
|
|
|
+ currencyInvoice: null,
|
|
|
+ selectedInvoice : null
|
|
|
+}
|
|
|
+
|
|
|
+const state = {
|
|
|
+ invoices: initialState.invoices,
|
|
|
+ currencyInvoice: initialState.currencyInvoice,
|
|
|
+ selectedInvoice: initialState.selectedInvoice
|
|
|
+}
|
|
|
+
|
|
|
+const getters = {
|
|
|
+ /**
|
|
|
+ * [invoices description]
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
+ invoices(state) {
|
|
|
+ return state.invoices
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [currencyInvoice description]
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
+ currencyInvoice(state) {
|
|
|
+ return state.currencyInvoice
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [selectedInvoice description]
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
+ selectedInvoice(state) {
|
|
|
+ return state.selectedInvoice
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mutations = {
|
|
|
+ /**
|
|
|
+ * [invoices description]
|
|
|
+ * @type {[type]}
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @param {[type]} payload [description]
|
|
|
+ */
|
|
|
+ [SET_INVOICES] (state, payload) {
|
|
|
+ state.invoices = payload
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [selectedInvoice description]
|
|
|
+ * @type {[type]}
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @param {[type]} payload [description]
|
|
|
+ */
|
|
|
+ [SET_SELECTED_INVOICE] (state, payload) {
|
|
|
+ state.selectedInvoice = payload
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [currencyInvoice description]
|
|
|
+ * @type {[type]}
|
|
|
+ * @param {[type]} state [description]
|
|
|
+ * @param {[type]} payload [description]
|
|
|
+ */
|
|
|
+ [SET_SELECTED_CURRENCY_INVOICE] (state, payload) {
|
|
|
+ state.currencyInvoice = payload
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const actions = {
|
|
|
+ /**
|
|
|
+ * [Selecciona las factura del cliente seleccionado]
|
|
|
+ * @param {*} param0
|
|
|
+ * @param {*} payload
|
|
|
+ */
|
|
|
+ [SELECT_CUSTOMER_INVOICES] ({ commit }, payload) {
|
|
|
+ commit(SET_INVOICES, payload)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * [Seleccionar una factura]
|
|
|
+ * @param {*} param0
|
|
|
+ * @param {*} payload
|
|
|
+ */
|
|
|
+ [SELECT_INVOICE] ({ commit, dispatch }, payload) {
|
|
|
+ commit(SET_SELECTED_INVOICE, payload)
|
|
|
+ commit(SET_SELECTED_CURRENCY_INVOICE, payload.currency)
|
|
|
+ dispatch(SELECT_MOVE_INVOICE, payload.moveLines)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default {
|
|
|
+ state,
|
|
|
+ getters,
|
|
|
+ mutations,
|
|
|
+ actions
|
|
|
+}
|