currency_contry_exchange 1.6.4 → 1.7.0
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/README.md +78 -35
- package/dist/main.cjs +34 -34
- package/dist/main.d.ts +3 -1
- package/dist/main.iife.js +34 -34
- package/dist/main.js +1066 -989
- package/dist/main.umd.cjs +34 -34
- package/dist/models/interfaces.d.ts +15 -0
- package/dist/utils/InterestAmount.d.ts +1 -0
- package/package.json +40 -40
package/README.md
CHANGED
|
@@ -1,62 +1,105 @@
|
|
|
1
1
|
# TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Librería para formateo de monedas, documentos, etiquetas y cálculo de intereses según país.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
## Install
|
|
5
|
+
## Instalación
|
|
7
6
|
|
|
8
7
|
```bash
|
|
9
|
-
|
|
8
|
+
npm install currency_contry_exchange
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
##
|
|
13
|
-
|
|
11
|
+
## Importación y Uso
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
14
|
import { Faastlocation } from 'faastlocation';
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
// Puedes inicializar con país por defecto (opcional)
|
|
17
|
+
const location = new Faastlocation('cl'); // o sin parámetro para usar el default
|
|
16
18
|
```
|
|
17
19
|
|
|
18
|
-
##
|
|
20
|
+
## Métodos Disponibles
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Devuelve una etiqueta específica basada en el país y la etiqueta proporcionada.
|
|
22
|
+
- **labels({ contry, label }): string**
|
|
23
|
+
Devuelve una etiqueta específica basada en el país y la etiqueta proporcionada.
|
|
23
24
|
|
|
24
|
-
validateFormaterRut({ contry
|
|
25
|
-
Valida o formatea un RUT (Rol Único Tributario) según el país especificado.
|
|
26
|
-
|
|
25
|
+
- **validateFormaterRut({ contry, rut, isValidate }): string | boolean**
|
|
26
|
+
Valida o formatea un RUT (Rol Único Tributario) según el país especificado.
|
|
27
|
+
Si `isValidate` es `true`, valida el rut; si es `false` (por defecto), lo formatea.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
- **validateFormaterDoc({ contry, rut, isValidate }): string | boolean**
|
|
30
|
+
Valida o formatea un documento según el país.
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
- **formaterCurrency({ contry, currency, typeCurrenzy }): string**
|
|
33
|
+
Formatea una cantidad de moneda específica según el país.
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```
|
|
35
|
+
- **formaterInputProps({ contry, typeCurrenzy, decimalScale, fixedDecimalScale }): object**
|
|
36
|
+
Devuelve propiedades de objeto específicas según el país, útil para librerías como NumberFormat.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
- **formaterAmount({ contry, amount, typeCurrenzy }): string**
|
|
39
|
+
Formatea una cantidad según el país especificado.
|
|
40
|
+
|
|
41
|
+
- **rutValidatorIsNatural({ contry, rut }): boolean**
|
|
42
|
+
Valida si el rut corresponde a una persona natural según el país.
|
|
43
|
+
|
|
44
|
+
- **symbolCurrencyIndicadorCartera({ contry }): string**
|
|
45
|
+
Devuelve el símbolo de la moneda para el país.
|
|
46
|
+
|
|
47
|
+
- **formaterNumDocument({ contry, value }): string**
|
|
48
|
+
Formatea el número de documento según el país.
|
|
49
|
+
|
|
50
|
+
- **interestAmountunt({ contry, type, anticipo, tasa, plazo, array_interes }): number | string | any[]**
|
|
51
|
+
Calcula el interés simple o compuesto según país y parámetros.
|
|
52
|
+
- Para Chile (`cl`): retorna entero, redondeando hacia arriba solo si hay decimales.
|
|
53
|
+
- Para Perú (`pe`): retorna con 2 decimales.
|
|
54
|
+
- Soporta cálculo individual o por arreglo (`array_interes`).
|
|
55
|
+
|
|
56
|
+
## Ejemplo de Uso
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const location = new Faastlocation('cl');
|
|
41
60
|
|
|
42
61
|
const label = location.labels({ contry: 'cl', label: 'cliente' });
|
|
43
62
|
console.log(label);
|
|
44
63
|
|
|
45
|
-
const formattedRut = location.validateFormaterRut({ contry: 'pe', rut: '123456789', isValidate: true
|
|
64
|
+
const formattedRut = location.validateFormaterRut({ contry: 'pe', rut: '123456789', isValidate: true });
|
|
46
65
|
console.log(formattedRut);
|
|
47
66
|
|
|
48
67
|
const formattedCurrency = location.formaterCurrency({ contry: 'cl', currency: 1000 });
|
|
49
68
|
console.log(formattedCurrency);
|
|
50
69
|
|
|
51
|
-
const
|
|
52
|
-
console.log(
|
|
70
|
+
const inputProps = location.formaterInputProps({ contry: 'cl', typeCurrenzy: 'CLP' });
|
|
71
|
+
console.log(inputProps);
|
|
72
|
+
|
|
73
|
+
const interest = location.interestAmountunt({ contry: 'cl', type: 'simple', anticipo: 650000, tasa: 1.8, plazo: 90 });
|
|
74
|
+
console.log(interest); // 35100
|
|
75
|
+
|
|
76
|
+
const interestArray = location.interestAmountunt({
|
|
77
|
+
contry: 'pe',
|
|
78
|
+
type: 'compuesto',
|
|
79
|
+
array_interes: [
|
|
80
|
+
{ id: 1, anticipo: 1000, tasa: 2, plazo: 60 },
|
|
81
|
+
{ id: 2, anticipo: 2000, tasa: 1.5, plazo: 30 }
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
console.log(interestArray); // [{ id: 1, result: },{ id: 2, result: }]
|
|
53
85
|
```
|
|
54
86
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
87
|
+
## Tabla de Métodos
|
|
88
|
+
|
|
89
|
+
| Método | Parámetros | Retorno | Descripción |
|
|
90
|
+
|------------------------------- |---------------------------------------------------------------------------|-----------------|---------------------------------------------------------------------------------------------------------------|
|
|
91
|
+
| labels | { contry: string, label: string } | string | Devuelve una etiqueta localizada. |
|
|
92
|
+
| validateFormaterRut | { contry: string, rut: string, isValidate: boolean } | string/boolean | Valida o formatea un RUT según país. |
|
|
93
|
+
| validateFormaterDoc | { contry: string, rut: string, isValidate: boolean } | string/boolean | Valida o formatea un documento según país. |
|
|
94
|
+
| formaterCurrency | { contry: string, currency: number, typeCurrenzy: string } | string | Formatea un valor monetario según país y tipo de moneda. |
|
|
95
|
+
| formaterInputProps | { contry: string, typeCurrenzy: string, decimalScale?: number, fixedDecimalScale?: boolean } | object | Devuelve propiedades de input adaptadas al país y moneda. |
|
|
96
|
+
| formaterAmount | { contry: string, amount: number, typeCurrenzy: string } | string | Devuelve el monto formateado según país. |
|
|
97
|
+
| rutValidatorIsNatural | { contry: string, rut: string } | boolean | Valida si el rut es de persona natural. |
|
|
98
|
+
| symbolCurrencyIndicadorCartera | { contry: string } | string | Devuelve el símbolo de la moneda para el país. |
|
|
99
|
+
| formaterNumDocument | { contry: string, value: string } | string | Formatea el número de documento según país. |
|
|
100
|
+
| interestAmountunt | { contry: string, type: 'simple' \| 'compuesto', anticipo: number, tasa: number, plazo: number, array_interes?: any[] } | number/string/any[] | Calcula interés simple o compuesto según país. CL: entero, redondeo arriba si hay decimales. PE: 2 decimales. |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
**Nota:**
|
|
105
|
+
Puedes inicializar la instancia con el país por defecto, así no necesitas pasar `contry` en cada método.
|