build version 400

This commit is contained in:
Mohit Panjwani
2020-12-02 17:54:08 +05:30
parent 326508e567
commit 89ee58590c
963 changed files with 62887 additions and 48868 deletions

View File

@ -1,74 +1,63 @@
import Ls from '@/services/ls'
import * as types from './mutation-types'
import * as userTypes from '../user/mutation-types'
import * as rootTypes from '../../mutation-types'
import router from '@/router.js'
export const login = ({ commit, dispatch, state }, data) => {
let loginData = {
username: data.email,
password: data.password
}
export const login = ({ commit }, data) => {
return new Promise((resolve, reject) => {
axios.post('/api/auth/login', loginData).then((response) => {
let token = response.data.access_token
Ls.set('auth.token', token)
window.axios.get('/sanctum/csrf-cookie').then((response) => {
window.axios
.post('/login', data)
.then((response) => {
commit(types.SET_LOGOUT, false)
commit('user/' + userTypes.RESET_CURRENT_USER, null, { root: true })
commit(rootTypes.UPDATE_APP_LOADING_STATUS, false, { root: true })
commit('user/' + userTypes.RESET_CURRENT_USER, null, { root: true })
commit(rootTypes.UPDATE_APP_LOADING_STATUS, false, { root: true })
commit(types.AUTH_SUCCESS, token)
window.toastr['success']('Login Successful')
resolve(response)
}).catch(err => {
commit(types.AUTH_ERROR, err.response)
Ls.remove('auth.token')
reject(err)
window.toastr['success']('Login Successful')
resolve(response)
})
.catch((err) => {
commit(types.AUTH_ERROR, err.response)
reject(err)
})
})
})
}
export const refreshToken = ({ commit, dispatch, state }) => {
export const setLogoutFalse = ({ state, commit }) => {
commit(types.SET_LOGOUT, false)
}
export const logout = ({ state, commit }) => {
return new Promise((resolve, reject) => {
let data = {
token: Ls.get('auth.token')
if (state.isLoggedOut) {
resolve()
return true
}
console.log('REFRESH ACTION')
axios.post('/api/auth/refresh_token', data).then((response) => {
let token = response.data.data.token
Ls.set('auth.token', token)
commit(types.REFRESH_SUCCESS, token)
resolve(response)
}).catch(err => {
reject(err)
})
commit(types.SET_LOGOUT, true)
window.axios
.get('/auth/logout')
.then(() => {
router.push('/login')
window.toastr['success']('Logged out!', 'Success')
})
.catch((err) => {
router.push('/login')
reject(err)
})
})
}
export const logout = ({ commit, dispatch, state }, noRequest = false) => {
if (noRequest) {
commit(types.AUTH_LOGOUT)
Ls.remove('auth.token')
router.push('/login')
return true
}
export const checkMail = ({ commit }, data) => {
return new Promise((resolve, reject) => {
axios.get('/api/auth/logout').then((response) => {
commit(types.AUTH_LOGOUT)
Ls.remove('auth.token')
router.push('/login')
window.toastr['success']('Logged out!', 'Success')
}).catch(err => {
reject(err)
commit(types.AUTH_LOGOUT)
Ls.remove('auth.token')
router.push('/login')
})
window.axios
.post('/api/v1/is-registered', data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const loginOnBoardingUser = ({ commit, dispatch, state }, token) => {
commit(types.AUTH_SUCCESS, token)
}

View File

@ -1,2 +1 @@
export const isAuthenticated = (state) => !!state.token
export const authStatus = (state) => state.status
export const isLoggedOut = (state) => state.isLoggedOut

View File

@ -1,13 +1,10 @@
import mutations from './mutations'
import * as actions from './actions'
import * as getters from './getters'
import Ls from '@/services/ls'
const initialState = {
token: Ls.get('auth.token'),
status: '',
validateTokenError: '',
validateTokenSuccess: ''
isLoggedOut: false,
}
export default {
@ -19,5 +16,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -2,3 +2,4 @@ export const AUTH_SUCCESS = 'AUTH_SUCCESS'
export const AUTH_LOGOUT = 'AUTH_LOGOUT'
export const AUTH_ERROR = 'AUTH_ERROR'
export const REFRESH_SUCCESS = 'REFRESH_SUCCESS'
export const SET_LOGOUT = 'SET_LOGOUT'

View File

@ -1,22 +1,22 @@
import * as types from './mutation-types'
export default {
[types.AUTH_SUCCESS] (state, token) {
[types.AUTH_SUCCESS](state, token) {
state.token = token
state.status = 'success'
},
[types.AUTH_LOGOUT] (state) {
state.token = null
[types.SET_LOGOUT](state, data) {
state.isLoggedOut = data
},
[types.AUTH_ERROR] (state, errorResponse) {
[types.AUTH_ERROR](state, errorResponse) {
state.token = null
state.status = 'error'
},
[types.REFRESH_SUCCESS] (state, token) {
[types.REFRESH_SUCCESS](state, token) {
state.token = token
state.status = 'success'
}
},
}

View File

@ -0,0 +1,41 @@
import * as types from './mutation-types'
export const fetchBackups = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/backups`, { params })
.then((response) => {
commit(types.SET_BACKUPS, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const createBackup = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post(`/api/v1/backups`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const removeBackup = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.delete(`/api/v1/backups/${params.disk}`, { params })
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -0,0 +1,3 @@
export const getBackups = (state) => state.backups
export const getBackupDisks = (state) => state.backupDisks
export const getBackupDisksInfo = (state) => state.backupDisksInfo

View File

@ -0,0 +1,21 @@
import mutations from './mutations'
import * as actions from './actions'
import * as getters from './getters'
const initialState = {
backups: [],
backupDisks: [],
backupDisksInfo: [],
}
export default {
namespaced: true,
state: initialState,
getters: getters,
actions: actions,
mutations: mutations,
}

View File

@ -0,0 +1,4 @@
export const SET_BACKUPS = 'SET_BACKUPS'
export const ADD_BACKUPS = 'ADD_BACKUPS'
export const DELETE_BACKUPS = 'DELETE_BACKUPS'
export const SET_BACKUP_DISKS = 'SET_BACKUP_DISKS'

View File

@ -0,0 +1,21 @@
import * as types from './mutation-types'
export default {
[types.SET_BACKUPS](state, data) {
state.backups = data.backups
state.backupDisks = data.disks
},
[types.SET_BACKUP_DISKS](state, data) {
state.backupDisksInfo = data.disks
},
[types.ADD_BACKUPS](state, data) {
state.backups.push(data.backup)
},
[types.DELETE_BACKUPS](state, id) {
let index = state.backups.findIndex((backup) => backup.id === id)
state.backups.splice(index, 1)
},
}

View File

@ -1,57 +1,72 @@
import * as types from './mutation-types'
export const fetchCategories = ({ commit, dispatch, state }, data) => {
export const fetchCategories = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/categories`).then((response) => {
commit(types.SET_CATEGORIES, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/categories`, { params })
.then((response) => {
commit(types.SET_CATEGORIES, response.data.categories.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchCategory = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/categories/${id}/edit`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/categories/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addCategory = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/categories', data).then((response) => {
commit(types.ADD_CATEGORY, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post('/api/v1/categories', data)
.then((response) => {
commit(types.ADD_CATEGORY, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateCategory = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/categories/${data.id}`, data).then((response) => {
commit(types.UPDATE_CATEGORY, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/categories/${data.id}`, data)
.then((response) => {
commit(types.UPDATE_CATEGORY, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteCategory = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/categories/${id}`).then((response) => {
if (response.data.success) {
commit(types.DELETE_CATEGORY, id)
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.delete(`/api/v1/categories/${id}`)
.then((response) => {
if (response.data.success) {
commit(types.DELETE_CATEGORY, id)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -3,7 +3,7 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
categories: []
categories: [],
}
export default {
@ -15,5 +15,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -1,21 +1,23 @@
import * as types from './mutation-types'
export default {
[types.SET_CATEGORIES] (state, data) {
state.categories = data.categories
[types.SET_CATEGORIES](state, categories) {
state.categories = categories
},
[types.ADD_CATEGORY] (state, data) {
[types.ADD_CATEGORY](state, data) {
state.categories.push(data.category)
},
[types.UPDATE_CATEGORY] (state, data) {
let pos = state.categories.findIndex(category => category.id === data.category.id)
Object.assign(state.categories[pos], {...data.category})
[types.UPDATE_CATEGORY](state, data) {
let pos = state.categories.findIndex(
(category) => category.id === data.category.id
)
Object.assign(state.categories[pos], { ...data.category })
},
[types.DELETE_CATEGORY] (state, id) {
let pos = state.categories.findIndex(category => category.id === id)
[types.DELETE_CATEGORY](state, id) {
let pos = state.categories.findIndex((category) => category.id === id)
state.categories.splice(pos, 1)
}
},
}

View File

@ -3,3 +3,121 @@ import * as types from './mutation-types'
export const setSelectedCompany = ({ commit, dispatch, state }, data) => {
commit(types.SET_SELECTED_COMPANY, data)
}
export const updateCompany = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.put('/api/v1/company', data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateCompanyLogo = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post('/api/v1/company/upload-logo', data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchCompanySettings = ({ commit, dispatch, state }, settings) => {
return new Promise((resolve, reject) => {
window.axios
.get('/api/v1/company/settings', {
params: {
settings,
},
})
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateCompanySettings = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post('/api/v1/company/settings', data)
.then((response) => {
commit(types.SET_CARBON_DATE_FORMAT, data.settings.carbon_date_format)
commit(types.SET_MOMENT_DATE_FORMAT, data.settings.moment_date_format)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const setItemDiscount = ({ commit, dispatch, state }) => {
commit(types.SET_ITEM_DISCOUNT)
}
export const fetchMailDrivers = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios
.get('/api/v1/mail/drivers')
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchMailConfig = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios
.get('/api/v1/mail/config')
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateMailConfig = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post('/api/v1/mail/config', data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const sendTestMail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post('/api/v1/mail/test', data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const setDefaultCurrency = ({ commit, dispatch, state }, data) => {
commit(types.SET_DEFAULT_CURRENCY, { default_currency: data })
}

View File

@ -1,2 +1,33 @@
export const getSelectedCompany = (state) => state.selectedCompany
export const getCompanies = (state) => state.companies
export const getMomentDateFormat = (state) => state.momentDateFormat
export const getCarbonDateFormat = (state) => state.carbonDateFormat
export const itemDiscount = (state) => state.item_discount
export const defaultFiscalYear = (state) => state.defaultFiscalYear
export const defaultTimeZone = (state) => state.defaultTimeZone
export const defaultCurrency = (state) => state.defaultCurrency
export const defaultCurrencyForInput = (state) => {
if (state.defaultCurrency) {
return {
decimal: state.defaultCurrency.decimal_separator,
thousands: state.defaultCurrency.thousand_separator,
prefix: state.defaultCurrency.symbol + ' ',
precision: state.defaultCurrency.precision,
masked: false,
}
}
return {
decimal: '.',
thousands: ',',
prefix: '$ ',
precision: 2,
masked: false,
}
}

View File

@ -3,8 +3,23 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
companies: [],
selectedCompany: null,
companies: []
company: null,
momentDateFormat: null,
carbonDateFormat: null,
item_discount: false,
defaultFiscalYear: null,
defaultTimeZone: null,
defaultCurrency: null,
}
export default {
@ -16,5 +31,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -1,2 +1,15 @@
export const BOOTSTRAP_COMPANIES = 'BOOTSTRAP_COMPANIES'
export const SET_SELECTED_COMPANY = 'SET_SELECTED_COMPANY'
export const SET_MOMENT_DATE_FORMAT = 'SET_MOMENT_DATE_FORMAT'
export const SET_CARBON_DATE_FORMAT = 'SET_CARBON_DATE_FORMAT'
export const SET_DEFAULT_FISCAL_YEAR = 'SET_DEFAULT_FISCAL_YEAR'
export const SET_DEFAULT_TIME_ZONE = 'SET_DEFAULT_TIME_ZONE'
export const SET_ITEM_DISCOUNT = 'SET_ITEM_DISCOUNT'
export const SET_DEFAULT_CURRENCY = 'SET_DEFAULT_CURRENCY'

View File

@ -2,12 +2,32 @@ import * as types from './mutation-types'
import Ls from '@/services/ls'
export default {
[types.BOOTSTRAP_COMPANIES] (state, companies) {
state.companies = companies
state.selectedCompany = companies[0]
},
[types.SET_SELECTED_COMPANY] (state, company) {
[types.SET_SELECTED_COMPANY](state, company) {
Ls.set('selectedCompany', company.id)
state.selectedCompany = company
}
},
[types.SET_MOMENT_DATE_FORMAT](state, data) {
state.momentDateFormat = data
},
[types.SET_CARBON_DATE_FORMAT](state, data) {
state.carbonDateFormat = data
},
[types.SET_ITEM_DISCOUNT](state) {
state.item_discount = true
},
[types.SET_DEFAULT_FISCAL_YEAR](state, data) {
state.defaultFiscalYear = data
},
[types.SET_DEFAULT_TIME_ZONE](state, data) {
state.defaultTimeZone = data
},
[types.SET_DEFAULT_CURRENCY](state, data) {
state.defaultCurrency = data.default_currency
},
}

View File

@ -1,70 +0,0 @@
import * as types from './mutation-types'
// export const indexLoadData = ({ commit, dispatch, state }) => {
// return new Promise((resolve, reject) => {
// window.axios.get('/api/settings/currencies').then((response) => {
// commit(types.BOOTSTRAP_CURRENCIES, response.data)
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
// export const loadData = ({ commit, dispatch, state }, id) => {
// return new Promise((resolve, reject) => {
// window.axios.get(`/api/settings/currencies/${id}/edit`).then((response) => {
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
// export const addCurrency = ({ commit, dispatch, state }, data) => {
// return new Promise((resolve, reject) => {
// window.axios.post('/api/settings/currencies', data).then((response) => {
// commit(types.ADD_CURRENCY, response.data)
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
// export const editCurrency = ({ commit, dispatch, state }, data) => {
// return new Promise((resolve, reject) => {
// window.axios.put('/api/settings/currency_setting', data).then((response) => {
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
// export const removeItem = ({ commit, dispatch, state }, id) => {
// return new Promise((resolve, reject) => {
// window.axios.delete(`/api/settings/currencies/${id}`).then((response) => {
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
// export const selectCurrency = ({ commit, dispatch, state }) => {
// return new Promise((resolve, reject) => {
// let data = {
// currency: state.currencyId
// }
// window.axios.delete(`/api/settings/currency_setting`, data).then((response) => {
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
export const setDefaultCurrency = ({ commit, dispatch, state }, data) => {
commit(types.SET_DEFAULT_CURRENCY, { default_currency: data })
}

View File

@ -1,21 +0,0 @@
export const currencies = (state) => state.currencies
export const defaultCurrency = (state) => state.defaultCurrency
export const defaultCurrencyForInput = (state) => {
if (state.defaultCurrency) {
return {
decimal: state.defaultCurrency.decimal_separator,
thousands: state.defaultCurrency.thousand_separator,
prefix: state.defaultCurrency.symbol + ' ',
precision: state.defaultCurrency.precision,
masked: false
}
}
return {
decimal: '.',
thousands: ',',
prefix: '$ ',
precision: 2,
masked: false
}
}

View File

@ -1,5 +0,0 @@
export const BOOTSTRAP_CURRENCIES = 'BOOTSTRAP_CURRENCIES'
export const SET_DEFAULT_CURRENCY = 'SET_DEFAULT_CURRENCY'
export const ADD_CURRENCY = 'ADD_CURRENCY'
export const UPDATE_CURRENCY = 'UPDATE_CURRENCY'
export const DELETE_CURRENCY = 'DELETE_CURRENCY'

View File

@ -1,16 +0,0 @@
import * as types from './mutation-types'
export default {
[types.BOOTSTRAP_CURRENCIES] (state, data) {
state.currencies = data.currencies
state.currencyId = data.currencyId
},
[types.SET_DEFAULT_CURRENCY] (state, data) {
state.defaultCurrency = data.default_currency
},
[types.ADD_CURRENCY] (state, data) {
state.currencies.push(data)
}
}

View File

@ -0,0 +1,91 @@
import * as types from './mutation-types'
export const fetchCustomFields = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/custom-fields`, { params })
.then((response) => {
commit(types.SET_CUSTOM_FIELDS, response.data.customFields.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchNoteCustomFields = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
if (state.isRequestOngoing) {
resolve({ requestOnGoing: true })
return true
}
commit(types.SET_REQUEST_STATE, true)
window.axios
.get(`/api/v1/custom-fields`, { params })
.then((response) => {
commit(types.SET_CUSTOM_FIELDS, response.data.customFields.data)
commit(types.SET_REQUEST_STATE, false)
resolve(response)
})
.catch((err) => {
commit(types.SET_REQUEST_STATE, false)
reject(err)
})
})
}
export const fetchCustomField = ({ commit, dispatch }, id) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/custom-fields/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addCustomField = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.post(`/api/v1/custom-fields`, params)
.then((response) => {
commit(types.ADD_CUSTOM_FIELDS, response.data.customField)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateCustomField = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.put(`/api/v1/custom-fields/${params.id}`, params)
.then((response) => {
commit(types.UPDATE_CUSTOM_FIELDS, params)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteCustomFields = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios
.delete(`/api/v1/custom-fields/${id}`)
.then((response) => {
commit(types.DELETE_CUSTOM_FIELDS, id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -0,0 +1 @@
export const getCustomFields = (state) => state.customFields

View File

@ -3,8 +3,8 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
currencies: [],
defaultCurrency: null
customFields: [],
isRequestOngoing: false,
}
export default {
@ -16,5 +16,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -0,0 +1,5 @@
export const SET_CUSTOM_FIELDS = 'SET_CUSTOM_FIELDS'
export const ADD_CUSTOM_FIELDS = 'ADD_CUSTOM_FIELDS'
export const UPDATE_CUSTOM_FIELDS = 'UPDATE_CUSTOM_FIELDS'
export const DELETE_CUSTOM_FIELDS = 'DELETE_CUSTOM_FIELDS'
export const SET_REQUEST_STATE = 'SET_REQUEST_STATE'

View File

@ -0,0 +1,42 @@
import * as types from './mutation-types'
export default {
[types.SET_CUSTOM_FIELDS](state, fields) {
state.customFields = fields
},
[types.ADD_CUSTOM_FIELDS](state, field) {
field = {
...field,
options: field.options.map((option) => {
return { name: option ? option : '' }
}),
}
state.customFields = [...state.customFields, field]
},
[types.UPDATE_CUSTOM_FIELDS](state, field) {
field = {
...field,
options: field.options.map((option) => {
return { name: option ? option : '' }
}),
}
let pos = state.customFields.findIndex((_f) => _f.id === field.id)
if (state.customFields[pos]) {
state.customFields[pos] = field
}
},
[types.DELETE_CUSTOM_FIELDS](state, id) {
let index = state.customFields.findIndex((field) => field.id === id)
state.customFields.splice(index, 1)
},
[types.SET_REQUEST_STATE](state, flag) {
state.isRequestOngoing = flag
},
}

View File

@ -1,70 +1,108 @@
import * as types from './mutation-types'
import * as searchTypes from '../search/mutation-types'
export const fetchCustomers = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/customers`, {params}).then((response) => {
commit(types.BOOTSTRAP_CUSTOMERS, response.data.customers.data)
commit(types.SET_TOTAL_CUSTOMERS, response.data.customers.total)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/customers`, { params })
.then((response) => {
commit(types.BOOTSTRAP_CUSTOMERS, response.data.customers.data)
commit(types.SET_TOTAL_CUSTOMERS, response.data.customerTotalCount)
commit(
'search/' + searchTypes.SET_CUSTOMER_LISTS,
response.data.customers.data,
{ root: true }
)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchCustomer = ({ commit, dispatch }, id) => {
export const fetchCustomer = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/customers/${id}/edit`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/customers/${params.id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchViewCustomer = ({ commit, dispatch }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/customers/${params.id}/stats`, { params })
.then((response) => {
commit(types.SET_SELECTED_VIEW_CUSTOMER, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addCustomer = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/customers', data).then((response) => {
commit(types.ADD_CUSTOMER, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post('/api/v1/customers', data)
.then((response) => {
commit(types.ADD_CUSTOMER, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateCustomer = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/customers/${data.id}`, data).then((response) => {
if(response.data.success){
commit(types.UPDATE_CUSTOMER, response.data)
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/customers/${data.id}`, data)
.then((response) => {
if (response.data.success) {
commit(types.UPDATE_CUSTOMER, response.data)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteCustomer = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/customers/${id}`).then((response) => {
commit(types.DELETE_CUSTOMER, id)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/customers/delete`, id)
.then((response) => {
commit(types.DELETE_CUSTOMER, id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteMultipleCustomers = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/customers/delete`, {'id': state.selectedCustomers}).then((response) => {
commit(types.DELETE_MULTIPLE_CUSTOMERS, state.selectedCustomers)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/customers/delete`, { ids: state.selectedCustomers })
.then((response) => {
commit(types.DELETE_MULTIPLE_CUSTOMERS, state.selectedCustomers)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -77,7 +115,7 @@ export const selectAllCustomers = ({ commit, dispatch, state }) => {
commit(types.SET_SELECTED_CUSTOMERS, [])
commit(types.SET_SELECT_ALL_STATE, false)
} else {
let allCustomerIds = state.customers.map(cust => cust.id)
let allCustomerIds = state.customers.map((cust) => cust.id)
commit(types.SET_SELECTED_CUSTOMERS, allCustomerIds)
commit(types.SET_SELECT_ALL_STATE, true)
}

View File

@ -2,3 +2,8 @@ export const customers = (state) => state.customers
export const selectAllField = (state) => state.selectAllField
export const selectedCustomers = (state) => state.selectedCustomers
export const totalCustomers = (state) => state.totalCustomers
export const getCustomer = (state) => (id) => {
let CstId = parseInt(id)
return state.customers.find((customer) => customer.id === CstId)
}
export const selectedViewCustomer = (state) => state.selectedViewCustomer

View File

@ -6,7 +6,8 @@ const initialState = {
customers: [],
totalCustomers: 0,
selectAllField: false,
selectedCustomers: []
selectedCustomers: [],
selectedViewCustomer: {},
}
export default {
@ -18,5 +19,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -7,3 +7,4 @@ export const SET_SELECTED_CUSTOMERS = 'SET_SELECTED_CUSTOMERS'
export const SET_TOTAL_CUSTOMERS = 'SET_TOTAL_CUSTOMERS'
export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER'
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
export const SET_SELECTED_VIEW_CUSTOMER = 'SET_SELECTED_VIEW_CUSTOMER'

View File

@ -1,48 +1,53 @@
import * as types from './mutation-types'
export default {
[types.BOOTSTRAP_CUSTOMERS] (state, customers) {
[types.BOOTSTRAP_CUSTOMERS](state, customers) {
state.customers = customers
},
[types.SET_TOTAL_CUSTOMERS] (state, totalCustomers) {
[types.SET_TOTAL_CUSTOMERS](state, totalCustomers) {
state.totalCustomers = totalCustomers
},
[types.ADD_CUSTOMER] (state, data) {
[types.ADD_CUSTOMER](state, data) {
state.customers.push(data.customer)
},
[types.UPDATE_CUSTOMER] (state, data) {
let pos = state.customers.findIndex(customer => customer.id === data.customer.id)
[types.UPDATE_CUSTOMER](state, data) {
let pos = state.customers.findIndex(
(customer) => customer.id === data.customer.id
)
state.customers[pos] = data.customer
},
[types.DELETE_CUSTOMER] (state, id) {
let index = state.customers.findIndex(customer => customer.id === id)
[types.DELETE_CUSTOMER](state, id) {
let index = state.customers.findIndex((customer) => customer.id === id)
state.customers.splice(index, 1)
},
[types.DELETE_MULTIPLE_CUSTOMERS] (state, selectedCustomers) {
[types.DELETE_MULTIPLE_CUSTOMERS](state, selectedCustomers) {
selectedCustomers.forEach((customer) => {
let index = state.customers.findIndex(_cust => _cust.id === customer.id)
let index = state.customers.findIndex((_cust) => _cust.id === customer.id)
state.customers.splice(index, 1)
})
state.selectedCustomers = []
},
[types.SET_SELECTED_CUSTOMERS] (state, data) {
[types.SET_SELECTED_CUSTOMERS](state, data) {
state.selectedCustomers = data
},
[types.RESET_SELECTED_CUSTOMER] (state, data) {
[types.RESET_SELECTED_CUSTOMER](state, data) {
state.selectedCustomer = null
},
[types.SET_SELECT_ALL_STATE] (state, data) {
[types.SET_SELECT_ALL_STATE](state, data) {
state.selectAllField = data
}
},
[types.SET_SELECTED_VIEW_CUSTOMER](state, selectedViewCustomer) {
state.selectedViewCustomer = selectedViewCustomer
},
}

View File

@ -1,21 +1,23 @@
import * as types from './mutation-types'
export const loadData = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/dashboard`, { params }).then((response) => {
commit(types.SET_INITIAL_DATA, response.data)
commit(types.GET_INITIAL_DATA, true)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/dashboard`, { params })
.then((response) => {
commit(types.SET_INITIAL_DATA, response.data)
commit(types.SET_DASHBOARD_DATA_LOADED_STATE, true)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
// export const getChart = ({ commit, dispatch, state }) => {
// return new Promise((resolve, reject) => {
// window.axios.get(`/api/dashboard/expense/chart`).then((response) => {
// window.axios.get(`/api/v1/dashboard/expense/chart`).then((response) => {
// commit(types.SET_INITIAL_DATA, response.data)
// resolve(response)
// }).catch((err) => {

View File

@ -9,7 +9,7 @@ export const getTotalDueAmount = (state) => state.totalDueAmount
export const getDueInvoices = (state) => state.dueInvoices
export const getRecentEstimates = (state) => state.recentEstimates
export const getLoadedData = (state) => state.isDataLoaded
export const getDashboardDataLoaded = (state) => state.isDashboardDataLoaded
export const getWeeklyInvoicesCounter = (state) => state.weeklyInvoices.counter
export const getWeeklyInvoicesDays = (state) => state.weeklyInvoices.days

View File

@ -8,11 +8,11 @@ const initialState = {
estimates: 0,
expenses: 0,
totalDueAmount: [],
isDataLoaded: false,
isDashboardDataLoaded: false,
weeklyInvoices: {
days: [],
counter: []
counter: [],
},
chartData: {
@ -20,7 +20,7 @@ const initialState = {
invoiceTotals: [],
expenseTotals: [],
netProfits: [],
receiptTotals: []
receiptTotals: [],
},
salesTotal: null,
@ -30,7 +30,7 @@ const initialState = {
dueInvoices: [],
recentEstimates: [],
newContacts: []
newContacts: [],
}
export default {
@ -42,5 +42,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -1,6 +1,6 @@
export const SET_INITIAL_DATA = 'SET_INITIAL_DATA'
export const GET_INITIAL_DATA = 'GET_INITIAL_DATA'
export const SET_DASHBOARD_DATA_LOADED_STATE = 'SET_DASHBOARD_DATA_LOADED_STATE'
export const DELETE_INVOICE = 'DELETE_INVOICE'
export const UPDATE_INVOICE_STATUS = 'UPDATE_INVOICE_STATUS'
export const DELETE_ESTIMATE = 'DELETE_ESTIMATE'
export const UPDATE_ESTIMATE_STATUS = 'UPDATE_ESTIMATE_STATUS'
export const UPDATE_ESTIMATE_STATUS = 'UPDATE_ESTIMATE_STATUS'

View File

@ -1,7 +1,7 @@
import * as types from './mutation-types'
export default {
[types.SET_INITIAL_DATA] (state, data) {
[types.SET_INITIAL_DATA](state, data) {
state.contacts = data.customersCount
state.invoices = data.invoicesCount
state.estimates = data.estimatesCount
@ -30,33 +30,39 @@ export default {
state.netProfit = data.netProfit
},
[types.GET_INITIAL_DATA] (state, data) {
state.isDataLoaded = data
[types.SET_DASHBOARD_DATA_LOADED_STATE](state, data) {
state.isDashboardDataLoaded = data
},
[types.UPDATE_INVOICE_STATUS] (state, data) {
let pos = state.dueInvoices.findIndex(invoice => invoice.id === data.id)
[types.UPDATE_INVOICE_STATUS](state, data) {
let pos = state.dueInvoices.findIndex((invoice) => invoice.id === data.id)
if (state.dueInvoices[pos]) {
state.dueInvoices[pos].status = data.status
}
},
[types.DELETE_INVOICE] (state, id) {
let index = state.dueInvoices.findIndex(invoice => invoice.id === id)
[types.DELETE_INVOICE](state, data) {
let index = state.dueInvoices.findIndex(
(invoice) => invoice.id === data.ids[0]
)
state.dueInvoices.splice(index, 1)
},
[types.DELETE_ESTIMATE] (state, id) {
let index = state.recentEstimates.findIndex(estimate => estimate.id === id)
[types.DELETE_ESTIMATE](state, data) {
let index = state.recentEstimates.findIndex(
(estimate) => estimate.id === data.ids[0]
)
state.recentEstimates.splice(index, 1)
},
[types.UPDATE_ESTIMATE_STATUS] (state, data) {
let pos = state.recentEstimates.findIndex(estimate => estimate.id === data.id)
[types.UPDATE_ESTIMATE_STATUS](state, data) {
let pos = state.recentEstimates.findIndex(
(estimate) => estimate.id === data.id
)
if (state.recentEstimates[pos]) {
state.recentEstimates[pos].status = data.status
}
}
},
}

View File

@ -0,0 +1,84 @@
import * as types from './mutation-types'
export const fetchDisks = ({ commit }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/disks`, { params })
.then((response) => {
commit(types.SET_DISKS, response.data.disks.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchDiskDrivers = ({ commit }) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/disk/drivers`)
.then((response) => {
commit(types.SET_DISK_DRIVER, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchDiskEnv = ({ commit }, data) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/disks/${data.disk}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const createDisk = ({ commit }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post(`/api/v1/disks`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateDisk = ({ commit }, data) => {
return new Promise((resolve, reject) => {
window.axios
.put(`/api/v1/disks/${data.id}`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteFileDisk = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios
.delete(`/api/v1/disks/${id}`)
.then((response) => {
if (response.data.success) {
commit(types.DELETE_DISK, id)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -0,0 +1,2 @@
export const getDisks = (state) => state.disks
export const getDiskDrivers = (state) => state.diskDrivers

View File

@ -3,7 +3,8 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
report: null
disks: [],
diskDrivers: [],
}
export default {
@ -15,5 +16,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -0,0 +1,4 @@
export const SET_DISKS = 'SET_DISKS'
export const SET_DISK_DRIVER = 'SET_DISK_DRIVER'
export const ADD_DISKS = 'ADD_DISKS'
export const DELETE_DISK = 'DELETE_DISK'

View File

@ -0,0 +1,20 @@
import * as types from './mutation-types'
export default {
[types.SET_DISKS](state, disks) {
state.disks = disks
},
[types.SET_DISK_DRIVER](state, data) {
state.diskDrivers = data.drivers
},
[types.ADD_DISKS](state, data) {
state.disks.push(data.disk)
},
[types.DELETE_DISK](state, id) {
let pos = state.disks.findIndex((disk) => disk.id === id)
state.disks.splice(pos, 1)
},
}

View File

@ -0,0 +1,15 @@
import * as types from './mutation-types'
export const fetchEstimateTemplates = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/estimates/templates`, { params })
.then((response) => {
commit(types.SET_ESTIMATE_TEMPLATES, response.data.templates)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -0,0 +1 @@
export const getEstimateTemplates = (state) => state.estimateTemplates

View File

@ -3,7 +3,7 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
estimates: []
estimateTemplates: [],
}
export default {
@ -15,5 +15,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -0,0 +1 @@
export const SET_ESTIMATE_TEMPLATES = 'SET_ESTIMATE_TEMPLATES'

View File

@ -0,0 +1,7 @@
import * as types from './mutation-types'
export default {
[types.SET_ESTIMATE_TEMPLATES](state, templates) {
state.estimateTemplates = templates
},
}

View File

@ -3,170 +3,249 @@ import * as dashboardTypes from '../dashboard/mutation-types'
export const fetchEstimates = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/estimates`, {params}).then((response) => {
commit(types.SET_ESTIMATES, response.data.estimates.data)
commit(types.SET_TOTAL_ESTIMATES, response.data.estimateTotalCount)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/estimates`, { params })
.then((response) => {
commit(types.SET_ESTIMATES, response.data.estimates.data)
commit(types.SET_TOTAL_ESTIMATES, response.data.estimateTotalCount)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const getRecord = ({ commit, dispatch, state }, record) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/estimates/records?record=${record}`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/estimates/records?record=${record}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchCreateEstimate = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/estimates/create`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/estimates`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const getEstimateNumber = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/next-number?key=estimate`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchEstimate = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/estimates/${id}/edit`).then((response) => {
commit(types.SET_TEMPLATE_ID, response.data.estimate.estimate_template_id)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/estimates/${id}`)
.then((response) => {
commit(
types.SET_TEMPLATE_ID,
response.data.estimate.estimate_template_id
)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchViewEstimate = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/estimates/${id}`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/estimates/${id}`)
.then((response) => {
commit(types.VIEW_ESTIMATE, response.data.estimate)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/send`, data).then((response) => {
if (response.data.success) {
commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' }, { root: true })
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/${data.id}/send`, data)
.then((response) => {
if (response.data.success) {
commit(types.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' })
commit(types.VIEW_ESTIMATE)
commit(
'dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS,
{ id: data.id, status: 'SENT' },
{ root: true }
)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addEstimate = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/estimates', data).then((response) => {
commit(types.ADD_ESTIMATE, response.data.estimate)
window.axios
.post('/api/v1/estimates', data)
.then((response) => {
commit(types.ADD_ESTIMATE, response.data.estimate)
resolve(response)
}).catch((err) => {
reject(err)
})
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteEstimate = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/estimates/${id}`).then((response) => {
commit(types.DELETE_ESTIMATE, id)
commit('dashboard/' + dashboardTypes.DELETE_ESTIMATE, id, { root: true })
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/delete`, id)
.then((response) => {
commit(types.DELETE_ESTIMATE, id)
commit('dashboard/' + dashboardTypes.DELETE_ESTIMATE, id, {
root: true,
})
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteMultipleEstimates = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/delete`, {'id': state.selectedEstimates}).then((response) => {
commit(types.DELETE_MULTIPLE_ESTIMATES, state.selectedEstimates)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/delete`, { ids: state.selectedEstimates })
.then((response) => {
commit(types.DELETE_MULTIPLE_ESTIMATES, state.selectedEstimates)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateEstimate = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/estimates/${data.id}`, data).then((response) => {
commit(types.UPDATE_ESTIMATE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/estimates/${data.id}`, data)
.then((response) => {
commit(types.UPDATE_ESTIMATE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const markAsAccepted = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/accept`, data).then((response) => {
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'ACCEPTED' }, { root: true })
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/${data.id}/status`, data)
.then((response) => {
commit(
'dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS,
{ id: data.id, status: 'ACCEPTED' },
{ root: true }
)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const markAsRejected = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/reject`, data).then((response) => {
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'REJECTED' }, { root: true })
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/${data.id}/status`, data)
.then((response) => {
commit(
'dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS,
{ id: data.id, status: 'REJECTED' },
{ root: true }
)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const markAsSent = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/mark-as-sent`, data).then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' }, { root: true })
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/${data.id}/status`, data)
.then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' })
commit(
'dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS,
{ id: data.id, status: 'SENT' },
{ root: true }
)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const convertToInvoice = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/${id}/convert-to-invoice`).then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/estimates/${id}/convert-to-invoice`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const searchEstimate = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/estimates?${data}`).then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/estimates?${data}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -188,7 +267,7 @@ export const selectAllEstimates = ({ commit, dispatch, state }) => {
commit(types.SET_SELECTED_ESTIMATES, [])
commit(types.SET_SELECT_ALL_STATE, false)
} else {
let allEstimateIds = state.estimates.map(estimt => estimt.id)
let allEstimateIds = state.estimates.map((estimt) => estimt.id)
commit(types.SET_SELECTED_ESTIMATES, allEstimateIds)
commit(types.SET_SELECT_ALL_STATE, true)
}
@ -225,16 +304,28 @@ export const setTemplate = ({ commit, dispatch, state }, data) => {
export const selectCustomer = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/customers/${id}`).then((response) => {
commit(types.RESET_SELECTED_CUSTOMER)
commit(types.SELECT_CUSTOMER, response.data.customer)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/customers/${id}`)
.then((response) => {
commit(types.RESET_SELECTED_CUSTOMER)
commit(types.SELECT_CUSTOMER, response.data.customer)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const resetSelectedCustomer = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_CUSTOMER)
}
export const selectNote = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_NOTE)
commit(types.SET_SELECTED_NOTE, data.notes)
}
export const resetSelectedNote = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_NOTE)
}

View File

@ -4,7 +4,8 @@ export const getTemplateId = (state) => state.estimateTemplateId
export const selectedEstimates = (state) => state.selectedEstimates
export const totalEstimates = (state) => state.totalEstimates
export const selectedCustomer = (state) => state.selectedCustomer
export const selectedNote = (state) => state.selectedNote
export const getEstimate = (state) => (id) => {
let invId = parseInt(id)
return state.estimates.find(estimate => estimate.id === invId)
return state.estimates.find((estimate) => estimate.id === invId)
}

View File

@ -8,7 +8,9 @@ const initialState = {
selectAllField: false,
selectedEstimates: [],
totalEstimates: 0,
selectedCustomer: null
selectedCustomer: null,
selectedEstimate: null,
selectedNote: null,
}
export default {
@ -20,5 +22,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -15,3 +15,7 @@ export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER'
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
export const RESET_SELECTED_ESTIMATES = 'RESET_SELECTED_ESTIMATES'
export const UPDATE_ESTIMATE_STATUS = 'UPDATE_ESTIMATE_STATUS'
export const VIEW_ESTIMATE = 'VIEW_ESTIMATE'
export const SET_SELECTED_NOTE = 'SET_SELECTED_NOTE'
export const RESET_SELECTED_NOTE = 'RESET_SELECTED_NOTE'

View File

@ -1,68 +1,82 @@
import * as types from './mutation-types'
export default {
[types.SET_ESTIMATES] (state, data) {
[types.SET_ESTIMATES](state, data) {
state.estimates = data
},
[types.SET_TOTAL_ESTIMATES] (state, totalEstimates) {
[types.SET_TOTAL_ESTIMATES](state, totalEstimates) {
state.totalEstimates = totalEstimates
},
[types.ADD_ESTIMATE] (state, data) {
[types.ADD_ESTIMATE](state, data) {
state.estimates = [...state.estimates, data]
},
[types.DELETE_ESTIMATE] (state, id) {
let index = state.estimates.findIndex(estimate => estimate.id === id)
[types.DELETE_ESTIMATE](state, id) {
let index = state.estimates.findIndex((estimate) => estimate.id === id)
state.estimates.splice(index, 1)
},
[types.SET_SELECTED_ESTIMATES] (state, data) {
[types.SET_SELECTED_ESTIMATES](state, data) {
state.selectedEstimates = data
},
[types.DELETE_MULTIPLE_ESTIMATES] (state, selectedEstimates) {
[types.DELETE_MULTIPLE_ESTIMATES](state, selectedEstimates) {
selectedEstimates.forEach((estimate) => {
let index = state.estimates.findIndex(_est => _est.id === estimate.id)
let index = state.estimates.findIndex((_est) => _est.id === estimate.id)
state.estimates.splice(index, 1)
})
state.selectedEstimates = []
},
[types.UPDATE_ESTIMATE] (state, data) {
let pos = state.estimates.findIndex(estimate => estimate.id === data.estimate.id)
[types.UPDATE_ESTIMATE](state, data) {
let pos = state.estimates.findIndex(
(estimate) => estimate.id === data.estimate.id
)
state.estimates[pos] = data.estimate
},
[types.UPDATE_ESTIMATE_STATUS] (state, data) {
let pos = state.estimates.findIndex(estimate => estimate.id === data.id)
[types.UPDATE_ESTIMATE_STATUS](state, data) {
let pos = state.estimates.findIndex((estimate) => estimate.id === data.id)
if (state.estimates[pos]) {
// state.estimates[pos] = { ...state.estimates[pos], status: data.status }
state.estimates[pos].status = data.status
}
},
[types.RESET_SELECTED_ESTIMATES] (state, data) {
[types.RESET_SELECTED_ESTIMATES](state, data) {
state.selectedEstimates = []
state.selectAllField = false
},
[types.SET_TEMPLATE_ID] (state, templateId) {
[types.SET_TEMPLATE_ID](state, templateId) {
state.estimateTemplateId = templateId
},
[types.SELECT_CUSTOMER] (state, data) {
[types.SELECT_CUSTOMER](state, data) {
state.selectedCustomer = data
},
[types.RESET_SELECTED_CUSTOMER] (state, data) {
[types.RESET_SELECTED_CUSTOMER](state, data) {
state.selectedCustomer = null
},
[types.SET_SELECT_ALL_STATE] (state, data) {
[types.SET_SELECT_ALL_STATE](state, data) {
state.selectAllField = data
}
},
[types.VIEW_ESTIMATE](state, estimate) {
state.selectedEstimate = estimate
},
[types.SET_SELECTED_NOTE](state, data) {
state.selectedNote = data
},
[types.RESET_SELECTED_NOTE](state, data) {
state.selectedNote = null
},
}

View File

@ -2,77 +2,111 @@ import * as types from './mutation-types'
export const fetchExpenses = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/expenses`, {params}).then((response) => {
commit(types.SET_EXPENSES, response.data.expenses.data)
commit(types.SET_TOTAL_EXPENSES, response.data.expenses.total)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const fetchCreateExpense = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/expenses/create`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/expenses`, { params })
.then((response) => {
commit(types.SET_EXPENSES, response.data.expenses.data)
commit(types.SET_TOTAL_EXPENSES, response.data.expenseTotalCount)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchExpense = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/expenses/${id}/edit`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/expenses/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const getExpenseReceipt = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/expenses/${id}/show/receipt`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const uploadExpenseReceipt = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post(`/api/v1/expenses/${data.id}/upload/receipts`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addExpense = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/expenses', data).then((response) => {
// commit(types.ADD_EXPENSE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post('/api/v1/expenses', data)
.then((response) => {
commit(types.ADD_EXPENSE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateExpense = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/expenses/${data.id}`, data.editData).then((response) => {
commit(types.UPDATE_EXPENSE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/expenses/${data.id}`, data.editData)
.then((response) => {
commit(types.UPDATE_EXPENSE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteExpense = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/expenses/${id}`).then((response) => {
commit(types.DELETE_EXPENSE, id)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/expenses/delete`, id)
.then((response) => {
commit(types.DELETE_EXPENSE, id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteMultipleExpenses = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/expenses/delete`, {'id': state.selectedExpenses}).then((response) => {
commit(types.DELETE_MULTIPLE_EXPENSES, state.selectedExpenses)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/expenses/delete`, { ids: state.selectedExpenses })
.then((response) => {
commit(types.DELETE_MULTIPLE_EXPENSES, state.selectedExpenses)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -85,7 +119,7 @@ export const selectAllExpenses = ({ commit, dispatch, state }) => {
commit(types.SET_SELECTED_EXPENSES, [])
commit(types.SET_SELECT_ALL_STATE, false)
} else {
let allExpenseIds = state.expenses.map(cust => cust.id)
let allExpenseIds = state.expenses.map((cust) => cust.id)
commit(types.SET_SELECTED_EXPENSES, allExpenseIds)
commit(types.SET_SELECT_ALL_STATE, true)
}

View File

@ -0,0 +1,15 @@
import * as types from './mutation-types'
export const fetchInvoiceTemplates = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/invoices/templates`, { params })
.then((response) => {
commit(types.SET_INVOICE_TEMPLATES, response.data.invoiceTemplates)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -0,0 +1 @@
export const getInvoiceTemplates = (state) => state.invoiceTemplates

View File

@ -3,7 +3,7 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
invoices: []
invoiceTemplates: [],
}
export default {
@ -15,5 +15,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -0,0 +1 @@
export const SET_INVOICE_TEMPLATES = 'SET_INVOICE_TEMPLATES'

View File

@ -0,0 +1,7 @@
import * as types from './mutation-types'
export default {
[types.SET_INVOICE_TEMPLATES](state, templates) {
state.invoiceTemplates = templates
},
}

View File

@ -3,156 +3,181 @@ import * as dashboardTypes from '../dashboard/mutation-types'
export const fetchInvoices = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/invoices`, {params}).then((response) => {
commit(types.SET_INVOICES, response.data.invoices.data)
commit(types.SET_TOTAL_INVOICES, response.data.invoiceTotalCount)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const fetchCreateInvoice = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/invoices/create`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/invoices`, { params })
.then((response) => {
commit(types.SET_INVOICES, response.data.invoices.data)
commit(types.SET_TOTAL_INVOICES, response.data.invoiceTotalCount)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchInvoice = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/invoices/${id}/edit`).then((response) => {
commit(types.SET_TEMPLATE_ID, response.data.invoice.invoice_template_id)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const fetchViewInvoice = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/invoices/${id}`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/invoices/${id}`)
.then((response) => {
commit(types.SET_TEMPLATE_ID, response.data.invoice.invoice_template_id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/send`, data).then((response) => {
if (response.data.success) {
commit(types.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'}, { root: true })
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/invoices/${data.id}/send`, data)
.then((response) => {
if (response.data.success) {
commit(types.UPDATE_INVOICE_STATUS, { id: data.id, status: 'SENT' })
commit(
'dashboard/' + dashboardTypes.UPDATE_INVOICE_STATUS,
{ id: data.id, status: 'SENT' },
{ root: true }
)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
// export const SentEmail = ({ commit, dispatch, state }, invoiceId) => {
// return new Promise((resolve, reject) => {
// window.axios.post(`/api/invoices/sent/${invoiceId}`).then((response) => {
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }
export const addInvoice = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/invoices', data).then((response) => {
commit(types.ADD_INVOICE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post('/api/v1/invoices', data)
.then((response) => {
commit(types.ADD_INVOICE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteInvoice = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/invoices/${id}`).then((response) => {
if (response.data.error) {
resolve(response)
} else {
commit(types.DELETE_INVOICE, id)
commit('dashboard/' + dashboardTypes.DELETE_INVOICE, id, { root: true })
resolve(response)
}
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/invoices/delete`, id)
.then((response) => {
if (response.data.error) {
resolve(response)
} else {
commit(types.DELETE_INVOICE, id)
commit('dashboard/' + dashboardTypes.DELETE_INVOICE, id, {
root: true,
})
resolve(response)
}
})
.catch((err) => {
reject(err)
})
})
}
export const deleteMultipleInvoices = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/delete`, {'id': state.selectedInvoices}).then((response) => {
if (response.data.error) {
resolve(response)
} else {
commit(types.DELETE_MULTIPLE_INVOICES, state.selectedInvoices)
resolve(response)
}
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/invoices/delete`, { ids: state.selectedInvoices })
.then((response) => {
if (response.data.error) {
resolve(response)
} else {
commit(types.DELETE_MULTIPLE_INVOICES, state.selectedInvoices)
resolve(response)
}
})
.catch((err) => {
reject(err)
})
})
}
export const updateInvoice = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/invoices/${data.id}`, data).then((response) => {
if (response.data.invoice) {
commit(types.UPDATE_INVOICE, response.data)
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/invoices/${data.id}`, data)
.then((response) => {
if (response.data.invoice) {
commit(types.UPDATE_INVOICE, response.data)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const markAsSent = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/mark-as-sent`, data).then((response) => {
commit(types.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'}, { root: true })
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/invoices/${data.id}/status`, data)
.then((response) => {
commit(types.UPDATE_INVOICE_STATUS, { id: data.id, status: 'SENT' })
commit(
'dashboard/' + dashboardTypes.UPDATE_INVOICE_STATUS,
{ id: data.id, status: 'SENT' },
{
root: true,
}
)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const cloneInvoice = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/clone`, data).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/invoices/${data.id}/clone`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const searchInvoice = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/invoices?${data}`).then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/invoices?${data}`)
.then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const getInvoiceNumber = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/next-number?key=invoice`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -174,7 +199,7 @@ export const selectAllInvoices = ({ commit, dispatch, state }) => {
commit(types.SET_SELECTED_INVOICES, [])
commit(types.SET_SELECT_ALL_STATE, false)
} else {
let allInvoiceIds = state.invoices.map(inv => inv.id)
let allInvoiceIds = state.invoices.map((inv) => inv.id)
commit(types.SET_SELECTED_INVOICES, allInvoiceIds)
commit(types.SET_SELECT_ALL_STATE, true)
}
@ -201,16 +226,37 @@ export const setTemplate = ({ commit, dispatch, state }, data) => {
export const selectCustomer = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/customers/${id}`).then((response) => {
commit(types.RESET_SELECTED_CUSTOMER)
commit(types.SELECT_CUSTOMER, response.data.customer)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/customers/${id}`)
.then((response) => {
commit(types.RESET_SELECTED_CUSTOMER)
commit(types.SELECT_CUSTOMER, response.data.customer)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const resetSelectedCustomer = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_CUSTOMER)
}
export const setItem = ({ commit, dispatch, state }, data) => {
commit(types.RESET_ITEM)
commit(types.SET_ITEM, data)
}
export const resetItem = ({ commit, dispatch, state }) => {
commit(types.RESET_ITEM)
}
export const selectNote = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_NOTE)
commit(types.SET_SELECTED_NOTE, data.notes)
}
export const resetSelectedNote = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_NOTE)
}

View File

@ -4,7 +4,9 @@ export const getTemplateId = (state) => state.invoiceTemplateId
export const selectedInvoices = (state) => state.selectedInvoices
export const totalInvoices = (state) => state.totalInvoices
export const selectedCustomer = (state) => state.selectedCustomer
export const selectedNote = (state) => state.selectedNote
export const selectedItem = (state) => state.selectedItem
export const getInvoice = (state) => (id) => {
let invId = parseInt(id)
return state.invoices.find(invoice => invoice.id === invId)
return state.invoices.find((invoice) => invoice.id === invId)
}

View File

@ -8,7 +8,9 @@ const initialState = {
selectedInvoices: [],
selectAllField: false,
totalInvoices: 0,
selectedCustomer: null
selectedCustomer: null,
selectedNote: null,
selectedItem: null,
}
export default {
@ -20,5 +22,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -5,13 +5,21 @@ export const DELETE_INVOICE = 'DELETE_INVOICE'
export const DELETE_MULTIPLE_INVOICES = 'DELETE_MULTIPLE_INVOICES'
export const SET_SELECTED_INVOICES = 'SET_SELECTED_INVOICES'
export const SET_TOTAL_INVOICES = 'SET_TOTAL_INVOICES'
export const RESET_CUSTOMER = 'RESET_CUSTOMER'
export const RESET_ITEM = 'RESET_ITEM'
export const SET_CUSTOMER = 'SET_CUSTOMER'
export const RESET_ITEM = 'RESET_ITEM'
export const SET_ITEM = 'SET_ITEM'
export const SET_TEMPLATE_ID = 'SET_TEMPLATE_ID'
export const SELECT_CUSTOMER = 'SELECT_CUSTOMER'
export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER'
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
export const RESET_SELECTED_INVOICES = 'RESET_SELECTED_INVOICES'
export const UPDATE_INVOICE_STATUS = 'UPDATE_INVOICE_STATUS'
export const RESET_SELECTED_NOTE = 'RESET_SELECTED_NOTE'
export const SET_SELECTED_NOTE = 'SET_SELECTED_NOTE'

View File

@ -1,67 +1,85 @@
import * as types from './mutation-types'
export default {
[types.SET_INVOICES] (state, invoices) {
[types.SET_INVOICES](state, invoices) {
state.invoices = invoices
},
[types.SET_TOTAL_INVOICES] (state, totalInvoices) {
[types.SET_TOTAL_INVOICES](state, totalInvoices) {
state.totalInvoices = totalInvoices
},
[types.ADD_INVOICE] (state, data) {
[types.ADD_INVOICE](state, data) {
state.invoices.push(data)
},
[types.DELETE_INVOICE] (state, id) {
let index = state.invoices.findIndex(invoice => invoice.id === id)
[types.DELETE_INVOICE](state, data) {
let index = state.invoices.findIndex((invoice) => invoice.id === data.id)
state.invoices.splice(index, 1)
},
[types.SET_SELECTED_INVOICES] (state, data) {
[types.SET_SELECTED_INVOICES](state, data) {
state.selectedInvoices = data
},
[types.UPDATE_INVOICE] (state, data) {
let pos = state.invoices.findIndex(invoice => invoice.id === data.invoice.id)
[types.UPDATE_INVOICE](state, data) {
let pos = state.invoices.findIndex(
(invoice) => invoice.id === data.invoice.id
)
state.invoices[pos] = data.invoice
},
[types.UPDATE_INVOICE_STATUS] (state, data) {
let pos = state.invoices.findIndex(invoice => invoice.id === data.id)
[types.UPDATE_INVOICE_STATUS](state, data) {
let pos = state.invoices.findIndex((invoice) => invoice.id === data.id)
if (state.invoices[pos]) {
state.invoices[pos].status = data.status
}
},
[types.RESET_SELECTED_INVOICES] (state, data) {
[types.RESET_SELECTED_INVOICES](state, data) {
state.selectedInvoices = []
state.selectAllField = false
},
[types.DELETE_MULTIPLE_INVOICES] (state, selectedInvoices) {
[types.DELETE_MULTIPLE_INVOICES](state, selectedInvoices) {
selectedInvoices.forEach((invoice) => {
let index = state.invoices.findIndex(_inv => _inv.id === invoice.id)
let index = state.invoices.findIndex((_inv) => _inv.id === invoice.id)
state.invoices.splice(index, 1)
})
state.selectedInvoices = []
},
[types.SET_TEMPLATE_ID] (state, templateId) {
[types.SET_TEMPLATE_ID](state, templateId) {
state.invoiceTemplateId = templateId
},
[types.SELECT_CUSTOMER] (state, data) {
[types.SELECT_CUSTOMER](state, data) {
state.selectedCustomer = data
},
[types.RESET_SELECTED_CUSTOMER] (state, data) {
[types.RESET_SELECTED_CUSTOMER](state, data) {
state.selectedCustomer = null
},
[types.SET_SELECT_ALL_STATE] (state, data) {
[types.SET_SELECT_ALL_STATE](state, data) {
state.selectAllField = data
}
},
[types.RESET_SELECTED_NOTE](state, data) {
state.selectedNote = null
},
[types.SET_SELECTED_NOTE](state, data) {
state.selectedNote = data
},
[types.RESET_ITEM](state, data) {
state.selectedItem = null
},
[types.SET_ITEM](state, data) {
state.selectedItem = data
},
}

View File

@ -2,67 +2,85 @@ import * as types from './mutation-types'
export const fetchItems = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/items`, {params}).then((response) => {
commit(types.BOOTSTRAP_ITEMS, response.data.items.data)
commit(types.SET_TOTAL_ITEMS, response.data.items.total)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/items`, { params })
.then((response) => {
commit(types.BOOTSTRAP_ITEMS, response.data.items.data)
commit(types.SET_TOTAL_ITEMS, response.data.itemTotalCount)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchItem = ({ commit, dispatch }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/items/${id}/edit`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/items/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addItem = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/items', data).then((response) => {
commit(types.ADD_ITEM, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post('/api/v1/items', data)
.then((response) => {
commit(types.ADD_ITEM, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateItem = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/items/${data.id}`, data).then((response) => {
commit(types.UPDATE_ITEM, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/items/${data.id}`, data)
.then((response) => {
commit(types.UPDATE_ITEM, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteItem = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/items/${id}`).then((response) => {
commit(types.DELETE_ITEM, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/items/delete`, id)
.then((response) => {
commit(types.DELETE_ITEM, id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteMultipleItems = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/items/delete`, {'id': state.selectedItems}).then((response) => {
commit(types.DELETE_MULTIPLE_ITEMS, state.selectedItems)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/items/delete`, { ids: state.selectedItems })
.then((response) => {
commit(types.DELETE_MULTIPLE_ITEMS, state.selectedItems)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -75,7 +93,7 @@ export const selectAllItems = ({ commit, dispatch, state }) => {
commit(types.SET_SELECTED_ITEMS, [])
commit(types.SET_SELECT_ALL_STATE, false)
} else {
let allItemIds = state.items.map(item => item.id)
let allItemIds = state.items.map((item) => item.id)
commit(types.SET_SELECTED_ITEMS, allItemIds)
commit(types.SET_SELECT_ALL_STATE, true)
}
@ -92,56 +110,71 @@ export const selectItem = ({ commit, dispatch, state }, data) => {
export const addItemUnit = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/units`, data).then((response) => {
commit(types.ADD_ITEM_UNIT, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/units`, data)
.then((response) => {
commit(types.ADD_ITEM_UNIT, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateItemUnit = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/units/${data.id}`, data).then((response) => {
commit(types.UPDATE_ITEM_UNIT, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/units/${data.id}`, data)
.then((response) => {
commit(types.UPDATE_ITEM_UNIT, response.data.unit)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchItemUnits = ({ commit, dispatch, state }) => {
export const fetchItemUnits = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/units`).then((response) => {
commit(types.SET_ITEM_UNITS, response.data.units)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/units`, { params })
.then((response) => {
commit(types.SET_ITEM_UNITS, response.data.units.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fatchItemUnit = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/units/${id}`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/units/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteItemUnit = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/units/${id}`).then((response) => {
if (!response.data.error) {
commit(types.DELETE_ITEM_UNIT, id)
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.delete(`/api/v1/units/${id}`)
.then((response) => {
if (!response.data.error) {
commit(types.DELETE_ITEM_UNIT, id)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -1,62 +1,61 @@
import * as types from './mutation-types'
export default {
[types.BOOTSTRAP_ITEMS] (state, items) {
[types.BOOTSTRAP_ITEMS](state, items) {
state.items = items
},
[types.SET_TOTAL_ITEMS] (state, totalItems) {
[types.SET_TOTAL_ITEMS](state, totalItems) {
state.totalItems = totalItems
},
[types.ADD_ITEM] (state, data) {
[types.ADD_ITEM](state, data) {
state.items.push(data.item)
},
[types.UPDATE_ITEM] (state, data) {
let pos = state.items.findIndex(item => item.id === data.item.id)
[types.UPDATE_ITEM](state, data) {
let pos = state.items.findIndex((item) => item.id === data.item.id)
state.items[pos] = data.item
},
[types.DELETE_ITEM] (state, id) {
let index = state.items.findIndex(item => item.id === id)
[types.DELETE_ITEM](state, id) {
let index = state.items.findIndex((item) => item.id === id)
state.items.splice(index, 1)
},
[types.DELETE_MULTIPLE_ITEMS] (state, selectedItems) {
[types.DELETE_MULTIPLE_ITEMS](state, selectedItems) {
selectedItems.forEach((item) => {
let index = state.items.findIndex(_item => _item.id === item.id)
let index = state.items.findIndex((_item) => _item.id === item.id)
state.items.splice(index, 1)
})
state.selectedItems = []
},
[types.SET_SELECTED_ITEMS] (state, data) {
[types.SET_SELECTED_ITEMS](state, data) {
state.selectedItems = data
},
[types.SET_SELECT_ALL_STATE] (state, data) {
[types.SET_SELECT_ALL_STATE](state, data) {
state.selectAllField = data
},
[types.ADD_ITEM_UNIT] (state, data) {
state.itemUnits = [data.unit, ...state.itemUnits]
[types.ADD_ITEM_UNIT](state, data) {
state.itemUnits.push(data.unit)
},
[types.SET_ITEM_UNITS] (state, data) {
state.itemUnits = data
[types.SET_ITEM_UNITS](state, itemUnits) {
state.itemUnits = itemUnits
},
[types.DELETE_ITEM_UNIT] (state, id) {
let index = state.itemUnits.findIndex(unit => unit.id === id)
[types.DELETE_ITEM_UNIT](state, id) {
let index = state.itemUnits.findIndex((unit) => unit.id === id)
state.itemUnits.splice(index, 1)
},
[types.UPDATE_ITEM_UNIT] (state, data) {
let pos = state.itemUnits.findIndex(unit => unit.id === data.unit.id)
state.itemUnits.splice(pos, 1)
state.itemUnits = [data.unit, ...state.itemUnits]
}
[types.UPDATE_ITEM_UNIT](state, unit) {
let pos = state.itemUnits.findIndex((unit) => unit.id === unit.id)
state.itemUnits[pos] = unit
},
}

View File

@ -13,6 +13,14 @@ export const openModal = ({ commit, dispatch, state }, payload) => {
commit(types.SET_DATA, payload.data)
}
if (payload.refreshData) {
commit(types.SET_REFRESH_DATA, payload.refreshData)
}
if (payload.variant) {
commit(types.SET_VARIANT, payload.variant)
}
if (payload.size) {
commit(types.SET_SIZE, payload.size)
}

View File

@ -1,6 +1,8 @@
export const modalActive = state => state.active
export const modalTitle = state => state.title
export const componentName = state => state.componentName
export const modalDataID = state => state.id
export const modalData = state => state.data
export const modalSize = state => state.size
export const modalActive = (state) => state.active
export const modalTitle = (state) => state.title
export const componentName = (state) => state.componentName
export const modalDataID = (state) => state.id
export const modalData = (state) => state.data
export const modalSize = (state) => state.size
export const refreshData = (state) => state.refreshData
export const variant = (state) => state.variant

View File

@ -9,7 +9,9 @@ const initialState = {
componentName: '',
id: '',
size: 'md',
data: null
data: null,
refreshData: null,
variant: '',
}
export default {
@ -21,5 +23,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -6,3 +6,5 @@ export const SET_ID = 'SET_ID'
export const SET_SIZE = 'SET_SIZE'
export const SET_DATA = 'SET_DATA'
export const RESET_DATA = 'RESET_DATA'
export const SET_REFRESH_DATA = 'SET_REFRESH_DATA'
export const SET_VARIANT = 'SET_VARIANT'

View File

@ -1,40 +1,48 @@
import * as types from './mutation-types'
export default {
[types.SHOW_MODAL] (state, data) {
[types.SHOW_MODAL](state, data) {
state.active = data
},
[types.HIDE_MODAL] (state, data) {
[types.HIDE_MODAL](state, data) {
state.active = data
},
[types.SET_TITLE] (state, data) {
[types.SET_TITLE](state, data) {
state.title = data
},
[types.SET_COMPONENT_NAME] (state, data) {
[types.SET_COMPONENT_NAME](state, data) {
state.componentName = data
},
[types.SET_ID] (state, data) {
[types.SET_ID](state, data) {
state.id = data
},
[types.SET_DATA] (state, data) {
[types.SET_DATA](state, data) {
state.data = data
},
[types.SET_SIZE] (state, size) {
[types.SET_SIZE](state, size) {
state.size = size
},
[types.RESET_DATA] (state) {
state.active = false
[types.SET_REFRESH_DATA](state, refreshData) {
state.refreshData = refreshData
},
[types.RESET_DATA](state) {
state.content = ''
state.title = ''
state.componentName = ''
state.id = ''
state.data = null
}
state.refreshData = null
},
[types.SET_VARIANT](state, data) {
state.variant = data
},
}

View File

@ -0,0 +1,70 @@
import * as types from './mutation-types'
export const fetchNotes = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/notes`, { params })
.then((response) => {
commit(types.BOOTSTRAP_NOTES, response.data.notes.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchNote = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/v1/notes/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addNote = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.post('/api/v1/notes', data)
.then((response) => {
commit(types.ADD_NOTE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updateNote = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios
.put(`/api/v1/notes/${data.id}`, data)
.then((response) => {
commit(types.UPDATE_NOTE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteNote = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios
.delete(`/api/v1/notes/${id}`)
.then((response) => {
commit(types.DELETE_NOTE, id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}

View File

@ -0,0 +1 @@
export const notes = (state) => state.notes

View File

@ -3,7 +3,7 @@ import * as actions from './actions'
import * as getters from './getters'
const initialState = {
report: []
notes: [],
}
export default {
@ -15,5 +15,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -0,0 +1,4 @@
export const BOOTSTRAP_NOTES = 'BOOTSTRAP_NOTES'
export const ADD_NOTE = 'ADD_NOTE'
export const UPDATE_NOTE = 'UPDATE_NOTE'
export const DELETE_NOTE = 'DELETE_NOTE'

View File

@ -0,0 +1,22 @@
import * as types from './mutation-types'
export default {
[types.BOOTSTRAP_NOTES](state, notes) {
state.notes = notes
},
[types.ADD_NOTE](state, data) {
state.notes.push(data.note)
},
[types.UPDATE_NOTE](state, data) {
let pos = state.notes.findIndex((note) => note.id === data.note.id)
state.notes[pos] = data.note
},
[types.DELETE_NOTE](state, id) {
let index = state.notes.findIndex((note) => note.id === id)
state.notes.splice(index, 1)
},
}

View File

@ -2,53 +2,42 @@ import * as types from './mutation-types'
export const fetchPayments = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payments`, {params}).then((response) => {
commit(types.SET_PAYMENTS, response.data.payments.data)
commit(types.SET_TOTAL_PAYMENTS, response.data.payments.total)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/payments`, { params })
.then((response) => {
commit(types.SET_PAYMENTS, response.data.payments.data)
commit(types.SET_TOTAL_PAYMENTS, response.data.paymentTotalCount)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchPayment = ({ commit, dispatch }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payments/${id}`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const fetchEditPaymentData = ({ commit, dispatch }, id) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payments/${id}/edit`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const fetchCreatePayment = ({ commit, dispatch }, page) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payments/create`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/payments/${id}`)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const addPayment = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/payments', data).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post('/api/v1/payments', data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -67,33 +56,42 @@ export const selectPayment = ({ commit, dispatch, state }, data) => {
export const updatePayment = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/payments/${data.id}`, data.editData).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const deletePayment = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/payments/${id}`).then((response) => {
commit(types.DELETE_PAYMENT, id)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/payments/${data.id}`, data.editData)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deleteMultiplePayments = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/payments/delete`, {'id': state.selectedPayments}).then((response) => {
commit(types.DELETE_MULTIPLE_PAYMENTS, state.selectedPayments)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/payments/delete`, { ids: state.selectedPayments })
.then((response) => {
commit(types.DELETE_MULTIPLE_PAYMENTS, state.selectedPayments)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deletePayment = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios
.post(`/api/v1/payments/delete`, id)
.then((response) => {
commit(types.DELETE_PAYMENT, id)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
@ -102,7 +100,7 @@ export const selectAllPayments = ({ commit, dispatch, state }) => {
commit(types.SET_SELECTED_PAYMENTS, [])
commit(types.SET_SELECT_ALL_STATE, false)
} else {
let allPaymentIds = state.payments.map(pay => pay.id)
let allPaymentIds = state.payments.map((pay) => pay.id)
commit(types.SET_SELECTED_PAYMENTS, allPaymentIds)
commit(types.SET_SELECT_ALL_STATE, true)
}
@ -110,77 +108,107 @@ export const selectAllPayments = ({ commit, dispatch, state }) => {
export const addPaymentMode = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/payment-methods`, data).then((response) => {
commit(types.ADD_PAYMENT_MODE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/payment-methods`, data)
.then((response) => {
commit(types.ADD_PAYMENT_MODE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const updatePaymentMode = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/payment-methods/${data.id}`, data).then((response) => {
commit(types.UPDATE_PAYMENT_MODE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.put(`/api/v1/payment-methods/${data.id}`, data)
.then((response) => {
commit(types.UPDATE_PAYMENT_MODE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchPaymentModes = ({ commit, dispatch, state }, data) => {
export const fetchPaymentModes = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payment-methods`, data).then((response) => {
commit(types.SET_PAYMENT_MODES, response.data.paymentMethods)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/payment-methods`, { params })
.then((response) => {
commit(types.SET_PAYMENT_MODES, response.data.paymentMethods.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const fetchPaymentMode = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payment-methods/${data.id}`, data).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/payment-methods/${data.id}`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const deletePaymentMode = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/payment-methods/${id}`).then((response) => {
if (!response.data.error) {
commit(types.DELETE_PAYMENT_MODE, id)
}
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.delete(`/api/v1/payment-methods/${id}`)
.then((response) => {
if (!response.data.error) {
commit(types.DELETE_PAYMENT_MODE, id)
}
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/payments/send`, data).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.post(`/api/v1/payments/${data.id}/send`, data)
.then((response) => {
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const searchPayment = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/payments?${data}`).then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
window.axios
.get(`/api/v1/payments?${data}`)
.then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
})
.catch((err) => {
reject(err)
})
})
}
export const selectNote = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_NOTE)
commit(types.SET_SELECTED_NOTE, data.notes)
}
export const resetSelectedNote = ({ commit, dispatch, state }, data) => {
commit(types.RESET_SELECTED_NOTE)
}

View File

@ -3,3 +3,4 @@ export const selectedPayments = (state) => state.selectedPayments
export const selectAllField = (state) => state.selectAllField
export const totalPayments = (state) => state.totalPayments
export const paymentModes = (state) => state.paymentModes
export const selectedNote = (state) => state.selectedNote

View File

@ -7,7 +7,8 @@ const initialState = {
totalPayments: 0,
selectAllField: false,
selectedPayments: [],
paymentModes: []
paymentModes: [],
selectedNote: null,
}
export default {
@ -19,5 +20,5 @@ export default {
actions: actions,
mutations: mutations
mutations: mutations,
}

View File

@ -10,3 +10,6 @@ export const ADD_PAYMENT_MODE = 'ADD_PAYMENT_MODE'
export const DELETE_PAYMENT_MODE = 'DELETE_PAYMENT_MODE'
export const SET_PAYMENT_MODES = 'SET_PAYMENT_MODES'
export const UPDATE_PAYMENT_MODE = 'UPDATE_PAYMENT_MODE'
export const RESET_SELECTED_NOTE = 'RESET_SELECTED_NOTE'
export const SET_SELECTED_NOTE = 'SET_SELECTED_NOTE'

View File

@ -1,56 +1,67 @@
import * as types from './mutation-types'
export default {
[types.SET_PAYMENTS] (state, payments) {
[types.SET_PAYMENTS](state, payments) {
state.payments = payments
},
[types.SET_TOTAL_PAYMENTS] (state, totalPayments) {
[types.SET_TOTAL_PAYMENTS](state, totalPayments) {
state.totalPayments = totalPayments
},
[types.ADD_PAYMENT] (state, data) {
[types.ADD_PAYMENT](state, data) {
state.payments.push(data)
},
[types.DELETE_PAYMENT] (state, id) {
let index = state.payments.findIndex(payment => payment.id === id)
[types.DELETE_PAYMENT](state, id) {
let index = state.payments.findIndex((payment) => payment.id === id)
state.payments.splice(index, 1)
},
[types.DELETE_MULTIPLE_PAYMENTS] (state, selectedPayments) {
[types.DELETE_MULTIPLE_PAYMENTS](state, selectedPayments) {
selectedPayments.forEach((payment) => {
let index = state.payments.findIndex(_inv => _inv.id === payment.id)
let index = state.payments.findIndex((_inv) => _inv.id === payment.id)
state.payments.splice(index, 1)
})
state.selectedPayments = []
},
[types.SET_SELECTED_PAYMENTS] (state, data) {
[types.SET_SELECTED_PAYMENTS](state, data) {
state.selectedPayments = data
},
[types.SET_SELECT_ALL_STATE] (state, data) {
[types.SET_SELECT_ALL_STATE](state, data) {
state.selectAllField = data
},
[types.SET_PAYMENT_MODES] (state, data) {
[types.SET_PAYMENT_MODES](state, data) {
state.paymentModes = data
},
[types.ADD_PAYMENT_MODE] (state, data) {
[types.ADD_PAYMENT_MODE](state, data) {
state.paymentModes = [data.paymentMethod, ...state.paymentModes]
},
[types.DELETE_PAYMENT_MODE] (state, id) {
let index = state.paymentModes.findIndex(paymentMethod => paymentMethod.id === id)
[types.DELETE_PAYMENT_MODE](state, id) {
let index = state.paymentModes.findIndex(
(paymentMethod) => paymentMethod.id === id
)
state.paymentModes.splice(index, 1)
},
[types.UPDATE_PAYMENT_MODE] (state, data) {
let pos = state.paymentModes.findIndex(paymentMethod => paymentMethod.id === data.paymentMethod.id)
state.paymentModes.splice(pos, 1)
state.paymentModes = [data.paymentMethod, ...state.paymentModes]
}
[types.UPDATE_PAYMENT_MODE](state, data) {
let pos = state.paymentModes.findIndex(
(paymentMethod) => paymentMethod.id === data.paymentMethod.id
)
state.paymentModes[pos] = data.paymentMethod
},
[types.RESET_SELECTED_NOTE](state, data) {
state.selectedNote = null
},
[types.SET_SELECTED_NOTE](state, data) {
state.selectedNote = data
},
}

View File

@ -1,12 +0,0 @@
import * as types from './mutation-types'
export const loadEstimateData = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios.get('/api/report/estimate').then((response) => {
commit(types.SET_ESTIMATES, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -1 +0,0 @@
export const estimates = (state) => state.estimates

View File

@ -1 +0,0 @@
export const SET_ESTIMATES = 'SET_ESTIMATES'

View File

@ -1,7 +0,0 @@
import * as types from './mutation-types'
export default {
[types.SET_ESTIMATES] (state, data) {
state.estimates = data.estimates
}
}

View File

@ -1,11 +0,0 @@
import * as types from './mutation-types'
export const loadExpensesLink = ({ commit, dispatch, state }, url) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/reports/expenses/link`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -1,5 +0,0 @@
import * as types from './mutation-types'
export default {
}

View File

@ -1,12 +0,0 @@
import * as types from './mutation-types'
export const loadInvoiceData = ({ commit, dispatch, state },data) => {
return new Promise((resolve, reject) => {
window.axios.post('/api/report/invoice', data).then((response) => {
commit(types.SET_INVOICES, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -1 +0,0 @@
export const invoices = (state) => state.invoices

View File

@ -1 +0,0 @@
export const SET_INVOICES = 'SET_INVOICES'

View File

@ -1,7 +0,0 @@
import * as types from './mutation-types'
export default {
[types.SET_INVOICES] (state, data) {
state.invoices = data.invoices
}
}

View File

@ -1,11 +0,0 @@
import * as types from './mutation-types'
export const loadProfitLossLink = ({ commit, dispatch, state }, url) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/reports/profit-loss/link`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -1,5 +0,0 @@
import * as types from './mutation-types'
export default {
}

View File

@ -1,21 +0,0 @@
import * as types from './mutation-types'
export const loadLinkByCustomer = ({ commit, dispatch, state }, url) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/reports/sales/customers/link`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const loadLinkByItems = ({ commit, dispatch, state }, url) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/reports/sales/items/link`).then((response) => {
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -1,19 +0,0 @@
import mutations from './mutations'
import * as actions from './actions'
import * as getters from './getters'
const initialState = {
report: null
}
export default {
namespaced: true,
state: initialState,
getters: getters,
actions: actions,
mutations: mutations
}

Some files were not shown because too many files have changed in this diff Show More