ideal-credit 0.2.4 → 0.2.6
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 +40 -41
- package/dist/ideal-credit.umd.js +1 -1
- package/package.json +2 -2
package/dist/ideal-credit.mjs
CHANGED
|
@@ -2,16 +2,17 @@ const I = ({
|
|
|
2
2
|
sum: e,
|
|
3
3
|
period: t,
|
|
4
4
|
interest: a,
|
|
5
|
-
startDate: r = w(new Date()),
|
|
5
|
+
startDate: r = w(/* @__PURE__ */ new Date()),
|
|
6
6
|
creditRatesToPay: u = 0,
|
|
7
7
|
desiredCreditRate: n = 0,
|
|
8
8
|
desiredTotalRate: f = 0,
|
|
9
|
-
desiredStartRate:
|
|
10
|
-
desiredStartDateToPay:
|
|
9
|
+
desiredStartRate: _ = 0,
|
|
10
|
+
desiredStartDateToPay: M = "",
|
|
11
|
+
monthWithoutInterest: c = 0
|
|
11
12
|
} = {}) => {
|
|
12
|
-
let l = {},
|
|
13
|
-
n = Number(n), f = Number(f),
|
|
14
|
-
for (
|
|
13
|
+
let l = {}, b = [], h = 0, D = 0, m = 0, s = 0, i = 0;
|
|
14
|
+
n = Number(n), f = Number(f), h = u || t, n > 0 && (f == 0 || !f) ? m = n : m = Math.round(e / h);
|
|
15
|
+
for (let o = 0; o < Number(t); o++) {
|
|
15
16
|
l = {
|
|
16
17
|
nr_rata: 0,
|
|
17
18
|
data_rata: "",
|
|
@@ -19,54 +20,52 @@ const I = ({
|
|
|
19
20
|
dobinda_rata: 0,
|
|
20
21
|
total_rata: 0
|
|
21
22
|
};
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let _ = v(r, s);
|
|
29
|
-
_ > 0 && (M = Math.round(M / 30.5 * _));
|
|
23
|
+
let p = _ + o + 1, N = "";
|
|
24
|
+
if (M ? N = w(x(o, M)) : N = w(x(o + 1, r)), Number(a) > 0 && (i = Math.round(
|
|
25
|
+
Number(a) * (Number(e) - D) / 100
|
|
26
|
+
)), M && M != r && o == 0) {
|
|
27
|
+
let g = F(r, N);
|
|
28
|
+
g > 0 && (i = Math.round(i / 30.5 * g));
|
|
30
29
|
}
|
|
31
|
-
if (f > 0 && f >=
|
|
30
|
+
if (+c > 0 && o < +c && (i = 0), f > 0 && f >= i && (m = f - i), Number(t) == o + 1 && (m = Number(e) - D), o >= Number(t) - h ? s = m + i : s = i, o >= Number(t) - h && (D = D + m), D > Number(e))
|
|
32
31
|
return console.log("totalInsertedRates > Number(sum)"), [];
|
|
33
|
-
l.nr_rata =
|
|
32
|
+
l.nr_rata = p, l.data_rata = N, o >= t - h && (l.credit_rata = m), l.dobinda_rata = i, l.total_rata = s, b.push(l);
|
|
34
33
|
}
|
|
35
|
-
return
|
|
36
|
-
},
|
|
34
|
+
return b;
|
|
35
|
+
}, L = (e, t, a = /* @__PURE__ */ new Date()) => {
|
|
37
36
|
if (e.length == 0)
|
|
38
37
|
return;
|
|
39
38
|
let r = [], u = 0;
|
|
40
39
|
return e.forEach((n) => {
|
|
41
40
|
r[n.data_rata] = n.total_rata;
|
|
42
|
-
}), u =
|
|
43
|
-
},
|
|
41
|
+
}), u = Y(t, a, r, 0.01) * 100, u.toFixed(2);
|
|
42
|
+
}, j = () => w(/* @__PURE__ */ new Date()), w = (e) => {
|
|
44
43
|
let t = new Date(e), a = t.getDate(), r = t.getMonth() + 1, u = t.getFullYear();
|
|
45
44
|
return a < 10 && (a = "0" + a), r < 10 && (r = "0" + r), u + "-" + r + "-" + a;
|
|
46
|
-
},
|
|
47
|
-
t ? t = new Date(t) : t = new Date();
|
|
45
|
+
}, x = (e, t = "") => {
|
|
46
|
+
t ? t = new Date(t) : t = /* @__PURE__ */ new Date();
|
|
48
47
|
let a = t.getDate();
|
|
49
|
-
return t.setDate(1), t.setMonth(t.getMonth() + e), t.setDate(Math.min(a,
|
|
50
|
-
},
|
|
48
|
+
return t.setDate(1), t.setMonth(t.getMonth() + e), t.setDate(Math.min(a, y(t.getFullYear(), t.getMonth())));
|
|
49
|
+
}, E = (e) => e % 4 === 0 && e % 100 !== 0 || e % 400 === 0, y = (e, t) => [31, E(e) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][t], F = (e, t) => Math.abs(new Date(t) - new Date(e)) / 864e5, Y = (e, t, a, r) => {
|
|
51
50
|
let u = [-1 * e], n = [1], f = new Date(t);
|
|
52
|
-
return Object.keys(a).forEach(function(
|
|
53
|
-
u.push(a[
|
|
51
|
+
return Object.keys(a).forEach(function(c) {
|
|
52
|
+
u.push(a[c]), n.push(
|
|
54
53
|
1 + Math.ceil(
|
|
55
|
-
Math.abs(new Date(
|
|
54
|
+
Math.abs(new Date(c).getTime() - f.getTime()) / 864e5
|
|
56
55
|
)
|
|
57
56
|
);
|
|
58
|
-
}), Math.abs(
|
|
59
|
-
let
|
|
60
|
-
return n.forEach(function(
|
|
61
|
-
|
|
62
|
-
}),
|
|
63
|
-
}, function(
|
|
64
|
-
let
|
|
65
|
-
return n.forEach(function(
|
|
66
|
-
|
|
67
|
-
}),
|
|
57
|
+
}), Math.abs(v(function(c) {
|
|
58
|
+
let l = 0;
|
|
59
|
+
return n.forEach(function(b, h) {
|
|
60
|
+
l += u[h] * Math.pow(1 + c, (n[0] - b) / 365);
|
|
61
|
+
}), l;
|
|
62
|
+
}, function(c) {
|
|
63
|
+
let l = 0;
|
|
64
|
+
return n.forEach(function(b, h) {
|
|
65
|
+
l += 1 / 365 * (n[0] - b) * u[h] * Math.pow(1 + c, (n[0] - b) / 365 - 1);
|
|
66
|
+
}), l;
|
|
68
67
|
}, r));
|
|
69
|
-
},
|
|
68
|
+
}, v = (e, t, a) => {
|
|
70
69
|
let u = Math.pow(10, -1 * 4), n = 0;
|
|
71
70
|
do
|
|
72
71
|
a = Number(a), n = Number(a), a = n - Number(e(a)) / Number(t(a));
|
|
@@ -74,9 +73,9 @@ const I = ({
|
|
|
74
73
|
return a;
|
|
75
74
|
};
|
|
76
75
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
x as addMonths,
|
|
77
|
+
L as calcDAE,
|
|
79
78
|
I as createGrafic,
|
|
80
79
|
w as formatDate,
|
|
81
|
-
|
|
80
|
+
j as todayDate
|
|
82
81
|
};
|
package/dist/ideal-credit.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,
|
|
1
|
+
(function(o,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(o=typeof globalThis<"u"?globalThis:o||self,D(o["ideal-credit"]={}))})(this,function(o){"use strict";const D=({sum:e,period:t,interest:a,startDate:r=s(new Date),creditRatesToPay:u=0,desiredCreditRate:n=0,desiredTotalRate:c=0,desiredStartRate:p=0,desiredStartDateToPay:N="",monthWithoutInterest:i=0}={})=>{let l={},b=[],h=0,w=0,M=0,y=0,m=0;n=Number(n),c=Number(c),h=u||t,n>0&&(c==0||!c)?M=n:M=Math.round(e/h);for(let f=0;f<Number(t);f++){l={nr_rata:0,data_rata:"",credit_rata:0,dobinda_rata:0,total_rata:0};let G=p+f+1,_="";if(N?_=s(g(f,N)):_=s(g(f+1,r)),Number(a)>0&&(m=Math.round(Number(a)*(Number(e)-w)/100)),N&&N!=r&&f==0){let E=F(r,_);E>0&&(m=Math.round(m/30.5*E))}if(+i>0&&f<+i&&(m=0),c>0&&c>=m&&(M=c-m),Number(t)==f+1&&(M=Number(e)-w),f>=Number(t)-h?y=M+m:y=m,f>=Number(t)-h&&(w=w+M),w>Number(e))return console.log("totalInsertedRates > Number(sum)"),[];l.nr_rata=G,l.data_rata=_,f>=t-h&&(l.credit_rata=M),l.dobinda_rata=m,l.total_rata=y,b.push(l)}return b},d=(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=Y(t,a,r,.01)*100,u.toFixed(2)},j=()=>s(new Date),s=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,x(t.getFullYear(),t.getMonth())))},v=e=>e%4===0&&e%100!==0||e%400===0,x=(e,t)=>[31,v(e)?29:28,31,30,31,30,31,31,30,31,30,31][t],F=(e,t)=>Math.abs(new Date(t)-new Date(e))/864e5,Y=(e,t,a,r)=>{let u=[-1*e],n=[1],c=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()-c.getTime())/864e5))}),Math.abs(A(function(i){let l=0;return n.forEach(function(b,h){l+=u[h]*Math.pow(1+i,(n[0]-b)/365)}),l},function(i){let l=0;return n.forEach(function(b,h){l+=1/365*(n[0]-b)*u[h]*Math.pow(1+i,(n[0]-b)/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};o.addMonths=g,o.calcDAE=d,o.createGrafic=D,o.formatDate=s,o.todayDate=j,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ideal-credit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Helper functions for www.idealcredit.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"author": "Nicolae Cojuhari <nicojuhari@gmail.com>",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"vite": "^3.
|
|
26
|
+
"vite": "^4.3.9"
|
|
27
27
|
}
|
|
28
28
|
}
|