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.
@@ -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: i = 0,
10
- desiredStartDateToPay: D = ""
9
+ desiredStartRate: _ = 0,
10
+ desiredStartDateToPay: M = "",
11
+ monthWithoutInterest: c = 0
11
12
  } = {}) => {
12
- let l = {}, m = [], o = 0, h = 0, b = 0, N = 0;
13
- n = Number(n), f = Number(f), o = u || t, n > 0 && (f == 0 || !f) ? b = n : b = Math.round(e / o);
14
- for (var c = 0; c < Number(t); c++) {
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 x = i + c + 1, s = "";
23
- D ? s = w(g(c, D)) : s = w(g(c + 1, r));
24
- let M = Math.round(
25
- Number(a) * (Number(e) - h) / 100
26
- );
27
- if (D && D != r && c == 0) {
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 >= M && (b = f - M), Number(t) == c + 1 && (b = Number(e) - h), c >= Number(t) - o ? N = b + M : N = M, c >= Number(t) - o && (h = h + b), h > Number(e))
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 = x, l.data_rata = s, c >= t - o && (l.credit_rata = b), l.dobinda_rata = M, l.total_rata = N, m.push(l);
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 m;
36
- }, Y = (e, t, a = new Date()) => {
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 = y(t, a, r, 0.01) * 100, u.toFixed(2);
43
- }, L = () => w(new Date()), w = (e) => {
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
- }, g = (e, t = "") => {
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, E(t.getFullYear(), t.getMonth())));
50
- }, p = (e) => e % 4 === 0 && e % 100 !== 0 || e % 400 === 0, E = (e, t) => [31, p(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, r) => {
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(l) {
53
- u.push(a[l]), n.push(
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(l).getTime() - f.getTime()) / 864e5
54
+ Math.abs(new Date(c).getTime() - f.getTime()) / 864e5
56
55
  )
57
56
  );
58
- }), Math.abs(F(function(l) {
59
- let m = 0;
60
- return n.forEach(function(o, h) {
61
- m += u[h] * Math.pow(1 + l, (n[0] - o) / 365);
62
- }), m;
63
- }, function(l) {
64
- let m = 0;
65
- return n.forEach(function(o, h) {
66
- m += 1 / 365 * (n[0] - o) * u[h] * Math.pow(1 + l, (n[0] - o) / 365 - 1);
67
- }), m;
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
- }, F = (e, t, a) => {
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
- g as addMonths,
78
- Y as calcDAE,
76
+ x as addMonths,
77
+ L as calcDAE,
79
78
  I as createGrafic,
80
79
  w as formatDate,
81
- L as todayDate
80
+ j as todayDate
82
81
  };
@@ -1 +1 @@
1
- (function(o,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(o=typeof globalThis<"u"?globalThis:o||self,M(o["ideal-credit"]={}))})(this,function(o){"use strict";const M=({sum:e,period:t,interest:a,startDate:r=D(new Date),creditRatesToPay:u=0,desiredCreditRate:n=0,desiredTotalRate:i=0,desiredStartRate:p=0,desiredStartDateToPay:w=""}={})=>{let l={},m=[],f=0,h=0,b=0,g=0;n=Number(n),i=Number(i),f=u||t,n>0&&(i==0||!i)?b=n:b=Math.round(e/f);for(var c=0;c<Number(t);c++){l={nr_rata:0,data_rata:"",credit_rata:0,dobinda_rata:0,total_rata:0};let Y=p+c+1,N="";w?N=D(_(c,w)):N=D(_(c+1,r));let s=Math.round(Number(a)*(Number(e)-h)/100);if(w&&w!=r&&c==0){let y=x(r,N);y>0&&(s=Math.round(s/30.5*y))}if(i>0&&i>=s&&(b=i-s),Number(t)==c+1&&(b=Number(e)-h),c>=Number(t)-f?g=b+s:g=s,c>=Number(t)-f&&(h=h+b),h>Number(e))return console.log("totalInsertedRates > Number(sum)"),[];l.nr_rata=Y,l.data_rata=N,c>=t-f&&(l.credit_rata=b),l.dobinda_rata=s,l.total_rata=g,m.push(l)}return m},E=(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=F(t,a,r,.01)*100,u.toFixed(2)},d=()=>D(new Date),D=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},_=(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,j(t.getFullYear(),t.getMonth())))},v=e=>e%4===0&&e%100!==0||e%400===0,j=(e,t)=>[31,v(e)?29:28,31,30,31,30,31,31,30,31,30,31][t],x=(e,t)=>Math.abs(new Date(t)-new Date(e))/864e5,F=(e,t,a,r)=>{let u=[-1*e],n=[1],i=new Date(t);return Object.keys(a).forEach(function(l){u.push(a[l]),n.push(1+Math.ceil(Math.abs(new Date(l).getTime()-i.getTime())/864e5))}),Math.abs(I(function(l){let m=0;return n.forEach(function(f,h){m+=u[h]*Math.pow(1+l,(n[0]-f)/365)}),m},function(l){let m=0;return n.forEach(function(f,h){m+=1/365*(n[0]-f)*u[h]*Math.pow(1+l,(n[0]-f)/365-1)}),m},r))},I=(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=_,o.calcDAE=E,o.createGrafic=M,o.formatDate=D,o.todayDate=d,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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.4",
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.1.3"
26
+ "vite": "^4.3.9"
27
27
  }
28
28
  }