Browse Source

Correctly represent fee types in estimates vue

master
Immanuel Onyeka 1 year ago
parent
commit
c566ddb991
3 changed files with 40 additions and 22 deletions
  1. +27
    -13
      components/estimates.vue
  2. +11
    -7
      components/fee-dialog.vue
  3. +2
    -2
      components/new/summary.vue

+ 27
- 13
components/estimates.vue View File

@@ -10,7 +10,7 @@
:key="fee.name + indx" class="fee" :key="fee.name + indx" class="fee"
> >
<label @click="() => edit = fee"> <label @click="() => edit = fee">
${{fee.amount}}{{ fee.perc ? ` ${fee.perc}%` : ''}} - {{fee.name}}<br>
${{fee.amount/100}}{{ fee.perc ? ` ${fee.perc}%` : ''}} - {{fee.name}}<br>
{{fee.type}} {{fee.type}}
</label> </label>
<img width="21" height="21" src="/assets/image/icon/x-red.svg" <img width="21" height="21" src="/assets/image/icon/x-red.svg"
@@ -37,9 +37,13 @@
</div> </div>
</template> </template>


<script>
<script setup>
import { ref, computed, onMounted } from 'vue'
import FeeDialog from "./fee-dialog.vue" import FeeDialog from "./fee-dialog.vue"


const props = defineProps(['user', 'fees'])
let edit = ref(null)

function newFee(fee, isDebit) { function newFee(fee, isDebit) {
this.edit = null this.edit = null
} }
@@ -52,15 +56,25 @@ function remove() {


} }


export default {
props: [ 'user', 'fees' ],
emits: [ 'deleteFee', 'update' ],
components: { FeeDialog },
methods: { newFee, newType, remove },
data() {
return {
edit: null
}
},
}
function getEstimates() {
const token = getCookie("skouter")
return fetch(`/api/estimates`,
{method: 'GET',
headers: {
"Accept": "application/json",
"Authorization": `Bearer ${token}`,
},
}).then(response => {
if (response.ok) { return response.json() }
}).then (result => {
if (!result || !result.length) return // Exit if token is invalid or no fees are saved
this.fees = result
})

}

onMounted(() => {
// getEstimates()
})
</script> </script>

+ 11
- 7
components/fee-dialog.vue View File

@@ -11,21 +11,20 @@
<label>Amount</label> <label>Amount</label>
<input <input
type="" type=""
:value="fee.amount"
@input="(e) => {fee.perc = 0; fee.amount = strip(e)}">
:value="fee.amount / 100 || ''"
@input="(e) => {fee.perc = 0; fee.amount = Math.round(strip(e) * 100)}">


<label>Percentage of price</label> <label>Percentage of price</label>
<input <input
type="" type=""
:value="fee.perc" :value="fee.perc"
@input="(e) => { fee.perc = stripPerc(e);
fee.amount = stripPerc(e)/100*price }">
@input="changePerc">


<select id="" name="" v-model="fee.type"> <select id="" name="" v-model="fee.type">
<option value="Title Company">Title Company</option>
<option value="Title">Title Company</option>
<option value="Government">Government</option> <option value="Government">Government</option>
<option value="Lender">Lender</option> <option value="Lender">Lender</option>
<option value="Services Required by Lender">Required by Lender</option>
<option value="Required">Required by Lender</option>
<option value="Other">Other</option> <option value="Other">Other</option>
</select> </select>


@@ -53,10 +52,15 @@ function validFee() {
return true return true
} }


function changePerc(e){
this.fee.perc = stripPerc(e)
this.fee.amount = stripPerc(e)/100*this.price
}

export default { export default {
components: { Dialog }, components: { Dialog },
methods: { methods: {
stripLetters, strip, stripInt, stripPerc
stripLetters, strip, stripInt, stripPerc, changePerc
}, },
computed: { computed: {
validFee, validFee,


+ 2
- 2
components/new/summary.vue View File

@@ -25,7 +25,7 @@
</section> </section>


<section class="form inputs"> <section class="form inputs">
<button @click="create">Save Estimate</button>
<button :disabled="saved" @click="create">Save Estimate</button>
<button>Generate PDF</button> <button>Generate PDF</button>
</section> </section>


@@ -35,7 +35,7 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
let valid = ref(false) let valid = ref(false)
let saved = ref(true)
let saved = ref(false)
const props = defineProps(['downpayment', 'loan', 'token', 'estimate']) const props = defineProps(['downpayment', 'loan', 'token', 'estimate'])


function amortize(principle, rate, periods) { function amortize(principle, rate, periods) {


Loading…
Cancel
Save