UNPKG

ipink-util

Version:

util.js

2 lines (1 loc) 2.15 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Loan{static t=null;static o(){return Loan.t||(Loan.t=new Loan),Loan.t}constructor(){}l(t){let{i:e=0,m:a,p:n=0,u:o=1}=t;if(!e&&!a)return console.warn("日利率或者年化利率不能为空"),{};a||(a=365*e);let l=new Array,r=0,s=0,i=0,m=n*a/12*.01*o;for(let y=1;y<=o;y++){let t=m/o;r=t,y==o&&(i=n,r=t+n),l[y-1]={h:y,total:r.toFixed(2),F:(r-i).toFixed(2),R:i.toFixed(2),L:(n-i*y).toFixed(2)},s+=r}s=Math.round(100*s)/100;let p=l[0].total,u=""+s;return{I:l,info:{M:parseFloat(p).toFixed(0),A:parseFloat(u).toFixed(0),j:parseFloat(""+m).toFixed(0)}}}v(t){let{i:e=0,m:a,p:n=0,u:o=1}=t;if(!e&&!a)return console.warn("日利率或者年化利率不能为空"),{};a||(a=365*e);let l=new Array,r=0,s=0,i=n/o,m=n*a/12*.01*o;for(let y=1;y<=o;y++){r=i+m/o,l[y-1]={h:y,total:r.toFixed(2),F:(r-i).toFixed(2),R:i.toFixed(2),L:(n-i*y).toFixed(2)},s+=r}s=Math.round(100*s)/100;let p=l[0].total,u=""+s;return{I:l,info:{M:parseFloat(p).toFixed(0),A:parseFloat(u).toFixed(0),j:parseFloat(""+m).toFixed(0)}}}O(t){let{i:e=0,m:a,p:n=0,u:o=1}=t;if(!e&&!a)return console.warn("日利率或者年化利率不能为空"),{};a||(a=365*e);let l=10*a/12*.001,r=new Array,s=0,i=0,m=n/o;for(let c=1;c<=o;c++){s=n/o+(n-n*(c-1)/o)*l,r[c-1]={h:c,total:s.toFixed(2),F:(s-m).toFixed(2),R:m.toFixed(2),L:(n-m*c).toFixed(2)},+(r[c-1].L||0)<=1&&(r[c-1].L=0),i+=s}i=Math.round(100*i)/100;let p=r[0].total,u=i,y=u-n;return{I:r,info:{M:parseFloat(p).toFixed(0),A:parseFloat(""+u).toFixed(0),j:parseFloat(""+y).toFixed(0)}}}S(t){let{i:e=0,m:a,p:n=0,u:o=1}=t;if(!e&&!a)return console.warn("日利率或者年化利率不能为空"),{};a||(a=365*e);let l=10*a/12*.001,r=Math.pow(1+l,o),s=(n*(l*(r/(r-1)))).toFixed(2);a*=.01;let i=a/12,m=new Array,p=0,u=0,y=1;for(y=1;y<=o;y++){m[y-1]={h:y,total:s,F:0,L:0},u=1==y?n:+(m[y-2].L||0),m[y-1].F=(u*i).toFixed(2);let t=+m[y-1].total-+m[y-1].F;m[y-1].R=t.toFixed(2),p+=t;let e=n-p;m[y-1].L=e.toFixed(2),e<=1&&(m[y-1].L=0)}let c=+s*o,h=c-n;return{I:m,info:{M:parseFloat(s).toFixed(0),A:parseFloat(""+c).toFixed(0),j:parseFloat(""+h).toFixed(0)}}}}exports.Loan=Loan;