Fix Invoice/Estimate template issues and Add Payment Receipt, Custom Payment Modes and Item units

This commit is contained in:
Jay Makwana
2020-01-05 07:22:36 +00:00
committed by Mohit Panjwani
parent 56a955befd
commit 4c33a5d88c
112 changed files with 5050 additions and 331 deletions

View File

@ -26,7 +26,6 @@ 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)
@ -90,3 +89,57 @@ export const selectItem = ({ commit, dispatch, state }, data) => {
commit(types.SET_SELECT_ALL_STATE, false)
}
}
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)
})
})
}
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)
})
})
}
export const fetchItemUnits = ({ commit, dispatch, state }) => {
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)
})
})
}
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)
})
})
}
export const deleteItemUnit = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/units/${id}`).then((response) => {
commit(types.DELETE_ITEM_UNIT, id)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -2,3 +2,4 @@ export const items = (state) => state.items
export const selectAllField = (state) => state.selectAllField
export const selectedItems = (state) => state.selectedItems
export const totalItems = (state) => state.totalItems
export const itemUnits = (state) => state.itemUnits

View File

@ -6,7 +6,8 @@ const initialState = {
items: [],
totalItems: 0,
selectAllField: false,
selectedItems: []
selectedItems: [],
itemUnits: []
}
export default {

View File

@ -6,3 +6,7 @@ export const DELETE_MULTIPLE_ITEMS = 'DELETE_MULTIPLE_ITEMS'
export const SET_SELECTED_ITEMS = 'SET_SELECTED_ITEMS'
export const SET_TOTAL_ITEMS = 'SET_TOTAL_ITEMS'
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
export const ADD_ITEM_UNIT = 'ADD_ITEM_UNIT'
export const SET_ITEM_UNITS = 'SET_ITEM_UNITS'
export const UPDATE_ITEM_UNIT = 'UPDATE_ITEM_UNIT'
export const DELETE_ITEM_UNIT = 'DELETE_ITEM_UNIT'

View File

@ -39,6 +39,25 @@ export default {
[types.SET_SELECT_ALL_STATE] (state, data) {
state.selectAllField = data
}
},
[types.ADD_ITEM_UNIT] (state, data) {
state.itemUnits.push(data.unit)
state.itemUnits = [data.unit, ...state.itemUnits]
},
[types.SET_ITEM_UNITS] (state, data) {
state.itemUnits = data
},
[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]
}
}