- invoice fixes

- optimization for new invoicing module
This commit is contained in:
Peter Papp
2021-05-24 16:47:21 +02:00
parent 26636dffab
commit 8a2af11f6a
9 changed files with 224 additions and 88 deletions
+5 -12
View File
@@ -117,29 +117,22 @@
methods: {
goTo(location) {
let routes = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
if (this.$route.name !== 'InvoicesList') {
this.$router.push({name: 'InvoicesList'})
}
this.$store.dispatch(routes[location])
this.$store.dispatch(...routes[location])
},
},
mounted() {
if (! this.currentFolder) {
this.$store.commit('STORE_CURRENT_FOLDER', {
name: this.$t('in.nav.invoices'),
id: undefined,
location: 'regular-invoice',
})
this.$store.dispatch('getRegularInvoices')
this.$store.dispatch('getInvoices', 'regular-invoice')
}
events.$on('mobile-menu:show', () => this.isScaledDown = true)
@@ -516,6 +516,12 @@
},
'invoice.client_ico': function (val) {
this.getCompanyDetails(val)
},
'isDiscount': function (val) {
if (!val) {
this.invoice.discount_type = undefined
this.invoice.discount_rate = undefined
}
}
},
data() {
@@ -636,10 +642,7 @@
})
// Reload invoices and go to invoice page
this.$store.dispatch({
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
}[this.invoice.invoice_type])
this.$store.dispatch('getInvoices', this.invoice.invoice_type)
this.$router.push({name: 'InvoicesList'})
})
@@ -416,6 +416,14 @@
return total
}
},
watch: {
'isDiscount': function (val) {
if (!val) {
this.invoice.discount_type = undefined
this.invoice.discount_rate = undefined
}
}
},
data() {
return {
fullDetails: undefined,
@@ -498,10 +506,7 @@
.put(`/api/v1/invoicing/invoices/${this.$route.params.id}`, this.invoice)
.then(() => {
this.$store.dispatch({
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
}[this.invoice.invoice_type])
this.$store.dispatch('getInvoices', this.invoice.invoice_type)
this.$router.push({name: 'InvoicesList'})
@@ -35,11 +35,11 @@ export default {
methods: {
showLocation(location) {
let routes = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
this.$store.dispatch(routes[location])
this.$store.dispatch(...routes[location])
}
}
}
+9 -9
View File
@@ -22,7 +22,7 @@ const OasisHelpers = {
location: 'regular-invoice',
})
store.dispatch('getRegularInvoices')
store.dispatch('getInvoices', 'regular-invoice')
}
Vue.prototype.$getInvoiceDataByLocation = function () {
@@ -32,12 +32,12 @@ const OasisHelpers = {
: undefined
let actions = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
store.dispatch(actions[currentLocation])
store.dispatch(...actions[currentLocation])
}
Vue.prototype.$shareInvoice = function (entry) {
@@ -98,12 +98,12 @@ const OasisHelpers = {
} else if (typeof value !== 'undefined') {
let locations = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
store.dispatch(locations[store.getters.currentFolder.location])
store.dispatch(...locations[store.getters.currentFolder.location])
store.commit('CHANGE_SEARCHING_STATE', false)
}
+7 -24
View File
@@ -10,38 +10,19 @@ const defaultState = {
}
const actions = {
getRegularInvoices: ({commit, getters}) => {
getInvoices: ({commit, getters}, type) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Invoices',
id: undefined,
location: 'regular-invoice',
location: type,
})
axios
.get('/api/v1/invoicing/invoices/regular' + getters.invoiceSorting.URI)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
events.$emit('scrollTop')
})
},
getAdvanceInvoices: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Advance Invoices',
id: undefined,
location: 'advance-invoice',
})
let order = getters.invoiceSorting.sorting.sort === 'DESC' ? '-' : ''
axios
.get('/api/v1/invoicing/invoices/advance' + getters.invoiceSorting.URI)
.get(`/api/v1/invoicing/invoices?filter[invoice_type]=${type}&sort=${order}${getters.invoiceSorting.sorting.field}`)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
@@ -61,8 +42,10 @@ const actions = {
location: 'clients',
})
let order = getters.invoiceSorting.sorting.sort === 'DESC' ? '-' : ''
axios
.get('/api/v1/invoicing/clients' + getters.invoiceSorting.URI)
.get(`/api/v1/invoicing/clients?sort=${order}${getters.invoiceSorting.sorting.field}`)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})