md-components-mdigial-azamat 0.0.295 → 0.0.296

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,12 +1,12 @@
1
- import { jsxs as t, jsx as e, Fragment as w } from "react/jsx-runtime";
2
- import { useState as M } from "react";
3
- import { sectionClass as m, Field as c, inputClass as d, PresetNotice as O, NumberInput as b, TextInput as i } from "../FinanceCalculator/builder/components.js";
4
- import { ApiCollectionsEditor as j, FieldsEditor as B, DocumentsEditor as E, UrlsByCurrencyEditor as _, RatesByCurrencyEditor as $ } from "./builder/editors.js";
5
- import { mergeFinanceApplicationFormConfig as k } from "./builder/config.js";
6
- import { financeApplicationPresets as A } from "./builder/presets.js";
7
- import { buildFinanceApplicationPayload as L, getFinanceApplicationTemplateValues as z } from "./payloadTemplate.js";
8
- const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
9
- `), V = (p) => p.split(/\r?\n/).reduce((o, a) => {
1
+ import { jsxs as t, jsx as e, Fragment as O } from "react/jsx-runtime";
2
+ import { useState as j } from "react";
3
+ import { sectionClass as m, Field as c, inputClass as u, PresetNotice as B, NumberInput as b, TextInput as i } from "../FinanceCalculator/builder/components.js";
4
+ import { ApiCollectionsEditor as E, FieldsEditor as _, DocumentsEditor as $, UrlsByCurrencyEditor as L, RatesByCurrencyEditor as z } from "./builder/editors.js";
5
+ import { mergeFinanceApplicationFormConfig as I } from "./builder/config.js";
6
+ import { financeApplicationPresets as S } from "./builder/presets.js";
7
+ import { buildFinanceApplicationPayload as D, getFinanceApplicationTemplateValues as U } from "./payloadTemplate.js";
8
+ const V = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
9
+ `), J = (p) => p.split(/\r?\n/).reduce((o, a) => {
10
10
  const r = a.trim();
11
11
  if (!r || r.startsWith("#"))
12
12
  return o;
@@ -15,21 +15,21 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
15
15
  return o;
16
16
  const n = r.slice(0, h).trim(), s = r.slice(h + 1).trim();
17
17
  return n && s && (o[n] = s), o;
18
- }, {}), Q = ({
18
+ }, {}), Y = ({
19
19
  config: p,
20
20
  onChange: o
21
21
  }) => {
22
- var f, x, N, C, R, P, F, T;
23
- const a = k(p), [r, h] = M(""), n = (l) => {
22
+ var N, C, R, P, F, T, k, A;
23
+ const a = I(p), [r, h] = j(""), n = (l) => {
24
24
  o({ ...a, ...l });
25
25
  }, s = (l) => {
26
26
  n({ submit: { ...a.submit, ...l } });
27
- }, S = (l) => {
28
- const g = A[l];
29
- g && (h(l), o(k(g.config)));
30
- }, y = a.calculation.rateType === "monthly_rate", u = a.calculation.rateSource === "api", v = u && ((f = a.calculation.apiRate) == null ? void 0 : f.fallbackToManual) !== !1, I = L(
27
+ }, w = (l) => {
28
+ const g = S[l];
29
+ g && (h(l), o(I(g.config)));
30
+ }, y = a.calculation.rateType === "monthly_rate", v = a.calculation.rateType === "annual_decimal", d = a.calculation.rateSource === "api", f = d && ((N = a.calculation.apiRate) == null ? void 0 : N.fallbackToManual) !== !1, x = !d || f, M = D(
31
31
  a.submit.payloadTemplate,
32
- z(a.fields, a.topic)
32
+ U(a.fields, a.topic)
33
33
  );
34
34
  return /* @__PURE__ */ t("div", { className: "h-full min-h-[560px] w-full overflow-auto rounded-xl bg-gray-50 p-6", children: [
35
35
  /* @__PURE__ */ t("div", { className: "mb-6 rounded-xl border border-gray-200 bg-white p-4", children: [
@@ -41,12 +41,12 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
41
41
  /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: /* @__PURE__ */ e(c, { label: "Быстро заполнить по пресету", children: /* @__PURE__ */ t(
42
42
  "select",
43
43
  {
44
- className: d,
44
+ className: u,
45
45
  value: r,
46
- onChange: (l) => S(l.target.value),
46
+ onChange: (l) => w(l.target.value),
47
47
  children: [
48
48
  /* @__PURE__ */ e("option", { value: "", children: "Выберите пресет" }),
49
- Object.entries(A).map(([l, g]) => /* @__PURE__ */ e(
49
+ Object.entries(S).map(([l, g]) => /* @__PURE__ */ e(
50
50
  "option",
51
51
  {
52
52
  value: l,
@@ -57,17 +57,17 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
57
57
  ]
58
58
  }
59
59
  ) }) }),
60
- /* @__PURE__ */ e("div", { className: "mt-3", children: /* @__PURE__ */ e(O, { children: "Пресет только быстро заполняет настройки. Его необязательно использовать: после выбора можно вручную изменить поля, расчет и отправку." }) })
60
+ /* @__PURE__ */ e("div", { className: "mt-3", children: /* @__PURE__ */ e(B, { children: "Пресет только быстро заполняет настройки. Его необязательно использовать: после выбора можно вручную изменить поля, расчет и отправку." }) })
61
61
  ] }),
62
62
  /* @__PURE__ */ e("div", { className: m, children: /* @__PURE__ */ e(
63
- j,
63
+ E,
64
64
  {
65
65
  items: a.apiCollections,
66
66
  onChange: (l) => n({ apiCollections: l })
67
67
  }
68
68
  ) }),
69
69
  /* @__PURE__ */ e("div", { className: m, children: /* @__PURE__ */ e(
70
- B,
70
+ _,
71
71
  {
72
72
  items: a.fields,
73
73
  apiCollections: a.apiCollections,
@@ -75,7 +75,7 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
75
75
  }
76
76
  ) }),
77
77
  /* @__PURE__ */ e("div", { className: m, children: /* @__PURE__ */ e(
78
- E,
78
+ $,
79
79
  {
80
80
  title: a.documents.title,
81
81
  items: a.documents.items,
@@ -88,7 +88,7 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
88
88
  /* @__PURE__ */ e(c, { label: "Preset", children: /* @__PURE__ */ t(
89
89
  "select",
90
90
  {
91
- className: d,
91
+ className: u,
92
92
  value: a.calculation.preset || "annuity",
93
93
  onChange: (l) => n({
94
94
  calculation: {
@@ -105,7 +105,7 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
105
105
  /* @__PURE__ */ e(c, { label: "Тип ставки", children: /* @__PURE__ */ t(
106
106
  "select",
107
107
  {
108
- className: d,
108
+ className: u,
109
109
  value: a.calculation.rateType || "annual_percent",
110
110
  onChange: (l) => n({
111
111
  calculation: {
@@ -114,15 +114,16 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
114
114
  }
115
115
  }),
116
116
  children: [
117
- /* @__PURE__ */ e("option", { value: "annual_percent", children: "Годовой процент" }),
118
- /* @__PURE__ */ e("option", { value: "monthly_rate", children: "Месячный коэффициент" })
117
+ /* @__PURE__ */ e("option", { value: "annual_percent", children: "Годовой процент (16.66)" }),
118
+ /* @__PURE__ */ e("option", { value: "annual_decimal", children: "Годовая decimal ставка (0.1666)" }),
119
+ /* @__PURE__ */ e("option", { value: "monthly_rate", children: "Месячный коэффициент (0.01583)" })
119
120
  ]
120
121
  }
121
122
  ) }),
122
123
  /* @__PURE__ */ e(c, { label: "Источник ставки", children: /* @__PURE__ */ t(
123
124
  "select",
124
125
  {
125
- className: d,
126
+ className: u,
126
127
  value: a.calculation.rateSource || "manual",
127
128
  onChange: (l) => n({
128
129
  calculation: {
@@ -136,26 +137,32 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
136
137
  ]
137
138
  }
138
139
  ) }),
139
- !y && /* @__PURE__ */ e(c, { label: "Годовая ставка / наценка, %", children: /* @__PURE__ */ e(
140
- b,
140
+ !y && x && /* @__PURE__ */ e(
141
+ c,
141
142
  {
142
- value: a.calculation.annualRate,
143
- onChange: (l) => n({
144
- calculation: {
145
- ...a.calculation,
146
- annualRate: l
143
+ label: d ? v ? "Fallback годовая decimal ставка" : "Fallback годовая ставка, %" : v ? "Годовая decimal ставка" : "Годовая ставка, %",
144
+ children: /* @__PURE__ */ e(
145
+ b,
146
+ {
147
+ value: a.calculation.annualRate,
148
+ onChange: (l) => n({
149
+ calculation: {
150
+ ...a.calculation,
151
+ annualRate: l
152
+ }
153
+ })
147
154
  }
148
- })
155
+ )
149
156
  }
150
- ) }),
151
- y && (!u || v) && /* @__PURE__ */ e(
157
+ ),
158
+ y && x && /* @__PURE__ */ e(
152
159
  c,
153
160
  {
154
- label: u ? "Fallback месячный коэффициент" : "Месячный коэффициент",
161
+ label: d ? "Fallback месячный коэффициент" : "Месячный коэффициент",
155
162
  children: /* @__PURE__ */ e(
156
163
  b,
157
164
  {
158
- value: ((x = a.calculation.manualRate) == null ? void 0 : x.defaultRate) ?? a.calculation.monthlyRate,
165
+ value: ((C = a.calculation.manualRate) == null ? void 0 : C.defaultRate) ?? a.calculation.monthlyRate,
159
166
  onChange: (l) => n({
160
167
  calculation: {
161
168
  ...a.calculation,
@@ -170,11 +177,11 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
170
177
  )
171
178
  }
172
179
  ),
173
- u && /* @__PURE__ */ t(w, { children: [
180
+ d && /* @__PURE__ */ t(O, { children: [
174
181
  /* @__PURE__ */ e(c, { label: "API URL для ставки", children: /* @__PURE__ */ e(
175
182
  i,
176
183
  {
177
- value: (N = a.calculation.apiRate) == null ? void 0 : N.url,
184
+ value: (R = a.calculation.apiRate) == null ? void 0 : R.url,
178
185
  onChange: (l) => n({
179
186
  calculation: {
180
187
  ...a.calculation,
@@ -189,7 +196,7 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
189
196
  /* @__PURE__ */ e(c, { label: "API зависит от поля", children: /* @__PURE__ */ e(
190
197
  i,
191
198
  {
192
- value: (C = a.calculation.apiRate) == null ? void 0 : C.dependsOnField,
199
+ value: (P = a.calculation.apiRate) == null ? void 0 : P.dependsOnField,
193
200
  onChange: (l) => n({
194
201
  calculation: {
195
202
  ...a.calculation,
@@ -204,7 +211,7 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
204
211
  /* @__PURE__ */ e(c, { label: "Путь ставки в ответе API", children: /* @__PURE__ */ e(
205
212
  i,
206
213
  {
207
- value: (R = a.calculation.apiRate) == null ? void 0 : R.responsePath,
214
+ value: (F = a.calculation.apiRate) == null ? void 0 : F.responsePath,
208
215
  onChange: (l) => n({
209
216
  calculation: {
210
217
  ...a.calculation,
@@ -217,9 +224,9 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
217
224
  }
218
225
  ) }),
219
226
  /* @__PURE__ */ e(
220
- _,
227
+ L,
221
228
  {
222
- items: (P = a.calculation.apiRate) == null ? void 0 : P.urlByCurrency,
229
+ items: (T = a.calculation.apiRate) == null ? void 0 : T.urlByCurrency,
223
230
  onChange: (l) => n({
224
231
  calculation: {
225
232
  ...a.calculation,
@@ -232,10 +239,10 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
232
239
  }
233
240
  )
234
241
  ] }),
235
- y && (!u || v) && /* @__PURE__ */ e(
236
- $,
242
+ y && (!d || f) && /* @__PURE__ */ e(
243
+ z,
237
244
  {
238
- items: ((F = a.calculation.manualRate) == null ? void 0 : F.byCurrency) || a.calculation.monthlyRateByCurrency,
245
+ items: ((k = a.calculation.manualRate) == null ? void 0 : k.byCurrency) || a.calculation.monthlyRateByCurrency,
239
246
  onChange: (l) => n({
240
247
  calculation: {
241
248
  ...a.calculation,
@@ -264,12 +271,12 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
264
271
  ),
265
272
  "Округлять платеж до целого"
266
273
  ] }),
267
- u && /* @__PURE__ */ t("label", { className: "flex items-center gap-2 text-sm text-gray-700", children: [
274
+ d && /* @__PURE__ */ t("label", { className: "flex items-center gap-2 text-sm text-gray-700", children: [
268
275
  /* @__PURE__ */ e(
269
276
  "input",
270
277
  {
271
278
  type: "checkbox",
272
- checked: ((T = a.calculation.apiRate) == null ? void 0 : T.fallbackToManual) !== !1,
279
+ checked: ((A = a.calculation.apiRate) == null ? void 0 : A.fallbackToManual) !== !1,
273
280
  onChange: (l) => n({
274
281
  calculation: {
275
282
  ...a.calculation,
@@ -389,7 +396,7 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
389
396
  /* @__PURE__ */ e(c, { label: "Method", children: /* @__PURE__ */ e(
390
397
  "select",
391
398
  {
392
- className: d,
399
+ className: u,
393
400
  value: a.submit.method || "POST",
394
401
  onChange: (l) => s({ method: l.target.value }),
395
402
  children: /* @__PURE__ */ e("option", { value: "POST", children: "POST" })
@@ -400,26 +407,26 @@ const U = (p) => Object.entries(p ?? {}).map(([o, a]) => `${o}: ${a}`).join(`
400
407
  /* @__PURE__ */ e(c, { label: "Payload template", children: /* @__PURE__ */ e(
401
408
  "textarea",
402
409
  {
403
- className: `${d} min-h-[220px] resize-y font-mono`,
410
+ className: `${u} min-h-[220px] resize-y font-mono`,
404
411
  value: a.submit.payloadTemplate,
405
412
  onChange: (l) => s({ payloadTemplate: l.target.value })
406
413
  }
407
414
  ) }),
408
415
  /* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children: [
409
416
  /* @__PURE__ */ e("span", { className: "text-xs font-medium text-gray-500", children: "Payload preview" }),
410
- /* @__PURE__ */ e("pre", { className: "m-0 min-h-[220px] overflow-auto rounded-lg border border-gray-300 bg-gray-950 p-3 text-xs leading-5 text-gray-50", children: JSON.stringify(I, null, 2) })
417
+ /* @__PURE__ */ e("pre", { className: "m-0 min-h-[220px] overflow-auto rounded-lg border border-gray-300 bg-gray-950 p-3 text-xs leading-5 text-gray-50", children: JSON.stringify(M, null, 2) })
411
418
  ] })
412
419
  ] }),
413
420
  /* @__PURE__ */ t("div", { className: "mt-3 grid grid-cols-1 gap-3 md:grid-cols-2", children: [
414
421
  /* @__PURE__ */ e(c, { label: "Ошибки API -> поля формы", children: /* @__PURE__ */ e(
415
422
  "textarea",
416
423
  {
417
- className: `${d} min-h-[120px] resize-y font-mono`,
418
- value: U(a.submit.errorFieldMap),
424
+ className: `${u} min-h-[120px] resize-y font-mono`,
425
+ value: V(a.submit.errorFieldMap),
419
426
  placeholder: `period: period
420
427
  price: price
421
428
  product: subject`,
422
- onChange: (l) => s({ errorFieldMap: V(l.target.value) })
429
+ onChange: (l) => s({ errorFieldMap: J(l.target.value) })
423
430
  }
424
431
  ) }),
425
432
  /* @__PURE__ */ t("div", { className: "rounded-lg border border-blue-100 bg-blue-50 p-3 text-xs leading-5 text-blue-900", children: [
@@ -441,5 +448,5 @@ product: subject`,
441
448
  ] });
442
449
  };
443
450
  export {
444
- Q as FinanceApplicationFormBuilder
451
+ Y as FinanceApplicationFormBuilder
445
452
  };
@@ -1,4 +1,4 @@
1
- import { getFinanceApplicationFormConfig as o } from "../defaultConfig.js";
1
+ import { getFinanceApplicationFormConfig as l } from "../defaultConfig.js";
2
2
  const p = {
3
3
  text: "Текст",
4
4
  phone: "Телефон",
@@ -7,10 +7,7 @@ const p = {
7
7
  term_range: "Срок + бегунок",
8
8
  computed: "Вычисляемое",
9
9
  checkbox: "Чекбокс"
10
- }, i = "https://murabaha.mbank.kg/callback/api/v1/region/getAllRegions", u = "https://murabaha.mbank.kg/callback/api/v1/percent/getBusinessPercent", c = "https://murabaha.mbank.kg/callback/api/v1/percent/getPotrebPercent", a = {
11
- kgs: 0.01583,
12
- usd: 833e-5
13
- }, m = [
10
+ }, i = "https://murabaha.mbank.kg/callback/api/v1/region/getAllRegions", o = "https://murabaha.mbank.kg/callback/api/v1/percent/getBusinessPercent", c = "https://murabaha.mbank.kg/callback/api/v1/percent/getPotrebPercent", u = 0.1666, m = [
14
11
  "Паспорт покупателя и продавца",
15
12
  "Паспорт супруги/супруга покупателя и продавца",
16
13
  "Свидетельство о регистрации брака или расторжения брака покупателя и продавца",
@@ -21,11 +18,11 @@ const p = {
21
18
  "Паспорт супруги/супруга покупателя и продавца",
22
19
  "Свидетельство о регистрации брака или расторжения брака покупателя и продавца",
23
20
  "Документ, подтверждающий доход покупателя"
24
- ], r = (e, n, t, l) => ({
21
+ ], a = (e, n, r, t) => ({
25
22
  topic: e,
26
23
  documents: {
27
24
  title: "Необходимые документы",
28
- items: l
25
+ items: t
29
26
  },
30
27
  apiCollections: [
31
28
  {
@@ -61,21 +58,18 @@ const p = {
61
58
  },
62
59
  calculation: {
63
60
  preset: "annuity",
64
- rateType: "monthly_rate",
61
+ rateType: "annual_decimal",
65
62
  rateSource: "api",
66
63
  amountField: "price",
67
64
  termField: "period",
68
65
  downPaymentField: "",
69
66
  downPaymentPercent: 0,
70
- annualRate: 16,
71
- monthlyRate: a.kgs,
72
- monthlyRateByCurrency: a,
73
- manualRate: {
74
- defaultRate: a.kgs,
75
- byCurrency: a
76
- },
67
+ annualRate: u,
68
+ monthlyRate: 0,
69
+ monthlyRateByCurrency: {},
70
+ manualRate: {},
77
71
  apiRate: {
78
- url: t,
72
+ url: r,
79
73
  urlByCurrency: {},
80
74
  dependsOnField: "currency",
81
75
  responsePath: "",
@@ -229,20 +223,20 @@ documents: {{agree}}`
229
223
  }), b = {
230
224
  istisnaa: {
231
225
  label: "Истиснаа",
232
- config: o({})
226
+ config: l({})
233
227
  },
234
228
  murabaha_business: {
235
229
  label: "Мурабаха бизнес",
236
- config: r(
230
+ config: a(
237
231
  "Мурабаха бизнес",
238
232
  "Все документы для получения финансирования на бизнес цели есть",
239
- u,
233
+ o,
240
234
  m
241
235
  )
242
236
  },
243
237
  murabaha_consumer: {
244
238
  label: "Мурабаха потребительская",
245
- config: r(
239
+ config: a(
246
240
  "Мурабаха потребительская",
247
241
  "Все документы для получения финансирования на потребительские цели есть",
248
242
  c,
@@ -1,39 +1,52 @@
1
- import { calculateAnnuity as d } from "../../FinanceCalculator/utils/calculations.js";
2
- import { toNumber as c } from "./format.js";
3
- const s = (t, r, a, e) => {
4
- if (t <= 0 || r <= 0)
1
+ import { toNumber as d } from "./format.js";
2
+ const f = (t, n, r, e) => {
3
+ if (t <= 0 || n <= 0)
5
4
  return 0;
6
- if (a <= 0) {
7
- const u = t / r;
8
- return e ? parseFloat(u.toFixed()) : u;
5
+ if (r <= 0) {
6
+ const y = t / n;
7
+ return e ? parseFloat(y.toFixed()) : y;
9
8
  }
10
- const n = Math.pow(1 + a, r), o = t * a * n / (n - 1 || 1);
9
+ const a = Math.pow(1 + r, n), o = t * r * a / (a - 1 || 1);
11
10
  return e ? parseFloat(o.toFixed()) : o;
12
- }, l = (t, r) => {
13
- var o, u, y, m;
14
- const a = t.currencyField || "currency", e = r[a], n = e === void 0 ? void 0 : String(e).toLowerCase();
15
- return n && ((u = (o = t.manualRate) == null ? void 0 : o.byCurrency) == null ? void 0 : u[n]) !== void 0 ? Number(t.manualRate.byCurrency[n]) : ((y = t.manualRate) == null ? void 0 : y.defaultRate) !== void 0 ? Number(t.manualRate.defaultRate) : n && ((m = t.monthlyRateByCurrency) == null ? void 0 : m[n]) !== void 0 ? Number(t.monthlyRateByCurrency[n]) : Number(t.monthlyRate || 0);
16
- }, R = (t, r, a) => {
17
- var m;
11
+ }, s = (t, n) => {
12
+ var o, y, u, m;
13
+ const r = t.currencyField || "currency", e = n[r], a = e === void 0 ? void 0 : String(e).toLowerCase();
14
+ return a && ((y = (o = t.manualRate) == null ? void 0 : o.byCurrency) == null ? void 0 : y[a]) !== void 0 ? Number(t.manualRate.byCurrency[a]) : ((u = t.manualRate) == null ? void 0 : u.defaultRate) !== void 0 ? Number(t.manualRate.defaultRate) : a && ((m = t.monthlyRateByCurrency) == null ? void 0 : m[a]) !== void 0 ? Number(t.monthlyRateByCurrency[a]) : Number(t.monthlyRate || 0);
15
+ }, c = (t) => Number(t.annualRate || 0), i = (t, n, r) => {
16
+ var e;
17
+ if (t.rateSource === "api") {
18
+ if (r !== void 0)
19
+ return r;
20
+ if (((e = t.apiRate) == null ? void 0 : e.fallbackToManual) === !1)
21
+ return 0;
22
+ }
23
+ return t.rateType === "monthly_rate" ? s(t, n) : c(t);
24
+ }, l = (t, n, r) => {
18
25
  const e = t.calculation;
19
26
  if ((e == null ? void 0 : e.preset) === "none")
20
27
  return 0;
21
- const n = c(r[e.amountField || "price"]), o = c(r[e.termField || "period"]), u = e.downPaymentField ? c(r[e.downPaymentField]) : n * Number(e.downPaymentPercent || 0) / 100, y = Math.max(n - u, 0);
28
+ const a = d(n[e.amountField || "price"]), o = d(n[e.termField || "period"]), y = e.downPaymentField ? d(n[e.downPaymentField]) : a * Number(e.downPaymentPercent || 0) / 100, u = Math.max(a - y, 0);
22
29
  if (e.rateType === "monthly_rate") {
23
- const i = e.rateSource === "api" && a !== void 0 ? a : e.rateSource === "api" && ((m = e.apiRate) == null ? void 0 : m.fallbackToManual) === !1 ? 0 : l(e, r);
24
- return s(
25
- y,
30
+ const m = i(e, n, r);
31
+ return f(
32
+ u,
26
33
  o,
27
- i,
34
+ m,
28
35
  e.roundMonthlyPayment !== !1
29
36
  );
30
37
  }
31
- return d({
32
- amount: y,
33
- term: o,
34
- annualRate: Number(e.annualRate || 0)
35
- }).monthlyPayment;
38
+ return e.rateType === "annual_decimal" ? f(
39
+ u,
40
+ o,
41
+ i(e, n, r) / 12,
42
+ e.roundMonthlyPayment !== !1
43
+ ) : f(
44
+ u,
45
+ o,
46
+ i(e, n, r) / 100 / 12,
47
+ e.roundMonthlyPayment !== !1
48
+ );
36
49
  };
37
50
  export {
38
- R as getMonthlyPayment
51
+ l as getMonthlyPayment
39
52
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "md-components-mdigial-azamat",
3
3
  "author": "Azamat Raimbekov",
4
4
  "private": false,
5
- "version": "0.0.295",
5
+ "version": "0.0.296",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",