public string EscreverTrailer(TrailerRemessaCnab400 infoTrailer, int sequenciaRegistro,
                                      int quantidadeTitulosArquivo, int sequencialNumeroRemessa)
        {
            if (infoTrailer == null)
            {
                throw new Exception("Os dados não foram informados na geração do TRAILER.");
            }

            var trailer = new string(' ', 400);

            try
            {
                trailer = trailer.PreencherValorNaLinha(1, 1, "9");
                trailer = trailer.PreencherValorNaLinha(2, 368, string.Empty.PadRight(367, ' '));
                trailer = trailer.PreencherValorNaLinha(369, 376,
                                                        quantidadeTitulosArquivo.BoletoBrToStringSafe().PadLeft(8, '0'));
                trailer = trailer.PreencherValorNaLinha(377, 391,
                                                        infoTrailer.ValorTotalTitulos.ToString("f").Replace(".", "").Replace(",", "").PadLeft(15, '0'));
                trailer = trailer.PreencherValorNaLinha(392, 394,
                                                        sequencialNumeroRemessa.BoletoBrToStringSafe().PadLeft(3, '0'));
                trailer = trailer.PreencherValorNaLinha(395, 400, sequenciaRegistro.ToString().PadLeft(6, '0'));

                return(trailer);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("<BoletoBr>{0}Falha na geração do TRAILER do arquivo de REMESSA.",
                                                  Environment.NewLine), e);
            }
        }
Example #2
0
        public string EscreverTrailer(TrailerRemessaCnab400 infoTrailer, int numeroRegistro)
        {
            if (numeroRegistro == 0)
            {
                throw new Exception("Sequencial do registro não foi informado na geração do TRAILER.");
            }

            var trailer = new string(' ', 400);

            try
            {
                trailer = trailer.PreencherValorNaLinha(1, 1, "9");
                trailer = trailer.PreencherValorNaLinha(2, 394, string.Empty.PadRight(393, ' '));
                // Contagem total de linhas do arquivo no formato '000000' - 6 dígitos
                trailer = trailer.PreencherValorNaLinha(395, 400,
                                                        numeroRegistro.ToString(CultureInfo.InvariantCulture).PadLeft(6, '0'));

                return(trailer);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("<BoletoBr>{0}Falha na geração do TRAILER do arquivo de REMESSA.",
                                                  Environment.NewLine), e);
            }
        }
Example #3
0
        public string EscreverTrailer(TrailerRemessaCnab400 infoTrailer)
        {
            if (infoTrailer == null)
            {
                throw new Exception("Os dados não foram informados na geração do TRAILER.");
            }

            if (infoTrailer.NumeroSequencialRegistro == 0)
            {
                throw new Exception("Sequencial do registro não foi informado na geração do TRAILER.");
            }

            var trailer = new string(' ', 400);

            try
            {
                trailer = trailer.PreencherValorNaLinha(1, 1, "9");
                trailer = trailer.PreencherValorNaLinha(2, 394, string.Empty.PadRight(393, ' '));
                trailer = trailer.PreencherValorNaLinha(395, 400, infoTrailer.NumeroSequencialRegistro.ToString().PadLeft(6, '0'));

                return(trailer);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("<BoletoBr>{0}Falha na geração do TRAILER do arquivo de REMESSA.",
                                                  Environment.NewLine), e);
            }
        }
        public string EscreverTrailer(TrailerRemessaCnab400 infoTrailer, int sequenciaTrailer)
        {
            var trailer = new string(' ', 400);

            try
            {
                trailer = trailer.PreencherValorNaLinha(1, 1, "9");
                trailer = trailer.PreencherValorNaLinha(2, 394, string.Empty.PadRight(393, ' '));
                trailer = trailer.PreencherValorNaLinha(395, 400, sequenciaTrailer.ToString().PadLeft(6, '0'));

                return(trailer);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("<BoletoBr>{0}Falha na geração do TRAILER do arquivo de REMESSA.",
                                                  Environment.NewLine), e);
            }
        }
        public string EscreverTrailer(TrailerRemessaCnab400 infoTrailer, int numeroRegistro)
        {
            var trailer = new string(' ', 400);

            try
            {
                trailer = trailer.PreencherValorNaLinha(1, 1, "9");
                trailer = trailer.PreencherValorNaLinha(2, 7, numeroRegistro.ToString().PadLeft(6, '0'));
                trailer = trailer.PreencherValorNaLinha(8, 20, infoTrailer.ValorTotalTitulos.ToString("f").Replace(",", "").PadLeft(13, '0') /*Valor total dos títulos*/);
                trailer = trailer.PreencherValorNaLinha(21, 394, string.Empty.PadRight(374, '0'));
                trailer = trailer.PreencherValorNaLinha(395, 400, numeroRegistro.ToString().PadLeft(6, '0'));

                return(trailer);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("<BoletoBr>{0}Falha na geração do TRAILER do arquivo de REMESSA.",
                                                  Environment.NewLine), e);
            }
        }
Example #6
0
        public RemessaCnab400 GerarRemessa(HeaderRemessaCnab400 header, List <Boleto> boletos,
                                           List <DetalheRemessaCnab400> detalhes, TrailerRemessaCnab400 trailer)
        {
            //var contadorSequencialRegistro = 1;
            var objReturn = new RemessaCnab400();

            objReturn.RegistrosDetalhe = new List <DetalheRemessaCnab400>();

            objReturn.Header = header;

            foreach (var detalhe in detalhes)
            {
                objReturn.RegistrosDetalhe.Add(detalhe);
                //objReturn.AdicionarBoleto(boletoAddRemessa, contadorSequencialRegistro);
                //contadorSequencialRegistro++;
            }

            objReturn.Trailer = trailer;

            return(objReturn);
        }
Example #7
0
        public string EscreverTrailer(TrailerRemessaCnab400 infoTrailer, int sequenciaTrailer)
        {
            var trailer = new string(' ', 400);

            try
            {
                trailer = trailer.PreencherValorNaLinha(1, 1, "9");
                trailer = trailer.PreencherValorNaLinha(2, 194, string.Empty.PadRight(193, ' '));

                var mensagem1 = new string(' ', 40);
                var mensagem2 = new string(' ', 40);
                var mensagem3 = new string(' ', 40);
                var mensagem4 = new string(' ', 40);
                var mensagem5 = new string(' ', 40);

                /* MENSAGEM 1 */
                trailer = trailer.PreencherValorNaLinha(195, 234, mensagem1);

                /* MENSAGEM 2 */
                trailer = trailer.PreencherValorNaLinha(235, 274, mensagem2);

                /* MENSAGEM 3 */
                trailer = trailer.PreencherValorNaLinha(275, 314, mensagem3);

                /* MENSAGEM 4 */
                trailer = trailer.PreencherValorNaLinha(315, 354, mensagem4);

                /* MENSAGEM 5 */
                trailer = trailer.PreencherValorNaLinha(355, 394, mensagem5);

                trailer = trailer.PreencherValorNaLinha(395, 400, sequenciaTrailer.ToString().PadLeft(6, '0'));

                return(trailer);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("<BoletoBr>{0}Falha na geração do TRAILER do arquivo de REMESSA.",
                                                  Environment.NewLine), e);
            }
        }