@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.
@@ -70,7 +70,7 @@ import * as moment_ from 'moment';
70
70
  import { MatDatepickerIntl as MatDatepickerIntl$1, MAT_DATEPICKER_SCROLL_STRATEGY as MAT_DATEPICKER_SCROLL_STRATEGY$1, MatDatepickerModule, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER as MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER$1, matDatepickerAnimations as matDatepickerAnimations$1 } from '@angular/material/datepicker';
71
71
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
72
72
  import { DomSanitizer } from '@angular/platform-browser';
73
- import { onlyNumbers, isValidIE, isValidCEP } from '@brazilian-utils/brazilian-utils';
73
+ import { isValidCEP } from '@brazilian-utils/brazilian-utils';
74
74
 
75
75
  var APP_MESSAGES = new InjectionToken('app.messages');
76
76
  var DEFAULT_MESSAGES = {
@@ -31801,6 +31801,602 @@ var CurrencyUtil = /** @class */ (function () {
31801
31801
  return CurrencyUtil;
31802
31802
  }());
31803
31803
 
31804
+ var cUFsValidas = [
31805
+ 'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA',
31806
+ 'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN',
31807
+ 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO', 'EX'
31808
+ ];
31809
+ var ACBrValidadorIE = /** @class */ (function () {
31810
+ function ACBrValidadorIE() {
31811
+ this._fsIgnorarChar = './-';
31812
+ this._fsDocumento = '';
31813
+ this.fsDocto = '';
31814
+ this._Complemento = '';
31815
+ this.fsMsgErro = '';
31816
+ this.fsDigitoCalculado = '';
31817
+ this.fsPermiteVazio = false;
31818
+ this.fsExibeDigitoCorreto = false;
31819
+ this.fsAjustarTamanho = false;
31820
+ }
31821
+ Object.defineProperty(ACBrValidadorIE.prototype, "IgnorarChar", {
31822
+ get: function () {
31823
+ return this._fsIgnorarChar;
31824
+ },
31825
+ set: function (value) {
31826
+ this._fsIgnorarChar = value;
31827
+ },
31828
+ enumerable: false,
31829
+ configurable: true
31830
+ });
31831
+ Object.defineProperty(ACBrValidadorIE.prototype, "Documento", {
31832
+ get: function () {
31833
+ return this._fsDocumento;
31834
+ },
31835
+ set: function (value) {
31836
+ if (this._fsDocumento === value) {
31837
+ return;
31838
+ }
31839
+ this._fsDocumento = value;
31840
+ this.fsMsgErro = 'Função Validar não foi chamada';
31841
+ this.fsDigitoCalculado = '';
31842
+ this.fsDocto = this._LimpaDocto(this._fsDocumento);
31843
+ },
31844
+ enumerable: false,
31845
+ configurable: true
31846
+ });
31847
+ Object.defineProperty(ACBrValidadorIE.prototype, "Complemento", {
31848
+ get: function () {
31849
+ return this._Complemento;
31850
+ },
31851
+ set: function (value) {
31852
+ this._Complemento = value;
31853
+ },
31854
+ enumerable: false,
31855
+ configurable: true
31856
+ });
31857
+ ACBrValidadorIE.prototype.isValid = function (IE, UF, ignorarChar) {
31858
+ if (ignorarChar === void 0) { ignorarChar = './-'; }
31859
+ this.Documento = IE;
31860
+ this.Complemento = UF;
31861
+ this.IgnorarChar = ignorarChar || './-';
31862
+ this.Documento = this.formatar();
31863
+ if (this._validar()) {
31864
+ return { ie: this.Documento, isValid: true, error: '' };
31865
+ }
31866
+ else {
31867
+ return { ie: this.Documento, isValid: false, error: this.fsMsgErro };
31868
+ }
31869
+ };
31870
+ ACBrValidadorIE.prototype._validar = function () {
31871
+ this.fsMsgErro = '';
31872
+ this.fsDocto = this._LimpaDocto(this._fsDocumento);
31873
+ this.fsDigitoCalculado = '';
31874
+ if (this.fsDocto === '') {
31875
+ if (this.fsPermiteVazio) {
31876
+ return true;
31877
+ }
31878
+ else {
31879
+ this.fsMsgErro = "Inscri\u00E7\u00E3o Estadual n\u00E3o pode ser vazio.";
31880
+ }
31881
+ }
31882
+ if (this.fsMsgErro === '') {
31883
+ this._ValidarIE();
31884
+ }
31885
+ return (this.fsMsgErro === '');
31886
+ };
31887
+ ACBrValidadorIE.prototype.formatar = function () {
31888
+ var doc = this._LimpaDocto(this._fsDocumento);
31889
+ return this._FormatarIE(doc);
31890
+ };
31891
+ ACBrValidadorIE.prototype._ValidarIE = function () {
31892
+ var c0_9 = '0-9';
31893
+ var cPesos = [
31894
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6],
31895
+ [0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5],
31896
+ [2, 0, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6],
31897
+ [0, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0],
31898
+ [0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0],
31899
+ [0, 2, 3, 4, 5, 6, 7, 0, 0, 8, 9, 0, 0, 0],
31900
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],
31901
+ [0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8],
31902
+ [0, 0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7],
31903
+ [0, 0, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 0],
31904
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 3, 0],
31905
+ [0, 0, 0, 0, 10, 8, 7, 6, 5, 4, 3, 1, 0, 0],
31906
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 0, 0],
31907
+ [0, 0, 2, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7]
31908
+ ];
31909
+ var vDigitos;
31910
+ var xROT;
31911
+ var yROT;
31912
+ var Tamanho;
31913
+ var FatorF;
31914
+ var FatorG;
31915
+ var xMD;
31916
+ var xTP;
31917
+ var yMD;
31918
+ var yTP;
31919
+ var DV;
31920
+ var DVX;
31921
+ var DVY;
31922
+ var SOMA;
31923
+ var SOMAq;
31924
+ var nD;
31925
+ var M;
31926
+ var OK;
31927
+ var Passo;
31928
+ var D;
31929
+ var LPrefixo;
31930
+ if (this.fsDocto.toUpperCase().trim() === 'ISENTO') {
31931
+ return;
31932
+ }
31933
+ if (this.Complemento === '') {
31934
+ this.fsMsgErro = 'Informe a UF no campo complemento';
31935
+ return;
31936
+ }
31937
+ this._ValidarUF(this.Complemento);
31938
+ if (this.fsMsgErro !== '') {
31939
+ return;
31940
+ }
31941
+ /**
31942
+ * Somente digitos ou letra P na primeira posicao
31943
+ * P é usado pela Insc.Estadual de Produtor Rural de SP
31944
+ */
31945
+ if (!this._StrIsNumber(this.fsDocto.substring(1)) ||
31946
+ (!this._CharIsNum(this.fsDocto[0]) && this.fsDocto[0] !== 'P')) {
31947
+ this.fsMsgErro = 'Caracteres inválidos na inscrição estadual';
31948
+ return;
31949
+ }
31950
+ Tamanho = 0;
31951
+ xROT = 'E';
31952
+ xMD = 11;
31953
+ xTP = 1;
31954
+ yROT = '';
31955
+ yMD = 0;
31956
+ yTP = 0;
31957
+ FatorF = 0;
31958
+ FatorG = 0;
31959
+ vDigitos = Array(14).fill('');
31960
+ if (this.Complemento === 'AC') {
31961
+ if (this.fsDocto.length === 9) {
31962
+ Tamanho = 9;
31963
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1', '0', '', '', '', '', ''];
31964
+ }
31965
+ else {
31966
+ Tamanho = 13;
31967
+ xTP = 2;
31968
+ yROT = 'E';
31969
+ yMD = 11;
31970
+ yTP = 1;
31971
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1', '0', ''];
31972
+ }
31973
+ }
31974
+ if (this.Complemento === 'AL') {
31975
+ Tamanho = 9;
31976
+ xROT = 'BD';
31977
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '4', '2', '', '', '', '', ''];
31978
+ }
31979
+ if (this.Complemento === 'AP') {
31980
+ Tamanho = 9;
31981
+ xROT = 'CE';
31982
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '3', '0', '', '', '', '', ''];
31983
+ if ((this.fsDocto >= '030170010') && (this.fsDocto <= '030190229')) {
31984
+ FatorF = 1;
31985
+ }
31986
+ else if (this.fsDocto >= '030190230') {
31987
+ xROT = 'E';
31988
+ }
31989
+ }
31990
+ if (this.Complemento === 'AM') {
31991
+ Tamanho = 9;
31992
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
31993
+ }
31994
+ if (this.Complemento === 'BA') {
31995
+ if (this.fsDocto.length < 9) {
31996
+ this.fsDocto = this._PadLeft(this.fsDocto, 9, '0');
31997
+ }
31998
+ Tamanho = 9;
31999
+ xTP = 2;
32000
+ yTP = 3;
32001
+ yROT = 'E';
32002
+ vDigitos = ['DVX', 'DVY', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32003
+ if ('0123458'.includes(this.fsDocto[1])) {
32004
+ xMD = 10;
32005
+ yMD = 10;
32006
+ }
32007
+ else {
32008
+ xMD = 11;
32009
+ yMD = 11;
32010
+ }
32011
+ }
32012
+ if (this.Complemento === 'CE') {
32013
+ Tamanho = 9;
32014
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '', '', '', '', ''];
32015
+ }
32016
+ if (this.Complemento === 'DF') {
32017
+ Tamanho = 13;
32018
+ xTP = 2;
32019
+ yROT = 'E';
32020
+ yMD = 11;
32021
+ yTP = 1;
32022
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '7,8', '0', ''];
32023
+ }
32024
+ if (this.Complemento === 'ES') {
32025
+ Tamanho = 9;
32026
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32027
+ }
32028
+ if (this.Complemento === 'GO') {
32029
+ Tamanho = 9;
32030
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,2', '', '', '', '', ''];
32031
+ LPrefixo = this.fsDocto[0] + this.fsDocto[1];
32032
+ var prefixoValido = [10, 11, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29];
32033
+ if (!prefixoValido.includes(parseInt(LPrefixo))) {
32034
+ this.fsMsgErro = 'Prefixo IE inválido 10 ou 11 / 20 a 29';
32035
+ }
32036
+ if ((parseInt(this.fsDocto) >= 101031050) && (parseInt(this.fsDocto) <= 101199979)) {
32037
+ FatorG = 1;
32038
+ }
32039
+ }
32040
+ if (this.Complemento === 'MA') {
32041
+ Tamanho = 9;
32042
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '2', '1', '', '', '', '', ''];
32043
+ }
32044
+ if (this.Complemento === 'MT') {
32045
+ if (this.fsDocto.length === 9) {
32046
+ this.fsDocto = this._PadLeft(this.fsDocto, 11, '0');
32047
+ }
32048
+ Tamanho = 11;
32049
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', ''];
32050
+ }
32051
+ if (this.Complemento === 'MS') {
32052
+ Tamanho = 9;
32053
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '8', '2', '', '', '', '', ''];
32054
+ }
32055
+ if (this.Complemento === 'MG') {
32056
+ Tamanho = 13;
32057
+ xROT = 'AE';
32058
+ xMD = 10;
32059
+ xTP = 10;
32060
+ yROT = 'E';
32061
+ yMD = 11;
32062
+ yTP = 11;
32063
+ 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, ''];
32064
+ }
32065
+ if (this.Complemento === 'PA') {
32066
+ Tamanho = 9;
32067
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '5', '1,7', '', '', '', '', ''];
32068
+ }
32069
+ if (this.Complemento === 'PB') {
32070
+ Tamanho = 9;
32071
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '6', '1', '', '', '', '', ''];
32072
+ }
32073
+ if (this.Complemento === 'PR') {
32074
+ Tamanho = 10;
32075
+ xTP = 9;
32076
+ yROT = 'E';
32077
+ yMD = 11;
32078
+ yTP = 8;
32079
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', ''];
32080
+ }
32081
+ if (this.Complemento === 'PE') {
32082
+ if (this.fsDocto.length === 14) {
32083
+ //Antigo CACEPE
32084
+ Tamanho = 14;
32085
+ xTP = 7;
32086
+ FatorF = 1;
32087
+ 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'];
32088
+ }
32089
+ else {
32090
+ Tamanho = 9;
32091
+ xTP = 14;
32092
+ yROT = 'E';
32093
+ yMD = 11;
32094
+ yTP = 7;
32095
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32096
+ }
32097
+ }
32098
+ if (this.Complemento === 'PI') {
32099
+ Tamanho = 9;
32100
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '9', '1', '', '', '', '', ''];
32101
+ }
32102
+ if (this.Complemento === 'RJ') {
32103
+ Tamanho = 8;
32104
+ xTP = 8;
32105
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,7,8,9', '', '', '', '', '', ''];
32106
+ }
32107
+ if (this.Complemento === 'RN') {
32108
+ if (this.fsDocto.length === 9) {
32109
+ Tamanho = 9;
32110
+ xROT = 'BD';
32111
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '2', '', '', '', '', ''];
32112
+ }
32113
+ else {
32114
+ Tamanho = 10;
32115
+ xROT = 'BD';
32116
+ xTP = 11;
32117
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '2', '', '', '', ''];
32118
+ }
32119
+ }
32120
+ if (this.Complemento === 'RS') {
32121
+ Tamanho = 10;
32122
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', ''];
32123
+ }
32124
+ if (this.Complemento === 'RO') {
32125
+ FatorF = 1;
32126
+ if (this.fsDocto.length === 9) {
32127
+ Tamanho = 9;
32128
+ xTP = 4;
32129
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1-9', '', '', '', '', ''];
32130
+ }
32131
+ else {
32132
+ Tamanho = 14;
32133
+ 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];
32134
+ }
32135
+ }
32136
+ if (this.Complemento === 'RR') {
32137
+ Tamanho = 9;
32138
+ xROT = 'D';
32139
+ xMD = 9;
32140
+ xTP = 5;
32141
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '4', '2', '', '', '', '', ''];
32142
+ }
32143
+ if ((this.Complemento === 'SC') || (this.Complemento === 'SE')) {
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 === 'SP') {
32148
+ xROT = 'D';
32149
+ xTP = 12;
32150
+ if (this.fsDocto[0] === 'P') {
32151
+ Tamanho = 13;
32152
+ 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', ''];
32153
+ }
32154
+ else {
32155
+ Tamanho = 12;
32156
+ yROT = 'D';
32157
+ yMD = 11;
32158
+ yTP = 13;
32159
+ vDigitos = ['DVY', c0_9, c0_9, 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', ''];
32160
+ }
32161
+ }
32162
+ if (this.Complemento === 'TO') {
32163
+ if (this.fsDocto.length === 11) {
32164
+ Tamanho = 11;
32165
+ xTP = 6;
32166
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,2,3,9', '0,9', '9', '2', '', '', ''];
32167
+ }
32168
+ else {
32169
+ /**
32170
+ * Tamanho = 10;
32171
+ * vDigitos = ['DVX',c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,'0-4','','','',''];
32172
+ */
32173
+ Tamanho = 9;
32174
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
32175
+ }
32176
+ }
32177
+ /** Verificando se o Tamanho Total está correto */
32178
+ if (this.fsAjustarTamanho) {
32179
+ this.fsDocto = this._PadLeft(this.fsDocto, Tamanho, '0');
32180
+ }
32181
+ OK = (Tamanho > 0) && (this.fsDocto.length === Tamanho);
32182
+ if (!OK) {
32183
+ this.fsMsgErro = "Tamanho inv\u00E1lido: Esperado " + Tamanho + " caracteres, mas foram digitados somente " + this.fsDocto.length + " caracteres.";
32184
+ }
32185
+ /** Verificando os digitos nas posicoes são permitidos */
32186
+ this.fsDocto = this._PadLeft(this.fsDocto, 14);
32187
+ DVX = 0;
32188
+ DVY = 0;
32189
+ var I = 13;
32190
+ while (OK && I >= 0) {
32191
+ var D_1 = this.fsDocto[13 - I];
32192
+ if (vDigitos[I] === '') {
32193
+ OK = (D_1 === ' ');
32194
+ }
32195
+ else if (vDigitos[I] === 'DVX' || vDigitos[I] === 'DVY' || vDigitos[I] === c0_9) {
32196
+ OK = this._CharIsNum(D_1);
32197
+ if (vDigitos[I] === 'DVX') {
32198
+ DVX = parseInt(D_1, 10);
32199
+ }
32200
+ else if (vDigitos[I] === 'DVY') {
32201
+ DVY = parseInt(D_1, 10);
32202
+ }
32203
+ }
32204
+ else if (vDigitos[I].includes(',')) {
32205
+ OK = vDigitos[I].split(',').includes(D_1);
32206
+ }
32207
+ else if (vDigitos[I].includes('-')) {
32208
+ var _a = __read(vDigitos[I].split('-'), 2), min = _a[0], max = _a[1];
32209
+ OK = (D_1 >= min && D_1 <= max);
32210
+ }
32211
+ else {
32212
+ OK = (D_1 === vDigitos[I]);
32213
+ }
32214
+ if (!OK) {
32215
+ this.fsMsgErro = "D\u00EDgito " + (13 - I - (13 - Tamanho)) + " deveria ser " + vDigitos[I];
32216
+ }
32217
+ I--;
32218
+ }
32219
+ Passo = 'X';
32220
+ while (OK && xTP > 0) {
32221
+ SOMA = 0;
32222
+ SOMAq = 0;
32223
+ I = 14;
32224
+ while (OK && I > 0) {
32225
+ D = this.fsDocto[14 - I];
32226
+ if (this._CharIsNum(D)) {
32227
+ nD = parseInt(D, 10);
32228
+ M = nD * cPesos[xTP - 1][I - 1];
32229
+ SOMA += M;
32230
+ if (xROT.includes('A')) {
32231
+ SOMAq += Math.floor(M / 10);
32232
+ }
32233
+ }
32234
+ I--;
32235
+ }
32236
+ if (xROT.includes('A')) {
32237
+ SOMA += SOMAq;
32238
+ }
32239
+ else if (xROT.includes('B')) {
32240
+ SOMA *= 10;
32241
+ }
32242
+ else if (xROT.includes('C')) {
32243
+ SOMA += (5 + (4 * FatorF));
32244
+ }
32245
+ /** Calculando digito verificador */
32246
+ DV = SOMA % xMD;
32247
+ if (xROT.includes('E')) {
32248
+ DV = xMD - DV;
32249
+ }
32250
+ if (DV === 10) {
32251
+ DV = FatorG; /** Apenas GO modifica o FatorG para diferente de 0 */
32252
+ }
32253
+ else if (DV === 11) {
32254
+ DV = FatorF;
32255
+ }
32256
+ if (Passo === 'X') {
32257
+ OK = (DVX === DV);
32258
+ }
32259
+ else {
32260
+ OK = (DVY === DV);
32261
+ }
32262
+ this.fsDigitoCalculado = DV.toString();
32263
+ if (!OK) {
32264
+ this.fsMsgErro = 'Dígito verificador inválido.';
32265
+ if (this.fsExibeDigitoCorreto) {
32266
+ this.fsMsgErro += ".. Calculado: " + this.fsDigitoCalculado;
32267
+ }
32268
+ }
32269
+ if (Passo === 'X') {
32270
+ Passo = 'Y';
32271
+ xROT = yROT;
32272
+ xMD = yMD;
32273
+ xTP = yTP;
32274
+ }
32275
+ else {
32276
+ break;
32277
+ }
32278
+ }
32279
+ this.fsDocto = this.fsDocto.trim();
32280
+ if (this.fsMsgErro !== '') {
32281
+ this.fsMsgErro = "Inscri\u00E7\u00E3o estadual inv\u00E1lida para " + this.Complemento + ". " + this.fsMsgErro;
32282
+ }
32283
+ };
32284
+ ACBrValidadorIE.prototype._ValidarUF = function (uf) {
32285
+ if (!cUFsValidas.includes(uf.toUpperCase())) {
32286
+ this.fsMsgErro = "UF inv\u00E1lido: " + uf;
32287
+ }
32288
+ };
32289
+ ACBrValidadorIE.prototype._StrIsNumber = function (s) {
32290
+ return /^\d+$/.test(s);
32291
+ };
32292
+ ACBrValidadorIE.prototype._CharIsNum = function (c) {
32293
+ return /^\d$/.test(c);
32294
+ };
32295
+ ACBrValidadorIE.prototype._PadLeft = function (value, length, padChar) {
32296
+ return value.padStart(length, padChar);
32297
+ };
32298
+ ACBrValidadorIE.prototype._LimpaDocto = function (aString) {
32299
+ var result = '';
32300
+ for (var a = 0; a < aString.length; a++) {
32301
+ if (!this.IgnorarChar.includes(aString[a])) {
32302
+ result += aString[a].toUpperCase();
32303
+ }
32304
+ }
32305
+ return result.trim();
32306
+ };
32307
+ ACBrValidadorIE.prototype._MascaraIE = function (AValue) {
32308
+ var LenDoc = AValue.length;
32309
+ var Mascara = '*'.repeat(LenDoc);
32310
+ if (this.Complemento === 'AC')
32311
+ Mascara = '**.***.***/***-**';
32312
+ if (this.Complemento === 'AL')
32313
+ Mascara = '*********';
32314
+ if (this.Complemento === 'AP')
32315
+ Mascara = '*********';
32316
+ if (this.Complemento === 'AM')
32317
+ Mascara = '**.***.***-*';
32318
+ if (this.Complemento === 'BA')
32319
+ Mascara = '*******-**';
32320
+ if (this.Complemento === 'CE')
32321
+ Mascara = '********-*';
32322
+ if (this.Complemento === 'DF')
32323
+ Mascara = '***********-**';
32324
+ if (this.Complemento === 'ES')
32325
+ Mascara = '*********';
32326
+ if (this.Complemento === 'GO')
32327
+ Mascara = '**.***.***-*';
32328
+ if (this.Complemento === 'MA')
32329
+ Mascara = '*********';
32330
+ if (this.Complemento === 'MT')
32331
+ Mascara = '**********-*';
32332
+ if (this.Complemento === 'MS')
32333
+ Mascara = '**.***.***-*';
32334
+ if (this.Complemento === 'MG')
32335
+ Mascara = '***.***.***/****';
32336
+ if (this.Complemento === 'PA')
32337
+ Mascara = '**-******-*';
32338
+ if (this.Complemento === 'PB')
32339
+ Mascara = '********-*';
32340
+ if (this.Complemento === 'PR')
32341
+ Mascara = '***.*****-**';
32342
+ if (this.Complemento === 'PE')
32343
+ Mascara = (LenDoc > 9) ? '**.*.***.*******-*' : '*******-**';
32344
+ if (this.Complemento === 'PI')
32345
+ Mascara = '*********';
32346
+ if (this.Complemento === 'RJ')
32347
+ Mascara = '**.***.**-*';
32348
+ if (this.Complemento === 'RN')
32349
+ Mascara = (LenDoc > 9) ? '**.*.***.***-*' : '**.***.***-*';
32350
+ if (this.Complemento === 'RS')
32351
+ Mascara = '***/*******';
32352
+ if (this.Complemento === 'RO')
32353
+ Mascara = (LenDoc > 13) ? '*************-*' : '***.*****-*';
32354
+ if (this.Complemento === 'RR')
32355
+ Mascara = '********-*';
32356
+ if (this.Complemento === 'SC')
32357
+ Mascara = '***.***.***';
32358
+ if (this.Complemento === 'SP')
32359
+ Mascara = ((LenDoc > 1) && (AValue[0] === 'P')) ? '*-********.*/***' : '***.***.***.***';
32360
+ if (this.Complemento === 'SE')
32361
+ Mascara = '**.***.***-*';
32362
+ if (this.Complemento === 'TO')
32363
+ Mascara = (LenDoc = 11) ? '**.**.******-*' : '**.***.***-*';
32364
+ return Mascara;
32365
+ };
32366
+ ACBrValidadorIE.prototype._FormatarIE = function (AValue) {
32367
+ if (AValue.trim().toUpperCase() === 'ISENTO') {
32368
+ return AValue;
32369
+ }
32370
+ var Mascara = this._MascaraIE(AValue);
32371
+ return this._FormatarMascaraNumerica(this._OnlyAlphaNum(AValue), Mascara);
32372
+ };
32373
+ ACBrValidadorIE.prototype._OnlyAlphaNum = function (str) {
32374
+ return str.replace(/[^a-zA-Z0-9]/g, '');
32375
+ };
32376
+ ACBrValidadorIE.prototype._FormatarMascaraNumerica = function (numValue, mascara) {
32377
+ var result = '';
32378
+ var wNumValue = numValue.trim();
32379
+ var lenMas = mascara.length;
32380
+ var lenDoc = wNumValue.length;
32381
+ var j = lenMas;
32382
+ for (var i = lenMas - 1; i >= 0; i--) {
32383
+ var c = mascara[i];
32384
+ if (c === '*') {
32385
+ if (j <= (lenMas - lenDoc)) {
32386
+ c = '0';
32387
+ }
32388
+ else {
32389
+ c = wNumValue[j - (lenMas - lenDoc) - 1];
32390
+ }
32391
+ j--;
32392
+ }
32393
+ result = c + result;
32394
+ }
32395
+ return result;
32396
+ };
32397
+ return ACBrValidadorIE;
32398
+ }());
32399
+
31804
32400
  /** @dynamic */
