PageSourceSearch

https://jhasolutions.com/assets/LoanAmortizationCalculator-DU4t_mMi.js

js jhasolutions.com collected 2026-09-24 14:47:34 UTC 4,382 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./query-vendor-Dp9tfhuh.js";import{I as j}from"./input-go5takyh.js";import{u as z,L as y}from"./index-CgOeqv80.js";import{S as N}from"./slider-BJvr272o.js";import{u as L}from"./useCurrency-BJBh1UrQ.js";import{T as w,a as F,b as S,c as o,d as B,e as c}from"./table-DCRDDm_8.js";import"./react-vendor-DfslLuwi.js";import"./ui-vendor-DW4RoVmg.js";import"./chart-vendor-BoynbIzZ.js";import"./index-BdQq_4o_.js";const O=()=>{const{t:V}=z(),{formatCurrency:a}=L(),[t,v]=i.useState(5e5),[d,g]=i.useState(6.5),[m,P]=i.useState(10),[x,T]=i.useState(25),n=i.useMemo(()=>{const s=d/100/12,b=x*12,l=t*(s*Math.pow(1+s,b))/(Math.pow(1+s,b)-1),C=m*12;let h=t;for(let r=0;r<C;r++){const u=h*s,p=l-u;h-=p}const I=h>0?h:0,M=l*12,R=l*b-t,A=[];let f=t;for(let r=1;r<=Math.min(12,C);r++){const u=f*s,p=l-u;f-=p,A.push({month:r,payment:l,principal:p,interest:u,balance:Math.max(0,f)})}return{monthlyPayment:l,balloonPayment:I,annualDebtService:M,totalInterest:R,schedule:A}},[t,d,m,x]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"loanAmount",children:"Loan Amount"}),e.jsx(j,{id:"loanAmount",type:"number",value:t,onChange:s=>v(Number(s.target.value)),className:"font-medium"}),e.jsx(N,{value:[t],onValueChange:([s])=>v(s),min:5e4,max:1e7,step:25e3,className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"interestRate",children:"Interest Rate (%)"}),e.jsx(j,{id:"interestRate",type:"number",step:"0.1",value:d,onChange:s=>g(Number(s.target.value)),className:"font-medium"}),e.jsx(N,{value:[d],onValueChange:([s])=>g(s),min:1,max:15,step:.1,className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"loanTerm",children:"Loan Term (Years)"}),e.jsx(j,{id:"loanTerm",type:"number",value:m,onChange:s=>P(Number(s.target.value)),className:"font-medium"}),e.jsx(N,{value:[m],onValueChange:([s])=>P(s),min:1,max:30,step:1,className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"amortizationPeriod",children:"Amortization Period (Years)"}),e.jsx(j,{id:"amortizationPeriod",type:"number",value:x,onChange:s=>T(Number(s.target.value)),className:"font-medium"}),e.jsx(N,{value:[x],onValueChange:([s])=>T(s),min:5,max:40,step:1,className:"mt-2"})]})]}),e.jsxs("div",{className:"mt-8 space-y-4 rounded-lg bg-muted p-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Monthly Payment"}),e.jsx("span",{className:"text-2xl font-bold text-primary",children:a(n.monthlyPayment)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Annual Debt Service"}),e.jsx("span",{className:"text-xl font-semibold",children:a(n.annualDebtService)})]})]}),e.jsxs("div",{className:"border-t pt-4 grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Balloon Payment (Year ",m,")"]}),e.jsx("span",{className:`text-xl font-semibold ${n.balloonPayment>0?"text-yellow-600":"text-green-600"}`,children:a(n.balloonPayment)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Interest"}),e.jsx("span",{className:"text-xl font-semibold",children:a(n.totalInterest)})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Amortization Schedule (First 12 Months)"}),e.jsx("div",{className:"tools-table-scroll max-h-[300px] rounded-md border",children:e.jsxs(w,{className:"!min-w-[640px]",children:[e.jsx(F,{children:e.jsxs(S,{children:[e.jsx(o,{className:"w-20",children:"Month"}),e.jsx(o,{children:"Payment"}),e.jsx(o,{children:"Principal"}),e.jsx(o,{children:"Interest"}),e.jsx(o,{children:"Balance"})]})}),e.jsx(B,{children:n.schedule.map(s=>e.jsxs(S,{children:[e.jsx(c,{className:"font-medium",children:s.month}),e.jsx(c,{children:a(s.payment)}),e.jsx(c,{children:a(s.principal)}),e.jsx(c,{children:a(s.interest)}),e.jsx(c,{children:a(s.balance)})]},s.month))})]})})]})]})};export{O as LoanAmortizationCalculator};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.