ideal-credit 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ideal-credit.mjs +22 -22
- package/dist/ideal-credit.umd.js +1 -1
- package/package.json +1 -1
package/dist/ideal-credit.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const L = ({
|
|
2
2
|
sum: e,
|
|
3
3
|
period: t,
|
|
4
4
|
interest: a,
|
|
5
|
-
startDate: n =
|
|
5
|
+
startDate: n = s(/* @__PURE__ */ new Date()),
|
|
6
6
|
creditRatesToPay: u = 0,
|
|
7
7
|
desiredCreditRate: r = 0,
|
|
8
8
|
desiredTotalRate: c = 0,
|
|
9
9
|
desiredStartRate: _ = 0,
|
|
10
|
-
desiredStartDateToPay:
|
|
10
|
+
desiredStartDateToPay: N = "",
|
|
11
11
|
monthWithoutInterest: f = 0
|
|
12
12
|
} = {}) => {
|
|
13
|
-
let l = {}, h = [], b = 0,
|
|
13
|
+
let l = {}, h = [], b = 0, M = 0, m = 0, w = 0, i = 0;
|
|
14
14
|
r = Number(r), c = Number(c), b = u || t, r > 0 && (c == 0 || !c) ? m = r : m = Math.round(e / b);
|
|
15
15
|
for (let o = 0; o < Number(t); o++) {
|
|
16
16
|
l = {
|
|
@@ -20,34 +20,34 @@ const V = ({
|
|
|
20
20
|
dobinda_rata: 0,
|
|
21
21
|
total_rata: 0
|
|
22
22
|
};
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
let g =
|
|
23
|
+
let p = _ + o + 1, D = "";
|
|
24
|
+
if (N ? D = s(x(o, N)) : D = s(x(o + 1, n)), Number(a) > 0 && (i = Math.round(Number(a) * (Number(e) - M) / 100)), N && N != n && o == 0) {
|
|
25
|
+
let g = v(n, D);
|
|
26
26
|
g > 0 && (i = Math.round(i / 30.5 * g));
|
|
27
27
|
}
|
|
28
|
-
if (+f > 0 && o < +f && (i = 0), c > 0 && c >= i && (m = c - i), Number(t) == o + 1 && (m = Number(e) -
|
|
28
|
+
if (+f > 0 && o < +f && (i = 0), c > 0 && c >= i && (m = c - i), Number(t) == o + 1 && (m = Number(e) - M), o >= Number(t) - b ? w = m + i : w = i, o >= Number(t) - b && (M = M + m), M > Number(e))
|
|
29
29
|
return console.log("totalInsertedRates > Number(sum)"), [];
|
|
30
|
-
l.nr_rata =
|
|
30
|
+
l.nr_rata = p, l.data_rata = D, o >= t - b && (l.credit_rata = m), l.dobinda_rata = i, l.total_rata = w, h.push(l);
|
|
31
31
|
}
|
|
32
32
|
return h;
|
|
33
|
-
},
|
|
33
|
+
}, V = (e, t, a = /* @__PURE__ */ new Date()) => {
|
|
34
34
|
if (e.length == 0) return;
|
|
35
35
|
let n = [], u = 0;
|
|
36
36
|
return e.forEach((r) => {
|
|
37
37
|
n[r.data_rata] = r.total_rata;
|
|
38
|
-
}), u =
|
|
39
|
-
},
|
|
38
|
+
}), u = Y(t, a, n, 0.01) * 100, u.toFixed(2);
|
|
39
|
+
}, j = (e = 0, t = 0, a = 0) => e + a == 0 || t == 0 ? 0 : ((Number(e) + Number(a)) / Number(t) * 100).toFixed(2), k = () => s(/* @__PURE__ */ new Date()), s = (e) => {
|
|
40
40
|
let t = new Date(e), a = t.getDate(), n = t.getMonth() + 1, u = t.getFullYear();
|
|
41
41
|
return a < 10 && (a = "0" + a), n < 10 && (n = "0" + n), u + "-" + n + "-" + a;
|
|
42
|
-
},
|
|
42
|
+
}, x = (e, t = "") => {
|
|
43
43
|
t ? t = new Date(t) : t = /* @__PURE__ */ new Date();
|
|
44
44
|
let a = t.getDate();
|
|
45
45
|
return t.setDate(1), t.setMonth(t.getMonth() + e), t.setDate(Math.min(a, F(t.getFullYear(), t.getMonth())));
|
|
46
|
-
}, E = (e) => e % 4 === 0 && e % 100 !== 0 || e % 400 === 0, F = (e, t) => [31, E(e) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][t],
|
|
46
|
+
}, E = (e) => e % 4 === 0 && e % 100 !== 0 || e % 400 === 0, F = (e, t) => [31, E(e) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][t], v = (e, t) => Math.abs(new Date(t) - new Date(e)) / 864e5, Y = (e, t, a, n) => {
|
|
47
47
|
let u = [-1 * e], r = [1], c = new Date(t);
|
|
48
48
|
return Object.keys(a).forEach(function(f) {
|
|
49
49
|
u.push(a[f]), r.push(1 + Math.ceil(Math.abs(new Date(f).getTime() - c.getTime()) / 864e5));
|
|
50
|
-
}), Math.abs(
|
|
50
|
+
}), Math.abs(I(function(f) {
|
|
51
51
|
let l = 0;
|
|
52
52
|
return r.forEach(function(h, b) {
|
|
53
53
|
l += u[b] * Math.pow(1 + f, (r[0] - h) / 365);
|
|
@@ -58,7 +58,7 @@ const V = ({
|
|
|
58
58
|
l += 1 / 365 * (r[0] - h) * u[b] * Math.pow(1 + f, (r[0] - h) / 365 - 1);
|
|
59
59
|
}), l;
|
|
60
60
|
}, n));
|
|
61
|
-
},
|
|
61
|
+
}, I = (e, t, a) => {
|
|
62
62
|
let u = Math.pow(10, -1 * 4), r = 0;
|
|
63
63
|
do
|
|
64
64
|
a = Number(a), r = Number(a), a = r - Number(e(a)) / Number(t(a));
|
|
@@ -66,10 +66,10 @@ const V = ({
|
|
|
66
66
|
return a;
|
|
67
67
|
};
|
|
68
68
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
x as addMonths,
|
|
70
|
+
V as calcDAE,
|
|
71
|
+
j as calcRSDV,
|
|
72
|
+
L as createGrafic,
|
|
73
|
+
s as formatDate,
|
|
74
|
+
k as todayDate
|
|
75
75
|
};
|
package/dist/ideal-credit.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,
|
|
1
|
+
(function(f,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(f=typeof globalThis<"u"?globalThis:f||self,s(f["ideal-credit"]={}))})(this,(function(f){"use strict";const s=({sum:e,period:t,interest:a,startDate:r=M(new Date),creditRatesToPay:u=0,desiredCreditRate:n=0,desiredTotalRate:o=0,desiredStartRate:p=0,desiredStartDateToPay:N="",monthWithoutInterest:i=0}={})=>{let l={},m=[],b=0,w=0,D=0,d=0,h=0;n=Number(n),o=Number(o),b=u||t,n>0&&(o==0||!o)?D=n:D=Math.round(e/b);for(let c=0;c<Number(t);c++){l={nr_rata:0,data_rata:"",credit_rata:0,dobinda_rata:0,total_rata:0};let G=p+c+1,_="";if(N?_=M(g(c,N)):_=M(g(c+1,r)),Number(a)>0&&(h=Math.round(Number(a)*(Number(e)-w)/100)),N&&N!=r&&c==0){let E=Y(r,_);E>0&&(h=Math.round(h/30.5*E))}if(+i>0&&c<+i&&(h=0),o>0&&o>=h&&(D=o-h),Number(t)==c+1&&(D=Number(e)-w),c>=Number(t)-b?d=D+h:d=h,c>=Number(t)-b&&(w=w+D),w>Number(e))return console.log("totalInsertedRates > Number(sum)"),[];l.nr_rata=G,l.data_rata=_,c>=t-b&&(l.credit_rata=D),l.dobinda_rata=h,l.total_rata=d,m.push(l)}return m},y=(e,t,a=new Date)=>{if(e.length==0)return;let r=[],u=0;return e.forEach(n=>{r[n.data_rata]=n.total_rata}),u=x(t,a,r,.01)*100,u.toFixed(2)},v=(e=0,t=0,a=0)=>e+a==0||t==0?0:((Number(e)+Number(a))/Number(t)*100).toFixed(2),F=()=>M(new Date),M=e=>{let t=new Date(e),a=t.getDate(),r=t.getMonth()+1,u=t.getFullYear();return a<10&&(a="0"+a),r<10&&(r="0"+r),u+"-"+r+"-"+a},g=(e,t="")=>{t?t=new Date(t):t=new Date;let a=t.getDate();return t.setDate(1),t.setMonth(t.getMonth()+e),t.setDate(Math.min(a,V(t.getFullYear(),t.getMonth())))},j=e=>e%4===0&&e%100!==0||e%400===0,V=(e,t)=>[31,j(e)?29:28,31,30,31,30,31,31,30,31,30,31][t],Y=(e,t)=>Math.abs(new Date(t)-new Date(e))/864e5,x=(e,t,a,r)=>{let u=[-1*e],n=[1],o=new Date(t);return Object.keys(a).forEach(function(i){u.push(a[i]),n.push(1+Math.ceil(Math.abs(new Date(i).getTime()-o.getTime())/864e5))}),Math.abs(A(function(i){let l=0;return n.forEach(function(m,b){l+=u[b]*Math.pow(1+i,(n[0]-m)/365)}),l},function(i){let l=0;return n.forEach(function(m,b){l+=1/365*(n[0]-m)*u[b]*Math.pow(1+i,(n[0]-m)/365-1)}),l},r))},A=(e,t,a)=>{let u=Math.pow(10,-1*4),n=0;do a=Number(a),n=Number(a),a=n-Number(e(a))/Number(t(a));while(Math.abs(a-n)>u);return a};f.addMonths=g,f.calcDAE=y,f.calcRSDV=v,f.createGrafic=s,f.formatDate=M,f.todayDate=F,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|