ideal-credit 0.2.2 → 0.2.4

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.
@@ -1,10 +1,13 @@
1
- const L = (e, t, a, {
1
+ const I = ({
2
+ sum: e,
3
+ period: t,
4
+ interest: a,
2
5
  startDate: r = w(new Date()),
3
6
  creditRatesToPay: u = 0,
4
7
  desiredCreditRate: n = 0,
5
8
  desiredTotalRate: f = 0,
6
- desiredStartRate: s = 0,
7
- desiredStartDateToPay: M = ""
9
+ desiredStartRate: i = 0,
10
+ desiredStartDateToPay: D = ""
8
11
  } = {}) => {
9
12
  let l = {}, m = [], o = 0, h = 0, b = 0, N = 0;
10
13
  n = Number(n), f = Number(f), o = u || t, n > 0 && (f == 0 || !f) ? b = n : b = Math.round(e / o);
@@ -16,18 +19,18 @@ const L = (e, t, a, {
16
19
  dobinda_rata: 0,
17
20
  total_rata: 0
18
21
  };
19
- let x = s + c + 1, D = "";
20
- M ? D = w(p(c, M)) : D = w(p(c + 1, r));
21
- let i = Math.round(
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(
22
25
  Number(a) * (Number(e) - h) / 100
23
26
  );
24
- if (M && M != r && c == 0) {
25
- let _ = v(r, D);
26
- _ > 0 && (i = Math.round(i / 30.5 * _));
27
+ if (D && D != r && c == 0) {
28
+ let _ = v(r, s);
29
+ _ > 0 && (M = Math.round(M / 30.5 * _));
27
30
  }
28
- if (f > 0 && f >= i && (b = f - i), Number(t) == c + 1 && (b = Number(e) - h), c >= Number(t) - o ? N = b + i : N = i, c >= Number(t) - o && (h = h + b), h > Number(e))
29
- return alert("Suma Total Lunar\u0103 este prea mare, incercati o suma mai mica"), [];
30
- l.nr_rata = x, l.data_rata = D, c >= t - o && (l.credit_rata = b), l.dobinda_rata = i, l.total_rata = N, m.push(l);
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))
32
+ 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);
31
34
  }
32
35
  return m;
33
36
  }, Y = (e, t, a = new Date()) => {
@@ -37,14 +40,14 @@ const L = (e, t, a, {
37
40
  return e.forEach((n) => {
38
41
  r[n.data_rata] = n.total_rata;
39
42
  }), u = y(t, a, r, 0.01) * 100, u.toFixed(2);
40
- }, I = () => w(new Date()), w = (e) => {
43
+ }, L = () => w(new Date()), w = (e) => {
41
44
  let t = new Date(e), a = t.getDate(), r = t.getMonth() + 1, u = t.getFullYear();
42
45
  return a < 10 && (a = "0" + a), r < 10 && (r = "0" + r), u + "-" + r + "-" + a;
43
- }, p = (e, t = "") => {
46
+ }, g = (e, t = "") => {
44
47
  t ? t = new Date(t) : t = new Date();
45
48
  let a = t.getDate();
46
49
  return t.setDate(1), t.setMonth(t.getMonth() + e), t.setDate(Math.min(a, E(t.getFullYear(), t.getMonth())));
47
- }, g = (e) => e % 4 === 0 && e % 100 !== 0 || e % 400 === 0, E = (e, t) => [31, g(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) => {
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
51
  let u = [-1 * e], n = [1], f = new Date(t);
49
52
  return Object.keys(a).forEach(function(l) {
50
53
  u.push(a[l]), n.push(
@@ -71,9 +74,9 @@ const L = (e, t, a, {
71
74
  return a;
72
75
  };
73
76
  export {
74
- p as addMonths,
77
+ g as addMonths,
75
78
  Y as calcDAE,
76
- L as createGrafic,
79
+ I as createGrafic,
77
80
  w as formatDate,
78
- I as todayDate
81
+ L as todayDate
79
82
  };
@@ -1 +1 @@
1
- (function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o["ideal-credit"]={}))})(this,function(o){"use strict";const s=(e,t,a,{startDate:r=D(new Date),creditRatesToPay:u=0,desiredCreditRate:n=0,desiredTotalRate:i=0,desiredStartRate:g=0,desiredStartDateToPay:w=""}={})=>{let l={},m=[],f=0,h=0,b=0,p=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=g+c+1,N="";w?N=D(_(c,w)):N=D(_(c+1,r));let M=Math.round(Number(a)*(Number(e)-h)/100);if(w&&w!=r&&c==0){let y=x(r,N);y>0&&(M=Math.round(M/30.5*y))}if(i>0&&i>=M&&(b=i-M),Number(t)==c+1&&(b=Number(e)-h),c>=Number(t)-f?p=b+M:p=M,c>=Number(t)-f&&(h=h+b),h>Number(e))return alert("Suma Total Lunar\u0103 este prea mare, incercati o suma mai mica"),[];l.nr_rata=Y,l.data_rata=N,c>=t-f&&(l.credit_rata=b),l.dobinda_rata=M,l.total_rata=p,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)},v=()=>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())))},d=e=>e%4===0&&e%100!==0||e%400===0,j=(e,t)=>[31,d(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(L(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))},L=(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=s,o.formatDate=D,o.todayDate=v,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ideal-credit",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Helper functions for www.idealcredit.md",
5
5
  "files": [
6
6
  "dist"