mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 13:41:09 -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
						Mohit Panjwani
					
				
			
			
				
	
			
			
			
						parent
						
							56a955befd
						
					
				
				
					commit
					4c33a5d88c
				
			| @ -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