diff --git a/ui/src/router/views/createExpense.vue b/ui/src/router/views/createExpense.vue index e286d36..e3e17dd 100644 --- a/ui/src/router/views/createExpense.vue +++ b/ui/src/router/views/createExpense.vue @@ -29,6 +29,7 @@ export default { showMore: false, quickEntry: null, myVehicles: [], + users: [], selectedVehicle: this.vehicle, expenseModel: this.expense, processQuickEntry: false, @@ -53,8 +54,10 @@ export default { mounted() { this.myVehicles = this.vehicles this.selectedVehicle = this.vehicle + this.fetchVehicleUsers() if (!this.expense.id) { this.expenseModel = this.getEmptyExpense() + this.expenseModel.userId = this.me.id } }, methods: { @@ -66,20 +69,25 @@ export default { odoReading: '', date: new Date(), comments: '', + userId: '', } }, - + fetchVehicleUsers() { + store + .dispatch('vehicles/fetchUsersByVehicleId', { vehicleId: this.selectedVehicle.id }) + .then((data) => { + this.users = data + }) + .catch((err) => console.log(err)) + }, createExpense() { this.tryingToCreate = true this.expenseModel.vehicleId = this.selectedVehicle.id - this.expenseModel.userId = this.me.id + // this.expenseModel.userId = this.me.id if (this.expense.id) { axios - .put( - `/api/vehicles/${this.selectedVehicle.id}/expenses/${this.expense.id}`, - this.expenseModel - ) + .put(`/api/vehicles/${this.selectedVehicle.id}/expenses/${this.expense.id}`, this.expenseModel) .then((data) => { this.$buefy.toast.open({ message: 'Expense Updated Successfully', @@ -88,9 +96,7 @@ export default { }) this.expenseModel = this.getEmptyExpense() if (this.processQuickEntry) { - store - .dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }) - .then((data) => {}) + store.dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }).then((data) => {}) } }) .catch((ex) => { @@ -115,11 +121,9 @@ export default { }) this.expenseModel = this.getEmptyExpense() if (this.processQuickEntry) { - store - .dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }) - .then((data) => { - this.quickEntry = null - }) + store.dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }).then((data) => { + this.quickEntry = null + }) } }) .catch((ex) => { @@ -145,14 +149,7 @@ export default {

Create Expense

- {{ - [ - selectedVehicle.nickname, - selectedVehicle.registration, - selectedVehicle.make, - selectedVehicle.model, - ].join(' | ') - }} + {{ [selectedVehicle.nickname, selectedVehicle.registration, selectedVehicle.make, selectedVehicle.model].join(' | ') }}

@@ -161,26 +158,21 @@ export default {
- + + + + + + - - + @@ -190,26 +182,13 @@ export default {

{{ me.currency }}

- +

{{ me.distanceUnitDetail.short }}

- +
@@ -221,21 +200,11 @@ export default { - Mark selected Quick Entry as processed + Mark selected Quick Entry as processed
- - +
diff --git a/ui/src/router/views/createFillup.vue b/ui/src/router/views/createFillup.vue index f046945..de14865 100644 --- a/ui/src/router/views/createFillup.vue +++ b/ui/src/router/views/createFillup.vue @@ -32,6 +32,7 @@ export default { showMore: false, quickEntry: null, myVehicles: [], + users: [], selectedVehicle: this.vehicle, fillupModel: this.fillup, processQuickEntry: false, @@ -47,16 +48,10 @@ export default { }, watch: { 'fillupModel.fuelQuantity': function(old, newOne) { - this.fillupModel.totalAmount = round( - this.fillupModel.fuelQuantity * this.fillupModel.perUnitPrice, - 2 - ) + this.fillupModel.totalAmount = round(this.fillupModel.fuelQuantity * this.fillupModel.perUnitPrice, 2) }, 'fillupModel.perUnitPrice': function(old, newOne) { - this.fillupModel.totalAmount = round( - this.fillupModel.fuelQuantity * this.fillupModel.perUnitPrice, - 2 - ) + this.fillupModel.totalAmount = round(this.fillupModel.fuelQuantity * this.fillupModel.perUnitPrice, 2) }, quickEntry: function(newOne, old) { if (old == null && newOne !== null) { @@ -67,11 +62,21 @@ export default { mounted() { this.myVehicles = this.vehicles this.selectedVehicle = this.vehicle + this.fetchVehicleUsers() if (!this.fillup.id) { this.fillupModel = this.getEmptyFillup() + this.fillupModel.userId = this.me.id } }, methods: { + fetchVehicleUsers() { + store + .dispatch('vehicles/fetchUsersByVehicleId', { vehicleId: this.selectedVehicle.id }) + .then((data) => { + this.users = data + }) + .catch((err) => console.log(err)) + }, getEmptyFillup() { return { vehicleId: this.selectedVehicle.id, @@ -85,18 +90,16 @@ export default { date: new Date(), fillingStation: '', comments: '', + userId: '', } }, async createFillup() { this.tryingToCreate = true this.fillupModel.vehicleId = this.selectedVehicle.id - this.fillupModel.userId = this.me.id + // this.fillupModel.userId = this.me.id if (this.fillup.id) { axios - .put( - `/api/vehicles/${this.selectedVehicle.id}/fillups/${this.fillup.id}`, - this.fillupModel - ) + .put(`/api/vehicles/${this.selectedVehicle.id}/fillups/${this.fillup.id}`, this.fillupModel) .then((data) => { this.$buefy.toast.open({ message: 'Fillup Updated Successfully', @@ -105,11 +108,9 @@ export default { }) this.fillupModel = this.getEmptyFillup() if (this.processQuickEntry) { - store - .dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }) - .then((data) => { - this.quickEntry = null - }) + store.dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }).then((data) => { + this.quickEntry = null + }) } }) .catch((ex) => { @@ -134,9 +135,7 @@ export default { }) this.fillupModel = this.getEmptyFillup() if (this.processQuickEntry) { - store - .dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }) - .then((data) => {}) + store.dispatch('vehicles/setQuickEntryAsProcessed', { id: this.quickEntry.id }).then((data) => {}) } }) .catch((ex) => { @@ -163,14 +162,7 @@ export default {

Create Fillup

- {{ - [ - selectedVehicle.nickname, - selectedVehicle.registration, - selectedVehicle.make, - selectedVehicle.model, - ].join(' | ') - }} + {{ [selectedVehicle.nickname, selectedVehicle.registration, selectedVehicle.make, selectedVehicle.model].join(' | ') }}

@@ -180,37 +172,24 @@ export default {
- + + + + + + - - + - +

{{ me.currency }}

- +

{{ me.distanceUnitDetail.short }}

- +
Did you get a full tank? - Did you miss the fillup entry before this one? + Did you miss the fillup entry before this one? Fill more details @@ -275,21 +232,11 @@ export default { - Mark selected Quick Entry as processed + Mark selected Quick Entry as processed
- - +

There was an error logging in to your account.