Skip to content

Commit

Permalink
replace downpay
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuiantw1212 committed May 10, 2024
1 parent e3d82d3 commit 47f5fbd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 59 deletions.
47 changes: 0 additions & 47 deletions components/calculator/dataCenter.vue

This file was deleted.

24 changes: 13 additions & 11 deletions components/calculator/mortgage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="已備頭期款">
<el-input-number v-model="mortgage.downpay" :min="0" :step="200000" required
@change="calculateMortgage({ setTotalPrice: true })" />
<el-form-item label="已備資產">
<el-text>
{{ Number(asset.presentAsset).toLocaleString() }}
</el-text>
</el-form-item>
</el-col>
<el-col :span="12">
Expand Down Expand Up @@ -291,8 +292,9 @@ const mortgage = computed(() => {
const unableToDrawChart = computed(() => {
const { monthlySaving } = props.career
const { irr, } = props.asset
const { downpay, downpayGoal } = mortgage.value
const noPv = !downpay
const { downpayGoal } = mortgage.value
const { presentAsset } = props.asset
const noPv = !presentAsset
const negativePmt = monthlySaving <= 0
const noN = !irr
const noFv = !downpayGoal
Expand Down Expand Up @@ -333,7 +335,6 @@ function calculateTotalPrice() {
const { downpayPercent, downpayGoal } = mortgage.value
if (downpayPercent) {
mortgage.value.totalPrice = Math.floor(downpayGoal / downpayPercent * 100)
// mortgage.value.downpayGoalStep = Math.floor(mortgage.value.totalPrice / 10)
}
}
function calculateTotalPriceEstimated() {
Expand Down Expand Up @@ -373,11 +374,11 @@ function calculateDownpayGoalPercent() {
}
}
function calculateLoanAmount() {
const { totalPrice, downpay } = mortgage.value
if (!totalPrice || !downpay) {
const { totalPrice, downpayGoal } = mortgage.value
if (!totalPrice || !downpayGoal) {
return
}
const loanAmount = totalPrice - downpay
const loanAmount = totalPrice - downpayGoal
mortgage.value.loanAmount = Math.floor(loanAmount)
}
function calculateMonthlyRepay() {
Expand Down Expand Up @@ -408,12 +409,13 @@ function drawDownpayChart(propagate = false) {
}
const { irr, } = props.asset
const { inflationRate, currentYear } = props.config
const { downpay, downpayGoal } = mortgage.value
const { downpayGoal } = mortgage.value
const { presentAsset } = props.asset
const { monthlySaving } = props.career
const irrModifier: number = 1 + irr / 100
const inflationRatio: number = 1 + inflationRate / 100
let pv: number = downpay
let pv: number = presentAsset
let pmt: number = 0
if (monthlySaving) {
pmt = monthlySaving * 12
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/parenting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<el-col :span="12">
<el-form-item label="壽險已備">
<el-input-number v-model="parenting.lifeInsurance" :min="0" :step="100000"
@change="calculateParenting($event)" />
:disabled="!parenting.firstBornYear" @change="calculateParenting($event)" />
</el-form-item>
</el-col>
<el-col :span="12">
Expand Down

0 comments on commit 47f5fbd

Please sign in to comment.