@bizy/core 19.14.4 → 19.14.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.
@@ -2580,23 +2580,7 @@ class BizyFilterPipe {
2580
2580
  return `__DATE__:${value.toISOString()}`;
2581
2581
  return value;
2582
2582
  }
2583
- // Sort keys consistently
2584
- const ordered = sortKeys(obj);
2585
- return JSON.stringify(ordered, replacer);
2586
- }
2587
- function sortKeys(obj) {
2588
- if (Array.isArray(obj)) {
2589
- return obj.map(sortKeys);
2590
- }
2591
- else if (obj && typeof obj === 'object' && !(obj instanceof Date)) {
2592
- return Object.keys(obj)
2593
- .sort()
2594
- .reduce((acc, key) => {
2595
- acc[key] = sortKeys(obj[key]);
2596
- return acc;
2597
- }, {});
2598
- }
2599
- return obj;
2583
+ return JSON.stringify(obj, replacer);
2600
2584
  }
2601
2585
  function uniqueObjects(items) {
2602
2586
  const seen = new Set();
@@ -4141,23 +4125,27 @@ class BizyValidatorService {
4141
4125
  isUppercase = (value) => validator.isUppercase(value);
4142
4126
  isMobilePhone = (data) => validator.isMobilePhone(data.value, data.locale);
4143
4127
  isCUIT(cuit) {
4144
- const regex = /(^[0-9]{2}-[0-9]{8}-[0-9]$)/i;
4145
- const isCUIT = regex.test(String(cuit).toLowerCase());
4146
- if (!isCUIT) {
4128
+ if (!cuit) {
4147
4129
  return false;
4148
4130
  }
4149
- cuit = String(cuit).replace(/[-_]/g, '');
4150
- if (cuit.length == 11) {
4151
- const mult = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
4152
- let total = 0;
4153
- for (let i = 0; i < mult.length; i++) {
4154
- total += parseInt(cuit[i]) * mult[i];
4155
- }
4156
- const mod = total % 11;
4157
- const digit = mod === 0 ? 0 : mod === 1 ? 9 : 11 - mod;
4158
- return digit === parseInt(cuit[10]);
4131
+ if (this.isString(cuit)) {
4132
+ cuit = cuit.replace(/[-]/g, '');
4133
+ }
4134
+ else {
4135
+ cuit = String(cuit);
4136
+ }
4137
+ // 20, 23, 24, 25, 26 y 27 Personas Físicas
4138
+ // 30, 33 y 34 Personas Jurídicas.
4139
+ if (!/^(20|23|24|25|26|27|30|33|34)\d{8}\d$/.test(cuit)) {
4140
+ return false;
4159
4141
  }
4160
- return false;
4142
+ const multipliers = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
4143
+ const digits = cuit.split('').map(Number);
4144
+ const checkDigit = digits[10];
4145
+ const sum = multipliers.reduce((acc, _multiplier, i) => acc + _multiplier * digits[i], 0);
4146
+ const mod11 = 11 - (sum % 11);
4147
+ const expectedDigit = mod11 === 11 ? 0 : mod11 === 10 ? 9 : mod11;
4148
+ return checkDigit === expectedDigit;
4161
4149
  }
4162
4150
  isDNI(dni) {
4163
4151
  const regex = /(^[1-9]{1}[0-9]{7}$)/i;