@gipisistemas/ng-core 1.1.15 → 1.1.16

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.
@@ -31954,6 +31954,602 @@
31954
31954
  return CurrencyUtil;
31955
31955
  }());
31956
31956
 
31957
+ var cUFsValidas = [
31958
+ 'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA',
31959
+ 'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN',
31960
+ 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO', 'EX'
31961
+ ];
31962
+ var ACBrValidadorIE = /** @class */ (function () {
31963
+ function ACBrValidadorIE() {
31964
+ this._fsIgnorarChar = './-';
31965
+ this._fsDocumento = '';
31966
+ this.fsDocto = '';
31967
+ this._Complemento = '';
31968
+ this.fsMsgErro = '';
31969
+ this.fsDigitoCalculado = '';
31970
+ this.fsPermiteVazio = false;
31971
+ this.fsExibeDigitoCorreto = false;
31972
+ this.fsAjustarTamanho = false;
31973
+ }
31974
+ Object.defineProperty(ACBrValidadorIE.prototype, "IgnorarChar", {
31975
+ get: function () {
31976
+ return this._fsIgnorarChar;
31977
+ },
31978
+ set: function (value) {
31979
+ this._fsIgnorarChar = value;
31980
+ },
31981
+ enumerable: false,
31982
+ configurable: true
31983
+ });
31984
+ Object.defineProperty(ACBrValidadorIE.prototype, "Documento", {
31985
+ get: function () {
31986
+ return this._fsDocumento;
31987
+ },
31988
+ set: function (value) {
31989
+ if (this._fsDocumento === value) {
31990
+ return;
31991
+ }
31992
+ this._fsDocumento = value;
31993
+ this.fsMsgErro = 'Função Validar não foi chamada';
31994
+ this.fsDigitoCalculado = '';
31995
+ this.fsDocto = this._LimpaDocto(this._fsDocumento);
31996
+ },
31997
+ enumerable: false,
31998
+ configurable: true
31999
+ });
32000
+ Object.defineProperty(ACBrValidadorIE.prototype, "Complemento", {
32001
+ get: function () {
32002
+ return this._Complemento;
32003
+ },
32004
+ set: function (value) {
32005
+ this._Complemento = value;
32006
+ },
32007
+ enumerable: false,
32008
+ configurable: true
32009
+ });
32010
+ ACBrValidadorIE.prototype.isValid = function (IE, UF, ignorarChar) {
32011
+ if (ignorarChar === void 0) { ignorarChar = './-'; }
32012
+ this.Documento = IE;
32013
+ this.Complemento = UF;
32014
+ this.IgnorarChar = ignorarChar || './-';
32015
+ this.Documento = this.formatar();
32016
+ if (this._validar()) {
32017
+ return { ie: this.Documento, isValid: true, error: '' };
32018
+ }
32019
+ else {
32020
+ return { ie: this.Documento, isValid: false, error: this.fsMsgErro };
32021
+ }
32022
+ };
32023
+ ACBrValidadorIE.prototype._validar = function () {
32024
+ this.fsMsgErro = '';
32025
+ this.fsDocto = this._LimpaDocto(this._fsDocumento);
32026
+ this.fsDigitoCalculado = '';
32027
+ if (this.fsDocto === '') {
32028
+ if (this.fsPermiteVazio) {
32029
+ return true;
32030
+ }
32031
+ else {
32032
+ this.fsMsgErro = "Inscri\u00E7\u00E3o Estadual n\u00E3o pode ser vazio.";
32033
+ }
32034
+ }
32035
+ if (this.fsMsgErro === '') {
32036
+ this._ValidarIE();
32037
+ }
32038
+ return (this.fsMsgErro === '');
32039
+ };
32040
+ ACBrValidadorIE.prototype.formatar = function () {
32041
+ var doc = this._LimpaDocto(this._fsDocumento);
32042
+ return this._FormatarIE(doc);
32043
+ };
32044
+ ACBrValidadorIE.prototype._ValidarIE = function () {
32045
+ var c0_9 = '0-9';
32046
+ var cPesos = [
32047
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6],
32048
+ [0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5],
32049
+ [2, 0, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6],
32050
+ [0, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0],
32051
+ [0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0],
32052
+ [0, 2, 3, 4, 5, 6, 7, 0, 0, 8, 9, 0, 0, 0],
32053
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],
32054
+ [0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8],
32055
+ [0, 0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7],
32056
+ [0, 0, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 0],
32057
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 3, 0],
32058
+ [0, 0, 0, 0, 10, 8, 7, 6, 5, 4, 3, 1, 0, 0],
32059
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 0, 0],
32060
+ [0, 0, 2, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7]
32061
+ ];
32062
+ var vDigitos;
32063
+ var xROT;
32064
+ var yROT;
32065
+ var Tamanho;
32066
+ var FatorF;
32067
+ var FatorG;
32068
+ var xMD;
32069
+ var xTP;
32070
+ var yMD;
32071
+ var yTP;
32072
+ var DV;
32073
+ var DVX;
32074
+ var DVY;
32075
+ var SOMA;
32076
+ var SOMAq;
32077
+ var nD;
32078
+ var M;
32079
+ var OK;
32080
+ var Passo;
32081
+ var D;
32082
+ var LPrefixo;
32083
+ if (this.fsDocto.toUpperCase().trim() === 'ISENTO') {
32084
+ return;
32085
+ }
32086
+ if (this.Complemento === '') {
32087
+ this.fsMsgErro = 'Informe a UF no campo complemento';
32088
+ return;
32089
+ }
32090
+ this._ValidarUF(this.Complemento);
32091
+ if (this.fsMsgErro !== '') {
32092
+ return;
32093
+ }
32094
+ /**
32095
+ * Somente digitos ou letra P na primeira posicao
32096
+ * P é usado pela Insc.Estadual de Produtor Rural de SP
32097
+ */
32098
+ if (!this._StrIsNumber(this.fsDocto.substring(1)) ||
32099
+ (!this._CharIsNum(this.fsDocto[0]) && this.fsDocto[0] !== 'P')) {
32100
+ this.fsMsgErro = 'Caracteres inválidos na inscrição estadual';
32101
+ return;
32102
+ }
32103
+ Tamanho = 0;
32104
+ xROT = 'E';
32105
+ xMD = 11;
32106
+ xTP = 1;
32107
+ yROT = '';
32108
+ yMD = 0;
32109
+ yTP = 0;
32110
+ FatorF = 0;
32111
+ FatorG = 0;
32112
+ vDigitos = Array(14).fill('');
32113
+ if (this.Complemento === 'AC') {
32114
+ if (this.fsDocto.length === 9) {
32115
+ Tamanho = 9;
32116
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1', '0', '', '', '', '', ''];
32117
+ }
32118
+ else {
32119
+ Tamanho = 13;
32120
+ xTP = 2;
32121
+ yROT = 'E';
32122
+ yMD = 11;
32123
+ yTP = 1;
32124
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1', '0', ''];
32125
+ }
32126
+ }
32127
+ if (this.Complemento === 'AL') {
32128
+ Tamanho = 9;
32129
+ xROT = 'BD';
32130
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '4', '2', '', '', '', '', ''];
32131
+ }
32132
+ if (this.Complemento === 'AP') {
32133
+ Tamanho = 9;
32134
+ xROT = 'CE';
32135
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '3', '0', '', '', '', '', ''];
32136
+ if ((this.fsDocto >= '030170010') && (this.fsDocto <= '030190229')) {
32137
+ FatorF = 1;
32138
+ }
32139
+ else if (this.fsDocto >= '030190230') {
32140
+ xROT = 'E';
32141
+ }
32142
+ }
32143
+ if (this.Complemento === 'AM') {
32144
+ Tamanho = 9;
32145
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32146
+ }
32147
+ if (this.Complemento === 'BA') {
32148
+ if (this.fsDocto.length < 9) {
32149
+ this.fsDocto = this._PadLeft(this.fsDocto, 9, '0');
32150
+ }
32151
+ Tamanho = 9;
32152
+ xTP = 2;
32153
+ yTP = 3;
32154
+ yROT = 'E';
32155
+ vDigitos = ['DVX', 'DVY', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32156
+ if ('0123458'.includes(this.fsDocto[1])) {
32157
+ xMD = 10;
32158
+ yMD = 10;
32159
+ }
32160
+ else {
32161
+ xMD = 11;
32162
+ yMD = 11;
32163
+ }
32164
+ }
32165
+ if (this.Complemento === 'CE') {
32166
+ Tamanho = 9;
32167
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '', '', '', '', ''];
32168
+ }
32169
+ if (this.Complemento === 'DF') {
32170
+ Tamanho = 13;
32171
+ xTP = 2;
32172
+ yROT = 'E';
32173
+ yMD = 11;
32174
+ yTP = 1;
32175
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '7,8', '0', ''];
32176
+ }
32177
+ if (this.Complemento === 'ES') {
32178
+ Tamanho = 9;
32179
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32180
+ }
32181
+ if (this.Complemento === 'GO') {
32182
+ Tamanho = 9;
32183
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,2', '', '', '', '', ''];
32184
+ LPrefixo = this.fsDocto[0] + this.fsDocto[1];
32185
+ var prefixoValido = [10, 11, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29];
32186
+ if (!prefixoValido.includes(parseInt(LPrefixo))) {
32187
+ this.fsMsgErro = 'Prefixo IE inválido 10 ou 11 / 20 a 29';
32188
+ }
32189
+ if ((parseInt(this.fsDocto) >= 101031050) && (parseInt(this.fsDocto) <= 101199979)) {
32190
+ FatorG = 1;
32191
+ }
32192
+ }
32193
+ if (this.Complemento === 'MA') {
32194
+ Tamanho = 9;
32195
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '2', '1', '', '', '', '', ''];
32196
+ }
32197
+ if (this.Complemento === 'MT') {
32198
+ if (this.fsDocto.length === 9) {
32199
+ this.fsDocto = this._PadLeft(this.fsDocto, 11, '0');
32200
+ }
32201
+ Tamanho = 11;
32202
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', ''];
32203
+ }
32204
+ if (this.Complemento === 'MS') {
32205
+ Tamanho = 9;
32206
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '8', '2', '', '', '', '', ''];
32207
+ }
32208
+ if (this.Complemento === 'MG') {
32209
+ Tamanho = 13;
32210
+ xROT = 'AE';
32211
+ xMD = 10;
32212
+ xTP = 10;
32213
+ yROT = 'E';
32214
+ yMD = 11;
32215
+ yTP = 11;
32216
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, ''];
32217
+ }
32218
+ if (this.Complemento === 'PA') {
32219
+ Tamanho = 9;
32220
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '5', '1,7', '', '', '', '', ''];
32221
+ }
32222
+ if (this.Complemento === 'PB') {
32223
+ Tamanho = 9;
32224
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '6', '1', '', '', '', '', ''];
32225
+ }
32226
+ if (this.Complemento === 'PR') {
32227
+ Tamanho = 10;
32228
+ xTP = 9;
32229
+ yROT = 'E';
32230
+ yMD = 11;
32231
+ yTP = 8;
32232
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', ''];
32233
+ }
32234
+ if (this.Complemento === 'PE') {
32235
+ if (this.fsDocto.length === 14) {
32236
+ //Antigo CACEPE
32237
+ Tamanho = 14;
32238
+ xTP = 7;
32239
+ FatorF = 1;
32240
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1-9', '8', '1'];
32241
+ }
32242
+ else {
32243
+ Tamanho = 9;
32244
+ xTP = 14;
32245
+ yROT = 'E';
32246
+ yMD = 11;
32247
+ yTP = 7;
32248
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32249
+ }
32250
+ }
32251
+ if (this.Complemento === 'PI') {
32252
+ Tamanho = 9;
32253
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '9', '1', '', '', '', '', ''];
32254
+ }
32255
+ if (this.Complemento === 'RJ') {
32256
+ Tamanho = 8;
32257
+ xTP = 8;
32258
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,7,8,9', '', '', '', '', '', ''];
32259
+ }
32260
+ if (this.Complemento === 'RN') {
32261
+ if (this.fsDocto.length === 9) {
32262
+ Tamanho = 9;
32263
+ xROT = 'BD';
32264
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '2', '', '', '', '', ''];
32265
+ }
32266
+ else {
32267
+ Tamanho = 10;
32268
+ xROT = 'BD';
32269
+ xTP = 11;
32270
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '2', '', '', '', ''];
32271
+ }
32272
+ }
32273
+ if (this.Complemento === 'RS') {
32274
+ Tamanho = 10;
32275
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', ''];
32276
+ }
32277
+ if (this.Complemento === 'RO') {
32278
+ FatorF = 1;
32279
+ if (this.fsDocto.length === 9) {
32280
+ Tamanho = 9;
32281
+ xTP = 4;
32282
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1-9', '', '', '', '', ''];
32283
+ }
32284
+ else {
32285
+ Tamanho = 14;
32286
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9];
32287
+ }
32288
+ }
32289
+ if (this.Complemento === 'RR') {
32290
+ Tamanho = 9;
32291
+ xROT = 'D';
32292
+ xMD = 9;
32293
+ xTP = 5;
32294
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '4', '2', '', '', '', '', ''];
32295
+ }
32296
+ if ((this.Complemento === 'SC') || (this.Complemento === 'SE')) {
32297
+ Tamanho = 9;
32298
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32299
+ }
32300
+ if (this.Complemento === 'SP') {
32301
+ xROT = 'D';
32302
+ xTP = 12;
32303
+ if (this.fsDocto[0] === 'P') {
32304
+ Tamanho = 13;
32305
+ vDigitos = [c0_9, c0_9, c0_9, 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, 'P', ''];
32306
+ }
32307
+ else {
32308
+ Tamanho = 12;
32309
+ yROT = 'D';
32310
+ yMD = 11;
32311
+ yTP = 13;
32312
+ vDigitos = ['DVY', c0_9, c0_9, 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', ''];
32313
+ }
32314
+ }
32315
+ if (this.Complemento === 'TO') {
32316
+ if (this.fsDocto.length === 11) {
32317
+ Tamanho = 11;
32318
+ xTP = 6;
32319
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,2,3,9', '0,9', '9', '2', '', '', ''];
32320
+ }
32321
+ else {
32322
+ /**
32323
+ * Tamanho = 10;
32324
+ * vDigitos = ['DVX',c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,'0-4','','','',''];
32325
+ */
32326
+ Tamanho = 9;
32327
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32328
+ }
32329
+ }
32330
+ /** Verificando se o Tamanho Total está correto */
32331
+ if (this.fsAjustarTamanho) {
32332
+ this.fsDocto = this._PadLeft(this.fsDocto, Tamanho, '0');
32333
+ }
32334
+ OK = (Tamanho > 0) && (this.fsDocto.length === Tamanho);
32335
+ if (!OK) {
32336
+ this.fsMsgErro = "Tamanho inv\u00E1lido: Esperado " + Tamanho + " caracteres, mas foram digitados somente " + this.fsDocto.length + " caracteres.";
32337
+ }
32338
+ /** Verificando os digitos nas posicoes são permitidos */
32339
+ this.fsDocto = this._PadLeft(this.fsDocto, 14);
32340
+ DVX = 0;
32341
+ DVY = 0;
32342
+ var I = 13;
32343
+ while (OK && I >= 0) {
32344
+ var D_1 = this.fsDocto[13 - I];
32345
+ if (vDigitos[I] === '') {
32346
+ OK = (D_1 === ' ');
32347
+ }
32348
+ else if (vDigitos[I] === 'DVX' || vDigitos[I] === 'DVY' || vDigitos[I] === c0_9) {
32349
+ OK = this._CharIsNum(D_1);
32350
+ if (vDigitos[I] === 'DVX') {
32351
+ DVX = parseInt(D_1, 10);
32352
+ }
32353
+ else if (vDigitos[I] === 'DVY') {
32354
+ DVY = parseInt(D_1, 10);
32355
+ }
32356
+ }
32357
+ else if (vDigitos[I].includes(',')) {
32358
+ OK = vDigitos[I].split(',').includes(D_1);
32359
+ }
32360
+ else if (vDigitos[I].includes('-')) {
32361
+ var _a = __read(vDigitos[I].split('-'), 2), min = _a[0], max = _a[1];
32362
+ OK = (D_1 >= min && D_1 <= max);
32363
+ }
32364
+ else {
32365
+ OK = (D_1 === vDigitos[I]);
32366
+ }
32367
+ if (!OK) {
32368
+ this.fsMsgErro = "D\u00EDgito " + (13 - I - (13 - Tamanho)) + " deveria ser " + vDigitos[I];
32369
+ }
32370
+ I--;
32371
+ }
32372
+ Passo = 'X';
32373
+ while (OK && xTP > 0) {
32374
+ SOMA = 0;
32375
+ SOMAq = 0;
32376
+ I = 14;
32377
+ while (OK && I > 0) {
32378
+ D = this.fsDocto[14 - I];
32379
+ if (this._CharIsNum(D)) {
32380
+ nD = parseInt(D, 10);
32381
+ M = nD * cPesos[xTP - 1][I - 1];
32382
+ SOMA += M;
32383
+ if (xROT.includes('A')) {
32384
+ SOMAq += Math.floor(M / 10);
32385
+ }
32386
+ }
32387
+ I--;
32388
+ }
32389
+ if (xROT.includes('A')) {
32390
+ SOMA += SOMAq;
32391
+ }
32392
+ else if (xROT.includes('B')) {
32393
+ SOMA *= 10;
32394
+ }
32395
+ else if (xROT.includes('C')) {
32396
+ SOMA += (5 + (4 * FatorF));
32397
+ }
32398
+ /** Calculando digito verificador */
32399
+ DV = SOMA % xMD;
32400
+ if (xROT.includes('E')) {
32401
+ DV = xMD - DV;
32402
+ }
32403
+ if (DV === 10) {
32404
+ DV = FatorG; /** Apenas GO modifica o FatorG para diferente de 0 */
32405
+ }
32406
+ else if (DV === 11) {
32407
+ DV = FatorF;
32408
+ }
32409
+ if (Passo === 'X') {
32410
+ OK = (DVX === DV);
32411
+ }
32412
+ else {
32413
+ OK = (DVY === DV);
32414
+ }
32415
+ this.fsDigitoCalculado = DV.toString();
32416
+ if (!OK) {
32417
+ this.fsMsgErro = 'Dígito verificador inválido.';
32418
+ if (this.fsExibeDigitoCorreto) {
32419
+ this.fsMsgErro += ".. Calculado: " + this.fsDigitoCalculado;
32420
+ }
32421
+ }
32422
+ if (Passo === 'X') {
32423
+ Passo = 'Y';
32424
+ xROT = yROT;
32425
+ xMD = yMD;
32426
+ xTP = yTP;
32427
+ }
32428
+ else {
32429
+ break;
32430
+ }
32431
+ }
32432
+ this.fsDocto = this.fsDocto.trim();
32433
+ if (this.fsMsgErro !== '') {
32434
+ this.fsMsgErro = "Inscri\u00E7\u00E3o estadual inv\u00E1lida para " + this.Complemento + ". " + this.fsMsgErro;
32435
+ }
32436
+ };
32437
+ ACBrValidadorIE.prototype._ValidarUF = function (uf) {
32438
+ if (!cUFsValidas.includes(uf.toUpperCase())) {
32439
+ this.fsMsgErro = "UF inv\u00E1lido: " + uf;
32440
+ }
32441
+ };
32442
+ ACBrValidadorIE.prototype._StrIsNumber = function (s) {
32443
+ return /^\d+$/.test(s);
32444
+ };
32445
+ ACBrValidadorIE.prototype._CharIsNum = function (c) {
32446
+ return /^\d$/.test(c);
32447
+ };
32448
+ ACBrValidadorIE.prototype._PadLeft = function (value, length, padChar) {
32449
+ return value.padStart(length, padChar);
32450
+ };
32451
+ ACBrValidadorIE.prototype._LimpaDocto = function (aString) {
32452
+ var result = '';
32453
+ for (var a = 0; a < aString.length; a++) {
32454
+ if (!this.IgnorarChar.includes(aString[a])) {
32455
+ result += aString[a].toUpperCase();
32456
+ }
32457
+ }
32458
+ return result.trim();
32459
+ };
32460
+ ACBrValidadorIE.prototype._MascaraIE = function (AValue) {
32461
+ var LenDoc = AValue.length;
32462
+ var Mascara = '*'.repeat(LenDoc);
32463
+ if (this.Complemento === 'AC')
32464
+ Mascara = '**.***.***/***-**';
32465
+ if (this.Complemento === 'AL')
32466
+ Mascara = '*********';
32467
+ if (this.Complemento === 'AP')
32468
+ Mascara = '*********';
32469
+ if (this.Complemento === 'AM')
32470
+ Mascara = '**.***.***-*';
32471
+ if (this.Complemento === 'BA')
32472
+ Mascara = '*******-**';
32473
+ if (this.Complemento === 'CE')
32474
+ Mascara = '********-*';
32475
+ if (this.Complemento === 'DF')
32476
+ Mascara = '***********-**';
32477
+ if (this.Complemento === 'ES')
32478
+ Mascara = '*********';
32479
+ if (this.Complemento === 'GO')
32480
+ Mascara = '**.***.***-*';
32481
+ if (this.Complemento === 'MA')
32482
+ Mascara = '*********';
32483
+ if (this.Complemento === 'MT')
32484
+ Mascara = '**********-*';
32485
+ if (this.Complemento === 'MS')
32486
+ Mascara = '**.***.***-*';
32487
+ if (this.Complemento === 'MG')
32488
+ Mascara = '***.***.***/****';
32489
+ if (this.Complemento === 'PA')
32490
+ Mascara = '**-******-*';
32491
+ if (this.Complemento === 'PB')
32492
+ Mascara = '********-*';
32493
+ if (this.Complemento === 'PR')
32494
+ Mascara = '***.*****-**';
32495
+ if (this.Complemento === 'PE')
32496
+ Mascara = (LenDoc > 9) ? '**.*.***.*******-*' : '*******-**';
32497
+ if (this.Complemento === 'PI')
32498
+ Mascara = '*********';
32499
+ if (this.Complemento === 'RJ')
32500
+ Mascara = '**.***.**-*';
32501
+ if (this.Complemento === 'RN')
32502
+ Mascara = (LenDoc > 9) ? '**.*.***.***-*' : '**.***.***-*';
32503
+ if (this.Complemento === 'RS')
32504
+ Mascara = '***/*******';
32505
+ if (this.Complemento === 'RO')
32506
+ Mascara = (LenDoc > 13) ? '*************-*' : '***.*****-*';
32507
+ if (this.Complemento === 'RR')
32508
+ Mascara = '********-*';
32509
+ if (this.Complemento === 'SC')
32510
+ Mascara = '***.***.***';
32511
+ if (this.Complemento === 'SP')
32512
+ Mascara = ((LenDoc > 1) && (AValue[0] === 'P')) ? '*-********.*/***' : '***.***.***.***';
32513
+ if (this.Complemento === 'SE')
32514
+ Mascara = '**.***.***-*';
32515
+ if (this.Complemento === 'TO')
32516
+ Mascara = (LenDoc = 11) ? '**.**.******-*' : '**.***.***-*';
32517
+ return Mascara;
32518
+ };
32519
+ ACBrValidadorIE.prototype._FormatarIE = function (AValue) {
32520
+ if (AValue.trim().toUpperCase() === 'ISENTO') {
32521
+ return AValue;
32522
+ }
32523
+ var Mascara = this._MascaraIE(AValue);
32524
+ return this._FormatarMascaraNumerica(this._OnlyAlphaNum(AValue), Mascara);
32525
+ };
32526
+ ACBrValidadorIE.prototype._OnlyAlphaNum = function (str) {
32527
+ return str.replace(/[^a-zA-Z0-9]/g, '');
32528
+ };
32529
+ ACBrValidadorIE.prototype._FormatarMascaraNumerica = function (numValue, mascara) {
32530
+ var result = '';
32531
+ var wNumValue = numValue.trim();
32532
+ var lenMas = mascara.length;
32533
+ var lenDoc = wNumValue.length;
32534
+ var j = lenMas;
32535
+ for (var i = lenMas - 1; i >= 0; i--) {
32536
+ var c = mascara[i];
32537
+ if (c === '*') {
32538
+ if (j <= (lenMas - lenDoc)) {
32539
+ c = '0';
32540
+ }
32541
+ else {
32542
+ c = wNumValue[j - (lenMas - lenDoc) - 1];
32543
+ }
32544
+ j--;
32545
+ }
32546
+ result = c + result;
32547
+ }
32548
+ return result;
32549
+ };
32550
+ return ACBrValidadorIE;
32551
+ }());
32552
+
31957
32553
  /** @dynamic */
