mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 20:21:10 -04:00
Fix Invoice/Estimate template issues and Add Payment Receipt, Custom Payment Modes and Item units
This commit is contained in:
committed by
Mohit Panjwani
parent
56a955befd
commit
4c33a5d88c
@ -4,6 +4,8 @@ import * as userTypes from './modules/user/mutation-types'
|
||||
import * as companyTypes from './modules/company/mutation-types'
|
||||
import * as preferencesTypes from './modules/settings/preferences/mutation-types'
|
||||
import * as taxTypeTypes from './modules/tax-type/mutation-types'
|
||||
import * as itemTypes from './modules/item/mutation-types'
|
||||
import * as paymentModes from './modules/payment/mutation-types'
|
||||
|
||||
export default {
|
||||
bootstrap ({ commit, dispatch, state }) {
|
||||
@ -17,6 +19,8 @@ export default {
|
||||
commit('taxType/' + taxTypeTypes.BOOTSTRAP_TAX_TYPES, response.data.taxTypes)
|
||||
commit('preferences/' + preferencesTypes.SET_MOMENT_DATE_FORMAT, response.data.moment_date_format)
|
||||
commit('preferences/' + preferencesTypes.SET_LANGUAGE_FORMAT, response.data.default_language)
|
||||
commit('item/' + itemTypes.SET_ITEM_UNITS, response.data.units)
|
||||
commit('payment/' + paymentModes.SET_PAYMENT_MODES, response.data.paymentMethods)
|
||||
commit(types.UPDATE_APP_LOADING_STATUS, true)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
|
||||
@ -135,6 +135,16 @@ export const markAsSent = ({ commit, dispatch, state }, data) => {
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const searchInvoice = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/invoices?${data}`).then((response) => {
|
||||
|
||||
@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -6,7 +6,8 @@ const initialState = {
|
||||
items: [],
|
||||
totalItems: 0,
|
||||
selectAllField: false,
|
||||
selectedItems: []
|
||||
selectedItems: [],
|
||||
itemUnits: []
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,9 +12,9 @@ export const fetchPayments = ({ commit, dispatch, state }, params) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchCreatePayment = ({ commit, dispatch }, page) => {
|
||||
export const fetchPayment = ({ commit, dispatch }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/payments/create`).then((response) => {
|
||||
window.axios.get(`/api/payments/${id}`).then((response) => {
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
@ -22,7 +22,7 @@ export const fetchCreatePayment = ({ commit, dispatch }, page) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchPayment = ({ commit, dispatch }, id) => {
|
||||
export const fetchEditPaymentData = ({ commit, dispatch }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/payments/${id}/edit`).then((response) => {
|
||||
resolve(response)
|
||||
@ -32,6 +32,16 @@ export const fetchPayment = ({ commit, dispatch }, id) => {
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const addPayment = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.post('/api/payments', data).then((response) => {
|
||||
@ -97,3 +107,78 @@ export const selectAllPayments = ({ commit, dispatch, state }) => {
|
||||
commit(types.SET_SELECT_ALL_STATE, true)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchPaymentModes = ({ commit, dispatch, state }, data) => {
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const deletePaymentMode = ({ commit, dispatch, state }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.delete(`/api/payment-methods/${id}`).then((response) => {
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -2,3 +2,4 @@ export const payments = (state) => state.payments
|
||||
export const selectedPayments = (state) => state.selectedPayments
|
||||
export const selectAllField = (state) => state.selectAllField
|
||||
export const totalPayments = (state) => state.totalPayments
|
||||
export const paymentModes = (state) => state.paymentModes
|
||||
|
||||
@ -6,7 +6,8 @@ const initialState = {
|
||||
payments: [],
|
||||
totalPayments: 0,
|
||||
selectAllField: false,
|
||||
selectedPayments: []
|
||||
selectedPayments: [],
|
||||
paymentModes: []
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@ -6,3 +6,7 @@ export const DELETE_MULTIPLE_PAYMENTS = 'DELETE_MULTIPLE_PAYMENTS'
|
||||
export const SET_SELECTED_PAYMENTS = 'SET_SELECTED_PAYMENTS'
|
||||
export const SET_TOTAL_PAYMENTS = 'SET_TOTAL_PAYMENTS'
|
||||
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
|
||||
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'
|
||||
|
||||
@ -33,5 +33,25 @@ export default {
|
||||
|
||||
[types.SET_SELECT_ALL_STATE] (state, data) {
|
||||
state.selectAllField = data
|
||||
},
|
||||
|
||||
[types.SET_PAYMENT_MODES] (state, data) {
|
||||
state.paymentModes = data
|
||||
},
|
||||
|
||||
[types.ADD_PAYMENT_MODE] (state, data) {
|
||||
state.paymentModes.push(data.paymentMethod)
|
||||
state.paymentModes = [data.paymentMethod, ...state.paymentModes]
|
||||
},
|
||||
|
||||
[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]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user