@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
  const APP_MESSAGES = new InjectionToken('app.messages');
76
76
  const DEFAULT_MESSAGES = {
@@ -29555,6 +29555,588 @@ class CurrencyUtil {
29555
29555
  }
29556
29556
  }
29557
29557
 
29558
+ const cUFsValidas = [
29559
+ 'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA',
29560
+ 'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN',
29561
+ 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO', 'EX'
29562
+ ];
29563
+ class ACBrValidadorIE {
29564
+ constructor() {
29565
+ this._fsIgnorarChar = './-';
29566
+ this._fsDocumento = '';
29567
+ this.fsDocto = '';
29568
+ this._Complemento = '';
29569
+ this.fsMsgErro = '';
29570
+ this.fsDigitoCalculado = '';
29571
+ this.fsPermiteVazio = false;
29572
+ this.fsExibeDigitoCorreto = false;
29573
+ this.fsAjustarTamanho = false;
29574
+ }
29575
+ get IgnorarChar() {
29576
+ return this._fsIgnorarChar;
29577
+ }
29578
+ set IgnorarChar(value) {
29579
+ this._fsIgnorarChar = value;
29580
+ }
29581
+ get Documento() {
29582
+ return this._fsDocumento;
29583
+ }
29584
+ set Documento(value) {
29585
+ if (this._fsDocumento === value) {
29586
+ return;
29587
+ }
29588
+ this._fsDocumento = value;
29589
+ this.fsMsgErro = 'Função Validar não foi chamada';
29590
+ this.fsDigitoCalculado = '';
29591
+ this.fsDocto = this._LimpaDocto(this._fsDocumento);
29592
+ }
29593
+ get Complemento() {
29594
+ return this._Complemento;
29595
+ }
29596
+ set Complemento(value) {
29597
+ this._Complemento = value;
29598
+ }
29599
+ isValid(IE, UF, ignorarChar = './-') {
29600
+ this.Documento = IE;
29601
+ this.Complemento = UF;
29602
+ this.IgnorarChar = ignorarChar || './-';
29603
+ this.Documento = this.formatar();
29604
+ if (this._validar()) {
29605
+ return { ie: this.Documento, isValid: true, error: '' };
29606
+ }
29607
+ else {
29608
+ return { ie: this.Documento, isValid: false, error: this.fsMsgErro };
29609
+ }
29610
+ }
29611
+ _validar() {
29612
+ this.fsMsgErro = '';
29613
+ this.fsDocto = this._LimpaDocto(this._fsDocumento);
29614
+ this.fsDigitoCalculado = '';
29615
+ if (this.fsDocto === '') {
29616
+ if (this.fsPermiteVazio) {
29617
+ return true;
29618
+ }
29619
+ else {
29620
+ this.fsMsgErro = `Inscrição Estadual não pode ser vazio.`;
29621
+ }
29622
+ }
29623
+ if (this.fsMsgErro === '') {
29624
+ this._ValidarIE();
29625
+ }
29626
+ return (this.fsMsgErro === '');
29627
+ }
29628
+ formatar() {
29629
+ const doc = this._LimpaDocto(this._fsDocumento);
29630
+ return this._FormatarIE(doc);
29631
+ }
29632
+ _ValidarIE() {
29633
+ const c0_9 = '0-9';
29634
+ const cPesos = [
29635
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6],
29636
+ [0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5],
29637
+ [2, 0, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6],
29638
+ [0, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0],
29639
+ [0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0],
29640
+ [0, 2, 3, 4, 5, 6, 7, 0, 0, 8, 9, 0, 0, 0],
29641
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],
29642
+ [0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8],
29643
+ [0, 0, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7],
29644
+ [0, 0, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 0],
29645
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 3, 0],
29646
+ [0, 0, 0, 0, 10, 8, 7, 6, 5, 4, 3, 1, 0, 0],
29647
+ [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 0, 0],
29648
+ [0, 0, 2, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7]
29649
+ ];
29650
+ let vDigitos;
29651
+ let xROT;
29652
+ let yROT;
29653
+ let Tamanho;
29654
+ let FatorF;
29655
+ let FatorG;
29656
+ let xMD;
29657
+ let xTP;
29658
+ let yMD;
29659
+ let yTP;
29660
+ let DV;
29661
+ let DVX;
29662
+ let DVY;
29663
+ let SOMA;
29664
+ let SOMAq;
29665
+ let nD;
29666
+ let M;
29667
+ let OK;
29668
+ let Passo;
29669
+ let D;
29670
+ let LPrefixo;
29671
+ if (this.fsDocto.toUpperCase().trim() === 'ISENTO') {
29672
+ return;
29673
+ }
29674
+ if (this.Complemento === '') {
29675
+ this.fsMsgErro = 'Informe a UF no campo complemento';
29676
+ return;
29677
+ }
29678
+ this._ValidarUF(this.Complemento);
29679
+ if (this.fsMsgErro !== '') {
29680
+ return;
29681
+ }
29682
+ /**
29683
+ * Somente digitos ou letra P na primeira posicao
29684
+ * P é usado pela Insc.Estadual de Produtor Rural de SP
29685
+ */
29686
+ if (!this._StrIsNumber(this.fsDocto.substring(1)) ||
29687
+ (!this._CharIsNum(this.fsDocto[0]) && this.fsDocto[0] !== 'P')) {
29688
+ this.fsMsgErro = 'Caracteres inválidos na inscrição estadual';
29689
+ return;
29690
+ }
29691
+ Tamanho = 0;
29692
+ xROT = 'E';
29693
+ xMD = 11;
29694
+ xTP = 1;
29695
+ yROT = '';
29696
+ yMD = 0;
29697
+ yTP = 0;
29698
+ FatorF = 0;
29699
+ FatorG = 0;
29700
+ vDigitos = Array(14).fill('');
29701
+ if (this.Complemento === 'AC') {
29702
+ if (this.fsDocto.length === 9) {
29703
+ Tamanho = 9;
29704
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1', '0', '', '', '', '', ''];
29705
+ }
29706
+ else {
29707
+ Tamanho = 13;
29708
+ xTP = 2;
29709
+ yROT = 'E';
29710
+ yMD = 11;
29711
+ yTP = 1;
29712
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1', '0', ''];
29713
+ }
29714
+ }
29715
+ if (this.Complemento === 'AL') {
29716
+ Tamanho = 9;
29717
+ xROT = 'BD';
29718
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '4', '2', '', '', '', '', ''];
29719
+ }
29720
+ if (this.Complemento === 'AP') {
29721
+ Tamanho = 9;
29722
+ xROT = 'CE';
29723
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '3', '0', '', '', '', '', ''];
29724
+ if ((this.fsDocto >= '030170010') && (this.fsDocto <= '030190229')) {
29725
+ FatorF = 1;
29726
+ }
29727
+ else if (this.fsDocto >= '030190230') {
29728
+ xROT = 'E';
29729
+ }
29730
+ }
29731
+ if (this.Complemento === 'AM') {
29732
+ Tamanho = 9;
29733
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
29734
+ }
29735
+ if (this.Complemento === 'BA') {
29736
+ if (this.fsDocto.length < 9) {
29737
+ this.fsDocto = this._PadLeft(this.fsDocto, 9, '0');
29738
+ }
29739
+ Tamanho = 9;
29740
+ xTP = 2;
29741
+ yTP = 3;
29742
+ yROT = 'E';
29743
+ vDigitos = ['DVX', 'DVY', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
29744
+ if ('0123458'.includes(this.fsDocto[1])) {
29745
+ xMD = 10;
29746
+ yMD = 10;
29747
+ }
29748
+ else {
29749
+ xMD = 11;
29750
+ yMD = 11;
29751
+ }
29752
+ }
29753
+ if (this.Complemento === 'CE') {
29754
+ Tamanho = 9;
29755
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '', '', '', '', ''];
29756
+ }
29757
+ if (this.Complemento === 'DF') {
29758
+ Tamanho = 13;
29759
+ xTP = 2;
29760
+ yROT = 'E';
29761
+ yMD = 11;
29762
+ yTP = 1;
29763
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '7,8', '0', ''];
29764
+ }
29765
+ if (this.Complemento === 'ES') {
29766
+ Tamanho = 9;
29767
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
29768
+ }
29769
+ if (this.Complemento === 'GO') {
29770
+ Tamanho = 9;
29771
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,2', '', '', '', '', ''];
29772
+ LPrefixo = this.fsDocto[0] + this.fsDocto[1];
29773
+ const prefixoValido = [10, 11, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29];
29774
+ if (!prefixoValido.includes(parseInt(LPrefixo))) {
29775
+ this.fsMsgErro = 'Prefixo IE inválido 10 ou 11 / 20 a 29';
29776
+ }
29777
+ if ((parseInt(this.fsDocto) >= 101031050) && (parseInt(this.fsDocto) <= 101199979)) {
29778
+ FatorG = 1;
29779
+ }
29780
+ }
29781
+ if (this.Complemento === 'MA') {
29782
+ Tamanho = 9;
29783
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '2', '1', '', '', '', '', ''];
29784
+ }
29785
+ if (this.Complemento === 'MT') {
29786
+ if (this.fsDocto.length === 9) {
29787
+ this.fsDocto = this._PadLeft(this.fsDocto, 11, '0');
29788
+ }
29789
+ Tamanho = 11;
29790
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', ''];
29791
+ }
29792
+ if (this.Complemento === 'MS') {
29793
+ Tamanho = 9;
29794
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '8', '2', '', '', '', '', ''];
29795
+ }
29796
+ if (this.Complemento === 'MG') {
29797
+ Tamanho = 13;
29798
+ xROT = 'AE';
29799
+ xMD = 10;
29800
+ xTP = 10;
29801
+ yROT = 'E';
29802
+ yMD = 11;
29803
+ yTP = 11;
29804
+ 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, ''];
29805
+ }
29806
+ if (this.Complemento === 'PA') {
29807
+ Tamanho = 9;
29808
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '5', '1,7', '', '', '', '', ''];
29809
+ }
29810
+ if (this.Complemento === 'PB') {
29811
+ Tamanho = 9;
29812
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '6', '1', '', '', '', '', ''];
29813
+ }
29814
+ if (this.Complemento === 'PR') {
29815
+ Tamanho = 10;
29816
+ xTP = 9;
29817
+ yROT = 'E';
29818
+ yMD = 11;
29819
+ yTP = 8;
29820
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', ''];
29821
+ }
29822
+ if (this.Complemento === 'PE') {
29823
+ if (this.fsDocto.length === 14) {
29824
+ //Antigo CACEPE
29825
+ Tamanho = 14;
29826
+ xTP = 7;
29827
+ FatorF = 1;
29828
+ 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'];
29829
+ }
29830
+ else {
29831
+ Tamanho = 9;
29832
+ xTP = 14;
29833
+ yROT = 'E';
29834
+ yMD = 11;
29835
+ yTP = 7;
29836
+ vDigitos = ['DVY', 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
29837
+ }
29838
+ }
29839
+ if (this.Complemento === 'PI') {
29840
+ Tamanho = 9;
29841
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '9', '1', '', '', '', '', ''];
29842
+ }
29843
+ if (this.Complemento === 'RJ') {
29844
+ Tamanho = 8;
29845
+ xTP = 8;
29846
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,7,8,9', '', '', '', '', '', ''];
29847
+ }
29848
+ if (this.Complemento === 'RN') {
29849
+ if (this.fsDocto.length === 9) {
29850
+ Tamanho = 9;
29851
+ xROT = 'BD';
29852
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '2', '', '', '', '', ''];
29853
+ }
29854
+ else {
29855
+ Tamanho = 10;
29856
+ xROT = 'BD';
29857
+ xTP = 11;
29858
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '0', '2', '', '', '', ''];
29859
+ }
29860
+ }
29861
+ if (this.Complemento === 'RS') {
29862
+ Tamanho = 10;
29863
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', ''];
29864
+ }
29865
+ if (this.Complemento === 'RO') {
29866
+ FatorF = 1;
29867
+ if (this.fsDocto.length === 9) {
29868
+ Tamanho = 9;
29869
+ xTP = 4;
29870
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1-9', '', '', '', '', ''];
29871
+ }
29872
+ else {
29873
+ Tamanho = 14;
29874
+ 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];
29875
+ }
29876
+ }
29877
+ if (this.Complemento === 'RR') {
29878
+ Tamanho = 9;
29879
+ xROT = 'D';
29880
+ xMD = 9;
29881
+ xTP = 5;
29882
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '4', '2', '', '', '', '', ''];
29883
+ }
29884
+ if ((this.Complemento === 'SC') || (this.Complemento === 'SE')) {
29885
+ Tamanho = 9;
29886
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
29887
+ }
29888
+ if (this.Complemento === 'SP') {
29889
+ xROT = 'D';
29890
+ xTP = 12;
29891
+ if (this.fsDocto[0] === 'P') {
29892
+ Tamanho = 13;
29893
+ 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', ''];
29894
+ }
29895
+ else {
29896
+ Tamanho = 12;
29897
+ yROT = 'D';
29898
+ yMD = 11;
29899
+ yTP = 13;
29900
+ vDigitos = ['DVY', c0_9, c0_9, 'DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', ''];
29901
+ }
29902
+ }
29903
+ if (this.Complemento === 'TO') {
29904
+ if (this.fsDocto.length === 11) {
29905
+ Tamanho = 11;
29906
+ xTP = 6;
29907
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '1,2,3,9', '0,9', '9', '2', '', '', ''];
29908
+ }
29909
+ else {
29910
+ /**
29911
+ * Tamanho = 10;
29912
+ * vDigitos = ['DVX',c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,c0_9,'0-4','','','',''];
29913
+ */
29914
+ Tamanho = 9;
29915
+ vDigitos = ['DVX', c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, c0_9, '', '', '', '', ''];
29916
+ }
29917
+ }
29918
+ /** Verificando se o Tamanho Total está correto */
29919
+ if (this.fsAjustarTamanho) {
29920
+ this.fsDocto = this._PadLeft(this.fsDocto, Tamanho, '0');
29921
+ }
29922
+ OK = (Tamanho > 0) && (this.fsDocto.length === Tamanho);
29923
+ if (!OK) {
29924
+ this.fsMsgErro = `Tamanho inválido: Esperado ${Tamanho} caracteres, mas foram digitados somente ${this.fsDocto.length} caracteres.`;
29925
+ }
29926
+ /** Verificando os digitos nas posicoes são permitidos */
29927
+ this.fsDocto = this._PadLeft(this.fsDocto, 14);
29928
+ DVX = 0;
29929
+ DVY = 0;
29930
+ let I = 13;
29931
+ while (OK && I >= 0) {
29932
+ const D = this.fsDocto[13 - I];
29933
+ if (vDigitos[I] === '') {
29934
+ OK = (D === ' ');
29935
+ }
29936
+ else if (vDigitos[I] === 'DVX' || vDigitos[I] === 'DVY' || vDigitos[I] === c0_9) {
29937
+ OK = this._CharIsNum(D);
29938
+ if (vDigitos[I] === 'DVX') {
29939
+ DVX = parseInt(D, 10);
29940
+ }
29941
+ else if (vDigitos[I] === 'DVY') {
29942
+ DVY = parseInt(D, 10);
29943
+ }
29944
+ }
29945
+ else if (vDigitos[I].includes(',')) {
29946
+ OK = vDigitos[I].split(',').includes(D);
29947
+ }
29948
+ else if (vDigitos[I].includes('-')) {
29949
+ const [min, max] = vDigitos[I].split('-');
29950
+ OK = (D >= min && D <= max);
29951
+ }
29952
+ else {
29953
+ OK = (D === vDigitos[I]);
29954
+ }
29955
+ if (!OK) {
29956
+ this.fsMsgErro = `Dígito ${13 - I - (13 - Tamanho)} deveria ser ${vDigitos[I]}`;
29957
+ }
29958
+ I--;
29959
+ }
29960
+ Passo = 'X';
29961
+ while (OK && xTP > 0) {
29962
+ SOMA = 0;
29963
+ SOMAq = 0;
29964
+ I = 14;
29965
+ while (OK && I > 0) {
29966
+ D = this.fsDocto[14 - I];
29967
+ if (this._CharIsNum(D)) {
29968
+ nD = parseInt(D, 10);
29969
+ M = nD * cPesos[xTP - 1][I - 1];
29970
+ SOMA += M;
29971
+ if (xROT.includes('A')) {
29972
+ SOMAq += Math.floor(M / 10);
29973
+ }
29974
+ }
29975
+ I--;
29976
+ }
29977
+ if (xROT.includes('A')) {
29978
+ SOMA += SOMAq;
29979
+ }
29980
+ else if (xROT.includes('B')) {
29981
+ SOMA *= 10;
29982
+ }
29983
+ else if (xROT.includes('C')) {
29984
+ SOMA += (5 + (4 * FatorF));
29985
+ }
29986
+ /** Calculando digito verificador */
29987
+ DV = SOMA % xMD;
29988
+ if (xROT.includes('E')) {
29989
+ DV = xMD - DV;
29990
+ }
29991
+ if (DV === 10) {
29992
+ DV = FatorG; /** Apenas GO modifica o FatorG para diferente de 0 */
29993
+ }
29994
+ else if (DV === 11) {
29995
+ DV = FatorF;
29996
+ }
29997
+ if (Passo === 'X') {
29998
+ OK = (DVX === DV);
29999
+ }
30000
+ else {
30001
+ OK = (DVY === DV);
30002
+ }
30003
+ this.fsDigitoCalculado = DV.toString();
30004
+ if (!OK) {
30005
+ this.fsMsgErro = 'Dígito verificador inválido.';
30006
+ if (this.fsExibeDigitoCorreto) {
30007
+ this.fsMsgErro += `.. Calculado: ${this.fsDigitoCalculado}`;
30008
+ }
30009
+ }
30010
+ if (Passo === 'X') {
30011
+ Passo = 'Y';
30012
+ xROT = yROT;
30013
+ xMD = yMD;
30014
+ xTP = yTP;
30015
+ }
30016
+ else {
30017
+ break;
30018
+ }
30019
+ }
30020
+ this.fsDocto = this.fsDocto.trim();
30021
+ if (this.fsMsgErro !== '') {
30022
+ this.fsMsgErro = `Inscrição estadual inválida para ${this.Complemento}. ${this.fsMsgErro}`;
30023
+ }
30024
+ }
30025
+ _ValidarUF(uf) {
30026
+ if (!cUFsValidas.includes(uf.toUpperCase())) {
30027
+ this.fsMsgErro = `UF inválido: ${uf}`;
30028
+ }
30029
+ }
30030
+ _StrIsNumber(s) {
30031
+ return /^\d+$/.test(s);
30032
+ }
30033
+ _CharIsNum(c) {
30034
+ return /^\d$/.test(c);
30035
+ }
30036
+ _PadLeft(value, length, padChar) {
30037
+ return value.padStart(length, padChar);
30038
+ }
30039
+ _LimpaDocto(aString) {
30040
+ let result = '';
30041
+ for (let a = 0; a < aString.length; a++) {
30042
+ if (!this.IgnorarChar.includes(aString[a])) {
30043
+ result += aString[a].toUpperCase();
30044
+ }
30045
+ }
30046
+ return result.trim();
30047
+ }
30048
+ _MascaraIE(AValue) {
30049
+ let LenDoc = AValue.length;
30050
+ let Mascara = '*'.repeat(LenDoc);
30051
+ if (this.Complemento === 'AC')
30052
+ Mascara = '**.***.***/***-**';
30053
+ if (this.Complemento === 'AL')
30054
+ Mascara = '*********';
30055
+ if (this.Complemento === 'AP')
30056
+ Mascara = '*********';
30057
+ if (this.Complemento === 'AM')
30058
+ Mascara = '**.***.***-*';
30059
+ if (this.Complemento === 'BA')
30060
+ Mascara = '*******-**';
30061
+ if (this.Complemento === 'CE')
30062
+ Mascara = '********-*';
30063
+ if (this.Complemento === 'DF')
30064
+ Mascara = '***********-**';
30065
+ if (this.Complemento === 'ES')
30066
+ Mascara = '*********';
30067
+ if (this.Complemento === 'GO')
30068
+ Mascara = '**.***.***-*';
30069
+ if (this.Complemento === 'MA')
30070
+ Mascara = '*********';
30071
+ if (this.Complemento === 'MT')
30072
+ Mascara = '**********-*';
30073
+ if (this.Complemento === 'MS')
30074
+ Mascara = '**.***.***-*';
30075
+ if (this.Complemento === 'MG')
30076
+ Mascara = '***.***.***/****';
30077
+ if (this.Complemento === 'PA')
30078
+ Mascara = '**-******-*';
30079
+ if (this.Complemento === 'PB')
30080
+ Mascara = '********-*';
30081
+ if (this.Complemento === 'PR')
30082
+ Mascara = '***.*****-**';
30083
+ if (this.Complemento === 'PE')
30084
+ Mascara = (LenDoc > 9) ? '**.*.***.*******-*' : '*******-**';
30085
+ if (this.Complemento === 'PI')
30086
+ Mascara = '*********';
30087
+ if (this.Complemento === 'RJ')
30088
+ Mascara = '**.***.**-*';
30089
+ if (this.Complemento === 'RN')
30090
+ Mascara = (LenDoc > 9) ? '**.*.***.***-*' : '**.***.***-*';
30091
+ if (this.Complemento === 'RS')
30092
+ Mascara = '***/*******';
30093
+ if (this.Complemento === 'RO')
30094
+ Mascara = (LenDoc > 13) ? '*************-*' : '***.*****-*';
30095
+ if (this.Complemento === 'RR')
30096
+ Mascara = '********-*';
30097
+ if (this.Complemento === 'SC')
30098
+ Mascara = '***.***.***';
30099
+ if (this.Complemento === 'SP')
30100
+ Mascara = ((LenDoc > 1) && (AValue[0] === 'P')) ? '*-********.*/***' : '***.***.***.***';
30101
+ if (this.Complemento === 'SE')
30102
+ Mascara = '**.***.***-*';
30103
+ if (this.Complemento === 'TO')
30104
+ Mascara = (LenDoc = 11) ? '**.**.******-*' : '**.***.***-*';
30105
+ return Mascara;
30106
+ }
30107
+ _FormatarIE(AValue) {
30108
+ if (AValue.trim().toUpperCase() === 'ISENTO') {
30109
+ return AValue;
30110
+ }
30111
+ const Mascara = this._MascaraIE(AValue);
30112
+ return this._FormatarMascaraNumerica(this._OnlyAlphaNum(AValue), Mascara);
30113
+ }
30114
+ _OnlyAlphaNum(str) {
30115
+ return str.replace(/[^a-zA-Z0-9]/g, '');
30116
+ }
30117
+ _FormatarMascaraNumerica(numValue, mascara) {
30118
+ let result = '';
30119
+ const wNumValue = numValue.trim();
30120
+ const lenMas = mascara.length;
30121
+ const lenDoc = wNumValue.length;
30122
+ let j = lenMas;
30123
+ for (let i = lenMas - 1; i >= 0; i--) {
30124
+ let c = mascara[i];
30125
+ if (c === '*') {
30126
+ if (j <= (lenMas - lenDoc)) {
30127
+ c = '0';
30128
+ }
30129
+ else {
30130
+ c = wNumValue[j - (lenMas - lenDoc) - 1];
30131
+ }
30132
+ j--;
30133
+ }
30134
+ result = c + result;
30135
+ }
30136
+ return result;
30137
+ }
30138
+ }
30139
+
29558
30140
  /** @dynamic */