31805
32401
  var DocumentUtil = /** @class */ (function () {
31806
32402
  function DocumentUtil() {
@@ -31905,20 +32501,12 @@ var DocumentUtil = /** @class */ (function () {
31905
32501
  };
31906
32502
  DocumentUtil.isValidStateRegistration = function (acronymState, stateRegistration) {
31907
32503
  if (StringUtil.isEmpty(acronymState) || StringUtil.isEmpty(stateRegistration)) {
31908
- return false;
31909
- }
31910
- else if (stateRegistration.toUpperCase() === 'ISENTO') {
31911
- return true;
32504
+ return { ie: stateRegistration, isValid: false, error: 'É nescessário informar a UF e a inscrição estadual para a validação' };
31912
32505
  }
31913
- else {
31914
- if (acronymState === 'GO') {
31915
- var digits = onlyNumbers(stateRegistration);
31916
- return this.calcDigit(digits);
31917
- }
31918
- else {
31919
- return isValidIE(acronymState, stateRegistration);
31920
- }
32506
+ if (stateRegistration.toUpperCase() === 'ISENTO') {
32507
+ return { ie: stateRegistration, isValid: true, error: '' };
31921
32508
  }
32509
+ return (new ACBrValidadorIE().isValid(stateRegistration, acronymState, './-'));
31922
32510
  };
31923
32511
  DocumentUtil.isValidCep = function (cep) {
31924
32512
  if (StringUtil.isEmpty(cep)) {
@@ -31926,32 +32514,6 @@ var DocumentUtil = /** @class */ (function () {
31926
32514
  }
31927
32515
  return isValidCEP(cep);
31928
32516
  };
31929
- DocumentUtil.calcDigit = function (ie) {
31930
- var length = ie.length;
31931
- var position = length - 1;
31932
- var weight = length;
31933
- var body = ie.substring(0, position);
31934
- // const bodyInt: number = parseInt(body, 10);
31935
- var sum = 0;
31936
- body.split('').forEach(function (digit) {
31937
- sum += parseInt(digit, 10) * weight;
31938
- weight--;
31939
- });
31940
- var rest = sum % 11;
31941
- var dig = 11 - rest;
31942
- var fatorG = 0;
31943
- if ((Number(ie) >= 101031050) && (Number(ie) <= 101199979)) {
31944
- fatorG = 1;
31945
- }
31946
- if (dig === 10) {
31947
- dig = fatorG;
31948
- }
31949
- else if (dig === 11) {
31950
- dig = 0;
31951
- }
31952
- var digIe = parseInt(ie.charAt(position), 10);
31953
- return dig === digIe;
31954
- };
31955
32517
  return DocumentUtil;
31956
32518
  }());
31957
32519