31958
32554
  var DocumentUtil = /** @class */ (function () {
31959
32555
  function DocumentUtil() {
@@ -32058,20 +32654,12 @@
32058
32654
  };
32059
32655
  DocumentUtil.isValidStateRegistration = function (acronymState, stateRegistration) {
32060
32656
  if (StringUtil.isEmpty(acronymState) || StringUtil.isEmpty(stateRegistration)) {
32061
- return false;
32062
- }
32063
- else if (stateRegistration.toUpperCase() === 'ISENTO') {
32064
- return true;
32657
+ return { ie: stateRegistration, isValid: false, error: 'É nescessário informar a UF e a inscrição estadual para a validação' };
32065
32658
  }
32066
- else {
32067
- if (acronymState === 'GO') {
32068
- var digits = brazilianUtils.onlyNumbers(stateRegistration);
32069
- return this.calcDigit(digits);
32070
- }
32071
- else {
32072
- return brazilianUtils.isValidIE(acronymState, stateRegistration);
32073
- }
32659
+ if (stateRegistration.toUpperCase() === 'ISENTO') {
32660
+ return { ie: stateRegistration, isValid: true, error: '' };
32074
32661
  }
32662
+ return (new ACBrValidadorIE().isValid(stateRegistration, acronymState, './-'));
32075
32663
  };
32076
32664
  DocumentUtil.isValidCep = function (cep) {
32077
32665
  if (StringUtil.isEmpty(cep)) {
@@ -32079,32 +32667,6 @@
32079
32667
  }
32080
32668
  return brazilianUtils.isValidCEP(cep);
32081
32669
  };
32082
- DocumentUtil.calcDigit = function (ie) {
32083
- var length = ie.length;
32084
- var position = length - 1;
32085
- var weight = length;
32086
- var body = ie.substring(0, position);
32087
- // const bodyInt: number = parseInt(body, 10);
32088
- var sum = 0;
32089
- body.split('').forEach(function (digit) {
32090
- sum += parseInt(digit, 10) * weight;
32091
- weight--;
32092
- });
32093
- var rest = sum % 11;
32094
- var dig = 11 - rest;
32095
- var fatorG = 0;
32096
- if ((Number(ie) >= 101031050) && (Number(ie) <= 101199979)) {
32097
- fatorG = 1;
32098
- }
32099
- if (dig === 10) {
32100
- dig = fatorG;
32101
- }
32102
- else if (dig === 11) {
32103
- dig = 0;
32104
- }
32105
- var digIe = parseInt(ie.charAt(position), 10);
32106
- return dig === digIe;
32107
- };
32108
32670
  return DocumentUtil;
32109
32671
  }());
32110
32672