29559
30141
  class DocumentUtil {
29560
30142
  static clearFormat(value) {
@@ -29657,20 +30239,12 @@ class DocumentUtil {
29657
30239
  }
29658
30240
  static isValidStateRegistration(acronymState, stateRegistration) {
29659
30241
  if (StringUtil.isEmpty(acronymState) || StringUtil.isEmpty(stateRegistration)) {
29660
- return false;
30242
+ return { ie: stateRegistration, isValid: false, error: 'É nescessário informar a UF e a inscrição estadual para a validação' };
29661
30243
  }
29662
- else if (stateRegistration.toUpperCase() === 'ISENTO') {
29663
- return true;
29664
- }
29665
- else {
29666
- if (acronymState === 'GO') {
29667
- const digits = onlyNumbers(stateRegistration);
29668
- return this.calcDigit(digits);
29669
- }
29670
- else {
29671
- return isValidIE(acronymState, stateRegistration);
29672
- }
30244
+ if (stateRegistration.toUpperCase() === 'ISENTO') {
30245
+ return { ie: stateRegistration, isValid: true, error: '' };
29673
30246
  }
30247
+ return (new ACBrValidadorIE().isValid(stateRegistration, acronymState, './-'));
29674
30248
  }
29675
30249
  static isValidCep(cep) {
29676
30250
  if (StringUtil.isEmpty(cep)) {
@@ -29678,32 +30252,6 @@ class DocumentUtil {
29678
30252
  }
29679
30253
  return isValidCEP(cep);
29680
30254
  }
29681
- static calcDigit(ie) {
29682
- const length = ie.length;
29683
- const position = length - 1;
29684
- let weight = length;
29685
- const body = ie.substring(0, position);
29686
- // const bodyInt: number = parseInt(body, 10);
29687
- let sum = 0;
29688
- body.split('').forEach((digit) => {
29689
- sum += parseInt(digit, 10) * weight;
29690
- weight--;
29691
- });
29692
- const rest = sum % 11;
29693
- let dig = 11 - rest;
29694
- let fatorG = 0;
29695
- if ((Number(ie) >= 101031050) && (Number(ie) <= 101199979)) {
29696
- fatorG = 1;
29697
- }
29698
- if (dig === 10) {
29699
- dig = fatorG;
29700
- }
29701
- else if (dig === 11) {
29702
- dig = 0;
29703
- }
29704
- const digIe = parseInt(ie.charAt(position), 10);
29705
- return dig === digIe;
29706
- }
29707
30255
  }
29708
30256
 
29709
30257
  /** @dynamic */