├── gen_files └── .keep ├── main.js ├── coffee ├── cnab │ ├── src │ │ ├── Utils.coffee │ │ ├── DevUtils.coffee │ │ ├── Remessa.coffee │ │ └── Retorno.coffee │ └── test │ │ ├── Utils.coffee │ │ ├── DevUtils.coffee │ │ └── Example.coffee ├── layout │ ├── Rules.coffee │ ├── HSBC │ │ ├── ArquivoTrailing.coffee │ │ ├── Pagamento │ │ │ ├── LoteTrailing.coffee │ │ │ ├── Constants.coffee │ │ │ ├── Pagamento2.coffee │ │ │ ├── LoteHeader.coffee │ │ │ └── Pagamento.coffee │ │ └── ArquivoHeader.coffee │ └── Bradesco │ │ ├── ArquivoTrailing.coffee │ │ ├── Pagamento │ │ ├── LoteTrailing.coffee │ │ ├── CodigosFindalidadeTED │ │ ├── Pagamento2.coffee │ │ ├── LoteHeader.coffee │ │ ├── Pagamento.coffee │ │ └── Constants.coffee │ │ └── ArquivoHeader.coffee └── utils │ ├── parseTEDfile.coffee │ └── output.json ├── .gitignore ├── cnab ├── src │ ├── Utils.js │ ├── DevUtils.js │ ├── Retorno.js │ └── Remessa.js └── test │ ├── DevUtils.js │ ├── Utils.js │ └── Example.js ├── LICENSE ├── layout ├── HSBC │ ├── ArquivoTrailing.js │ ├── Pagamento │ │ ├── LoteTrailing.js │ │ ├── Constants.js │ │ ├── Pagamento2.js │ │ ├── LoteHeader.js │ │ └── Pagamento.js │ └── ArquivoHeader.js ├── Rules.js └── Bradesco │ ├── ArquivoTrailing.js │ ├── Pagamento │ ├── LoteTrailing.js │ ├── CodigosFindalidadeTED │ ├── Pagamento2.js │ ├── LoteHeader.js │ ├── Pagamento.js │ └── Constants.js │ ├── Conciliacao │ ├── Constants.js │ ├── LoteTrailing.js │ ├── LoteHeader.js │ └── Conciliacao.js │ └── ArquivoHeader.js ├── package.json ├── Gruntfile.coffee ├── coffeelint.json └── README.md /gen_files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | Remessa: require('./cnab/src/Remessa.js'), 3 | Retorno: require('./cnab/src/Retorno.js') 4 | }; -------------------------------------------------------------------------------- /coffee/cnab/src/Utils.coffee: -------------------------------------------------------------------------------- 1 | class Utils 2 | 3 | # expects item.value and item.length 4 | padString: (item) -> 5 | value = item.value?.toString().trim() or '' 6 | value.toString().trim() + new Array(item.length).fill(' ').join('').substring(value.length) 7 | 8 | # expects item.value and item.length 9 | padNumber: (item) -> 10 | value = item.value?.toString().trim() or '' 11 | new Array(item.length).fill('0').join('').substring(value.length) + value 12 | 13 | module.exports = Utils 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | coverage.html 40 | gen_files/*.REM 41 | 42 | js/* 43 | -------------------------------------------------------------------------------- /coffee/cnab/test/Utils.coffee: -------------------------------------------------------------------------------- 1 | _ = require 'lodash' 2 | expect = require 'expect.js' 3 | Utils = require '../src/Utils' 4 | 5 | describe 'Utils', -> 6 | 7 | utils = null 8 | 9 | beforeEach -> 10 | utils = new Utils 11 | 12 | describe 'padString', -> 13 | 14 | it 'should add whitespaces do the right of the value', -> 15 | expect(utils.padString value: '123456', length: 10).to.be '123456 ' 16 | 17 | it 'should return whitespaces if value is undefined', -> 18 | expect(utils.padString length: 10).to.be ' ' 19 | 20 | describe 'padNumber', -> 21 | 22 | it 'should add zeroes do the left of the value', -> 23 | expect(utils.padNumber value: '123456', length: 10).to.be '0000123456' 24 | 25 | it 'should return zeroes if value is undefined', -> 26 | expect(utils.padNumber length: 10).to.be '0000000000' 27 | -------------------------------------------------------------------------------- /cnab/src/Utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * decaffeinate suggestions: 3 | * DS102: Remove unnecessary code created because of implicit returns 4 | * DS207: Consider shorter variations of null checks 5 | * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md 6 | */ 7 | class Utils { 8 | 9 | // expects item.value and item.length 10 | padString(item) { 11 | const value = (item.value != null ? item.value.toString().trim() : undefined) || ''; 12 | return value.toString().trim() + new Array(item.length).fill(' ').join('').substring(value.length); 13 | } 14 | 15 | // expects item.value and item.length 16 | padNumber(item) { 17 | const value = (item.value != null ? item.value.toString().trim() : undefined) || ''; 18 | return new Array(item.length).fill('0').join('').substring(value.length) + value; 19 | } 20 | } 21 | 22 | module.exports = Utils; 23 | -------------------------------------------------------------------------------- /cnab/test/DevUtils.js: -------------------------------------------------------------------------------- 1 | const _ = require('lodash') 2 | const expect = require('expect.js') 3 | const DevUtils = require('../src/DevUtils') 4 | const fs = require('fs') 5 | 6 | FILE_HEADER = 'ArquivoHeader' 7 | FILE_TRAILING = 'ArquivoTrailing' 8 | LOT_HEADER = 'LoteHeader' 9 | LOT_TRAILING = 'LoteTrailing' 10 | DETAIL = 'Detail' 11 | DETAIL2 = 'Detail2' 12 | FILE_SECTIONS = [FILE_HEADER, LOT_HEADER, DETAIL, DETAIL2, LOT_TRAILING, FILE_TRAILING] 13 | 14 | const bank = 'Bradesco' 15 | const type = 'Conciliacao' 16 | 17 | validator = new DevUtils(bank, type) 18 | validator.validate() 19 | const fileData = fs.readFileSync('/skyunix/EXTRATOS/extb237_3646_08021803.ret', 'utf8') 20 | console.log('###') 21 | console.log(fileData) 22 | console.log('###') 23 | 24 | console.log('\n>>>>> extracted fields\n') 25 | const extractedFields = validator.extract(FILE_SECTIONS, fileData) 26 | console.log(extractedFields); 27 | 28 | console.log('\n>>>>> fields length validation') 29 | validator.validateFieldsLength(extractedFields) 30 | 31 | // coffeelint: enable=no_trailing_whitespace 32 | // validator.extract sections, string 33 | -------------------------------------------------------------------------------- /coffee/layout/Rules.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | HSBC: 3 | ArquivoHeader: require './HSBC/ArquivoHeader.coffee' 4 | ArquivoTrailing: require './HSBC/ArquivoTrailing.coffee' 5 | Pagamento: 6 | LoteHeader: require './HSBC/Pagamento/LoteHeader.coffee' 7 | LoteTrailing: require './HSBC/Pagamento/LoteTrailing.coffee' 8 | Detail: require './HSBC/Pagamento/Pagamento.coffee' 9 | Detail2: require './HSBC/Pagamento/Pagamento2.coffee' 10 | Constants: require './HSBC/Pagamento/Constants.coffee' 11 | Bradesco: 12 | ArquivoHeader: require './Bradesco/ArquivoHeader.coffee' 13 | ArquivoTrailing: require './Bradesco/ArquivoTrailing.coffee' 14 | Pagamento: 15 | LoteHeader: require './Bradesco/Pagamento/LoteHeader.coffee' 16 | LoteTrailing: require './Bradesco/Pagamento/LoteTrailing.coffee' 17 | Detail: require './Bradesco/Pagamento/Pagamento.coffee' 18 | Detail2: require './Bradesco/Pagamento/Pagamento2.coffee' 19 | Constants: require './Bradesco/Pagamento/Constants.coffee' 20 | -------------------------------------------------------------------------------- /coffee/utils/parseTEDfile.coffee: -------------------------------------------------------------------------------- 1 | readline = require 'readline' 2 | fs = require 'fs' 3 | # CNAB = require 'cnab240-nodejs' 4 | 5 | Retorno = require '../cnab/src/Retorno' 6 | 7 | ui = readline.createInterface 8 | input: process.stdin 9 | output: process.stdout 10 | 11 | # ui.question 'Informe o caminho completo do arquivo:\n> ', (path) -> 12 | path = '/home/kanno/Documentos/Projects/cnab-service/emulate_skyunix/BKP/_pag237_3646_28111700.ret' 13 | console.log '' 14 | console.log "Abrindo '#{path}'" 15 | fs.readFile path, {encoding: 'utf8'}, (error, data) -> 16 | if error 17 | console.log error 18 | process.exit 1 19 | retorno = new Retorno 'Bradesco', 'Pagamento' 20 | extracted = retorno.extract data 21 | console.log JSON.stringify(extracted, null, 2) 22 | console.log "Escrevendo em 'output.json'..." 23 | fs.writeFile './output.json', JSON.stringify(extracted, null, 2), (error) -> 24 | if error 25 | console.log error 26 | process.exit 1 27 | console.log 'Feito. Saindo...' 28 | process.exit() -------------------------------------------------------------------------------- /cnab/test/Utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * decaffeinate suggestions: 3 | * DS102: Remove unnecessary code created because of implicit returns 4 | * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md 5 | */ 6 | const _ = require('lodash'); 7 | const expect = require('expect.js'); 8 | const Utils = require('../src/Utils'); 9 | 10 | describe('Utils', function() { 11 | 12 | let utils = null; 13 | 14 | beforeEach(() => utils = new Utils); 15 | 16 | describe('padString', function() { 17 | 18 | it('should add whitespaces do the right of the value', () => expect(utils.padString({value: '123456', length: 10})).to.be('123456 ')); 19 | 20 | return it('should return whitespaces if value is undefined', () => expect(utils.padString({length: 10})).to.be(' ')); 21 | }); 22 | 23 | return describe('padNumber', function() { 24 | 25 | it('should add zeroes do the left of the value', () => expect(utils.padNumber({value: '123456', length: 10})).to.be('0000123456')); 26 | 27 | return it('should return zeroes if value is undefined', () => expect(utils.padNumber({length: 10})).to.be('0000000000')); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /coffee/cnab/test/DevUtils.coffee: -------------------------------------------------------------------------------- 1 | # _ = require 'lodash' 2 | # expect = require 'expect.js' 3 | # DevUtils = require '../src/DevUtils' 4 | # fs = require 'fs' 5 | 6 | # FILE_HEADER = 'ArquivoHeader' 7 | # FILE_TRAILING = 'ArquivoTrailing' 8 | # LOT_HEADER = 'LoteHeader' 9 | # LOT_TRAILING = 'LoteTrailing' 10 | # DETAIL = 'Detail' 11 | # DETAIL2 = 'Detail2' 12 | # FILE_SECTIONS = [FILE_HEADER, LOT_HEADER, DETAIL, DETAIL2, LOT_TRAILING, FILE_TRAILING] 13 | 14 | # bank = 'Bradesco' 15 | # type = 'Pagamento' 16 | 17 | # validator = new DevUtils bank, type 18 | # # validator.validate() 19 | # # validator.getRequired() 20 | 21 | # fileString = fs.readFileSync '/home/andre/remessa' 22 | # fileData = fileString.toString() 23 | # # process.stdout.write '### ' 24 | # # console.log fileData 25 | # # process.stdout.write ' ###' 26 | 27 | # # console.log '\n>>>>> extracted fields\n' 28 | # extractedFields = validator.extract FILE_SECTIONS, fileData 29 | 30 | # # console.log '\n>>>>> fields length validation' 31 | # validator.validateFieldsLength extractedFields 32 | 33 | # # console.log '\n>>>>> file length validation\n' 34 | # expect(fileData.length).to.be FILE_SECTIONS.length * 240 + FILE_SECTIONS.length - 1 35 | 36 | 37 | # # coffeelint: enable=no_trailing_whitespace 38 | # # validator.extract sections, string 39 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/ArquivoTrailing.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 399 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '9999' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 9 25 | } 26 | { 27 | field: 'filler' 28 | startPos: 9 29 | endPos: 17 30 | length: 9 31 | required: false 32 | default: new Array(9).fill(' ').join('') 33 | } 34 | { 35 | field: 'qtde_lotes' 36 | startPos: 18 37 | endPos: 23 38 | length: 6 39 | required: true 40 | type: 'numeric' 41 | } 42 | { 43 | field: 'qtde_registros' 44 | startPos: 24 45 | endPos: 29 46 | length: 6 47 | required: true 48 | type: 'numeric' 49 | } 50 | { 51 | field: 'filler' 52 | startPos: 30 53 | endPos: 240 54 | length: 211 55 | required: false 56 | default: new Array(211).fill(' ').join('') 57 | } 58 | ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, s2way 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /layout/HSBC/ArquivoTrailing.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 399 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '9999' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 9 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'qtde_lotes', 36 | startPos: 18, 37 | endPos: 23, 38 | length: 6, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'qtde_registros', 44 | startPos: 24, 45 | endPos: 29, 46 | length: 6, 47 | required: true, 48 | type: 'numeric' 49 | }, 50 | { 51 | field: 'filler', 52 | startPos: 30, 53 | endPos: 240, 54 | length: 211, 55 | required: false, 56 | default: new Array(211).fill(' ').join('') 57 | } 58 | ]; -------------------------------------------------------------------------------- /layout/Rules.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | HSBC: { 3 | ArquivoHeader: require('./HSBC/ArquivoHeader.js'), 4 | ArquivoTrailing: require('./HSBC/ArquivoTrailing.js'), 5 | Pagamento: { 6 | LoteHeader: require('./HSBC/Pagamento/LoteHeader.js'), 7 | LoteTrailing: require('./HSBC/Pagamento/LoteTrailing.js'), 8 | Detail: require('./HSBC/Pagamento/Pagamento.js'), 9 | Detail2: require('./HSBC/Pagamento/Pagamento2.js'), 10 | Constants: require('./HSBC/Pagamento/Constants.js') 11 | } 12 | }, 13 | Bradesco: { 14 | ArquivoHeader: require('./Bradesco/ArquivoHeader.js'), 15 | ArquivoTrailing: require('./Bradesco/ArquivoTrailing.js'), 16 | Pagamento: { 17 | LoteHeader: require('./Bradesco/Pagamento/LoteHeader.js'), 18 | LoteTrailing: require('./Bradesco/Pagamento/LoteTrailing.js'), 19 | Detail: require('./Bradesco/Pagamento/Pagamento.js'), 20 | Detail2: require('./Bradesco/Pagamento/Pagamento2.js'), 21 | Constants: require('./Bradesco/Pagamento/Constants.js') 22 | }, 23 | Conciliacao: { 24 | LoteHeader: require('./Bradesco/Conciliacao/LoteHeader.js'), 25 | LoteTrailing: require('./Bradesco/Conciliacao/LoteTrailing.js'), 26 | Detail: require('./Bradesco/Conciliacao/Conciliacao.js'), 27 | Constants: require('./Bradesco/Conciliacao/Constants.js') 28 | } 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /coffee/layout/Bradesco/ArquivoTrailing.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 237 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '9999' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: '9' 25 | } 26 | { 27 | field: 'filler' 28 | startPos: 9 29 | endPos: 17 30 | length: 9 31 | required: false 32 | default: new Array(9).fill(' ').join('') 33 | } 34 | { 35 | field: 'qtde_lotes' 36 | startPos: 18 37 | endPos: 23 38 | length: 6 39 | required: true 40 | type: 'numeric' 41 | } 42 | { 43 | field: 'qtde_registros' 44 | startPos: 24 45 | endPos: 29 46 | length: 6 47 | required: true 48 | type: 'numeric' 49 | } 50 | { 51 | field: 'qtde_contas' 52 | startPos: 30 53 | endPos: 35 54 | length: 6 55 | required: true 56 | type: 'numeric' 57 | } 58 | { 59 | field: 'filler' 60 | startPos: 36 61 | endPos: 240 62 | length: 205 63 | required: false 64 | default: new Array(205).fill(' ').join('') 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/Pagamento/LoteTrailing.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 399 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 5 25 | } 26 | { 27 | field: 'filler' 28 | startPos: 9 29 | endPos: 17 30 | length: 9 31 | required: false 32 | default: new Array(9).fill(' ').join('') 33 | } 34 | { 35 | field: 'qtde_registros' 36 | startPos: 18 37 | endPos: 23 38 | length: 6 39 | required: true 40 | type: 'numeric' 41 | } 42 | { 43 | field: 'filler' 44 | startPos: 24 45 | endPos: 26 46 | length: 3 47 | required: false 48 | default: new Array(3).fill(' ').join('') 49 | } 50 | { 51 | field: 'valor_credito' 52 | startPos: 27 53 | endPos: 41 54 | length: 15 55 | required: true 56 | type: 'numeric' 57 | } 58 | { 59 | field: 'filler' 60 | startPos: 42 61 | endPos: 240 62 | length: 199 63 | required: false 64 | default: new Array(199).fill(' ').join('') 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /layout/Bradesco/ArquivoTrailing.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '9999' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: '9' 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'qtde_lotes', 36 | startPos: 18, 37 | endPos: 23, 38 | length: 6, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'qtde_registros', 44 | startPos: 24, 45 | endPos: 29, 46 | length: 6, 47 | required: true, 48 | type: 'numeric' 49 | }, 50 | { 51 | field: 'qtde_contas', 52 | startPos: 30, 53 | endPos: 35, 54 | length: 6, 55 | required: true, 56 | type: 'numeric' 57 | }, 58 | { 59 | field: 'filler', 60 | startPos: 36, 61 | endPos: 240, 62 | length: 205, 63 | required: false, 64 | default: new Array(205).fill(' ').join('') 65 | } 66 | ]; 67 | -------------------------------------------------------------------------------- /layout/HSBC/Pagamento/LoteTrailing.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 399 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 5 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'qtde_registros', 36 | startPos: 18, 37 | endPos: 23, 38 | length: 6, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'filler', 44 | startPos: 24, 45 | endPos: 26, 46 | length: 3, 47 | required: false, 48 | default: new Array(3).fill(' ').join('') 49 | }, 50 | { 51 | field: 'valor_credito', 52 | startPos: 27, 53 | endPos: 41, 54 | length: 15, 55 | required: true, 56 | type: 'numeric' 57 | }, 58 | { 59 | field: 'filler', 60 | startPos: 42, 61 | endPos: 240, 62 | length: 199, 63 | required: false, 64 | default: new Array(199).fill(' ').join('') 65 | } 66 | ]; 67 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/Pagamento/Constants.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | LoteHeader: 3 | TIPO_SERVICO: 4 | COBRANCA: '01' 5 | PAGAMENTO_DIVIDENDOS: '10' 6 | VENDA_ACOES: '11' 7 | PAGAMENTO_FORNECEDORES: '20' 8 | PAGAMENTO_CONTAS: '22' 9 | PAGAMNETO_EMPRESTIMOS: '34' 10 | PAGAMENTO_COMISSOES: '36' 11 | PAGAMENTO_LOJISTAS: '40' 12 | TRANSFERENCIA_TITULARIDADE: '50' 13 | PAGAMENTO_DESPESA_VIAJANTE: '60' 14 | PAGAMENTO_ADIANTAMENTO: '61' 15 | REEMBOLSO_DESPESA: '62' 16 | PAGAMENTO_AUTORIZADO: '70' 17 | PAGAMENTO_BENEFICIOS: '90' 18 | PAGAMENTO_ASSISTENCIA_MEDICA: '91' 19 | PAGAMENTO_PIS_PASEP: '92' 20 | PAGAMENTO_GPS: '95' 21 | FORMA_LANCAMENTO: 22 | CREDITO_CC: '10' 23 | CEDITO_ADM: '02' 24 | DOCTO_CREDITO: '03' # DOC/TED 25 | CREDITO_POUPANCA: '05' 26 | PGTO_CONTAS: '11' 27 | DARF: '16' 28 | LIQUIDACAO_TITULOS_HSBC: '30' 29 | LIQUIDACAO_TITULOS_OUTROS: '31' 30 | LIBERACAO_TITULOS_HSBC: '32' 31 | LIQUIDACAO_PARCELAS: '33' 32 | GPS: '34' 33 | Detail: 34 | TIPO_MOVIMENTO: # tipo de movimento a que o detalhe se destina 35 | I: 0 # inclusão com compromisso 36 | B: 5 # inclusão com bloqueio 37 | E: 9 # exclusão do compromisso 38 | CODIGO_MOVIMENTO: # indica a movimentação a ser efetuada 39 | INCLUSAO: '00' # inclusão com registro detalhe 40 | EXCLUSAO: '99' # exclusão do compromisso 41 | INCLUSAO_COM_BLOQUEIO: '55' # inclusão com bloqueio -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cnab240-nodejs", 3 | "version": "0.1.0", 4 | "description": "Gerador de arquivo de remessa padrão CNAB 240 / HSBC", 5 | "main": "main.js", 6 | "scripts": { 7 | "pretest": "node_modules/.bin/coffeelint -f coffeelint.json src", 8 | "test": "mocha test --recursive -R progress --compilers coffee:coffee-script/register" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/s2way/cnab240-nodejs.git" 13 | }, 14 | "config": { 15 | "blanket": { 16 | "pattern": "cov/src", 17 | "loader": "./node-loaders/coffee-script.js" 18 | }, 19 | "mocha-cov-reporter": { 20 | "failOnError": true, 21 | "threshold": 96, 22 | "useColors": true 23 | } 24 | }, 25 | "keywords": [ 26 | "query builder", 27 | "mysql" 28 | ], 29 | "author": "Newborns/S2Way", 30 | "bugs": { 31 | "url": "https://github.com/s2way/cnab240-nodejs/issues" 32 | }, 33 | "homepage": "https://github.com/s2way/cnab240-nodejs", 34 | "devDependencies": { 35 | "blanket": "^1.2.1", 36 | "coffee-script": "1.10.0", 37 | "coffeelint": "^1.9.4", 38 | "decaffeinate": "^3.3.16", 39 | "grunt": "^0.4.5", 40 | "grunt-cli": "^0.1.13", 41 | "grunt-coffeelint": "0.0.13", 42 | "grunt-contrib-coffee": "^2.0.0", 43 | "grunt-contrib-jshint": "^1.0.0", 44 | "grunt-contrib-watch": "~0.6.1", 45 | "grunt-exec": "~0.4.6", 46 | "grunt-mocha-test": "^0.12.7", 47 | "load-grunt-tasks": "^3.1.0", 48 | "mocha": "^2.2.4", 49 | "mocha-cov-reporter": "^1.1.0", 50 | "mocha-multi": "~0.7.1" 51 | }, 52 | "dependencies": { 53 | "expect.js": "^0.3.1", 54 | "joi": "^9.0.4", 55 | "lodash": "^4.15.0", 56 | "moment": "^2.14.1", 57 | "remove-accents": "^0.4.1" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /layout/HSBC/Pagamento/Constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | LoteHeader: { 3 | TIPO_SERVICO: { 4 | COBRANCA: '01', 5 | PAGAMENTO_DIVIDENDOS: '10', 6 | VENDA_ACOES: '11', 7 | PAGAMENTO_FORNECEDORES: '20', 8 | PAGAMENTO_CONTAS: '22', 9 | PAGAMNETO_EMPRESTIMOS: '34', 10 | PAGAMENTO_COMISSOES: '36', 11 | PAGAMENTO_LOJISTAS: '40', 12 | TRANSFERENCIA_TITULARIDADE: '50', 13 | PAGAMENTO_DESPESA_VIAJANTE: '60', 14 | PAGAMENTO_ADIANTAMENTO: '61', 15 | REEMBOLSO_DESPESA: '62', 16 | PAGAMENTO_AUTORIZADO: '70', 17 | PAGAMENTO_BENEFICIOS: '90', 18 | PAGAMENTO_ASSISTENCIA_MEDICA: '91', 19 | PAGAMENTO_PIS_PASEP: '92', 20 | PAGAMENTO_GPS: '95' 21 | }, 22 | FORMA_LANCAMENTO: { 23 | CREDITO_CC: '10', 24 | CEDITO_ADM: '02', 25 | DOCTO_CREDITO: '03', // DOC/TED 26 | CREDITO_POUPANCA: '05', 27 | PGTO_CONTAS: '11', 28 | DARF: '16', 29 | LIQUIDACAO_TITULOS_HSBC: '30', 30 | LIQUIDACAO_TITULOS_OUTROS: '31', 31 | LIBERACAO_TITULOS_HSBC: '32', 32 | LIQUIDACAO_PARCELAS: '33', 33 | GPS: '34' 34 | } 35 | }, 36 | Detail: { 37 | TIPO_MOVIMENTO: { // tipo de movimento a que o detalhe se destina 38 | I: 0, // inclusão com compromisso 39 | B: 5, // inclusão com bloqueio 40 | E: 9 41 | }, // exclusão do compromisso 42 | CODIGO_MOVIMENTO: { // indica a movimentação a ser efetuada 43 | INCLUSAO: '00', // inclusão com registro detalhe 44 | EXCLUSAO: '99', // exclusão do compromisso 45 | INCLUSAO_COM_BLOQUEIO: '55' 46 | } 47 | } // inclusão com bloqueio 48 | }; -------------------------------------------------------------------------------- /coffee/layout/Bradesco/Pagamento/LoteTrailing.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 237 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 5 25 | } 26 | { 27 | field: 'filler' 28 | startPos: 9 29 | endPos: 17 30 | length: 9 31 | required: false 32 | default: new Array(9).fill(' ').join('') 33 | } 34 | { 35 | field: 'qtde_registros' 36 | startPos: 18 37 | endPos: 23 38 | length: 6 39 | required: true 40 | type: 'numeric' 41 | } 42 | { 43 | field: 'somatoria_valores' 44 | startPos: 24 45 | endPos: 41 46 | length: 18 47 | required: true 48 | } 49 | { 50 | field: 'somatoria_qtde_moedas' 51 | startPos: 42 52 | endPos: 59 53 | length: 18 54 | required: false 55 | default: new Array(18).fill('0').join('') 56 | } 57 | { 58 | field: 'num_aviso_debito' 59 | startPos: 60 60 | endPos: 65 61 | length: 6 62 | required: false 63 | } 64 | { 65 | field: 'filler' 66 | startPos: 66 67 | endPos: 230 68 | length: 165 69 | required: false 70 | default: new Array(165).fill(' ').join('') 71 | } 72 | { 73 | field: 'codigos_ocorrencias' 74 | startPos: 231 75 | endPos: 240 76 | length: 10 77 | required: false 78 | default: new Array(10).fill(' ').join('') 79 | } 80 | ] 81 | -------------------------------------------------------------------------------- /layout/Bradesco/Pagamento/LoteTrailing.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 5 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'qtde_registros', 36 | startPos: 18, 37 | endPos: 23, 38 | length: 6, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'somatoria_valores', 44 | startPos: 24, 45 | endPos: 41, 46 | length: 18, 47 | required: true 48 | }, 49 | { 50 | field: 'somatoria_qtde_moedas', 51 | startPos: 42, 52 | endPos: 59, 53 | length: 18, 54 | required: false, 55 | default: new Array(18).fill('0').join('') 56 | }, 57 | { 58 | field: 'num_aviso_debito', 59 | startPos: 60, 60 | endPos: 65, 61 | length: 6, 62 | required: false 63 | }, 64 | { 65 | field: 'filler', 66 | startPos: 66, 67 | endPos: 230, 68 | length: 165, 69 | required: false, 70 | default: new Array(165).fill(' ').join('') 71 | }, 72 | { 73 | field: 'codigos_ocorrencias', 74 | startPos: 231, 75 | endPos: 240, 76 | length: 10, 77 | required: false, 78 | default: new Array(10).fill(' ').join('') 79 | } 80 | ]; 81 | -------------------------------------------------------------------------------- /layout/Bradesco/Pagamento/CodigosFindalidadeTED: -------------------------------------------------------------------------------- 1 | 2 | 00001 Pagamento de Imposto, Tributos e Taxas 3 | 00002 Pagamentos a concessionárias de serviços Públicos 4 | 00003 Pagamentos de Dividendos 5 | 00004 Pagamentos de Salários 6 | 00005 Pagamentos de Fornecedores 7 | 00006 Pagamentos de Honorários 8 | 00007 Pagamentos de Aluguéis e Taxas e Condomínio 9 | 00008 Pagamentos de Duplicatas e Títulos 10 | 00009 Pagamentos de Honorários 11 | 00010 Créditos em Conta 12 | 00011 Pagamentos a Corretoras 13 | 00016 Créditos em Conta Investimento 14 | 00100 Depósitos Judiciais 15 | 00101 Pensões Alimentícias 16 | 00200 Transferências Internacional de Reais 17 | 00201 Ajustes Posição Mercado Futuro 18 | 00202 Repasse de Valores do BNDS 19 | 00203 Liquidação de Compromisso com BNDS 20 | 00204 Compra\Venda de Ações – Bolsa de Valores e Mercado de Balção 21 | 00205 Contrato referenciado em Ações/Índices de Ações – BV/BMF 22 | 00300 Restituição Imposto de Renda 23 | 00500 Restituição Prêmio de Seguros 24 | 00501 Pagamento de Indenização de Sinistro de Seguro 25 | 00502 Pagamento de Prêmio de Co - seguro 26 | 00503 Restituição de Prêmio de CO - Seguro 27 | 00504 Pagamentos de Indenização de CO - Seguro 28 | 00505 Pagamentos de Prêmio de Resseguro 29 | 00506 Restituição de Prêmio de Resseguro 30 | 00507 Pagamento de Indenização de sinistro de Resseguro 31 | 00508 Restituição de Indenização de Sinistro de Resseguro 32 | 00509 Pagamento de Despesas com sinistros 33 | 00510 Pagamento de Inspeções/Vistorias Prévias 34 | 00511 Pagamento de Resgate de Título de Capitalização 35 | 00512 Pagamento de Sorteio de Título de Capitalização 36 | 00513 Pagamento de Devolução de Mensalidade de Títulos de Capitalização 37 | 00514 Restituição de Contribuição de Plano Previdência 38 | 00515 Pagamento de Beneficio Previdência de Pecúlio 39 | 00516 Pagamento de Beneficio Previdenciário de Pensão 40 | 00517 Pagamento de Beneficio Previdenciário de Aposentadoria 41 | 00518 Pagamento de Resgate Previdenciário 42 | 00519 Pagamento de Comissão de Corretagem 43 | 00520 Pagamento de Transferências/Portabilidade de Reserva de Seguro/Previdência 44 | 99999 Outros 45 | -------------------------------------------------------------------------------- /coffee/layout/Bradesco/Pagamento/CodigosFindalidadeTED: -------------------------------------------------------------------------------- 1 | 2 | 00001 Pagamento de Imposto, Tributos e Taxas 3 | 00002 Pagamentos a concessionárias de serviços Públicos 4 | 00003 Pagamentos de Dividendos 5 | 00004 Pagamentos de Salários 6 | 00005 Pagamentos de Fornecedores 7 | 00006 Pagamentos de Honorários 8 | 00007 Pagamentos de Aluguéis e Taxas e Condomínio 9 | 00008 Pagamentos de Duplicatas e Títulos 10 | 00009 Pagamentos de Honorários 11 | 00010 Créditos em Conta 12 | 00011 Pagamentos a Corretoras 13 | 00016 Créditos em Conta Investimento 14 | 00100 Depósitos Judiciais 15 | 00101 Pensões Alimentícias 16 | 00200 Transferências Internacional de Reais 17 | 00201 Ajustes Posição Mercado Futuro 18 | 00202 Repasse de Valores do BNDS 19 | 00203 Liquidação de Compromisso com BNDS 20 | 00204 Compra\Venda de Ações – Bolsa de Valores e Mercado de Balção 21 | 00205 Contrato referenciado em Ações/Índices de Ações – BV/BMF 22 | 00300 Restituição Imposto de Renda 23 | 00500 Restituição Prêmio de Seguros 24 | 00501 Pagamento de Indenização de Sinistro de Seguro 25 | 00502 Pagamento de Prêmio de Co - seguro 26 | 00503 Restituição de Prêmio de CO - Seguro 27 | 00504 Pagamentos de Indenização de CO - Seguro 28 | 00505 Pagamentos de Prêmio de Resseguro 29 | 00506 Restituição de Prêmio de Resseguro 30 | 00507 Pagamento de Indenização de sinistro de Resseguro 31 | 00508 Restituição de Indenização de Sinistro de Resseguro 32 | 00509 Pagamento de Despesas com sinistros 33 | 00510 Pagamento de Inspeções/Vistorias Prévias 34 | 00511 Pagamento de Resgate de Título de Capitalização 35 | 00512 Pagamento de Sorteio de Título de Capitalização 36 | 00513 Pagamento de Devolução de Mensalidade de Títulos de Capitalização 37 | 00514 Restituição de Contribuição de Plano Previdência 38 | 00515 Pagamento de Beneficio Previdência de Pecúlio 39 | 00516 Pagamento de Beneficio Previdenciário de Pensão 40 | 00517 Pagamento de Beneficio Previdenciário de Aposentadoria 41 | 00518 Pagamento de Resgate Previdenciário 42 | 00519 Pagamento de Comissão de Corretagem 43 | 00520 Pagamento de Transferências/Portabilidade de Reserva de Seguro/Previdência 44 | 99999 Outros 45 | -------------------------------------------------------------------------------- /Gruntfile.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (grunt) -> 2 | 3 | config = 4 | pkg: grunt.file.readJSON 'package.json' 5 | coffeelint: 6 | app: ['cnab/src/*.coffee', 'cnab/test/*.coffee'] 7 | options: 8 | configFile: 'coffeelint.json' 9 | mochaTest: 10 | progress: 11 | options: 12 | reporter: 'progress' 13 | require: ['coffee-script/register', 'blanket'] 14 | captureFile: 'mochaTest.log' 15 | quiet: false, 16 | clearRequireCache: false 17 | src: ['cnab/test/*.coffee'] 18 | spec: 19 | options: 20 | reporter: 'spec' 21 | require: ['coffee-script/register', 'blanket'] 22 | captureFile: 'mochaTest.log' 23 | quiet: false, 24 | clearRequireCache: false 25 | src: ['cnab/test/*.coffee'] 26 | exec: 27 | cov: " 28 | rm -rf cov; 29 | mkdir -p cov; 30 | ./node_modules/.bin/coffee --compile --output cov cnab; 31 | ./node_modules/mocha/bin/mocha cov/test -r blanket --reporter mocha-cov-reporter --compilers coffee:coffee-script/register --recursive; 32 | ./node_modules/mocha/bin/mocha cov/test -r blanket --reporter html-cov --compilers coffee:coffee-script/register --recursive > coverage.html" 33 | watch: 34 | src: 35 | files: ['**/**/*.coffee'] 36 | tasks: ['lint', 'test', 'coverage'] 37 | gruntfile: 38 | files: ['Gruntfile.coffee'] 39 | 40 | grunt.initConfig config 41 | 42 | require('load-grunt-tasks')(grunt) 43 | 44 | grunt.registerTask 'default', 'Default', -> 45 | grunt.task.run 'lint' 46 | grunt.task.run 'test' 47 | # grunt.task.run 'compile' 48 | grunt.task.run 'coverage' 49 | grunt.registerTask 'lint', ['coffeelint'] 50 | grunt.registerTask 'test', ['mochaTest:progress'] 51 | grunt.registerTask 'coverage', ['exec:cov'] 52 | -------------------------------------------------------------------------------- /coffee/cnab/test/Example.coffee: -------------------------------------------------------------------------------- 1 | params = 2 | ArquivoHeader: 3 | empresa_inscricao_tipo: '2' 4 | empresa_inscricao_num: '09999999000101' 5 | convenio: '456789' 6 | empresa_nome: 'Versul Tecnologias Ltda' 7 | nome_banco: 'HSBC' 8 | arquivo_data_geracao: '29082016' 9 | arquivo_hora_geracao: '085600' 10 | arquivo_sequencia: '1' 11 | ArquivoTrailing: 12 | qtde_lotes: '1' 13 | qtde_registros: '1' 14 | LoteHeader: 15 | servico: '10' 16 | forma_lancamento: '03' 17 | empresa_tipo_insc: '2' 18 | empresa_num_insc: '09999999000101' 19 | convenio: '111' 20 | empresa_nome: 'Versul Tecnologias Ltda' 21 | LoteTrailing: 22 | qtde_registros: '1' 23 | valor_credito: '10000' 24 | Detail: 25 | num_seq_registro_lote: '1' 26 | movimento_tipo: '9' 27 | movimento_cod: '00' 28 | cod_camara: '018' 29 | favorecido_cod_banco: '001' 30 | favorecido_agencia: '2898' 31 | favorecido_num_conta: '17945' 32 | favorecido_dig_verificador: '7' 33 | favorecido_nome: 'Chuck Norris' 34 | doc_num: '153' 35 | data_lcto_credito: '29082016' 36 | valor_lcto: '10000' 37 | Detail2: 38 | num_seq_registro_lote: '1' 39 | movimento_tipo: '9' 40 | movimento_cod: '00' 41 | cod_camara: '018' 42 | favorecido_cod_banco: '001' 43 | favorecido_agencia: '2898' 44 | favorecido_num_conta: '17945' 45 | favorecido_dig_verificador: '7' 46 | favorecido_nome: 'Chuck Norris' 47 | doc_num: '153' 48 | data_lcto_credito: '29082016' 49 | valor_lcto: '10000' 50 | 51 | Remessa = require('../../main').Remessa 52 | remessa = new Remessa 'HSBC', 'Pagamento' 53 | # file = remessa.process params 54 | # 55 | # require('expect.js')(file).to.have.length 1204 56 | # 57 | # moment = require 'moment' 58 | # fileName = "example_file.REM" 59 | # path = process.env.EFS or './gen_files' 60 | # 61 | # fs = require 'fs' 62 | # 63 | # fs.writeFile "#{path}/#{fileName}", file, (err) -> 64 | # return console.log "file save error: #{err}" if err? 65 | # console.log "file '#{fileName}' successfully saved" 66 | -------------------------------------------------------------------------------- /cnab/test/Example.js: -------------------------------------------------------------------------------- 1 | const params = { 2 | ArquivoHeader: { 3 | empresa_inscricao_tipo: '2', 4 | empresa_inscricao_num: '09999999000101', 5 | convenio: '456789', 6 | empresa_nome: 'Versul Tecnologias Ltda', 7 | nome_banco: 'HSBC', 8 | arquivo_data_geracao: '29082016', 9 | arquivo_hora_geracao: '085600', 10 | arquivo_sequencia: '1' 11 | }, 12 | ArquivoTrailing: { 13 | qtde_lotes: '1', 14 | qtde_registros: '1' 15 | }, 16 | LoteHeader: { 17 | servico: '10', 18 | forma_lancamento: '03', 19 | empresa_tipo_insc: '2', 20 | empresa_num_insc: '09999999000101', 21 | convenio: '111', 22 | empresa_nome: 'Versul Tecnologias Ltda' 23 | }, 24 | LoteTrailing: { 25 | qtde_registros: '1', 26 | valor_credito: '10000' 27 | }, 28 | Detail: { 29 | num_seq_registro_lote: '1', 30 | movimento_tipo: '9', 31 | movimento_cod: '00', 32 | cod_camara: '018', 33 | favorecido_cod_banco: '001', 34 | favorecido_agencia: '2898', 35 | favorecido_num_conta: '17945', 36 | favorecido_dig_verificador: '7', 37 | favorecido_nome: 'Chuck Norris', 38 | doc_num: '153', 39 | data_lcto_credito: '29082016', 40 | valor_lcto: '10000' 41 | }, 42 | Detail2: { 43 | num_seq_registro_lote: '1', 44 | movimento_tipo: '9', 45 | movimento_cod: '00', 46 | cod_camara: '018', 47 | favorecido_cod_banco: '001', 48 | favorecido_agencia: '2898', 49 | favorecido_num_conta: '17945', 50 | favorecido_dig_verificador: '7', 51 | favorecido_nome: 'Chuck Norris', 52 | doc_num: '153', 53 | data_lcto_credito: '29082016', 54 | valor_lcto: '10000' 55 | } 56 | }; 57 | 58 | const { Remessa } = require('../../main'); 59 | const remessa = new Remessa('HSBC', 'Pagamento'); 60 | // file = remessa.process params 61 | // 62 | // require('expect.js')(file).to.have.length 1204 63 | // 64 | // moment = require 'moment' 65 | // fileName = "example_file.REM" 66 | // path = process.env.EFS or './gen_files' 67 | // 68 | // fs = require 'fs' 69 | // 70 | // fs.writeFile "#{path}/#{fileName}", file, (err) -> 71 | // return console.log "file save error: #{err}" if err? 72 | // console.log "file '#{fileName}' successfully saved" 73 | -------------------------------------------------------------------------------- /layout/Bradesco/Conciliacao/Constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | Conciliacao: { 3 | REGISTRY_FIELD: 'cod_seg_registro_lote' 4 | }, 5 | Detail: 'E', 6 | Segmentos: { 7 | E: 'Detail' 8 | }, 9 | ArquivoHeader: { 10 | REGISTRY_FIELD: 'registro', 11 | ARQUIVO_COD: { 12 | REMESSA: '1', 13 | RETORNO: '2' 14 | }, 15 | TIPO_INSC_EMPRESA: { 16 | ISENTO: '0', 17 | CPF: '1', 18 | CNPJ: '2', 19 | PIS_PASEP: '3', 20 | OUTRO: '9' 21 | } 22 | }, 23 | ArquivoTrailing: { 24 | TOTAL_LOTES_FIELD: 'qtde_lotes', 25 | REGISTRY_FIELD: 'registro' 26 | }, 27 | LoteHeader: { 28 | REGISTRY_FIELD: 'registro', 29 | TIPO_SERVICO: { 30 | COBRANCA: '01', 31 | BLOQUETO_ELETRONICO: '03', 32 | CONCILIACAO_BANCARIA: '04', 33 | DEBITOS: '05', 34 | CUSTODIA_CHEQUES: '06', 35 | GESTAO_CAIXA: '07', 36 | CONSULTA_MARGEM: '08', 37 | AVERBACAO_CONSIGNACAO: '09', 38 | PAGAMENTO_DIVIDENDOS: '10', 39 | MANUTENCAO_CONSIGNACAO: '11', 40 | CONSIGNACAO_PARCELAS: '12', 41 | GLOSA_CONSIGNACAO: '13', 42 | CONSULTA_TRIBUTOS_PAGAR: '14', 43 | PAGAMENTO_FORNECEDORES: '20', 44 | PAGAMENTO_CONTAS: '22', 45 | COMPROR: '25', 46 | COMPROR_ROTATIVO: '26', 47 | ALEGACAO_SACADO: '29', 48 | PAGAMENTO_SALARIOS: '30', 49 | PAGAMENTO_HONORARIOS: '32', 50 | PAGAMENTO_BOLSA_AUXILIO: '33', 51 | PAGAMNETO_PREBENDA: '34', 52 | VENDOR: '40', 53 | VENDOR_TERMO: '41', 54 | PAGAMENTO_SINISTROS: '50', 55 | PAGAMENTO_DESPESAS_VIAJANTE: '60', 56 | PAGAMENTO_AUTORIZADO: '70', 57 | PAGAMENTO_CREDENCIADOS: '75', 58 | PAGAMENTO_REMUNERACAO: '77', 59 | PAGAMENTO_REPRESENTANTES: '80', 60 | PAGAMENTO_BENEFICIOS: '90', 61 | PAGAMENTOS_DIVERSOS: '98', 62 | EXCLUSIVO_BRADESCO: '99' 63 | }, 64 | FORMA_LANCAMENTO: { 65 | CREDITO_CC: '01', // transferência para contas do Bradesco 66 | CEDITO_ADM: '02', 67 | DOCTO_CREDITO: '03', // DOC/TED 68 | CARTAO_SALARIO: '04', // Somente para tipo serviço 30 69 | CREDITO_POUPANCA: '05', 70 | OP_DISPOSICAO: '10', 71 | PGTO_CONTAS: '11', 72 | TED_OUTRA_TITULARIDADE: '41' 73 | } 74 | }, 75 | // ... 99 76 | LoteTrailing: { 77 | REGISTRY_FIELD: 'registro' 78 | } 79 | }; 80 | -------------------------------------------------------------------------------- /coffeelint.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrow_spacing": { 3 | "level": "ignore" 4 | }, 5 | "camel_case_classes": { 6 | "level": "error" 7 | }, 8 | "coffeescript_error": { 9 | "level": "error" 10 | }, 11 | "colon_assignment_spacing": { 12 | "level": "ignore", 13 | "spacing": { 14 | "left": 0, 15 | "right": 0 16 | } 17 | }, 18 | "cyclomatic_complexity": { 19 | "value": 10, 20 | "level": "ignore" 21 | }, 22 | "duplicate_key": { 23 | "level": "error" 24 | }, 25 | "empty_constructor_needs_parens": { 26 | "level": "ignore" 27 | }, 28 | "indentation": { 29 | "value": 4, 30 | "level": "error" 31 | }, 32 | "line_endings": { 33 | "level": "ignore", 34 | "value": "unix" 35 | }, 36 | "max_line_length": { 37 | "value": 1000, 38 | "level": "error", 39 | "limitComments": true 40 | }, 41 | "missing_fat_arrows": { 42 | "level": "ignore" 43 | }, 44 | "newlines_after_classes": { 45 | "value": 3, 46 | "level": "ignore" 47 | }, 48 | "no_backticks": { 49 | "level": "error" 50 | }, 51 | "no_debugger": { 52 | "level": "warn" 53 | }, 54 | "no_empty_functions": { 55 | "level": "ignore" 56 | }, 57 | "no_empty_param_list": { 58 | "level": "ignore" 59 | }, 60 | "no_implicit_braces": { 61 | "level": "ignore", 62 | "strict": true 63 | }, 64 | "no_implicit_parens": { 65 | "strict": true, 66 | "level": "ignore" 67 | }, 68 | "no_interpolation_in_single_quotes": { 69 | "level": "ignore" 70 | }, 71 | "no_plusplus": { 72 | "level": "ignore" 73 | }, 74 | "no_stand_alone_at": { 75 | "level": "ignore" 76 | }, 77 | "no_tabs": { 78 | "level": "error" 79 | }, 80 | "no_throwing_strings": { 81 | "level": "error" 82 | }, 83 | "no_trailing_semicolons": { 84 | "level": "error" 85 | }, 86 | "no_trailing_whitespace": { 87 | "level": "error", 88 | "allowed_in_comments": false, 89 | "allowed_in_empty_lines": true 90 | }, 91 | "no_unnecessary_double_quotes": { 92 | "level": "ignore" 93 | }, 94 | "no_unnecessary_fat_arrows": { 95 | "level": "warn" 96 | }, 97 | "non_empty_constructor_needs_parens": { 98 | "level": "ignore" 99 | }, 100 | "prefer_english_operator": { 101 | "level": "ignore", 102 | "doubleNotLevel": "ignore" 103 | }, 104 | "space_operators": { 105 | "level": "ignore" 106 | } 107 | } -------------------------------------------------------------------------------- /coffee/cnab/src/DevUtils.coffee: -------------------------------------------------------------------------------- 1 | rules = require '../../layout/Rules' 2 | expect = require 'expect.js' 3 | _ = require 'lodash' 4 | 5 | class DevUtils 6 | 7 | constructor: (bank, type) -> 8 | @rules = 9 | ArquivoHeader: rules[bank].ArquivoHeader 10 | ArquivoTrailing: rules[bank].ArquivoTrailing 11 | LoteHeader: rules[bank][type].LoteHeader 12 | LoteTrailing: rules[bank][type].LoteTrailing 13 | Detail: rules[bank][type].Detail 14 | Detail2: rules[bank][type].Detail2 15 | 16 | getRequired: -> 17 | for key, subject of @rules 18 | @_log '---------------------' 19 | @_log "Required for #{key}" 20 | required = _.filter(subject, required: true).map (item) -> 21 | "#{item.field}": _.pick item, ['type', 'length', 'default'] unless item.default? 22 | @_log JSON.stringify _.compact(required), null, 4 23 | 24 | getAllFields: -> 25 | for key, subject of @rules 26 | @_log '---------------------' 27 | @_log "Fields for #{key}" 28 | required = _.map subject, (item) -> 29 | "#{item.field}": _.pick item, ['type', 'length', 'default'] 30 | # @_log required 31 | 32 | extract: (sections, fileString) -> 33 | fileSections = fileString.split '\n' 34 | _.each fileSections, (section) -> expect(section.length).to.be 240 35 | merged = _.reduce sections, (parsed, section, index) => 36 | rules = @rules[section] 37 | content = fileSections[index] 38 | sectionData = _.reduce rules, (extracted, rule) -> 39 | extracted.push "#{rule.field}": content?.split('').slice(rule.startPos-1, rule.endPos).join '' 40 | extracted 41 | , [] 42 | parsed[section] = sectionData 43 | parsed 44 | , {} 45 | merged 46 | 47 | validate: -> 48 | for key, subject of @rules 49 | expect(subject).not.to.be undefined 50 | @_log '---------------------' 51 | @_log "Testing #{key}" 52 | 53 | total = _.reduce subject, (control, value) => 54 | @_stdout "Testing field #{value.field}... " 55 | expect(value.startPos).to.be control.lastPos + 1 56 | expect(value.endPos - value.startPos + 1).to.be value.length 57 | @_stdout "done.\n" 58 | control.lastPos = value.endPos 59 | control.totalLength += value.length 60 | control 61 | , {totalLength: 0, lastPos: 0} 62 | 63 | expect(total.totalLength).to.be 240 64 | 65 | validateFieldsLength: (fileData) => 66 | sections = _.keys @rules 67 | _.each sections, (section) => 68 | fieldsConfig = @rules[section] 69 | sectionTotalLength = 0 70 | _.each fieldsConfig, (config) -> 71 | dataField = _.find fileData[section], config.field 72 | _.pull fileData[section], dataField 73 | # console.log "Checking #{section}.#{config.field} length. Expected: #{config.length}, got: #{dataField[config.field].length}" 74 | expect(dataField[config.field].length).to.be config.length 75 | sectionTotalLength += dataField[config.field].length 76 | # console.log "Checking section '#{section}' total length... expected 240, got #{sectionTotalLength}" 77 | expect(sectionTotalLength).to.be 240 78 | 79 | _log: (msg) -> 80 | # console.log msg 81 | 82 | _stdout: (msg) -> 83 | process.stdout.write msg 84 | 85 | 86 | module.exports = DevUtils 87 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/Pagamento/Pagamento2.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 399 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 3 25 | } 26 | { 27 | field: 'num_seq_registro_lote' 28 | startPos: 9 29 | endPos: 13 30 | length: 5 31 | required: true 32 | type: 'numeric' 33 | } 34 | { 35 | field: 'cod_seg_registro_lote' 36 | startPos: 14 37 | endPos: 14 38 | length: 1 39 | required: true 40 | default: 'B' 41 | type: 'alphanumeric' 42 | } 43 | { 44 | field: 'filler' 45 | startPos: 15 46 | endPos: 17 47 | length: 3 48 | required: false 49 | default: new Array(3).fill(' ').join('') 50 | type: 'alphanumeric' 51 | } 52 | { 53 | field: 'favorecido_tipo_inscricao' 54 | startPos: 18 55 | endPos: 18 56 | length: 1 57 | required: true 58 | type: 'numeric' 59 | } 60 | { 61 | field: 'favorecido_num_inscricao' 62 | startPos: 19 63 | endPos: 32 64 | length: 14 65 | required: true 66 | type: 'numeric' 67 | } 68 | { 69 | field: 'favorecido_logradouro' 70 | startPos: 33 71 | endPos: 62 72 | length: 30 73 | required: false 74 | type: 'alphanumeric' 75 | } 76 | { 77 | field: 'favorecido_num' 78 | startPos: 63 79 | endPos: 67 80 | length: 5 81 | required: false 82 | type: 'alphanumeric' 83 | } 84 | { 85 | field: 'favorecido_compl' 86 | startPos: 68 87 | endPos: 82 88 | length: 15 89 | required: false 90 | type: 'alphanumeric' 91 | } 92 | { 93 | field: 'favorecido_bairro' 94 | startPos: 83 95 | endPos: 97 96 | length: 15 97 | required: false 98 | type: 'alphanumeric' 99 | } 100 | { 101 | field: 'favorecido_cidade' 102 | startPos: 98 103 | endPos: 117 104 | length: 20 105 | required: false 106 | type: 'alphanumeric' 107 | } 108 | { 109 | field: 'favorecido_cep' 110 | startPos: 118 111 | endPos: 122 112 | length: 5 113 | required: false 114 | type: 'numeric' 115 | } 116 | { 117 | field: 'favorecido_cep_compl' 118 | startPos: 123 119 | endPos: 125 120 | length: 3 121 | required: false 122 | type: 'numeric' 123 | } 124 | { 125 | field: 'favorecido_estado' 126 | startPos: 126 127 | endPos: 127 128 | length: 2 129 | required: false 130 | type: 'alphanumeric' 131 | } 132 | { 133 | field: 'filler' 134 | startPos: 128 135 | endPos: 232 136 | length: 105 137 | required: false 138 | default: new Array(105).fill(' ').join('') 139 | type: 'alphanumeric' 140 | } 141 | { 142 | field: 'filler' 143 | startPos: 233 144 | endPos: 240 145 | length: 8 146 | required: false 147 | type: 'alphanumeric' 148 | } 149 | ] -------------------------------------------------------------------------------- /layout/HSBC/Pagamento/Pagamento2.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 399 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 3 25 | }, 26 | { 27 | field: 'num_seq_registro_lote', 28 | startPos: 9, 29 | endPos: 13, 30 | length: 5, 31 | required: true, 32 | type: 'numeric' 33 | }, 34 | { 35 | field: 'cod_seg_registro_lote', 36 | startPos: 14, 37 | endPos: 14, 38 | length: 1, 39 | required: true, 40 | default: 'B', 41 | type: 'alphanumeric' 42 | }, 43 | { 44 | field: 'filler', 45 | startPos: 15, 46 | endPos: 17, 47 | length: 3, 48 | required: false, 49 | default: new Array(3).fill(' ').join(''), 50 | type: 'alphanumeric' 51 | }, 52 | { 53 | field: 'favorecido_tipo_inscricao', 54 | startPos: 18, 55 | endPos: 18, 56 | length: 1, 57 | required: true, 58 | type: 'numeric' 59 | }, 60 | { 61 | field: 'favorecido_num_inscricao', 62 | startPos: 19, 63 | endPos: 32, 64 | length: 14, 65 | required: true, 66 | type: 'numeric' 67 | }, 68 | { 69 | field: 'favorecido_logradouro', 70 | startPos: 33, 71 | endPos: 62, 72 | length: 30, 73 | required: false, 74 | type: 'alphanumeric' 75 | }, 76 | { 77 | field: 'favorecido_num', 78 | startPos: 63, 79 | endPos: 67, 80 | length: 5, 81 | required: false, 82 | type: 'alphanumeric' 83 | }, 84 | { 85 | field: 'favorecido_compl', 86 | startPos: 68, 87 | endPos: 82, 88 | length: 15, 89 | required: false, 90 | type: 'alphanumeric' 91 | }, 92 | { 93 | field: 'favorecido_bairro', 94 | startPos: 83, 95 | endPos: 97, 96 | length: 15, 97 | required: false, 98 | type: 'alphanumeric' 99 | }, 100 | { 101 | field: 'favorecido_cidade', 102 | startPos: 98, 103 | endPos: 117, 104 | length: 20, 105 | required: false, 106 | type: 'alphanumeric' 107 | }, 108 | { 109 | field: 'favorecido_cep', 110 | startPos: 118, 111 | endPos: 122, 112 | length: 5, 113 | required: false, 114 | type: 'numeric' 115 | }, 116 | { 117 | field: 'favorecido_cep_compl', 118 | startPos: 123, 119 | endPos: 125, 120 | length: 3, 121 | required: false, 122 | type: 'numeric' 123 | }, 124 | { 125 | field: 'favorecido_estado', 126 | startPos: 126, 127 | endPos: 127, 128 | length: 2, 129 | required: false, 130 | type: 'alphanumeric' 131 | }, 132 | { 133 | field: 'filler', 134 | startPos: 128, 135 | endPos: 232, 136 | length: 105, 137 | required: false, 138 | default: new Array(105).fill(' ').join(''), 139 | type: 'alphanumeric' 140 | }, 141 | { 142 | field: 'filler', 143 | startPos: 233, 144 | endPos: 240, 145 | length: 8, 146 | required: false, 147 | type: 'alphanumeric' 148 | } 149 | ]; -------------------------------------------------------------------------------- /coffee/layout/Bradesco/ArquivoHeader.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 237 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: '0' 25 | } 26 | { 27 | field: 'filler' 28 | startPos: 9 29 | endPos: 17 30 | length: 9 31 | required: false 32 | default: new Array(9).fill(' ').join('') 33 | } 34 | { 35 | field: 'empresa_inscricao_tipo' 36 | startPos: 18 37 | endPos: 18 38 | length: 1 39 | required: true 40 | type: 'numeric' 41 | } 42 | { 43 | field: 'empresa_inscricao_num' 44 | startPos: 19 45 | endPos: 32 46 | length: 14 47 | required: true 48 | type: 'numeric' 49 | } 50 | { 51 | field: 'convenio' 52 | startPos: 33 53 | endPos: 38 54 | length: 6 55 | required: true 56 | type: 'numeric' 57 | } 58 | { 59 | field: 'filler' 60 | startPos: 39 61 | endPos: 52 62 | length: 14 63 | required: false 64 | default: new Array(14).fill(' ').join('') 65 | } 66 | { 67 | field: 'conta_agencia' 68 | startPos: 53 69 | endPos: 57 70 | length: 5 71 | required: false 72 | type: 'numeric' 73 | } 74 | { 75 | field: 'agencia_dig_verificador' 76 | startPos: 58 77 | endPos: 58 78 | length: 1 79 | required: true 80 | type: 'alphanumeric' 81 | } 82 | { 83 | field: 'conta_num' 84 | startPos: 59 85 | endPos: 70 86 | length: 12 87 | required: false 88 | type: 'numeric' 89 | } 90 | { 91 | field: 'conta_dig_verificador' 92 | startPos: 71 93 | endPos: 71 94 | length: 1 95 | required: false 96 | type: 'alphanumeric' 97 | } 98 | { 99 | field: 'filler' 100 | startPos: 72 101 | endPos: 72 102 | length: 1 103 | required: false 104 | default: ' ' 105 | } 106 | { 107 | field: 'empresa_nome' 108 | startPos: 73 109 | endPos: 102 110 | length: 30 111 | required: true 112 | type: 'alphanumeric' 113 | } 114 | { 115 | field: 'nome_banco' 116 | startPos: 103 117 | endPos: 132 118 | length: 30 119 | required: true 120 | type: 'alphanumeric' 121 | } 122 | { 123 | field: 'filler' 124 | startPos: 133 125 | endPos: 142 126 | length: 10 127 | required: false 128 | default: new Array(10).fill(' ').join('') 129 | } 130 | { 131 | field: 'arquivo_cod' 132 | startPos: 143 133 | endPos: 143 134 | length: 1 135 | required: true 136 | default: 1 137 | } 138 | { 139 | field: 'arquivo_data_geracao' 140 | startPos: 144 141 | endPos: 151 142 | length: 8 143 | required: true 144 | type: 'date' 145 | } 146 | { 147 | field: 'arquivo_hora_geracao' 148 | startPos: 152 149 | endPos: 157 150 | length: 6 151 | required: true 152 | type: 'hour' 153 | } 154 | { 155 | field: 'arquivo_sequencia' 156 | startPos: 158 157 | endPos: 163 158 | length: 6 159 | required: true 160 | type: 'numeric' 161 | } 162 | { 163 | field: 'arquivo_layout' 164 | startPos: 164 165 | endPos: 166 166 | length: 3 167 | required: true 168 | default: '089' 169 | } 170 | { 171 | field: 'arquivo_densidade' 172 | startPos: 167 173 | endPos: 171 174 | length: 5 175 | required: false 176 | default: '01600' 177 | } 178 | { 179 | field: 'reservado_banco' 180 | startPos: 172 181 | endPos: 191 182 | length: 20 183 | required: false 184 | type: 'alphanumeric' 185 | } 186 | { 187 | field: 'reservado_empresa' 188 | startPos: 192 189 | endPos: 211 190 | length: 20 191 | type: 'alphanumeric' 192 | default: new Array(20).fill(' ').join('') 193 | } 194 | { 195 | field: 'filler' 196 | startPos: 212 197 | endPos: 240 198 | length: 29 199 | required: false 200 | default: new Array(29).fill(' ').join('') 201 | } 202 | ] 203 | -------------------------------------------------------------------------------- /layout/Bradesco/Conciliacao/LoteTrailing.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 5 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'empresa_tipo_insc', 36 | startPos: 18, 37 | endPos: 18, 38 | length: 1, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'empresa_num_insc', 44 | startPos: 19, 45 | endPos: 32, 46 | length: 14, 47 | required: true, 48 | type: 'numeric' 49 | }, 50 | { 51 | field: 'convenio', 52 | startPos: 33, 53 | endPos: 38, 54 | length: 6, 55 | required: true, 56 | type: 'numeric' 57 | }, 58 | { 59 | field: 'filler', 60 | startPos: 39, 61 | endPos: 52, 62 | length: 14, 63 | required: false, 64 | default: new Array(14).fill(' ').join('') 65 | }, 66 | { 67 | field: 'conta_agencia', 68 | startPos: 53, 69 | endPos: 57, 70 | length: 5, 71 | required: false, 72 | type: 'numeric' 73 | }, 74 | { 75 | field: 'agencia_dig_verificador', 76 | startPos: 58, 77 | endPos: 58, 78 | length: 1, 79 | required: false, 80 | type: 'alphanumeric' 81 | }, 82 | { 83 | field: 'conta_num', 84 | startPos: 59, 85 | endPos: 70, 86 | length: 12, 87 | required: false, 88 | type: 'numeric' 89 | }, 90 | { 91 | field: 'conta_dig_verificador', 92 | startPos: 71, 93 | endPos: 71, 94 | length: 1, 95 | required: false, 96 | type: 'alphanumeric' 97 | }, 98 | { 99 | field: 'ag_conta_dig_verificador', 100 | startPos: 72, 101 | endPos: 72, 102 | length: 1, 103 | required: false, 104 | type: 'alphanumeric' 105 | }, 106 | { 107 | field: 'filler', 108 | startPos: 73, 109 | endPos: 88, 110 | length: 16, 111 | required: false, 112 | default: new Array(16).fill(' ').join('') 113 | }, 114 | { 115 | field: 'vinculado', 116 | startPos: 89, 117 | endPos: 106, 118 | length: 18, 119 | required: false, 120 | type: 'numeric' 121 | }, 122 | { 123 | field: 'limite', 124 | startPos: 107, 125 | endPos: 124, 126 | length: 18, 127 | required: false, 128 | type: 'numeric' 129 | }, 130 | { 131 | field: 'bloqueado', 132 | startPos: 125, 133 | endPos: 142, 134 | length: 18, 135 | required: false, 136 | type: 'numeric' 137 | }, 138 | { 139 | field: 'data_saldo_final', 140 | startPos: 143, 141 | endPos: 150, 142 | length: 8, 143 | required: false, 144 | type: 'numeric' 145 | }, 146 | { 147 | field: 'valor_saldo_final', 148 | startPos: 151, 149 | endPos: 168, 150 | length: 18, 151 | required: false, 152 | type: 'numeric' 153 | }, 154 | { 155 | field: 'situacao_saldo_final', 156 | startPos: 169, 157 | endPos: 169, 158 | length: 1, 159 | required: false, 160 | type: 'alphanumeric' 161 | }, 162 | { 163 | field: 'posicao', 164 | startPos: 170, 165 | endPos: 170, 166 | length: 1, 167 | required: false, 168 | type: 'alphanumeric' 169 | }, 170 | { 171 | field: 'qtde_registros', 172 | startPos: 171, 173 | endPos: 176, 174 | length: 6, 175 | required: false, 176 | }, 177 | { 178 | field: 'somatoria_debitos', 179 | startPos: 177, 180 | endPos: 194, 181 | length: 18, 182 | required: false, 183 | }, 184 | { 185 | field: 'somatoria_creditos', 186 | startPos: 195, 187 | endPos: 212, 188 | length: 18, 189 | required: false, 190 | }, 191 | { 192 | field: 'filler', 193 | startPos: 213, 194 | endPos: 240, 195 | length: 28, 196 | required: false, 197 | default: new Array(28).fill(' ').join('') 198 | } 199 | ]; 200 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/ArquivoHeader.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 399 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: '0' 25 | } 26 | { 27 | field: 'filler' 28 | startPos: 9 29 | endPos: 17 30 | length: 9 31 | required: false 32 | default: new Array(9).fill(' ').join('') 33 | } 34 | { 35 | field: 'empresa_inscricao_tipo' 36 | startPos: 18 37 | endPos: 18 38 | length: 1 39 | required: true 40 | type: 'numeric' 41 | } 42 | { 43 | field: 'empresa_inscricao_num' 44 | startPos: 19 45 | endPos: 32 46 | length: 14 47 | required: true 48 | type: 'numeric' 49 | } 50 | { 51 | field: 'convenio' 52 | startPos: 33 53 | endPos: 38 54 | length: 6 55 | required: true 56 | type: 'numeric' 57 | } 58 | { 59 | field: 'filler' 60 | startPos: 39 61 | endPos: 52 62 | length: 14 63 | required: false 64 | default: new Array(14).fill(' ').join('') 65 | } 66 | { 67 | field: 'conta_agencia' 68 | startPos: 53 69 | endPos: 57 70 | length: 5 71 | required: false 72 | type: 'numeric' 73 | } 74 | { 75 | field: 'filler' 76 | startPos: 58 77 | endPos: 58 78 | length: 1 79 | required: false 80 | default: ' ' 81 | } 82 | { 83 | field: 'conta_num' 84 | startPos: 59 85 | endPos: 70 86 | length: 12 87 | required: false 88 | type: 'numeric' 89 | } 90 | { 91 | field: 'conta_dig_verificador' 92 | startPos: 71 93 | endPos: 71 94 | length: 1 95 | required: false 96 | type: 'alphanumeric' 97 | } 98 | { 99 | field: 'filler' 100 | startPos: 72 101 | endPos: 72 102 | length: 1 103 | required: false 104 | default: ' ' 105 | } 106 | { 107 | field: 'empresa_nome' 108 | startPos: 73 109 | endPos: 102 110 | length: 30 111 | required: true 112 | type: 'alphanumeric' 113 | } 114 | { 115 | field: 'nome_banco' 116 | startPos: 103 117 | endPos: 132 118 | length: 30 119 | required: true 120 | type: 'alphanumeric' 121 | } 122 | { 123 | field: 'filler' 124 | startPos: 133 125 | endPos: 142 126 | length: 10 127 | required: false 128 | default: new Array(10).fill(' ').join('') 129 | } 130 | { 131 | field: 'arquivo_cod' 132 | startPos: 143 133 | endPos: 143 134 | length: 1 135 | required: true 136 | default: 1 137 | } 138 | { 139 | field: 'arquivo_data_geracao' 140 | startPos: 144 141 | endPos: 151 142 | length: 8 143 | required: true 144 | type: 'date' 145 | } 146 | { 147 | field: 'arquivo_hora_geracao' 148 | startPos: 152 149 | endPos: 157 150 | length: 6 151 | required: true 152 | type: 'hour' 153 | } 154 | { 155 | field: 'arquivo_sequencia' 156 | startPos: 158 157 | endPos: 163 158 | length: 6 159 | required: true 160 | type: 'numeric' 161 | } 162 | { 163 | field: 'arquivo_layout' 164 | startPos: 164 165 | endPos: 166 166 | length: 3 167 | required: true 168 | default: '020' 169 | } 170 | { 171 | field: 'arquivo_densidade' 172 | startPos: 167 173 | endPos: 171 174 | length: 5 175 | required: true 176 | default: '01600' 177 | } 178 | { 179 | field: 'aplicacao' 180 | startPos: 172 181 | endPos: 174 182 | length: 3 183 | required: true 184 | default: 'CPG' 185 | } 186 | { 187 | field: 'ident_ano_2000' 188 | startPos: 175 189 | endPos: 177 190 | length: 3 191 | required: true 192 | default: 'Y2K' 193 | } 194 | { 195 | field: 'controle_CPG' 196 | startPos: 178 197 | endPos: 191 198 | length: 14 199 | required: false 200 | default: new Array(14).fill(' ').join('') 201 | } 202 | { 203 | field: 'filler' 204 | startPos: 192 205 | endPos: 240 206 | length: 49 207 | required: false 208 | default: new Array(49).fill(' ').join('') 209 | } 210 | ] -------------------------------------------------------------------------------- /layout/Bradesco/ArquivoHeader.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: '0' 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'empresa_inscricao_tipo', 36 | startPos: 18, 37 | endPos: 18, 38 | length: 1, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'empresa_inscricao_num', 44 | startPos: 19, 45 | endPos: 32, 46 | length: 14, 47 | required: true, 48 | type: 'numeric' 49 | }, 50 | { 51 | field: 'convenio', 52 | startPos: 33, 53 | endPos: 38, 54 | length: 6, 55 | required: true, 56 | type: 'numeric' 57 | }, 58 | { 59 | field: 'filler', 60 | startPos: 39, 61 | endPos: 52, 62 | length: 14, 63 | required: false, 64 | default: new Array(14).fill(' ').join('') 65 | }, 66 | { 67 | field: 'conta_agencia', 68 | startPos: 53, 69 | endPos: 57, 70 | length: 5, 71 | required: false, 72 | type: 'numeric' 73 | }, 74 | { 75 | field: 'agencia_dig_verificador', 76 | startPos: 58, 77 | endPos: 58, 78 | length: 1, 79 | required: true, 80 | type: 'alphanumeric' 81 | }, 82 | { 83 | field: 'conta_num', 84 | startPos: 59, 85 | endPos: 70, 86 | length: 12, 87 | required: false, 88 | type: 'numeric' 89 | }, 90 | { 91 | field: 'conta_dig_verificador', 92 | startPos: 71, 93 | endPos: 71, 94 | length: 1, 95 | required: false, 96 | type: 'alphanumeric' 97 | }, 98 | { 99 | field: 'filler', 100 | startPos: 72, 101 | endPos: 72, 102 | length: 1, 103 | required: false, 104 | default: ' ' 105 | }, 106 | { 107 | field: 'empresa_nome', 108 | startPos: 73, 109 | endPos: 102, 110 | length: 30, 111 | required: true, 112 | type: 'alphanumeric' 113 | }, 114 | { 115 | field: 'nome_banco', 116 | startPos: 103, 117 | endPos: 132, 118 | length: 30, 119 | required: true, 120 | type: 'alphanumeric' 121 | }, 122 | { 123 | field: 'filler', 124 | startPos: 133, 125 | endPos: 142, 126 | length: 10, 127 | required: false, 128 | default: new Array(10).fill(' ').join('') 129 | }, 130 | { 131 | field: 'arquivo_cod', 132 | startPos: 143, 133 | endPos: 143, 134 | length: 1, 135 | required: true, 136 | default: 1 137 | }, 138 | { 139 | field: 'arquivo_data_geracao', 140 | startPos: 144, 141 | endPos: 151, 142 | length: 8, 143 | required: true, 144 | type: 'date' 145 | }, 146 | { 147 | field: 'arquivo_hora_geracao', 148 | startPos: 152, 149 | endPos: 157, 150 | length: 6, 151 | required: true, 152 | type: 'hour' 153 | }, 154 | { 155 | field: 'arquivo_sequencia', 156 | startPos: 158, 157 | endPos: 163, 158 | length: 6, 159 | required: true, 160 | type: 'numeric' 161 | }, 162 | { 163 | field: 'arquivo_layout', 164 | startPos: 164, 165 | endPos: 166, 166 | length: 3, 167 | required: true, 168 | default: '089' 169 | }, 170 | { 171 | field: 'arquivo_densidade', 172 | startPos: 167, 173 | endPos: 171, 174 | length: 5, 175 | required: false, 176 | default: '01600' 177 | }, 178 | { 179 | field: 'reservado_banco', 180 | startPos: 172, 181 | endPos: 191, 182 | length: 20, 183 | required: false, 184 | type: 'alphanumeric' 185 | }, 186 | { 187 | field: 'reservado_empresa', 188 | startPos: 192, 189 | endPos: 211, 190 | length: 20, 191 | type: 'alphanumeric', 192 | default: new Array(20).fill(' ').join('') 193 | }, 194 | { 195 | field: 'filler', 196 | startPos: 212, 197 | endPos: 240, 198 | length: 29, 199 | required: false, 200 | default: new Array(29).fill(' ').join('') 201 | } 202 | ]; 203 | -------------------------------------------------------------------------------- /layout/Bradesco/Conciliacao/LoteHeader.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 1 25 | }, 26 | { 27 | field: 'operacao', 28 | startPos: 9, 29 | endPos: 9, 30 | length: 1, 31 | required: true, 32 | default: 'E' 33 | }, 34 | { 35 | field: 'servico', 36 | startPos: 10, 37 | endPos: 11, 38 | length: 2, 39 | required: true, 40 | default: '04' 41 | }, 42 | { 43 | field: 'forma_lancamento', 44 | startPos: 12, 45 | endPos: 13, 46 | length: 2, 47 | default: 40 48 | }, 49 | { 50 | field: 'versao_layout', 51 | startPos: 14, 52 | endPos: 16, 53 | length: 3, 54 | default: '055' 55 | }, 56 | { 57 | field: 'filler', 58 | startPos: 17, 59 | endPos: 17, 60 | length: 1, 61 | required: false, 62 | default: ' ' 63 | }, 64 | { 65 | field: 'empresa_tipo_insc', 66 | startPos: 18, 67 | endPos: 18, 68 | length: 1, 69 | required: true, 70 | type: 'numeric' 71 | }, 72 | { 73 | field: 'empresa_num_insc', 74 | startPos: 19, 75 | endPos: 32, 76 | length: 14, 77 | required: true, 78 | type: 'numeric' 79 | }, 80 | { 81 | field: 'convenio', 82 | startPos: 33, 83 | endPos: 38, 84 | length: 6, 85 | required: true, 86 | type: 'numeric' 87 | }, 88 | { 89 | field: 'filler', 90 | startPos: 39, 91 | endPos: 52, 92 | length: 14, 93 | required: false, 94 | default: new Array(14).fill(' ').join('') 95 | }, 96 | { 97 | field: 'conta_agencia', 98 | startPos: 53, 99 | endPos: 57, 100 | length: 5, 101 | required: false, 102 | type: 'numeric' 103 | }, 104 | { 105 | field: 'agencia_dig_verificador', 106 | startPos: 58, 107 | endPos: 58, 108 | length: 1, 109 | required: false, 110 | type: 'alphanumeric' 111 | }, 112 | { 113 | field: 'conta_num', 114 | startPos: 59, 115 | endPos: 70, 116 | length: 12, 117 | required: false, 118 | type: 'numeric' 119 | }, 120 | { 121 | field: 'conta_dig_verificador', 122 | startPos: 71, 123 | endPos: 71, 124 | length: 1, 125 | required: false, 126 | type: 'numeric' 127 | }, 128 | { 129 | field: 'filler', 130 | startPos: 72, 131 | endPos: 72, 132 | length: 1, 133 | required: false, 134 | default: ' ' 135 | }, 136 | { 137 | field: 'empresa_nome', 138 | startPos: 73, 139 | endPos: 102, 140 | length: 30, 141 | required: true, 142 | type: 'alphanumeric' 143 | }, 144 | { 145 | field: 'filler', 146 | startPos: 103, 147 | endPos: 142, 148 | length: 40, 149 | required: false, 150 | default: new Array(40).fill(' ').join('') 151 | }, 152 | { 153 | field: 'data_inicial', 154 | startPos: 143, 155 | endPos: 150, 156 | length: 8, 157 | required: true, 158 | type: 'numeric' 159 | }, 160 | { 161 | field: 'valor_saldo_inicial', 162 | startPos: 151, 163 | endPos: 168, 164 | length: 18, 165 | required: false, 166 | type: 'numeric' 167 | }, 168 | { 169 | field: 'situacao_saldo_inicial', 170 | startPos: 169, 171 | endPos: 169, 172 | length: 1, 173 | required: false, 174 | type: 'alphanumeric' 175 | }, 176 | { 177 | field: 'status', 178 | startPos: 170, 179 | endPos: 170, 180 | length: 1, 181 | required: false, 182 | type: 'alphanumeric' 183 | }, 184 | { 185 | field: 'tipo_moeda', 186 | startPos: 171, 187 | endPos: 173, 188 | length: 3, 189 | required: true, 190 | type: 'alphanumeric' 191 | }, 192 | { 193 | field: 'sequencia_extrato', 194 | startPos: 174, 195 | endPos: 178, 196 | length: 5, 197 | required: false, 198 | type: 'numeric' 199 | }, 200 | { 201 | field: 'filler', 202 | startPos: 179, 203 | endPos: 240, 204 | length: 62, 205 | required: false, 206 | default: new Array(62).fill(' ').join('') 207 | } 208 | ]; 209 | -------------------------------------------------------------------------------- /coffee/layout/Bradesco/Pagamento/Pagamento2.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 237 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 3 25 | } 26 | { 27 | field: 'num_seq_registro_lote' 28 | startPos: 9 29 | endPos: 13 30 | length: 5 31 | required: true 32 | type: 'numeric' 33 | } 34 | { 35 | field: 'cod_seg_registro_lote' 36 | startPos: 14 37 | endPos: 14 38 | length: 1 39 | required: true 40 | default: 'B' 41 | type: 'alphanumeric' 42 | } 43 | { 44 | field: 'filler' 45 | startPos: 15 46 | endPos: 17 47 | length: 3 48 | required: false 49 | default: new Array(3).fill(' ').join('') 50 | type: 'alphanumeric' 51 | } 52 | { 53 | field: 'favorecido_tipo_inscricao' 54 | startPos: 18 55 | endPos: 18 56 | length: 1 57 | required: true 58 | type: 'numeric' 59 | } 60 | { 61 | field: 'favorecido_num_inscricao' 62 | startPos: 19 63 | endPos: 32 64 | length: 14 65 | required: true 66 | type: 'numeric' 67 | } 68 | { 69 | field: 'favorecido_logradouro' 70 | startPos: 33 71 | endPos: 62 72 | length: 30 73 | required: false 74 | type: 'alphanumeric' 75 | } 76 | { 77 | field: 'favorecido_num' 78 | startPos: 63 79 | endPos: 67 80 | length: 5 81 | required: false 82 | type: 'alphanumeric' 83 | } 84 | { 85 | field: 'favorecido_compl' 86 | startPos: 68 87 | endPos: 82 88 | length: 15 89 | required: false 90 | type: 'alphanumeric' 91 | } 92 | { 93 | field: 'favorecido_bairro' 94 | startPos: 83 95 | endPos: 97 96 | length: 15 97 | required: false 98 | type: 'alphanumeric' 99 | } 100 | { 101 | field: 'favorecido_cidade' 102 | startPos: 98 103 | endPos: 117 104 | length: 20 105 | required: false 106 | type: 'alphanumeric' 107 | } 108 | { 109 | field: 'favorecido_cep' 110 | startPos: 118 111 | endPos: 122 112 | length: 5 113 | required: false 114 | type: 'numeric' 115 | } 116 | { 117 | field: 'favorecido_cep_compl' 118 | startPos: 123 119 | endPos: 125 120 | length: 3 121 | required: false 122 | type: 'numeric' 123 | } 124 | { 125 | field: 'favorecido_estado' 126 | startPos: 126 127 | endPos: 127 128 | length: 2 129 | required: false 130 | type: 'alphanumeric' 131 | } 132 | { 133 | field: 'data_vencimento' 134 | startPos: 128 135 | endPos: 135 136 | length: 8 137 | required: true 138 | type: 'numeric' 139 | } 140 | { 141 | field: 'valor_documento' 142 | startPos: 136 143 | endPos: 150 144 | length: 15 145 | required: true 146 | type: 'numeric' 147 | } 148 | { 149 | field: 'valor_abatimento' 150 | startPos: 151 151 | endPos: 165 152 | length: 15 153 | required: false 154 | type: 'numeric' 155 | } 156 | { 157 | field: 'valor_desconto' 158 | startPos: 166 159 | endPos: 180 160 | length: 15 161 | required: false 162 | type: 'numeric' 163 | } 164 | { 165 | field: 'valor_mora' 166 | startPos: 181 167 | endPos: 195 168 | length: 15 169 | required: false 170 | type: 'numeric' 171 | } 172 | { 173 | field: 'valor_multa' 174 | startPos: 196 175 | endPos: 210 176 | length: 15 177 | required: false 178 | type: 'numeric' 179 | } 180 | { 181 | field: 'cod_doc_favorecido' 182 | startPos: 211 183 | endPos: 225 184 | length: 15 185 | required: false 186 | type: 'alphanumeric' 187 | } 188 | { 189 | field: 'aviso_ao_favorecido' 190 | startPos: 226 191 | endPos: 226 192 | length: 1 193 | required: false 194 | type: 'numeric' 195 | } 196 | { 197 | field: 'filler' 198 | startPos: 227 199 | endPos: 232 200 | length: 6 201 | required: false 202 | default: new Array(6).fill(' ').join('') 203 | } 204 | { 205 | field: 'codigo_ispb' 206 | startPos: 233 207 | endPos: 240 208 | length: 8 209 | required: false 210 | default: new Array(8).fill(' ').join('') 211 | } 212 | ] 213 | -------------------------------------------------------------------------------- /layout/HSBC/ArquivoHeader.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 399 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: '0' 25 | }, 26 | { 27 | field: 'filler', 28 | startPos: 9, 29 | endPos: 17, 30 | length: 9, 31 | required: false, 32 | default: new Array(9).fill(' ').join('') 33 | }, 34 | { 35 | field: 'empresa_inscricao_tipo', 36 | startPos: 18, 37 | endPos: 18, 38 | length: 1, 39 | required: true, 40 | type: 'numeric' 41 | }, 42 | { 43 | field: 'empresa_inscricao_num', 44 | startPos: 19, 45 | endPos: 32, 46 | length: 14, 47 | required: true, 48 | type: 'numeric' 49 | }, 50 | { 51 | field: 'convenio', 52 | startPos: 33, 53 | endPos: 38, 54 | length: 6, 55 | required: true, 56 | type: 'numeric' 57 | }, 58 | { 59 | field: 'filler', 60 | startPos: 39, 61 | endPos: 52, 62 | length: 14, 63 | required: false, 64 | default: new Array(14).fill(' ').join('') 65 | }, 66 | { 67 | field: 'conta_agencia', 68 | startPos: 53, 69 | endPos: 57, 70 | length: 5, 71 | required: false, 72 | type: 'numeric' 73 | }, 74 | { 75 | field: 'filler', 76 | startPos: 58, 77 | endPos: 58, 78 | length: 1, 79 | required: false, 80 | default: ' ' 81 | }, 82 | { 83 | field: 'conta_num', 84 | startPos: 59, 85 | endPos: 70, 86 | length: 12, 87 | required: false, 88 | type: 'numeric' 89 | }, 90 | { 91 | field: 'conta_dig_verificador', 92 | startPos: 71, 93 | endPos: 71, 94 | length: 1, 95 | required: false, 96 | type: 'alphanumeric' 97 | }, 98 | { 99 | field: 'filler', 100 | startPos: 72, 101 | endPos: 72, 102 | length: 1, 103 | required: false, 104 | default: ' ' 105 | }, 106 | { 107 | field: 'empresa_nome', 108 | startPos: 73, 109 | endPos: 102, 110 | length: 30, 111 | required: true, 112 | type: 'alphanumeric' 113 | }, 114 | { 115 | field: 'nome_banco', 116 | startPos: 103, 117 | endPos: 132, 118 | length: 30, 119 | required: true, 120 | type: 'alphanumeric' 121 | }, 122 | { 123 | field: 'filler', 124 | startPos: 133, 125 | endPos: 142, 126 | length: 10, 127 | required: false, 128 | default: new Array(10).fill(' ').join('') 129 | }, 130 | { 131 | field: 'arquivo_cod', 132 | startPos: 143, 133 | endPos: 143, 134 | length: 1, 135 | required: true, 136 | default: 1 137 | }, 138 | { 139 | field: 'arquivo_data_geracao', 140 | startPos: 144, 141 | endPos: 151, 142 | length: 8, 143 | required: true, 144 | type: 'date' 145 | }, 146 | { 147 | field: 'arquivo_hora_geracao', 148 | startPos: 152, 149 | endPos: 157, 150 | length: 6, 151 | required: true, 152 | type: 'hour' 153 | }, 154 | { 155 | field: 'arquivo_sequencia', 156 | startPos: 158, 157 | endPos: 163, 158 | length: 6, 159 | required: true, 160 | type: 'numeric' 161 | }, 162 | { 163 | field: 'arquivo_layout', 164 | startPos: 164, 165 | endPos: 166, 166 | length: 3, 167 | required: true, 168 | default: '020' 169 | }, 170 | { 171 | field: 'arquivo_densidade', 172 | startPos: 167, 173 | endPos: 171, 174 | length: 5, 175 | required: true, 176 | default: '01600' 177 | }, 178 | { 179 | field: 'aplicacao', 180 | startPos: 172, 181 | endPos: 174, 182 | length: 3, 183 | required: true, 184 | default: 'CPG' 185 | }, 186 | { 187 | field: 'ident_ano_2000', 188 | startPos: 175, 189 | endPos: 177, 190 | length: 3, 191 | required: true, 192 | default: 'Y2K' 193 | }, 194 | { 195 | field: 'controle_CPG', 196 | startPos: 178, 197 | endPos: 191, 198 | length: 14, 199 | required: false, 200 | default: new Array(14).fill(' ').join('') 201 | }, 202 | { 203 | field: 'filler', 204 | startPos: 192, 205 | endPos: 240, 206 | length: 49, 207 | required: false, 208 | default: new Array(49).fill(' ').join('') 209 | } 210 | ]; -------------------------------------------------------------------------------- /coffee/cnab/src/Remessa.coffee: -------------------------------------------------------------------------------- 1 | Rules = require '../../layout/Rules' 2 | Utils = require './Utils' 3 | Joi = require 'joi' 4 | expect = require 'expect.js' 5 | _ = require 'lodash' 6 | removeAccents = require 'remove-accents' 7 | 8 | class Remessa 9 | 10 | FILE_HEADER = 'ArquivoHeader' 11 | FILE_TRAILING = 'ArquivoTrailing' 12 | LOT_HEADER = 'LoteHeader' 13 | LOT_TRAILING = 'LoteTrailing' 14 | DETAIL = 'Detail' 15 | DETAIL2 = 'Detail2' 16 | FILE_SECTIONS = [FILE_HEADER, LOT_HEADER, DETAIL, DETAIL2, LOT_TRAILING, FILE_TRAILING] 17 | 18 | constructor: (bank, type, deps) -> 19 | rules = deps?.Rules or Rules 20 | throw new Error 'Bank is mandatory' unless bank? 21 | throw new Error 'Type is mandatory' unless type? 22 | @rules = 23 | ArquivoHeader: rules[bank].ArquivoHeader 24 | ArquivoTrailing: rules[bank].ArquivoTrailing 25 | LoteHeader: rules[bank][type]?.LoteHeader 26 | LoteTrailing: rules[bank][type]?.LoteTrailing 27 | Detail: rules[bank][type]?.Detail 28 | Detail2: rules[bank][type]?.Detail2 29 | @CONSTANTS = rules[bank][type]?.Constants 30 | 31 | # TODO: add data, enum and range validations 32 | validateLenghts: (rulesName, userValues) -> 33 | throw new Error 'RulesName is mandatory' unless rulesName? 34 | throw new Error 'UserValues is mandatory' unless userValues? 35 | rules = _.reduce @rules[rulesName], (rules, fieldConfig) -> 36 | rule = Joi.string().max(fieldConfig.length) 37 | rule = rule.required() if fieldConfig.required and not fieldConfig.default? 38 | rules[fieldConfig.field] = rule 39 | rules 40 | , {} 41 | rules.section = Joi.string().optional() 42 | 43 | validation = (Joi.validate userValues, Joi.object(rules), abortEarly: false)?.error?.details?.map (error) -> error.message 44 | throw new Error validation unless _.isEmpty validation 45 | _.each _.filter(@rules[rulesName], 'default'), (config) -> 46 | if config.default.toString().length isnt config.length 47 | throw new Error "#{rulesName}.#{config.field} length must be less than or equal to #{config.length} characters long" 48 | 49 | prepare: (rulesName, validated) -> 50 | utils = new Utils 51 | rules = _.cloneDeep @rules[rulesName] 52 | for key, value of validated 53 | fieldConfig = _.find rules, field: key 54 | fieldConfig?.value = value 55 | 56 | # formats all fields to match the required length 57 | _.map rules, (item) -> 58 | # we consider that the default values already have the correct length 59 | return item if item.default? and not item.value? 60 | # if there's no value (eg, non-required field with no default value) 61 | unless item.value? 62 | meaninglessChar = if item.type is 'alphanumeric' then ' ' else '0' 63 | item.value = new Array(item.length).fill(meaninglessChar).join '' 64 | # for now, when the field doesn't have a type, it defaults to numeric 65 | item.value = if item.type? and item.type is 'alphanumeric' then utils.padString(item) else utils.padNumber(item) 66 | item 67 | 68 | # inserts the params into the 240b string, filling gaps where no values are passed 69 | build: (prepared) -> 70 | base = Array 240 71 | _.map prepared, (fieldConfig) -> 72 | fieldValue = fieldConfig.value?.toString() or fieldConfig.default?.toString() 73 | args = [fieldConfig.startPos, fieldConfig.length].concat fieldValue.toString().split '' 74 | base.splice.apply(base, args).join '' 75 | base.shift() 76 | # console.log 'Checking section size on build' 77 | # expect(base.length).to.be 240 78 | base.join '' 79 | 80 | process: (userValues, fileSections, newLine = '\n') -> 81 | FILE_SECTIONS ?= fileSections 82 | # let's test if all required file sections were given 83 | missingKeys = _.difference FILE_SECTIONS, _.keys userValues 84 | throw Error "Missing file sections: #{missingKeys.join(', ')}" unless _.isEmpty missingKeys 85 | 86 | # now we'll put the section key into each values object... 87 | valuesArr =_.map FILE_SECTIONS, (section) -> 88 | # the detail section could have several items 89 | if section is DETAIL and _.isArray(userValues[section]) 90 | _.map userValues[section], (subsection) -> 91 | subsection[0].section = section 92 | subsection 93 | else 94 | userValues[section].section = section 95 | userValues[section] 96 | #... and then flatten the array 97 | sections = _.flattenDeep valuesArr 98 | # process'em all! 99 | remessa = _.map sections, (section) => 100 | sectionKey = section.section 101 | sectionValues = _.omit section, 'section' 102 | @validateLenghts sectionKey, sectionValues 103 | @build @prepare sectionKey, sectionValues 104 | removeAccents(remessa.join(newLine) + newLine) 105 | 106 | module.exports = Remessa 107 | -------------------------------------------------------------------------------- /layout/Bradesco/Pagamento/Pagamento2.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 3 25 | }, 26 | { 27 | field: 'num_seq_registro_lote', 28 | startPos: 9, 29 | endPos: 13, 30 | length: 5, 31 | required: true, 32 | type: 'numeric' 33 | }, 34 | { 35 | field: 'cod_seg_registro_lote', 36 | startPos: 14, 37 | endPos: 14, 38 | length: 1, 39 | required: true, 40 | default: 'B', 41 | type: 'alphanumeric' 42 | }, 43 | { 44 | field: 'filler', 45 | startPos: 15, 46 | endPos: 17, 47 | length: 3, 48 | required: false, 49 | default: new Array(3).fill(' ').join(''), 50 | type: 'alphanumeric' 51 | }, 52 | { 53 | field: 'favorecido_tipo_inscricao', 54 | startPos: 18, 55 | endPos: 18, 56 | length: 1, 57 | required: true, 58 | type: 'numeric' 59 | }, 60 | { 61 | field: 'favorecido_num_inscricao', 62 | startPos: 19, 63 | endPos: 32, 64 | length: 14, 65 | required: true, 66 | type: 'numeric' 67 | }, 68 | { 69 | field: 'favorecido_logradouro', 70 | startPos: 33, 71 | endPos: 62, 72 | length: 30, 73 | required: false, 74 | type: 'alphanumeric' 75 | }, 76 | { 77 | field: 'favorecido_num', 78 | startPos: 63, 79 | endPos: 67, 80 | length: 5, 81 | required: false, 82 | type: 'alphanumeric' 83 | }, 84 | { 85 | field: 'favorecido_compl', 86 | startPos: 68, 87 | endPos: 82, 88 | length: 15, 89 | required: false, 90 | type: 'alphanumeric' 91 | }, 92 | { 93 | field: 'favorecido_bairro', 94 | startPos: 83, 95 | endPos: 97, 96 | length: 15, 97 | required: false, 98 | type: 'alphanumeric' 99 | }, 100 | { 101 | field: 'favorecido_cidade', 102 | startPos: 98, 103 | endPos: 117, 104 | length: 20, 105 | required: false, 106 | type: 'alphanumeric' 107 | }, 108 | { 109 | field: 'favorecido_cep', 110 | startPos: 118, 111 | endPos: 122, 112 | length: 5, 113 | required: false, 114 | type: 'numeric' 115 | }, 116 | { 117 | field: 'favorecido_cep_compl', 118 | startPos: 123, 119 | endPos: 125, 120 | length: 3, 121 | required: false, 122 | type: 'numeric' 123 | }, 124 | { 125 | field: 'favorecido_estado', 126 | startPos: 126, 127 | endPos: 127, 128 | length: 2, 129 | required: false, 130 | type: 'alphanumeric' 131 | }, 132 | { 133 | field: 'data_vencimento', 134 | startPos: 128, 135 | endPos: 135, 136 | length: 8, 137 | required: true, 138 | type: 'numeric' 139 | }, 140 | { 141 | field: 'valor_documento', 142 | startPos: 136, 143 | endPos: 150, 144 | length: 15, 145 | required: true, 146 | type: 'numeric' 147 | }, 148 | { 149 | field: 'valor_abatimento', 150 | startPos: 151, 151 | endPos: 165, 152 | length: 15, 153 | required: false, 154 | type: 'numeric' 155 | }, 156 | { 157 | field: 'valor_desconto', 158 | startPos: 166, 159 | endPos: 180, 160 | length: 15, 161 | required: false, 162 | type: 'numeric' 163 | }, 164 | { 165 | field: 'valor_mora', 166 | startPos: 181, 167 | endPos: 195, 168 | length: 15, 169 | required: false, 170 | type: 'numeric' 171 | }, 172 | { 173 | field: 'valor_multa', 174 | startPos: 196, 175 | endPos: 210, 176 | length: 15, 177 | required: false, 178 | type: 'numeric' 179 | }, 180 | { 181 | field: 'cod_doc_favorecido', 182 | startPos: 211, 183 | endPos: 225, 184 | length: 15, 185 | required: false, 186 | type: 'alphanumeric' 187 | }, 188 | { 189 | field: 'aviso_ao_favorecido', 190 | startPos: 226, 191 | endPos: 226, 192 | length: 1, 193 | required: false, 194 | type: 'numeric' 195 | }, 196 | { 197 | field: 'filler', 198 | startPos: 227, 199 | endPos: 232, 200 | length: 6, 201 | required: false, 202 | default: new Array(6).fill(' ').join('') 203 | }, 204 | { 205 | field: 'codigo_ispb', 206 | startPos: 233, 207 | endPos: 240, 208 | length: 8, 209 | required: false, 210 | default: new Array(8).fill(' ').join('') 211 | } 212 | ]; -------------------------------------------------------------------------------- /cnab/src/DevUtils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * decaffeinate suggestions: 3 | * DS102: Remove unnecessary code created because of implicit returns 4 | * DS205: Consider reworking code to avoid use of IIFEs 5 | * DS207: Consider shorter variations of null checks 6 | * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md 7 | */ 8 | let rules = require('../../layout/Rules'); 9 | const expect = require('expect.js'); 10 | const _ = require('lodash'); 11 | 12 | class DevUtils { 13 | 14 | constructor(bank, type) { 15 | this.validateFieldsLength = this.validateFieldsLength.bind(this); 16 | this.rules = { 17 | ArquivoHeader: rules[bank].ArquivoHeader, 18 | ArquivoTrailing: rules[bank].ArquivoTrailing, 19 | LoteHeader: rules[bank][type].LoteHeader, 20 | LoteTrailing: rules[bank][type].LoteTrailing, 21 | Detail: rules[bank][type].Detail, 22 | Detail2: rules[bank][type].Detail2 23 | }; 24 | } 25 | 26 | getRequired() { 27 | return (() => { 28 | const result = []; 29 | for (let key in this.rules) { 30 | const subject = this.rules[key]; 31 | this._log('---------------------'); 32 | this._log(`Required for ${key}`); 33 | const required = _.filter(subject, {required: true}).map(function(item) { 34 | if (item.default == null) { return {[item.field]: _.pick(item, ['type', 'length', 'default'])}; } 35 | }); 36 | result.push(this._log(JSON.stringify(_.compact(required), null, 4))); 37 | } 38 | return result; 39 | })(); 40 | } 41 | 42 | getAllFields() { 43 | return (() => { 44 | const result = []; 45 | for (let key in this.rules) { 46 | var required; 47 | const subject = this.rules[key]; 48 | this._log('---------------------'); 49 | this._log(`Fields for ${key}`); 50 | result.push(required = _.map(subject, item => ({[item.field]: _.pick(item, ['type', 'length', 'default'])}))); 51 | } 52 | return result; 53 | })(); 54 | } 55 | // @_log required 56 | 57 | extract(sections, fileString) { 58 | const fileSections = fileString.split('\n'); 59 | _.each(fileSections.pop(), section => expect(section.length).to.be(241)); 60 | const merged = _.reduce(sections, (parsed, section, index) => { 61 | rules = this.rules[section]; 62 | const content = fileSections[index]; 63 | const sectionData = _.reduce(rules, function(extracted, rule) { 64 | extracted.push({[rule.field]: (content != null ? content.split('').slice(rule.startPos-1, rule.endPos).join('') : undefined)}); 65 | return extracted; 66 | } 67 | , []); 68 | parsed[section] = sectionData; 69 | return parsed; 70 | } 71 | , {}); 72 | return merged; 73 | } 74 | 75 | validate() { 76 | return (() => { 77 | const result = []; 78 | for (let key in this.rules) { 79 | const subject = this.rules[key]; 80 | expect(subject).not.to.be(undefined); 81 | this._log('---------------------'); 82 | this._log(`Testing ${key}`); 83 | 84 | const total = _.reduce(subject, (control, value) => { 85 | this._stdout(`Testing field ${value.field}... `); 86 | expect(value.startPos).to.be(control.lastPos + 1); 87 | expect((value.endPos - value.startPos) + 1).to.be(value.length); 88 | this._stdout("done.\n"); 89 | control.lastPos = value.endPos; 90 | control.totalLength += value.length; 91 | return control; 92 | } 93 | , {totalLength: 0, lastPos: 0}); 94 | 95 | result.push(expect(total.totalLength).to.be(240)); 96 | } 97 | return result; 98 | })(); 99 | } 100 | 101 | validateFieldsLength(fileData) { 102 | const sections = _.keys(this.rules); 103 | return _.each(sections, section => { 104 | const fieldsConfig = this.rules[section]; 105 | let sectionTotalLength = 0; 106 | _.each(fieldsConfig, function(config) { 107 | const dataField = _.find(fileData[section], config.field); 108 | _.pull(fileData[section], dataField); 109 | // console.log "Checking #{section}.#{config.field} length. Expected: #{config.length}, got: #{dataField[config.field].length}" 110 | expect(dataField[config.field].length).to.be(config.length); 111 | return sectionTotalLength += dataField[config.field].length; 112 | }); 113 | // console.log "Checking section '#{section}' total length... expected 240, got #{sectionTotalLength}" 114 | return expect(sectionTotalLength).to.be(240); 115 | }); 116 | } 117 | 118 | _log(msg) { 119 | console.log(msg) 120 | } 121 | 122 | _stdout(msg) { 123 | return process.stdout.write(msg); 124 | } 125 | } 126 | 127 | 128 | module.exports = DevUtils; 129 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/Pagamento/LoteHeader.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 399 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 1 25 | } 26 | { 27 | field: 'operacao' 28 | startPos: 9 29 | endPos: 9 30 | length: 1 31 | required: true 32 | default: 'C' 33 | type: 'numeric' 34 | } 35 | { 36 | field: 'servico' 37 | startPos: 10 38 | endPos: 11 39 | length: 2 40 | required: true 41 | type: 'numeric' 42 | } 43 | { 44 | field: 'forma_lancamento' 45 | startPos: 12 46 | endPos: 13 47 | length: 2 48 | required: true 49 | type: 'numeric' 50 | } 51 | { 52 | field: 'versao_layout' 53 | startPos: 14 54 | endPos: 16 55 | length: 3 56 | required: true 57 | default: '020' 58 | } 59 | { 60 | field: 'filler' 61 | startPos: 17 62 | endPos: 17 63 | length: 1 64 | required: false 65 | default: ' ' 66 | } 67 | { 68 | field: 'empresa_tipo_insc' 69 | startPos: 18 70 | endPos: 18 71 | length: 1 72 | required: true 73 | type: 'numeric' 74 | } 75 | { 76 | field: 'empresa_num_insc' 77 | startPos: 19 78 | endPos: 32 79 | length: 14 80 | required: true 81 | type: 'numeric' 82 | } 83 | { 84 | field: 'convenio' 85 | startPos: 33 86 | endPos: 38 87 | length: 6 88 | required: true 89 | type: 'numeric' 90 | } 91 | { 92 | field: 'filler' 93 | startPos: 39 94 | endPos: 52 95 | length: 14 96 | required: false 97 | default: new Array(14).fill(' ').join('') 98 | } 99 | { 100 | field: 'conta_agencia' 101 | startPos: 53 102 | endPos: 57 103 | length: 5 104 | required: false 105 | type: 'numeric' 106 | } 107 | { 108 | field: 'filler' 109 | startPos: 58 110 | endPos: 58 111 | length: 1 112 | required: false 113 | default: ' ' 114 | } 115 | { 116 | field: 'conta_num' 117 | startPos: 59 118 | endPos: 70 119 | length: 12 120 | required: false 121 | type: 'numeric' 122 | } 123 | { 124 | field: 'conta_dig_verificador' 125 | startPos: 71 126 | endPos: 71 127 | length: 1 128 | required: false 129 | type: 'numeric' 130 | } 131 | { 132 | field: 'filler' 133 | startPos: 72 134 | endPos: 72 135 | length: 1 136 | required: false 137 | default: ' ' 138 | } 139 | { 140 | field: 'empresa_nome' 141 | startPos: 73 142 | endPos: 102 143 | length: 30 144 | required: true 145 | type: 'alphanumeric' 146 | } 147 | { 148 | field: 'mensagem_mkt' 149 | startPos: 103 150 | endPos: 142 151 | length: 40 152 | required: false 153 | type: 'alphanumeric' 154 | } 155 | { 156 | field: 'endereco_logradouro' 157 | startPos: 143 158 | endPos: 172 159 | length: 30 160 | required: false 161 | type: 'alphanumeric' 162 | } 163 | { 164 | field: 'endereco_num' 165 | startPos: 173 166 | endPos: 177 167 | length: 5 168 | required: false 169 | type: 'alphanumeric' 170 | } 171 | { 172 | field: 'endereco_compl' 173 | startPos: 178 174 | endPos: 192 175 | length: 15 176 | required: false 177 | type: 'alphanumeric' 178 | } 179 | { 180 | field: 'endereco_cidade' 181 | startPos: 193 182 | endPos: 212 183 | length: 20 184 | required: false 185 | type: 'alphanumeric' 186 | } 187 | { 188 | field: 'endereco_cep' 189 | startPos: 213 190 | endPos: 217 191 | length: 5 192 | required: false 193 | type: 'numeric' 194 | } 195 | { 196 | field: 'endereco_cep_compl' 197 | startPos: 218 198 | endPos: 220 199 | length: 3 200 | required: false 201 | type: 'numeric' 202 | } 203 | { 204 | field: 'endereco_estado' 205 | startPos: 221 206 | endPos: 222 207 | length: 2 208 | required: false 209 | type: 'alphanumeric' 210 | } 211 | { 212 | field: 'comprovante_pgto' 213 | startPos: 223 214 | endPos: 223 215 | length: 1 216 | required: false 217 | type: 'alphanumeric' 218 | } 219 | { 220 | field: 'filler' 221 | startPos: 224 222 | endPos: 240 223 | length: 17 224 | required: false 225 | default: new Array(17).fill(' ').join('') 226 | } 227 | ] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cnab240-nodejs 2 | Biblioteca para gerar arquivos de remessa no padrão CNAB 240 3 | 4 | Este projeto foi concebido para facilitar a geração de arquivos no padrão CNAB 240 da Febraban (veja o manual em: http://bit.ly/2c9ssdZ). Se você já possui alguma familiaridade com o padrão 240 posições, sabe que, para gerar um arquivo de remessa, é preciso no mínimo 5 strings de 240 caracteres separadas por quebras de linha, sendo que cada string equivale a uma seção do arquivo: 5 | 6 | Header do Arquivo 7 | Header do Lote 8 | Detalhe 9 | Trailing do Lote 10 | Trailing do Arquivo 11 | 12 | Enquanto o header e trailing de arquivo são os mesmos para qualquer tipo de operação, as seções pertinentes ao lote e o detalhe (ou detalhes) possuem informações especializadas. O lote pode conter uma ou mais operações. 13 | 14 | Embora a FEBRABAN tenha criado o padrão para normatizar a comunicação via arquivos digitais, cada banco implementou o padrão de forma diferente, o que implica em um layout diferente por banco. Por isso, se a operação do banco com o qual você está integrando não existir, você irá precisar criar o layout. 15 | 16 | Esta biblioteca funciona de forma muito simples: você tem os arquivos de layout e o motor que gera as strings de 240 posições de cada seção do arquivo; para gerar um arquivo, você passa os parâmetros requeridos e o nome do layout para a biblioteca, e ela irá retornar a string. 17 | 18 | Os arquivos de layout ficam na pasta "layout" e estão organizados conforme a seguinte estrutura: 19 | 20 | -- layout 21 | -- {nome do banco} 22 | -- ArquivoHeader.coffee 23 | -- ArquivoTrailing.coffee 24 | -- {nome da operacao} 25 | -- LoteHeader.coffee 26 | -- LoteTrailing.coffee 27 | -- {nome da operacao}.coffee 28 | 29 | Na pasta layout há, ainda, um arquivo que exporta as regras na mesma estrutura: 30 | 31 | module.exports = 32 | {nome do banco}: 33 | ArquivoHeader: require './{nome do banco}/ArquivoHeader.coffee' 34 | ArquivoTrailing: require './{nome do banco}/ArquivoTrailing.coffee' 35 | {nome da operacao}: 36 | LoteHeader: require './{nome do banco}/{nome da operacao}/LoteHeader.coffee' 37 | LoteTrailing: require './{nome do banco}/{nome da operacao}/LoteTrailing.coffee' 38 | Detail: require './{nome do banco}/{nome da operacao}/{nome da operacao}.coffee' 39 | 40 | Então, ao criar um novo layout você precisa, além de seguir a estrutura acima definida, atualizar o arquivo Rules.coffee para que exporte o novo layout. 41 | 42 | O arquivo de layout nada mais é que um array com as regras de cada campo. 43 | 44 | 45 | ``` 46 | module.exports = [ 47 | { 48 | field: 'banco' 49 | startPos: 1 50 | endPos: 3 51 | length: 3 52 | required: true 53 | default: 399 54 | } 55 | { 56 | field: 'lote' 57 | startPos: 4 58 | endPos: 7 59 | length: 4 60 | required: true 61 | default: '0000' 62 | } 63 | { 64 | field: 'registro' 65 | startPos: 8 66 | endPos: 8 67 | length: 1 68 | required: true 69 | default: '0' 70 | } 71 | ... 72 | ``` 73 | 74 | E o que significa cada regra? 75 | 76 | - field: *nome do campo* 77 | - startPos: *posicao na string em que o campo começa* 78 | - endPos: *posicao na string em que o campo termina* 79 | - length: *comprimento do campo* 80 | - required: *se o campo é obrigatório ou não* 81 | - default: *valor padrão do campo (seja ele fixo ou não)* (opcional) 82 | - type: *tipo do dado* (opcional se o campo default existir) 83 | 84 | Para a criação dos arquivos de layout, você deve seguir o manual disponibilizado por cada banco. 85 | 86 | ## API 87 | 88 | ### new Remessa(bank, type) 89 | Cria uma nova instância utilizando o layout `type` de `bank`. 90 | 91 | `new Remessa('HSBC', 'Pagamento')` 92 | 93 | ### validate(rulesName, userValues) 94 | Valida as informações de `userValues` contra as regras da seção `rulesName` 95 | ``` 96 | userValues = 97 | banco: 'HSBC' 98 | lote: '1' 99 | registro: '0' 100 | validate('ArquivoHeader', userValues) 101 | ``` 102 | 103 | ### prepare(rulesName, validated) 104 | Formata as informações para corresponder às configurações do campo 105 | Retorna as regras com os valores formatados 106 | 107 | `prepare('LoteHeader', userValues)` 108 | 109 | ### build(prepared) 110 | Constrói a string de 240 posições inserindo os valores em suas respectivas posições, a partir do retorno da função prepare() 111 | Retorna uma string de 240 posições 112 | 113 | `build(prepared)` 114 | 115 | ### process(userValues) 116 | Executa o processo de validação, preparação e construção de strings em sequência. 117 | Retorna uma string com todas as seções do arquivo de remessa, separadas por quebras de linha 118 | 119 | `process(userValues)` 120 | 121 | ---------------------------------- 122 | Observações: 123 | 124 | Para utilizar o wrapper process() os dados devem estar estruturados em seções, conforme exemplificado em cnab/test/Example.coffee. 125 | 126 | Para gerar mais de uma operação por lote (por exemplo, 5 TEDs ou 100 boletos) a chave `Detail` deve conter, em lugar de um objeto, um array de objetos. 127 | 128 | ## TODO 129 | Adicionar validações (date, range, enum etc) 130 | -------------------------------------------------------------------------------- /coffee/cnab/src/Retorno.coffee: -------------------------------------------------------------------------------- 1 | _ = require 'lodash' 2 | expect = require 'expect.js' 3 | rules = require '../../layout/Rules' 4 | 5 | class Retorno 6 | 7 | ### 8 | JSON ouput structure: 9 | 10 | ArquivoHeader: {} 11 | lots: [ 12 | { 13 | LoteHeader: {} 14 | details: [ 15 | [ 16 | { 17 | Segment1: {} 18 | Segment2: {} 19 | } 20 | ] 21 | [ 22 | { 23 | Segment1: {} 24 | Segment2: {} 25 | } 26 | ] 27 | ] 28 | LoteTrailing: {} 29 | } 30 | ] 31 | ArquivoTrailing: {} 32 | 33 | ### 34 | 35 | FILE_HEADER = 'ArquivoHeader' 36 | FILE_TRAILING = 'ArquivoTrailing' 37 | LOT_HEADER = 'LoteHeader' 38 | LOT_TRAILING = 'LoteTrailing' 39 | DETAIL = 'Detail' 40 | DETAIL2 = 'Detail2' 41 | 42 | FILE_SECTIONS = 43 | FILE_HEADER: '0' 44 | LOT_HEADER: '1' 45 | DETAIL: 'A' 46 | LOT_TRAILING: '5' 47 | FILE_TRAILING: '9' 48 | 49 | constructor: (bank, type) -> 50 | throw new Error 'Bank is mandatory' unless bank? 51 | throw new Error 'Type is mandatory' unless type? 52 | @rules = 53 | ArquivoHeader: rules[bank].ArquivoHeader 54 | ArquivoTrailing: rules[bank].ArquivoTrailing 55 | LoteHeader: rules[bank][type]?.LoteHeader 56 | LoteTrailing: rules[bank][type]?.LoteTrailing 57 | Detail: rules[bank][type]?.Detail 58 | Detail2: rules[bank][type]?.Detail2 59 | @CONSTANTS = rules[bank][type]?.Constants 60 | 61 | extractSingleField: (line, rule) -> 62 | line?.split('').slice(rule.startPos-1, rule.endPos).join('') 63 | 64 | # this method mutates {lines} 65 | extractSection: (lines, sectionName, sectionCode) -> 66 | registryRule = _.find @rules[sectionName], field: @CONSTANTS[sectionName].REGISTRY_FIELD 67 | line = _.filter lines, (line) -> 68 | line?.split('').slice(registryRule.startPos-1, registryRule.endPos).join('') is sectionCode 69 | _.pull lines, line[0] 70 | line[0] 71 | 72 | extractBulk: (lines, rule, condition) -> 73 | _.reduce lines, (memo, line) => 74 | currentPos = if memo.length is 0 then 0 else memo.length - 1 75 | if @extractSingleField(line, rule) is condition 76 | memo.push [] 77 | memo[memo.length - 1].push line 78 | else 79 | memo[currentPos]?.push line 80 | memo 81 | , [] 82 | 83 | numberOf: (fileTrailingLine, sectionName, registryField) -> 84 | lotNumRule = _.find @rules[sectionName], field: registryField 85 | parseInt(@extractSingleField(fileTrailingLine, lotNumRule) || 0) 86 | 87 | extractFields: (line, sectionName) -> 88 | localRules = @rules[sectionName] 89 | _.reduce localRules, (extracted, rule) => 90 | extracted["#{rule.field}"] = @extractSingleField line, rule 91 | extracted 92 | , {} 93 | 94 | extractSegments: (detailLines) -> 95 | detailSegmentCodeRule = _.find @rules.Detail, field: 'cod_seg_registro_lote' 96 | _.reduce detailLines, (memo, detailLine) => 97 | segmentCode = @extractSingleField detailLine, detailSegmentCodeRule 98 | memo.push @extractFields detailLine, @CONSTANTS.Segmentos[segmentCode] 99 | memo 100 | , [] 101 | 102 | extractDetails: (lotLines) -> 103 | lotHeaderLine = @extractSection lotLines, LOT_HEADER, FILE_SECTIONS.LOT_HEADER 104 | lotTrailingLine = @extractSection lotLines, LOT_TRAILING, FILE_SECTIONS.LOT_TRAILING 105 | detailsBulks = @extractBulk lotLines, _.find(@rules.Detail, field: @CONSTANTS.Pagamento.REGISTRY_FIELD), FILE_SECTIONS.DETAIL 106 | detailsWithSegments = _.map detailsBulks, @extractSegments.bind @ 107 | { 108 | "#{LOT_HEADER}": @extractFields lotHeaderLine, LOT_HEADER 109 | details: detailsWithSegments 110 | "#{LOT_TRAILING}": @extractFields lotTrailingLine, LOT_TRAILING 111 | } 112 | 113 | extract: (fileString) -> 114 | # console.log fileString 115 | # sanitizedFileString = _.replace fileString, '\r\n', '\n' 116 | # console.log sanitizedFileString 117 | # lines = _.compact(sanitizedFileString.split '\n') 118 | # console.log lines 119 | lines = _.compact(fileString.split '\n') 120 | 121 | fileHeaderLine = @extractSection lines, FILE_HEADER, FILE_SECTIONS.FILE_HEADER 122 | fileTrailingLine = @extractSection lines, FILE_TRAILING, FILE_SECTIONS.FILE_TRAILING 123 | 124 | lots = @extractBulk lines, _.find(@rules.LoteHeader, field: @CONSTANTS.LoteHeader.REGISTRY_FIELD), FILE_SECTIONS.LOT_HEADER 125 | 126 | lotsWithSegments = _.map lots, @extractDetails.bind @ 127 | 128 | { 129 | "#{FILE_HEADER}": @extractFields fileHeaderLine, FILE_HEADER 130 | lots: lotsWithSegments 131 | "#{FILE_TRAILING}": @extractFields fileTrailingLine, FILE_TRAILING 132 | } 133 | 134 | module.exports = Retorno 135 | -------------------------------------------------------------------------------- /layout/HSBC/Pagamento/LoteHeader.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 399 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 1 25 | }, 26 | { 27 | field: 'operacao', 28 | startPos: 9, 29 | endPos: 9, 30 | length: 1, 31 | required: true, 32 | default: 'C', 33 | type: 'numeric' 34 | }, 35 | { 36 | field: 'servico', 37 | startPos: 10, 38 | endPos: 11, 39 | length: 2, 40 | required: true, 41 | type: 'numeric' 42 | }, 43 | { 44 | field: 'forma_lancamento', 45 | startPos: 12, 46 | endPos: 13, 47 | length: 2, 48 | required: true, 49 | type: 'numeric' 50 | }, 51 | { 52 | field: 'versao_layout', 53 | startPos: 14, 54 | endPos: 16, 55 | length: 3, 56 | required: true, 57 | default: '020' 58 | }, 59 | { 60 | field: 'filler', 61 | startPos: 17, 62 | endPos: 17, 63 | length: 1, 64 | required: false, 65 | default: ' ' 66 | }, 67 | { 68 | field: 'empresa_tipo_insc', 69 | startPos: 18, 70 | endPos: 18, 71 | length: 1, 72 | required: true, 73 | type: 'numeric' 74 | }, 75 | { 76 | field: 'empresa_num_insc', 77 | startPos: 19, 78 | endPos: 32, 79 | length: 14, 80 | required: true, 81 | type: 'numeric' 82 | }, 83 | { 84 | field: 'convenio', 85 | startPos: 33, 86 | endPos: 38, 87 | length: 6, 88 | required: true, 89 | type: 'numeric' 90 | }, 91 | { 92 | field: 'filler', 93 | startPos: 39, 94 | endPos: 52, 95 | length: 14, 96 | required: false, 97 | default: new Array(14).fill(' ').join('') 98 | }, 99 | { 100 | field: 'conta_agencia', 101 | startPos: 53, 102 | endPos: 57, 103 | length: 5, 104 | required: false, 105 | type: 'numeric' 106 | }, 107 | { 108 | field: 'filler', 109 | startPos: 58, 110 | endPos: 58, 111 | length: 1, 112 | required: false, 113 | default: ' ' 114 | }, 115 | { 116 | field: 'conta_num', 117 | startPos: 59, 118 | endPos: 70, 119 | length: 12, 120 | required: false, 121 | type: 'numeric' 122 | }, 123 | { 124 | field: 'conta_dig_verificador', 125 | startPos: 71, 126 | endPos: 71, 127 | length: 1, 128 | required: false, 129 | type: 'numeric' 130 | }, 131 | { 132 | field: 'filler', 133 | startPos: 72, 134 | endPos: 72, 135 | length: 1, 136 | required: false, 137 | default: ' ' 138 | }, 139 | { 140 | field: 'empresa_nome', 141 | startPos: 73, 142 | endPos: 102, 143 | length: 30, 144 | required: true, 145 | type: 'alphanumeric' 146 | }, 147 | { 148 | field: 'mensagem_mkt', 149 | startPos: 103, 150 | endPos: 142, 151 | length: 40, 152 | required: false, 153 | type: 'alphanumeric' 154 | }, 155 | { 156 | field: 'endereco_logradouro', 157 | startPos: 143, 158 | endPos: 172, 159 | length: 30, 160 | required: false, 161 | type: 'alphanumeric' 162 | }, 163 | { 164 | field: 'endereco_num', 165 | startPos: 173, 166 | endPos: 177, 167 | length: 5, 168 | required: false, 169 | type: 'alphanumeric' 170 | }, 171 | { 172 | field: 'endereco_compl', 173 | startPos: 178, 174 | endPos: 192, 175 | length: 15, 176 | required: false, 177 | type: 'alphanumeric' 178 | }, 179 | { 180 | field: 'endereco_cidade', 181 | startPos: 193, 182 | endPos: 212, 183 | length: 20, 184 | required: false, 185 | type: 'alphanumeric' 186 | }, 187 | { 188 | field: 'endereco_cep', 189 | startPos: 213, 190 | endPos: 217, 191 | length: 5, 192 | required: false, 193 | type: 'numeric' 194 | }, 195 | { 196 | field: 'endereco_cep_compl', 197 | startPos: 218, 198 | endPos: 220, 199 | length: 3, 200 | required: false, 201 | type: 'numeric' 202 | }, 203 | { 204 | field: 'endereco_estado', 205 | startPos: 221, 206 | endPos: 222, 207 | length: 2, 208 | required: false, 209 | type: 'alphanumeric' 210 | }, 211 | { 212 | field: 'comprovante_pgto', 213 | startPos: 223, 214 | endPos: 223, 215 | length: 1, 216 | required: false, 217 | type: 'alphanumeric' 218 | }, 219 | { 220 | field: 'filler', 221 | startPos: 224, 222 | endPos: 240, 223 | length: 17, 224 | required: false, 225 | default: new Array(17).fill(' ').join('') 226 | } 227 | ]; -------------------------------------------------------------------------------- /layout/Bradesco/Conciliacao/Conciliacao.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 3 25 | }, 26 | { 27 | field: 'num_seq_registro_lote', 28 | startPos: 9, 29 | endPos: 13, 30 | length: 5, 31 | required: true, 32 | type: 'numeric' 33 | }, 34 | { 35 | field: 'cod_seg_registro_lote', 36 | startPos: 14, 37 | endPos: 14, 38 | length: 1, 39 | required: true, 40 | default: 'E' 41 | }, 42 | { 43 | field: 'filler', 44 | startPos: 15, 45 | endPos: 17, 46 | length: 3, 47 | required: false, 48 | default: new Array(3).fill(' ').join('') 49 | }, 50 | { 51 | field: 'empresa_tipo_insc', 52 | startPos: 18, 53 | endPos: 18, 54 | length: 1, 55 | required: true, 56 | type: 'numeric' 57 | }, 58 | { 59 | field: 'empresa_num_insc', 60 | startPos: 19, 61 | endPos: 32, 62 | length: 14, 63 | required: true, 64 | type: 'numeric' 65 | }, 66 | { 67 | field: 'convenio', 68 | startPos: 33, 69 | endPos: 52, 70 | length: 20, 71 | required: true, 72 | type: 'numeric' 73 | }, 74 | { 75 | field: 'conta_agencia', 76 | startPos: 53, 77 | endPos: 57, 78 | length: 5, 79 | required: false, 80 | type: 'numeric' 81 | }, 82 | { 83 | field: 'agencia_dig_verificador', 84 | startPos: 58, 85 | endPos: 58, 86 | length: 1, 87 | required: false, 88 | type: 'alphanumeric' 89 | }, 90 | { 91 | field: 'conta_num', 92 | startPos: 59, 93 | endPos: 70, 94 | length: 12, 95 | required: false, 96 | type: 'numeric' 97 | }, 98 | { 99 | field: 'conta_dig_verificador', 100 | startPos: 71, 101 | endPos: 71, 102 | length: 1, 103 | required: false, 104 | type: 'numeric' 105 | }, 106 | { 107 | field: 'ag_conta_digito_verificador', 108 | startPos: 72, 109 | endPos: 72, 110 | length: 1, 111 | required: false, 112 | default: ' ' 113 | }, 114 | { 115 | field: 'empresa_nome', 116 | startPos: 73, 117 | endPos: 102, 118 | length: 30, 119 | required: true, 120 | type: 'alphanumeric' 121 | }, 122 | { 123 | field: 'filler', 124 | startPos: 103, 125 | endPos: 108, 126 | length: 6, 127 | required: false, 128 | default: new Array(6).fill(' ').join('') 129 | }, 130 | { 131 | field: 'natureza_lcto', 132 | startPos: 109, 133 | endPos: 111, 134 | length: 3, 135 | required: false, 136 | type: 'numeric', 137 | }, 138 | { 139 | field: 'tipo_complemento', 140 | startPos: 112, 141 | endPos: 113, 142 | length: 2, 143 | required: false, 144 | type: 'numeric' 145 | }, 146 | { 147 | field: 'complemento', 148 | startPos: 114, 149 | endPos: 133, 150 | length: 20, 151 | required: false, 152 | type: 'alphanumeric' 153 | }, 154 | { 155 | field: 'isencao_cpmf', 156 | startPos: 134, 157 | endPos: 134, 158 | length: 1, 159 | required: false, 160 | type: 'alphanumeric' 161 | }, 162 | { 163 | field: 'data_contabil', 164 | startPos: 135, 165 | endPos: 142, 166 | length: 8, 167 | required: false, 168 | type: 'numeric' 169 | }, 170 | { 171 | field: 'data_lancamento', 172 | startPos: 143, 173 | endPos: 150, 174 | length: 8, 175 | required: false, 176 | type: 'numeric' 177 | }, 178 | { 179 | field: 'valor_lancamento', 180 | startPos: 151, 181 | endPos: 168, 182 | length: 18, 183 | required: false, 184 | type: 'numeric' 185 | }, 186 | { 187 | field: 'tipo_lancamento', 188 | startPos: 169, 189 | endPos: 169, 190 | length: 1, 191 | required: true, 192 | type: 'alphanumeric' 193 | }, 194 | { 195 | field: 'categoria_lancamento', 196 | startPos: 170, 197 | endPos: 172, 198 | length: 3, 199 | required: false, 200 | type: 'numeric' 201 | }, 202 | { 203 | field: 'codigo_historico', 204 | startPos: 173, 205 | endPos: 176, 206 | length: 4, 207 | required: false, 208 | type: 'alphanumeric' 209 | }, 210 | { 211 | field: 'descricao_historico', 212 | startPos: 177, 213 | endPos: 201, 214 | length: 25, 215 | required: false, 216 | type: 'alphanumeric' 217 | }, 218 | { 219 | field: 'num_documento_compl', 220 | startPos: 202, 221 | endPos: 240, 222 | length: 39, 223 | required: false 224 | } 225 | ]; 226 | -------------------------------------------------------------------------------- /coffee/layout/Bradesco/Pagamento/LoteHeader.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 237 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 1 25 | } 26 | { 27 | field: 'operacao' 28 | startPos: 9 29 | endPos: 9 30 | length: 1 31 | required: true 32 | default: 'C' 33 | type: 'numeric' 34 | } 35 | { 36 | field: 'servico' 37 | startPos: 10 38 | endPos: 11 39 | length: 2 40 | required: true 41 | type: 'numeric' 42 | } 43 | { 44 | field: 'forma_lancamento' 45 | startPos: 12 46 | endPos: 13 47 | length: 2 48 | required: true 49 | type: 'numeric' 50 | } 51 | { 52 | field: 'versao_layout' 53 | startPos: 14 54 | endPos: 16 55 | length: 3 56 | required: true 57 | default: '045' 58 | } 59 | { 60 | field: 'filler' 61 | startPos: 17 62 | endPos: 17 63 | length: 1 64 | required: false 65 | default: ' ' 66 | } 67 | { 68 | field: 'empresa_tipo_insc' 69 | startPos: 18 70 | endPos: 18 71 | length: 1 72 | required: true 73 | type: 'numeric' 74 | } 75 | { 76 | field: 'empresa_num_insc' 77 | startPos: 19 78 | endPos: 32 79 | length: 14 80 | required: true 81 | type: 'numeric' 82 | } 83 | { 84 | field: 'convenio' 85 | startPos: 33 86 | endPos: 38 87 | length: 6 88 | required: true 89 | type: 'numeric' 90 | } 91 | { 92 | field: 'filler' 93 | startPos: 39 94 | endPos: 52 95 | length: 14 96 | required: false 97 | default: new Array(14).fill(' ').join('') 98 | } 99 | { 100 | field: 'conta_agencia' 101 | startPos: 53 102 | endPos: 57 103 | length: 5 104 | required: false 105 | type: 'numeric' 106 | } 107 | { 108 | field: 'agencia_dig_verificador' 109 | startPos: 58 110 | endPos: 58 111 | length: 1 112 | required: false 113 | type: 'alphanumeric' 114 | } 115 | { 116 | field: 'conta_num' 117 | startPos: 59 118 | endPos: 70 119 | length: 12 120 | required: false 121 | type: 'numeric' 122 | } 123 | { 124 | field: 'conta_dig_verificador' 125 | startPos: 71 126 | endPos: 71 127 | length: 1 128 | required: false 129 | type: 'numeric' 130 | } 131 | { 132 | field: 'filler' 133 | startPos: 72 134 | endPos: 72 135 | length: 1 136 | required: false 137 | default: ' ' 138 | } 139 | { 140 | field: 'empresa_nome' 141 | startPos: 73 142 | endPos: 102 143 | length: 30 144 | required: true 145 | type: 'alphanumeric' 146 | } 147 | { 148 | field: 'mensagem' 149 | startPos: 103 150 | endPos: 142 151 | length: 40 152 | required: false 153 | type: 'alphanumeric' 154 | } 155 | { 156 | field: 'endereco_logradouro' 157 | startPos: 143 158 | endPos: 172 159 | length: 30 160 | required: false 161 | type: 'alphanumeric' 162 | } 163 | { 164 | field: 'endereco_num' 165 | startPos: 173 166 | endPos: 177 167 | length: 5 168 | required: false 169 | type: 'alphanumeric' 170 | } 171 | { 172 | field: 'endereco_compl' 173 | startPos: 178 174 | endPos: 192 175 | length: 15 176 | required: false 177 | type: 'alphanumeric' 178 | } 179 | { 180 | field: 'endereco_cidade' 181 | startPos: 193 182 | endPos: 212 183 | length: 20 184 | required: false 185 | type: 'alphanumeric' 186 | } 187 | { 188 | field: 'endereco_cep' 189 | startPos: 213 190 | endPos: 217 191 | length: 5 192 | required: false 193 | type: 'numeric' 194 | } 195 | { 196 | field: 'endereco_cep_compl' 197 | startPos: 218 198 | endPos: 220 199 | length: 3 200 | required: false 201 | type: 'numeric' 202 | } 203 | { 204 | field: 'endereco_estado' 205 | startPos: 221 206 | endPos: 222 207 | length: 2 208 | required: false 209 | type: 'alphanumeric' 210 | } 211 | { 212 | field: 'forma_pgto_servico' 213 | startPos: 223 214 | endPos: 224 215 | length: 2 216 | required: false 217 | default: '01' # débito em conta corrente 218 | } 219 | { 220 | field: 'filler' 221 | startPos: 225 222 | endPos: 230 223 | length: 6 224 | required: false 225 | default: new Array(6).fill(' ').join('') 226 | } 227 | { 228 | field: 'codigos_ocorrencias' 229 | startPos: 231 230 | endPos: 240 231 | length: 10 232 | required: false 233 | default: new Array(10).fill(' ').join('') 234 | } 235 | ] 236 | -------------------------------------------------------------------------------- /coffee/utils/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "ArquivoHeader": { 3 | "banco": "237", 4 | "lote": "0000", 5 | "registro": "0", 6 | "filler": " ", 7 | "empresa_inscricao_tipo": "2", 8 | "empresa_inscricao_num": "07144407000131", 9 | "convenio": "000031", 10 | "conta_agencia": "03507", 11 | "agencia_dig_verificador": "6", 12 | "conta_num": "000000000364", 13 | "conta_dig_verificador": "6", 14 | "empresa_nome": "VERSUL TECNOLOGIA DE ACESSO IN", 15 | "nome_banco": "BRADESCO ", 16 | "arquivo_cod": "2", 17 | "arquivo_data_geracao": "28112017", 18 | "arquivo_hora_geracao": "162833", 19 | "arquivo_sequencia": "000001", 20 | "arquivo_layout": "089", 21 | "arquivo_densidade": "00000", 22 | "reservado_banco": "00000000BRAD ", 23 | "reservado_empresa": " " 24 | }, 25 | "lots": [ 26 | { 27 | "LoteHeader": { 28 | "banco": "237", 29 | "lote": "0001", 30 | "registro": "1", 31 | "operacao": "C", 32 | "servico": "20", 33 | "forma_lancamento": "41", 34 | "versao_layout": "045", 35 | "filler": " ", 36 | "empresa_tipo_insc": "2", 37 | "empresa_num_insc": "07144407000131", 38 | "convenio": "000031", 39 | "conta_agencia": "03507", 40 | "agencia_dig_verificador": "6", 41 | "conta_num": "000000000364", 42 | "conta_dig_verificador": "6", 43 | "empresa_nome": "VERSUL TECNOLOGIA DE ACESSO IN", 44 | "mensagem": " ", 45 | "endereco_logradouro": "Rua Marcilio Dias ", 46 | "endereco_num": "1659 ", 47 | "endereco_compl": " ", 48 | "endereco_cidade": "Novo Hamburgo ", 49 | "endereco_cep": "93410", 50 | "endereco_cep_compl": "185", 51 | "endereco_estado": "RS", 52 | "forma_pgto_servico": "01", 53 | "codigos_ocorrencias": " " 54 | }, 55 | "details": [ 56 | [ 57 | { 58 | "banco": "237", 59 | "lote": "0001", 60 | "registro": "3", 61 | "num_seq_registro_lote": "00001", 62 | "cod_seg_registro_lote": "A", 63 | "movimento_tipo": "0", 64 | "movimento_cod": "00", 65 | "cod_camara": "018", 66 | "favorecido_cod_banco": "041", 67 | "favorecido_agencia": "00675", 68 | "favorecido_dig_agencia": "0", 69 | "favorecido_num_conta": "000060410140", 70 | "favorecido_dig_verificador": "4", 71 | "ag_conta_digito_verificador": " ", 72 | "favorecido_nome": "STACIONE ROTATIVO LTDA EPP ", 73 | "doc_empresa": "XXX28112017BRL000000", 74 | "data_pagamento": "00000000", 75 | "tipo_moeda": "000", 76 | "qtde_moeda": "0000000636332XX", 77 | "valor_pagamento": "X00000000000000", 78 | "num_doc_atribuido_banco": "000636332 ", 79 | "data_real_efetivacao_pgto": " ", 80 | "valor_real_efetivacao_pgto": " ", 81 | "info2": " 0001001 0BD ", 82 | "cod_finalidade_doc": "", 83 | "cod_finalidade_ted": "", 84 | "cod_finalidade_compl": "", 85 | "cnab": "", 86 | "aviso": "", 87 | "codigos_ocorrencias": "" 88 | }, 89 | { 90 | "banco": "237", 91 | "lote": "0001", 92 | "registro": "3", 93 | "num_seq_registro_lote": "00002", 94 | "cod_seg_registro_lote": "B", 95 | "filler": " ", 96 | "favorecido_tipo_inscricao": "2", 97 | "favorecido_num_inscricao": "06200940000291", 98 | "favorecido_logradouro": " ", 99 | "favorecido_num": " ", 100 | "favorecido_compl": " ", 101 | "favorecido_bairro": " ", 102 | "favorecido_cidade": " ", 103 | "favorecido_cep": "00000", 104 | "favorecido_cep_compl": "000", 105 | "favorecido_estado": " ", 106 | "data_vencimento": "28112017", 107 | "valor_documento": "000000000636332", 108 | "valor_abatimento": "000000000000000", 109 | "valor_desconto": "000000000000000", 110 | "valor_mora": "000000000000000", 111 | "valor_multa": "000000000000000", 112 | "cod_doc_favorecido": " ", 113 | "aviso_ao_favorecido": "0", 114 | "codigo_ispb": "92702067" 115 | } 116 | ] 117 | ], 118 | "LoteTrailing": { 119 | "banco": "237", 120 | "lote": "0001", 121 | "registro": "5", 122 | "filler": "0 ", 123 | "qtde_registros": "00000q", 124 | "somatoria_valores": "400000000000063633", 125 | "somatoria_qtde_moedas": "200000000000000000", 126 | "num_aviso_debito": "000000", 127 | "codigos_ocorrencias": " " 128 | } 129 | } 130 | ], 131 | "ArquivoTrailing": { 132 | "banco": "237", 133 | "lote": "9999", 134 | "registro": "9", 135 | "filler": " ", 136 | "qtde_lotes": "000001", 137 | "qtde_registros": "000006", 138 | "qtde_contas": " " 139 | } 140 | } -------------------------------------------------------------------------------- /layout/Bradesco/Pagamento/LoteHeader.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 1 25 | }, 26 | { 27 | field: 'operacao', 28 | startPos: 9, 29 | endPos: 9, 30 | length: 1, 31 | required: true, 32 | default: 'C', 33 | type: 'numeric' 34 | }, 35 | { 36 | field: 'servico', 37 | startPos: 10, 38 | endPos: 11, 39 | length: 2, 40 | required: true, 41 | type: 'numeric' 42 | }, 43 | { 44 | field: 'forma_lancamento', 45 | startPos: 12, 46 | endPos: 13, 47 | length: 2, 48 | required: true, 49 | type: 'numeric' 50 | }, 51 | { 52 | field: 'versao_layout', 53 | startPos: 14, 54 | endPos: 16, 55 | length: 3, 56 | required: true, 57 | default: '045' 58 | }, 59 | { 60 | field: 'filler', 61 | startPos: 17, 62 | endPos: 17, 63 | length: 1, 64 | required: false, 65 | default: ' ' 66 | }, 67 | { 68 | field: 'empresa_tipo_insc', 69 | startPos: 18, 70 | endPos: 18, 71 | length: 1, 72 | required: true, 73 | type: 'numeric' 74 | }, 75 | { 76 | field: 'empresa_num_insc', 77 | startPos: 19, 78 | endPos: 32, 79 | length: 14, 80 | required: true, 81 | type: 'numeric' 82 | }, 83 | { 84 | field: 'convenio', 85 | startPos: 33, 86 | endPos: 38, 87 | length: 6, 88 | required: true, 89 | type: 'numeric' 90 | }, 91 | { 92 | field: 'filler', 93 | startPos: 39, 94 | endPos: 52, 95 | length: 14, 96 | required: false, 97 | default: new Array(14).fill(' ').join('') 98 | }, 99 | { 100 | field: 'conta_agencia', 101 | startPos: 53, 102 | endPos: 57, 103 | length: 5, 104 | required: false, 105 | type: 'numeric' 106 | }, 107 | { 108 | field: 'agencia_dig_verificador', 109 | startPos: 58, 110 | endPos: 58, 111 | length: 1, 112 | required: false, 113 | type: 'alphanumeric' 114 | }, 115 | { 116 | field: 'conta_num', 117 | startPos: 59, 118 | endPos: 70, 119 | length: 12, 120 | required: false, 121 | type: 'numeric' 122 | }, 123 | { 124 | field: 'conta_dig_verificador', 125 | startPos: 71, 126 | endPos: 71, 127 | length: 1, 128 | required: false, 129 | type: 'numeric' 130 | }, 131 | { 132 | field: 'filler', 133 | startPos: 72, 134 | endPos: 72, 135 | length: 1, 136 | required: false, 137 | default: ' ' 138 | }, 139 | { 140 | field: 'empresa_nome', 141 | startPos: 73, 142 | endPos: 102, 143 | length: 30, 144 | required: true, 145 | type: 'alphanumeric' 146 | }, 147 | { 148 | field: 'mensagem', 149 | startPos: 103, 150 | endPos: 142, 151 | length: 40, 152 | required: false, 153 | type: 'alphanumeric' 154 | }, 155 | { 156 | field: 'endereco_logradouro', 157 | startPos: 143, 158 | endPos: 172, 159 | length: 30, 160 | required: false, 161 | type: 'alphanumeric' 162 | }, 163 | { 164 | field: 'endereco_num', 165 | startPos: 173, 166 | endPos: 177, 167 | length: 5, 168 | required: false, 169 | type: 'alphanumeric' 170 | }, 171 | { 172 | field: 'endereco_compl', 173 | startPos: 178, 174 | endPos: 192, 175 | length: 15, 176 | required: false, 177 | type: 'alphanumeric' 178 | }, 179 | { 180 | field: 'endereco_cidade', 181 | startPos: 193, 182 | endPos: 212, 183 | length: 20, 184 | required: false, 185 | type: 'alphanumeric' 186 | }, 187 | { 188 | field: 'endereco_cep', 189 | startPos: 213, 190 | endPos: 217, 191 | length: 5, 192 | required: false, 193 | type: 'numeric' 194 | }, 195 | { 196 | field: 'endereco_cep_compl', 197 | startPos: 218, 198 | endPos: 220, 199 | length: 3, 200 | required: false, 201 | type: 'numeric' 202 | }, 203 | { 204 | field: 'endereco_estado', 205 | startPos: 221, 206 | endPos: 222, 207 | length: 2, 208 | required: false, 209 | type: 'alphanumeric' 210 | }, 211 | { 212 | field: 'forma_pgto_servico', 213 | startPos: 223, 214 | endPos: 224, 215 | length: 2, 216 | required: false, 217 | default: '01' // débito em conta corrente 218 | }, 219 | { 220 | field: 'filler', 221 | startPos: 225, 222 | endPos: 230, 223 | length: 6, 224 | required: false, 225 | default: new Array(6).fill(' ').join('') 226 | }, 227 | { 228 | field: 'codigos_ocorrencias', 229 | startPos: 231, 230 | endPos: 240, 231 | length: 10, 232 | required: false, 233 | default: new Array(10).fill(' ').join('') 234 | } 235 | ]; 236 | -------------------------------------------------------------------------------- /coffee/layout/Bradesco/Pagamento/Pagamento.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 237 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 3 25 | } 26 | { 27 | field: 'num_seq_registro_lote' 28 | startPos: 9 29 | endPos: 13 30 | length: 5 31 | required: true 32 | type: 'numeric' 33 | } 34 | { 35 | field: 'cod_seg_registro_lote' 36 | startPos: 14 37 | endPos: 14 38 | length: 1 39 | required: true 40 | default: 'A' 41 | type: 'alphanumeric' 42 | } 43 | { 44 | field: 'movimento_tipo' 45 | startPos: 15 46 | endPos: 15 47 | length: 1 48 | required: true 49 | type: 'numeric' 50 | default: 0 51 | } 52 | { 53 | field: 'movimento_cod' 54 | startPos: 16 55 | endPos: 17 56 | length: 2 57 | required: true 58 | type: 'numeric' 59 | } 60 | { 61 | field: 'cod_camara' 62 | startPos: 18 63 | endPos: 20 64 | length: 3 65 | required: true 66 | type: 'numeric' 67 | } 68 | { 69 | field: 'favorecido_cod_banco' 70 | startPos: 21 71 | endPos: 23 72 | length: 3 73 | required: true 74 | default: 237 75 | } 76 | { 77 | field: 'favorecido_agencia' 78 | startPos: 24 79 | endPos: 28 80 | length: 5 81 | required: true 82 | type: 'numeric' 83 | } 84 | { 85 | field: 'favorecido_dig_agencia' 86 | startPos: 29 87 | endPos: 29 88 | length: 1 89 | required: false 90 | type: 'numeric' 91 | } 92 | { 93 | field: 'favorecido_num_conta' 94 | startPos: 30 95 | endPos: 41 96 | length: 12 97 | required: true 98 | type: 'numeric' 99 | } 100 | { 101 | field: 'favorecido_dig_verificador' 102 | startPos: 42 103 | endPos: 42 104 | length: 1 105 | required: true 106 | type: 'alphanumeric' 107 | } 108 | { 109 | field: 'ag_conta_digito_verificador' 110 | startPos: 43 111 | endPos: 43 112 | length: 1 113 | required: false 114 | default: ' ' 115 | } 116 | { 117 | field: 'favorecido_nome' 118 | startPos: 44 119 | endPos: 73 120 | length: 30 121 | required: true 122 | type: 'alphanumeric' 123 | } 124 | { 125 | field: 'doc_empresa' 126 | startPos: 74 127 | endPos: 93 128 | length: 20 129 | required: true 130 | type: 'date' 131 | } 132 | { 133 | field: 'data_pagamento' 134 | startPos: 94 135 | endPos: 101 136 | length: 8 137 | required: false 138 | type: 'numeric' 139 | } 140 | { 141 | field: 'tipo_moeda' 142 | startPos: 102 143 | endPos: 104 144 | length: 3 145 | required: false 146 | default: 'BRL' 147 | } 148 | { 149 | field: 'qtde_moeda' 150 | startPos: 105 151 | endPos: 119 152 | length: 15 153 | required: false 154 | type: 'numeric' 155 | } 156 | { 157 | field: 'valor_pagamento' 158 | startPos: 120 159 | endPos: 134 160 | length: 15 161 | required: false 162 | type: 'numeric' 163 | } 164 | { 165 | field: 'num_doc_atribuido_banco' 166 | startPos: 135 167 | endPos: 154 168 | length: 20 169 | required: false 170 | type: 'alphanumeric' 171 | } 172 | { 173 | field: 'data_real_efetivacao_pgto' 174 | startPos: 155 175 | endPos: 162 176 | length: 8 177 | required: false 178 | type: 'numeric' 179 | } 180 | { 181 | field: 'valor_real_efetivacao_pgto' 182 | startPos: 163 183 | endPos: 177 184 | length: 15 185 | required: false 186 | type: 'numeric' 187 | } 188 | { 189 | field: 'info2' 190 | startPos: 178 191 | endPos: 217 192 | length: 40 193 | required: false 194 | type: 'alphanumeric' 195 | } 196 | { 197 | field: 'cod_finalidade_doc' 198 | startPos: 218 199 | endPos: 219 200 | length: 2 201 | required: false 202 | type: 'alphanumeric' 203 | } 204 | { 205 | field: 'cod_finalidade_ted' 206 | startPos: 220 207 | endPos: 224 208 | length: 5 209 | required: true 210 | type: 'numeric' 211 | } 212 | { 213 | field: 'cod_finalidade_compl' 214 | startPos: 225 215 | endPos: 226 216 | length: 2 217 | required: false 218 | default: 'CC' 219 | } 220 | { 221 | field: 'cnab' 222 | startPos: 227 223 | endPos: 229 224 | length: 3 225 | required: false 226 | default: new Array(3).fill(' ').join('') 227 | } 228 | { 229 | field: 'aviso' 230 | startPos: 230 231 | endPos: 230 232 | length: 1 233 | required: false 234 | default: '0' 235 | } 236 | { 237 | field: 'codigos_ocorrencias' 238 | startPos: 231 239 | endPos: 240 240 | length: 10 241 | required: false 242 | default: new Array(10).fill(' ').join('') 243 | } 244 | ] 245 | -------------------------------------------------------------------------------- /layout/Bradesco/Pagamento/Pagamento.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 237 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 3 25 | }, 26 | { 27 | field: 'num_seq_registro_lote', 28 | startPos: 9, 29 | endPos: 13, 30 | length: 5, 31 | required: true, 32 | type: 'numeric' 33 | }, 34 | { 35 | field: 'cod_seg_registro_lote', 36 | startPos: 14, 37 | endPos: 14, 38 | length: 1, 39 | required: true, 40 | default: 'A', 41 | type: 'alphanumeric' 42 | }, 43 | { 44 | field: 'movimento_tipo', 45 | startPos: 15, 46 | endPos: 15, 47 | length: 1, 48 | required: true, 49 | type: 'numeric', 50 | default: 0 51 | }, 52 | { 53 | field: 'movimento_cod', 54 | startPos: 16, 55 | endPos: 17, 56 | length: 2, 57 | required: true, 58 | type: 'numeric' 59 | }, 60 | { 61 | field: 'cod_camara', 62 | startPos: 18, 63 | endPos: 20, 64 | length: 3, 65 | required: true, 66 | type: 'numeric' 67 | }, 68 | { 69 | field: 'favorecido_cod_banco', 70 | startPos: 21, 71 | endPos: 23, 72 | length: 3, 73 | required: true, 74 | default: 237 75 | }, 76 | { 77 | field: 'favorecido_agencia', 78 | startPos: 24, 79 | endPos: 28, 80 | length: 5, 81 | required: true, 82 | type: 'numeric' 83 | }, 84 | { 85 | field: 'favorecido_dig_agencia', 86 | startPos: 29, 87 | endPos: 29, 88 | length: 1, 89 | required: false, 90 | type: 'numeric' 91 | }, 92 | { 93 | field: 'favorecido_num_conta', 94 | startPos: 30, 95 | endPos: 41, 96 | length: 12, 97 | required: true, 98 | type: 'numeric' 99 | }, 100 | { 101 | field: 'favorecido_dig_verificador', 102 | startPos: 42, 103 | endPos: 42, 104 | length: 1, 105 | required: true, 106 | type: 'alphanumeric' 107 | }, 108 | { 109 | field: 'ag_conta_digito_verificador', 110 | startPos: 43, 111 | endPos: 43, 112 | length: 1, 113 | required: false, 114 | default: ' ' 115 | }, 116 | { 117 | field: 'favorecido_nome', 118 | startPos: 44, 119 | endPos: 73, 120 | length: 30, 121 | required: true, 122 | type: 'alphanumeric' 123 | }, 124 | { 125 | field: 'doc_empresa', 126 | startPos: 74, 127 | endPos: 93, 128 | length: 20, 129 | required: true, 130 | type: 'date' 131 | }, 132 | { 133 | field: 'data_pagamento', 134 | startPos: 94, 135 | endPos: 101, 136 | length: 8, 137 | required: false, 138 | type: 'numeric' 139 | }, 140 | { 141 | field: 'tipo_moeda', 142 | startPos: 102, 143 | endPos: 104, 144 | length: 3, 145 | required: false, 146 | default: 'BRL' 147 | }, 148 | { 149 | field: 'qtde_moeda', 150 | startPos: 105, 151 | endPos: 119, 152 | length: 15, 153 | required: false, 154 | type: 'numeric' 155 | }, 156 | { 157 | field: 'valor_pagamento', 158 | startPos: 120, 159 | endPos: 134, 160 | length: 15, 161 | required: false, 162 | type: 'numeric' 163 | }, 164 | { 165 | field: 'num_doc_atribuido_banco', 166 | startPos: 135, 167 | endPos: 154, 168 | length: 20, 169 | required: false, 170 | type: 'alphanumeric' 171 | }, 172 | { 173 | field: 'data_real_efetivacao_pgto', 174 | startPos: 155, 175 | endPos: 162, 176 | length: 8, 177 | required: false, 178 | type: 'numeric' 179 | }, 180 | { 181 | field: 'valor_real_efetivacao_pgto', 182 | startPos: 163, 183 | endPos: 177, 184 | length: 15, 185 | required: false, 186 | type: 'numeric' 187 | }, 188 | { 189 | field: 'info2', 190 | startPos: 178, 191 | endPos: 217, 192 | length: 40, 193 | required: false, 194 | type: 'alphanumeric' 195 | }, 196 | { 197 | field: 'cod_finalidade_doc', 198 | startPos: 218, 199 | endPos: 219, 200 | length: 2, 201 | required: false, 202 | type: 'alphanumeric' 203 | }, 204 | { 205 | field: 'cod_finalidade_ted', 206 | startPos: 220, 207 | endPos: 224, 208 | length: 5, 209 | required: true, 210 | type: 'numeric' 211 | }, 212 | { 213 | field: 'cod_finalidade_compl', 214 | startPos: 225, 215 | endPos: 226, 216 | length: 2, 217 | required: false, 218 | default: 'CC' 219 | }, 220 | { 221 | field: 'cnab', 222 | startPos: 227, 223 | endPos: 229, 224 | length: 3, 225 | required: false, 226 | default: new Array(3).fill(' ').join('') 227 | }, 228 | { 229 | field: 'aviso', 230 | startPos: 230, 231 | endPos: 230, 232 | length: 1, 233 | required: false, 234 | default: '0' 235 | }, 236 | { 237 | field: 'codigos_ocorrencias', 238 | startPos: 231, 239 | endPos: 240, 240 | length: 10, 241 | required: false, 242 | default: new Array(10).fill(' ').join('') 243 | } 244 | ]; 245 | -------------------------------------------------------------------------------- /coffee/layout/HSBC/Pagamento/Pagamento.coffee: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco' 4 | startPos: 1 5 | endPos: 3 6 | length: 3 7 | required: true 8 | default: 399 9 | } 10 | { 11 | field: 'lote' 12 | startPos: 4 13 | endPos: 7 14 | length: 4 15 | required: true 16 | default: '0000' 17 | } 18 | { 19 | field: 'registro' 20 | startPos: 8 21 | endPos: 8 22 | length: 1 23 | required: true 24 | default: 3 25 | } 26 | { 27 | field: 'num_seq_registro_lote' 28 | startPos: 9 29 | endPos: 13 30 | length: 5 31 | required: true 32 | type: 'numeric' 33 | } 34 | { 35 | field: 'cod_seg_registro_lote' 36 | startPos: 14 37 | endPos: 14 38 | length: 1 39 | required: true 40 | default: 'A' 41 | type: 'alphanumeric' 42 | } 43 | { 44 | field: 'movimento_tipo' 45 | startPos: 15 46 | endPos: 15 47 | length: 1 48 | required: true 49 | type: 'numeric' 50 | } 51 | { 52 | field: 'movimento_cod' 53 | startPos: 16 54 | endPos: 17 55 | length: 2 56 | required: true 57 | type: 'numeric' 58 | } 59 | { 60 | field: 'cod_camara' 61 | startPos: 18 62 | endPos: 20 63 | length: 3 64 | required: true 65 | type: 'numeric' 66 | } 67 | { 68 | field: 'favorecido_cod_banco' 69 | startPos: 21 70 | endPos: 23 71 | length: 3 72 | required: true 73 | type: 'numeric' 74 | } 75 | { 76 | field: 'favorecido_agencia' 77 | startPos: 24 78 | endPos: 28 79 | length: 5 80 | required: true 81 | type: 'numeric' 82 | } 83 | { 84 | field: 'filler' 85 | startPos: 29 86 | endPos: 29 87 | length: 1 88 | required: false 89 | default: ' ' 90 | } 91 | { 92 | field: 'favorecido_num_conta' 93 | startPos: 30 94 | endPos: 41 95 | length: 12 96 | required: true 97 | type: 'numeric' 98 | } 99 | { 100 | field: 'favorecido_dig_verificador' 101 | startPos: 42 102 | endPos: 42 103 | length: 1 104 | required: true 105 | type: 'alphanumeric' 106 | } 107 | { 108 | field: 'filler' 109 | startPos: 43 110 | endPos: 43 111 | length: 1 112 | required: false 113 | default: ' ' 114 | } 115 | { 116 | field: 'favorecido_nome' 117 | startPos: 44 118 | endPos: 73 119 | length: 30 120 | required: true 121 | type: 'alphanumeric' 122 | } 123 | { 124 | field: 'doc_num' 125 | startPos: 74 126 | endPos: 89 127 | length: 16 128 | required: true 129 | type: 'alphanumeric' 130 | } 131 | { 132 | field: 'filler' 133 | startPos: 90 134 | endPos: 93 135 | length: 4 136 | required: false 137 | default: new Array(4).fill(' ').join('') 138 | } 139 | { 140 | field: 'data_lcto_credito' 141 | startPos: 94 142 | endPos: 101 143 | length: 8 144 | required: true 145 | type: 'date' 146 | } 147 | { 148 | field: 'tipo_moeda' 149 | startPos: 102 150 | endPos: 104 151 | length: 3 152 | required: true 153 | default: 'R$ ' 154 | type: 'alphanumeric' 155 | } 156 | { 157 | field: 'filler' 158 | startPos: 105 159 | endPos: 121 160 | length: 17 161 | required: false 162 | default: new Array(17).fill(' ').join('') 163 | } 164 | { 165 | field: 'valor_lcto' 166 | startPos: 122 167 | endPos: 134 168 | length: 13 169 | required: true 170 | type: 'numeric' 171 | } 172 | { 173 | field: 'comprovante_pgto' 174 | startPos: 135 175 | endPos: 135 176 | length: 1 177 | required: false 178 | type: 'alphanumeric' 179 | } 180 | { 181 | field: 'pagador_efetivo' 182 | startPos: 136 183 | endPos: 165 184 | length: 30 185 | required: false 186 | type: 'alphanumeric' 187 | } 188 | { 189 | field: 'filler' 190 | startPos: 166 191 | endPos: 177 192 | length: 12 193 | required: false 194 | default: new Array(12).fill(' ').join('') 195 | } 196 | { 197 | field: 'info2' 198 | startPos: 178 199 | endPos: 217 200 | length: 40 201 | required: false 202 | type: 'alphanumeric' 203 | } 204 | { 205 | field: 'cod_finalidade_doc' 206 | startPos: 218 207 | endPos: 219 208 | length: 2 209 | required: false 210 | type: 'alphanumeric' 211 | } 212 | { 213 | field: 'cod_finalidade_ted' 214 | startPos: 220 215 | endPos: 224 216 | length: 5 217 | required: false 218 | type: 'alphanumeric' 219 | } 220 | { 221 | field: 'cod_finalidade_compl' 222 | startPos: 225 223 | endPos: 226 224 | length: 2 225 | required: false 226 | type: 'alphanumeric' 227 | } 228 | { 229 | field: 'cnab' 230 | startPos: 227 231 | endPos: 229 232 | length: 3 233 | required: false 234 | default: new Array(3).fill(' ').join('') 235 | } 236 | { 237 | field: 'aviso' 238 | startPos: 230 239 | endPos: 230 240 | length: 1 241 | required: false 242 | type: 'alphanumeric' 243 | } 244 | { 245 | field: 'filler' 246 | startPos: 231 247 | endPos: 240 248 | length: 10 249 | required: false 250 | default: new Array(10).fill(' ').join('') 251 | } 252 | ] -------------------------------------------------------------------------------- /layout/HSBC/Pagamento/Pagamento.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | field: 'banco', 4 | startPos: 1, 5 | endPos: 3, 6 | length: 3, 7 | required: true, 8 | default: 399 9 | }, 10 | { 11 | field: 'lote', 12 | startPos: 4, 13 | endPos: 7, 14 | length: 4, 15 | required: true, 16 | default: '0000' 17 | }, 18 | { 19 | field: 'registro', 20 | startPos: 8, 21 | endPos: 8, 22 | length: 1, 23 | required: true, 24 | default: 3 25 | }, 26 | { 27 | field: 'num_seq_registro_lote', 28 | startPos: 9, 29 | endPos: 13, 30 | length: 5, 31 | required: true, 32 | type: 'numeric' 33 | }, 34 | { 35 | field: 'cod_seg_registro_lote', 36 | startPos: 14, 37 | endPos: 14, 38 | length: 1, 39 | required: true, 40 | default: 'A', 41 | type: 'alphanumeric' 42 | }, 43 | { 44 | field: 'movimento_tipo', 45 | startPos: 15, 46 | endPos: 15, 47 | length: 1, 48 | required: true, 49 | type: 'numeric' 50 | }, 51 | { 52 | field: 'movimento_cod', 53 | startPos: 16, 54 | endPos: 17, 55 | length: 2, 56 | required: true, 57 | type: 'numeric' 58 | }, 59 | { 60 | field: 'cod_camara', 61 | startPos: 18, 62 | endPos: 20, 63 | length: 3, 64 | required: true, 65 | type: 'numeric' 66 | }, 67 | { 68 | field: 'favorecido_cod_banco', 69 | startPos: 21, 70 | endPos: 23, 71 | length: 3, 72 | required: true, 73 | type: 'numeric' 74 | }, 75 | { 76 | field: 'favorecido_agencia', 77 | startPos: 24, 78 | endPos: 28, 79 | length: 5, 80 | required: true, 81 | type: 'numeric' 82 | }, 83 | { 84 | field: 'filler', 85 | startPos: 29, 86 | endPos: 29, 87 | length: 1, 88 | required: false, 89 | default: ' ' 90 | }, 91 | { 92 | field: 'favorecido_num_conta', 93 | startPos: 30, 94 | endPos: 41, 95 | length: 12, 96 | required: true, 97 | type: 'numeric' 98 | }, 99 | { 100 | field: 'favorecido_dig_verificador', 101 | startPos: 42, 102 | endPos: 42, 103 | length: 1, 104 | required: true, 105 | type: 'alphanumeric' 106 | }, 107 | { 108 | field: 'filler', 109 | startPos: 43, 110 | endPos: 43, 111 | length: 1, 112 | required: false, 113 | default: ' ' 114 | }, 115 | { 116 | field: 'favorecido_nome', 117 | startPos: 44, 118 | endPos: 73, 119 | length: 30, 120 | required: true, 121 | type: 'alphanumeric' 122 | }, 123 | { 124 | field: 'doc_num', 125 | startPos: 74, 126 | endPos: 89, 127 | length: 16, 128 | required: true, 129 | type: 'alphanumeric' 130 | }, 131 | { 132 | field: 'filler', 133 | startPos: 90, 134 | endPos: 93, 135 | length: 4, 136 | required: false, 137 | default: new Array(4).fill(' ').join('') 138 | }, 139 | { 140 | field: 'data_lcto_credito', 141 | startPos: 94, 142 | endPos: 101, 143 | length: 8, 144 | required: true, 145 | type: 'date' 146 | }, 147 | { 148 | field: 'tipo_moeda', 149 | startPos: 102, 150 | endPos: 104, 151 | length: 3, 152 | required: true, 153 | default: 'R$ ', 154 | type: 'alphanumeric' 155 | }, 156 | { 157 | field: 'filler', 158 | startPos: 105, 159 | endPos: 121, 160 | length: 17, 161 | required: false, 162 | default: new Array(17).fill(' ').join('') 163 | }, 164 | { 165 | field: 'valor_lcto', 166 | startPos: 122, 167 | endPos: 134, 168 | length: 13, 169 | required: true, 170 | type: 'numeric' 171 | }, 172 | { 173 | field: 'comprovante_pgto', 174 | startPos: 135, 175 | endPos: 135, 176 | length: 1, 177 | required: false, 178 | type: 'alphanumeric' 179 | }, 180 | { 181 | field: 'pagador_efetivo', 182 | startPos: 136, 183 | endPos: 165, 184 | length: 30, 185 | required: false, 186 | type: 'alphanumeric' 187 | }, 188 | { 189 | field: 'filler', 190 | startPos: 166, 191 | endPos: 177, 192 | length: 12, 193 | required: false, 194 | default: new Array(12).fill(' ').join('') 195 | }, 196 | { 197 | field: 'info2', 198 | startPos: 178, 199 | endPos: 217, 200 | length: 40, 201 | required: false, 202 | type: 'alphanumeric' 203 | }, 204 | { 205 | field: 'cod_finalidade_doc', 206 | startPos: 218, 207 | endPos: 219, 208 | length: 2, 209 | required: false, 210 | type: 'alphanumeric' 211 | }, 212 | { 213 | field: 'cod_finalidade_ted', 214 | startPos: 220, 215 | endPos: 224, 216 | length: 5, 217 | required: false, 218 | type: 'alphanumeric' 219 | }, 220 | { 221 | field: 'cod_finalidade_compl', 222 | startPos: 225, 223 | endPos: 226, 224 | length: 2, 225 | required: false, 226 | type: 'alphanumeric' 227 | }, 228 | { 229 | field: 'cnab', 230 | startPos: 227, 231 | endPos: 229, 232 | length: 3, 233 | required: false, 234 | default: new Array(3).fill(' ').join('') 235 | }, 236 | { 237 | field: 'aviso', 238 | startPos: 230, 239 | endPos: 230, 240 | length: 1, 241 | required: false, 242 | type: 'alphanumeric' 243 | }, 244 | { 245 | field: 'filler', 246 | startPos: 231, 247 | endPos: 240, 248 | length: 10, 249 | required: false, 250 | default: new Array(10).fill(' ').join('') 251 | } 252 | ]; -------------------------------------------------------------------------------- /cnab/src/Retorno.js: -------------------------------------------------------------------------------- 1 | /* 2 | * decaffeinate suggestions: 3 | * DS102: Remove unnecessary code created because of implicit returns 4 | * DS206: Consider reworking classes to avoid initClass 5 | * DS207: Consider shorter variations of null checks 6 | * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md 7 | */ 8 | const _ = require('lodash'); 9 | const expect = require('expect.js'); 10 | const rules = require('../../layout/Rules'); 11 | 12 | var Retorno = (function() { 13 | let FILE_HEADER = undefined; 14 | let FILE_TRAILING = undefined; 15 | let LOT_HEADER = undefined; 16 | let LOT_TRAILING = undefined; 17 | let DETAIL = undefined; 18 | let DETAIL2 = undefined; 19 | let FILE_SECTIONS = undefined; 20 | Retorno = class Retorno { 21 | static initClass() { 22 | 23 | /* 24 | JSON ouput structure: 25 | 26 | ArquivoHeader: {} 27 | lots: [ 28 | { 29 | LoteHeader: {} 30 | details: [ 31 | [ 32 | { 33 | Segment1: {} 34 | Segment2: {} 35 | } 36 | ] 37 | [ 38 | { 39 | Segment1: {} 40 | Segment2: {} 41 | } 42 | ] 43 | ] 44 | LoteTrailing: {} 45 | } 46 | ] 47 | ArquivoTrailing: {} 48 | 49 | */ 50 | 51 | FILE_HEADER = 'ArquivoHeader'; 52 | FILE_TRAILING = 'ArquivoTrailing'; 53 | LOT_HEADER = 'LoteHeader'; 54 | LOT_TRAILING = 'LoteTrailing'; 55 | DETAIL = 'Detail'; 56 | DETAIL2 = 'Detail2'; 57 | 58 | FILE_SECTIONS = { 59 | FILE_HEADER: '0', 60 | LOT_HEADER: '1', 61 | // DETAIL: 'A', 62 | DETAIL: 'E', 63 | LOT_TRAILING: '5', 64 | FILE_TRAILING: '9' 65 | }; 66 | } 67 | 68 | constructor(bank, type) { 69 | if (bank == null) { throw new Error('Bank is mandatory'); } 70 | if (type == null) { throw new Error('Type is mandatory'); } 71 | this.type = type 72 | this.rules = { 73 | ArquivoHeader: rules[bank].ArquivoHeader, 74 | ArquivoTrailing: rules[bank].ArquivoTrailing, 75 | LoteHeader: (rules[bank][type] != null ? rules[bank][type].LoteHeader : undefined), 76 | LoteTrailing: (rules[bank][type] != null ? rules[bank][type].LoteTrailing : undefined), 77 | Detail: (rules[bank][type] != null ? rules[bank][type].Detail : undefined), 78 | Detail2: (rules[bank][type] != null ? rules[bank][type].Detail2 : undefined) 79 | }; 80 | this.CONSTANTS = rules[bank][type] != null ? rules[bank][type].Constants : undefined; 81 | } 82 | 83 | extractSingleField(line, rule) { 84 | return (line != null ? line.split('').slice(rule.startPos-1, rule.endPos).join('') : undefined); 85 | } 86 | 87 | // this method mutates {lines} 88 | extractSection(lines, sectionName, sectionCode) { 89 | const registryRule = _.find(this.rules[sectionName], {field: this.CONSTANTS[sectionName].REGISTRY_FIELD}); 90 | const line = _.filter(lines, line => (line != null ? line.split('').slice(registryRule.startPos-1, registryRule.endPos).join('') : undefined) === sectionCode); 91 | _.pull(lines, line[0]); 92 | return line[0]; 93 | } 94 | 95 | extractBulk(lines, rule, condition) { 96 | return _.reduce(lines, (memo, line) => { 97 | const currentPos = memo.length === 0 ? 0 : memo.length - 1; 98 | if (this.extractSingleField(line, rule) === condition) { 99 | memo.push([]); 100 | memo[memo.length - 1].push(line); 101 | } else { 102 | if (memo[currentPos] != null) { 103 | memo[currentPos].push(line); 104 | } 105 | } 106 | return memo; 107 | } 108 | , []); 109 | } 110 | 111 | numberOf(fileTrailingLine, sectionName, registryField) { 112 | const lotNumRule = _.find(this.rules[sectionName], {field: registryField}); 113 | return parseInt(this.extractSingleField(fileTrailingLine, lotNumRule) || 0); 114 | } 115 | 116 | extractFields(line, sectionName) { 117 | const localRules = this.rules[sectionName]; 118 | return _.reduce(localRules, (extracted, rule) => { 119 | extracted[`${rule.field}`] = this.extractSingleField(line, rule); 120 | return extracted; 121 | } 122 | , {}); 123 | } 124 | 125 | extractSegments(detailLines) { 126 | const detailSegmentCodeRule = _.find(this.rules.Detail, {field: 'cod_seg_registro_lote'}); 127 | return _.reduce(detailLines, (memo, detailLine) => { 128 | const segmentCode = this.extractSingleField(detailLine, detailSegmentCodeRule); 129 | memo.push(this.extractFields(detailLine, this.CONSTANTS.Segmentos[segmentCode])); 130 | return memo; 131 | } 132 | , []); 133 | } 134 | 135 | extractDetails(lotLines) { 136 | const lotHeaderLine = this.extractSection(lotLines, LOT_HEADER, FILE_SECTIONS.LOT_HEADER); 137 | const lotTrailingLine = this.extractSection(lotLines, LOT_TRAILING, FILE_SECTIONS.LOT_TRAILING); 138 | const detailsBulks = this.extractBulk(lotLines, _.find(this.rules.Detail, {field: this.CONSTANTS[this.type].REGISTRY_FIELD}), this.CONSTANTS.Detail); 139 | const detailsWithSegments = _.map(detailsBulks, this.extractSegments.bind(this)); 140 | return { 141 | [LOT_HEADER]: this.extractFields(lotHeaderLine, LOT_HEADER), 142 | details: detailsWithSegments, 143 | [LOT_TRAILING]: this.extractFields(lotTrailingLine, LOT_TRAILING) 144 | }; 145 | } 146 | 147 | extract(fileString) { 148 | // console.log fileString 149 | // sanitizedFileString = _.replace fileString, '\r\n', '\n' 150 | // console.log sanitizedFileString 151 | // lines = _.compact(sanitizedFileString.split '\n') 152 | // console.log lines 153 | const lines = _.compact(fileString.split('\n')); 154 | 155 | const fileHeaderLine = this.extractSection(lines, FILE_HEADER, FILE_SECTIONS.FILE_HEADER); 156 | const fileTrailingLine = this.extractSection(lines, FILE_TRAILING, FILE_SECTIONS.FILE_TRAILING); 157 | 158 | const lots = this.extractBulk(lines, _.find(this.rules.LoteHeader, {field: this.CONSTANTS.LoteHeader.REGISTRY_FIELD}), FILE_SECTIONS.LOT_HEADER); 159 | 160 | const lotsWithSegments = _.map(lots, this.extractDetails.bind(this)); 161 | 162 | return { 163 | [FILE_HEADER]: this.extractFields(fileHeaderLine, FILE_HEADER), 164 | lots: lotsWithSegments, 165 | [FILE_TRAILING]: this.extractFields(fileTrailingLine, FILE_TRAILING) 166 | }; 167 | } 168 | }; 169 | Retorno.initClass(); 170 | return Retorno; 171 | })(); 172 | 173 | module.exports = Retorno; 174 | -------------------------------------------------------------------------------- /cnab/src/Remessa.js: -------------------------------------------------------------------------------- 1 | /* 2 | * decaffeinate suggestions: 3 | * DS102: Remove unnecessary code created because of implicit returns 4 | * DS103: Rewrite code to no longer use __guard__ 5 | * DS206: Consider reworking classes to avoid initClass 6 | * DS207: Consider shorter variations of null checks 7 | * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md 8 | */ 9 | const Rules = require('../../layout/Rules'); 10 | const Utils = require('./Utils'); 11 | const Joi = require('joi'); 12 | const expect = require('expect.js'); 13 | const _ = require('lodash'); 14 | const removeAccents = require('remove-accents'); 15 | 16 | var Remessa = (function() { 17 | let FILE_HEADER = undefined; 18 | let FILE_TRAILING = undefined; 19 | let LOT_HEADER = undefined; 20 | let LOT_TRAILING = undefined; 21 | let DETAIL = undefined; 22 | let DETAIL2 = undefined; 23 | let FILE_SECTIONS = undefined; 24 | Remessa = class Remessa { 25 | static initClass() { 26 | 27 | FILE_HEADER = 'ArquivoHeader'; 28 | FILE_TRAILING = 'ArquivoTrailing'; 29 | LOT_HEADER = 'LoteHeader'; 30 | LOT_TRAILING = 'LoteTrailing'; 31 | DETAIL = 'Detail'; 32 | DETAIL2 = 'Detail2'; 33 | FILE_SECTIONS = [FILE_HEADER, LOT_HEADER, DETAIL, DETAIL2, LOT_TRAILING, FILE_TRAILING]; 34 | } 35 | 36 | constructor(bank, type, deps) { 37 | const rules = (deps != null ? deps.Rules : undefined) || Rules; 38 | if (bank == null) { throw new Error('Bank is mandatory'); } 39 | if (type == null) { throw new Error('Type is mandatory'); } 40 | this.rules = { 41 | ArquivoHeader: rules[bank].ArquivoHeader, 42 | ArquivoTrailing: rules[bank].ArquivoTrailing, 43 | LoteHeader: (rules[bank][type] != null ? rules[bank][type].LoteHeader : undefined), 44 | LoteTrailing: (rules[bank][type] != null ? rules[bank][type].LoteTrailing : undefined), 45 | Detail: (rules[bank][type] != null ? rules[bank][type].Detail : undefined), 46 | Detail2: (rules[bank][type] != null ? rules[bank][type].Detail2 : undefined) 47 | }; 48 | this.CONSTANTS = rules[bank][type] != null ? rules[bank][type].Constants : undefined; 49 | } 50 | 51 | // TODO: add data, enum and range validations 52 | validateLenghts(rulesName, userValues) { 53 | if (rulesName == null) { throw new Error('RulesName is mandatory'); } 54 | if (userValues == null) { throw new Error('UserValues is mandatory'); } 55 | const rules = _.reduce(this.rules[rulesName], function(rules, fieldConfig) { 56 | let rule = Joi.string().max(fieldConfig.length); 57 | if (fieldConfig.required && (fieldConfig.default == null)) { rule = rule.required(); } 58 | rules[fieldConfig.field] = rule; 59 | return rules; 60 | } 61 | , {}); 62 | rules.section = Joi.string().optional(); 63 | 64 | const validation = __guard__(__guard__(__guard__((Joi.validate(userValues, Joi.object(rules), {abortEarly: false})), x2 => x2.error), x1 => x1.details), x => x.map(error => error.message)); 65 | if (!_.isEmpty(validation)) { throw new Error(validation); } 66 | return _.each(_.filter(this.rules[rulesName], 'default'), function(config) { 67 | if (config.default.toString().length !== config.length) { 68 | throw new Error(`${rulesName}.${config.field} length must be less than or equal to ${config.length} characters long`); 69 | } 70 | }); 71 | } 72 | 73 | prepare(rulesName, validated) { 74 | let value; 75 | const utils = new Utils; 76 | const rules = _.cloneDeep(this.rules[rulesName]); 77 | for (let key in validated) { 78 | value = validated[key]; 79 | const fieldConfig = _.find(rules, {field: key}); 80 | if (fieldConfig != null) { 81 | fieldConfig.value = value; 82 | } 83 | } 84 | 85 | // formats all fields to match the required length 86 | return _.map(rules, function(item) { 87 | // we consider that the default values already have the correct length 88 | if ((item.default != null) && (item.value == null)) { return item; } 89 | // if there's no value (eg, non-required field with no default value) 90 | if (item.value == null) { 91 | const meaninglessChar = item.type === 'alphanumeric' ? ' ' : '0'; 92 | item.value = new Array(item.length).fill(meaninglessChar).join(''); 93 | } 94 | // for now, when the field doesn't have a type, it defaults to numeric 95 | item.value = (item.type != null) && (item.type === 'alphanumeric') ? utils.padString(item) : utils.padNumber(item); 96 | return item; 97 | }); 98 | } 99 | 100 | // inserts the params into the 240b string, filling gaps where no values are passed 101 | build(prepared) { 102 | const base = Array(240); 103 | _.map(prepared, function(fieldConfig) { 104 | const fieldValue = (fieldConfig.value != null ? fieldConfig.value.toString() : undefined) || (fieldConfig.default != null ? fieldConfig.default.toString() : undefined); 105 | const args = [fieldConfig.startPos, fieldConfig.length].concat(fieldValue.toString().split('')); 106 | return base.splice.apply(base, args).join(''); 107 | }); 108 | base.shift(); 109 | // console.log 'Checking section size on build' 110 | // expect(base.length).to.be 240 111 | return base.join(''); 112 | } 113 | 114 | process(userValues, fileSections, newLine) { 115 | if (newLine == null) { newLine = '\n'; } 116 | if (FILE_SECTIONS == null) { FILE_SECTIONS = fileSections; } 117 | // let's test if all required file sections were given 118 | const missingKeys = _.difference(FILE_SECTIONS, _.keys(userValues)); 119 | if (!_.isEmpty(missingKeys)) { throw Error(`Missing file sections: ${missingKeys.join(', ')}`); } 120 | 121 | // now we'll put the section key into each values object... 122 | const valuesArr =_.map(FILE_SECTIONS, function(section) { 123 | // the detail section could have several items 124 | if ((section === DETAIL) && _.isArray(userValues[section])) { 125 | return _.map(userValues[section], function(subsection) { 126 | subsection[0].section = section; 127 | return subsection; 128 | }); 129 | } else { 130 | userValues[section].section = section; 131 | return userValues[section]; 132 | } 133 | }); 134 | //... and then flatten the array 135 | const sections = _.flattenDeep(valuesArr); 136 | // process'em all! 137 | const remessa = _.map(sections, section => { 138 | const sectionKey = section.section; 139 | const sectionValues = _.omit(section, 'section'); 140 | this.validateLenghts(sectionKey, sectionValues); 141 | return this.build(this.prepare(sectionKey, sectionValues)); 142 | }); 143 | return removeAccents(remessa.join(newLine) + newLine); 144 | } 145 | }; 146 | Remessa.initClass(); 147 | return Remessa; 148 | })(); 149 | 150 | module.exports = Remessa; 151 | 152 | function __guard__(value, transform) { 153 | return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined; 154 | } -------------------------------------------------------------------------------- /coffee/layout/Bradesco/Pagamento/Constants.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | ArquivoHeader: 3 | REGISTRY_FIELD: 'registro' 4 | ARQUIVO_COD: 5 | REMESSA: '1' 6 | RETORNO: '2' 7 | TIPO_INSC_EMPRESA: 8 | ISENTO: '0' 9 | CPF: '1' 10 | CNPJ: '2' 11 | PIS_PASEP: '3' 12 | OUTRO: '9' 13 | ArquivoTrailing: 14 | TOTAL_LOTES_FIELD: 'qtde_lotes' 15 | REGISTRY_FIELD: 'registro' 16 | LoteHeader: 17 | REGISTRY_FIELD: 'registro' 18 | TIPO_SERVICO: 19 | COBRANCA: '01' 20 | BLOQUETO_ELETRONICO: '03' 21 | CONCILIACAO_BANCARIA: '04' 22 | DEBITOS: '05' 23 | CUSTODIA_CHEQUES: '06' 24 | GESTAO_CAIXA: '07' 25 | CONSULTA_MARGEM: '08' 26 | AVERBACAO_CONSIGNACAO: '09' 27 | PAGAMENTO_DIVIDENDOS: '10' 28 | MANUTENCAO_CONSIGNACAO: '11' 29 | CONSIGNACAO_PARCELAS: '12' 30 | GLOSA_CONSIGNACAO: '13' 31 | CONSULTA_TRIBUTOS_PAGAR: '14' 32 | PAGAMENTO_FORNECEDORES: '20' 33 | PAGAMENTO_CONTAS: '22' 34 | COMPROR: '25' 35 | COMPROR_ROTATIVO: '26' 36 | ALEGACAO_SACADO: '29' 37 | PAGAMENTO_SALARIOS: '30' 38 | PAGAMENTO_HONORARIOS: '32' 39 | PAGAMENTO_BOLSA_AUXILIO: '33' 40 | PAGAMNETO_PREBENDA: '34' 41 | VENDOR: '40' 42 | VENDOR_TERMO: '41' 43 | PAGAMENTO_SINISTROS: '50' 44 | PAGAMENTO_DESPESAS_VIAJANTE: '60' 45 | PAGAMENTO_AUTORIZADO: '70' 46 | PAGAMENTO_CREDENCIADOS: '75' 47 | PAGAMENTO_REMUNERACAO: '77' 48 | PAGAMENTO_REPRESENTANTES: '80' 49 | PAGAMENTO_BENEFICIOS: '90' 50 | PAGAMENTOS_DIVERSOS: '98' 51 | EXCLUSIVO_BRADESCO: '99' 52 | FORMA_LANCAMENTO: 53 | CREDITO_CC: '01' # transferência para contas do Bradesco 54 | CEDITO_ADM: '02' 55 | DOCTO_CREDITO: '03' # DOC/TED 56 | CARTAO_SALARIO: '04' # Somente para tipo serviço 30 57 | CREDITO_POUPANCA: '05' 58 | OP_DISPOSICAO: '10' 59 | PGTO_CONTAS: '11' 60 | TED_OUTRA_TITULARIDADE: '41' 61 | # ... 99 62 | LoteTrailing: 63 | REGISTRY_FIELD: 'registro' 64 | Pagamento: 65 | REGISTRY_FIELD: 'cod_seg_registro_lote' 66 | TIPO_MOVIMENTO: # tipo de movimento a que o detalhe se destina 67 | INCLUSAO: 0 68 | CONSULTA: 1 69 | ESTORNO: 3 70 | ALTERACAO: 5 71 | LIQUIDACAO: 7 72 | EXCLUSAO: 9 73 | CODIGO_MOVIMENTO: # indica a movimentação a ser efetuada 74 | INCLUSAO: '00' # inclusão com registro detalhe 75 | INCLUSAO_COM_BLOQUEIO: '09' # inclusão com bloqueio 76 | COD_CAMARA_CENTRALIZADORA: 77 | TED: '18' 78 | DOC: '700' 79 | SegmentoInicial: 'A' 80 | Segmentos: 81 | A: 'Detail' 82 | B: 'Detail2' 83 | C: false 84 | '5': false 85 | CodigosOcorrencias: 86 | '00': 'Crédito ou Débito Efetivado' 87 | '01': 'Insuficiência de Fundos - Débito Não Efetuado' 88 | '02': 'Crédito ou Débito Cancelado pelo Pagador/Credor' 89 | '03': 'Débito Autorizado pela Agência - Efetuado' 90 | AA: 'Controle Inválido' 91 | AB: 'Tipo de Operação Inválido' 92 | AC: 'Tipo de Serviço Inválido' 93 | AD: 'Forma de Lançamento Inválida' 94 | AE: 'Tipo/Número de Inscrição Inválido' 95 | AF: 'Código de Convênio Inválido' 96 | AG: 'Agência/Conta Corrente/DV Inválido' 97 | AH: 'Nº Sequencial do Registro no Lote Inválido' 98 | AI: 'Código de Segmento de Detalhe Inválido' 99 | AJ: 'Tipo de Movimento Inválido' 100 | AK: 'Código da Câmara de Compensação do Banco Favorecido/Depositário Inválido' 101 | AL: 'Código do Banco Favorecido ou Depositário Inválido' 102 | AM: 'Agência Mantenedora da Conta Corrente do Favorecido Inválida' 103 | AN: 'Conta Corrente/DV do Favorecido Inválido' 104 | AO: 'Nome do Favorecido Não Informado' 105 | AP: 'Data Lançamento Inválido' 106 | AQ: 'Tipo/Quantidade da Moeda Inválido' 107 | AR: 'Valor do Lançamento Inválido' 108 | AS: 'Aviso ao Favorecido - Identificação Inválida' 109 | AT: 'Tipo/Número de Inscrição do Favorecido Inválido' 110 | AU: 'Logradouro do Favorecido Não Informado' 111 | AV: 'Nº do Local do Favorecido Não Informado' 112 | AW: 'Cidade do Favorecido Não Informada' 113 | AX: 'CEP/Complemento do Favorecido Inválido' 114 | AY: 'Sigla do Estado do Favorecido Inválida' 115 | AZ: 'Código/Nome do Banco Depositário Inválido' 116 | BA: 'Código/Nome da Agência Depositária Não Informado' 117 | BB: 'Seu Número Inválido' 118 | BC: 'Nosso Número Inválido' 119 | BD: 'Inclusão Efetuada com Sucesso' 120 | BE: 'Alteração Efetuada com Sucesso' 121 | BF: 'Exclusão Efetuada com Sucesso' 122 | BG: 'Agência/Conta Impedida Legalmente' 123 | BH: 'Empresa não pagou salário' 124 | BI: 'Falecimento do mutuário' 125 | BJ: 'Empresa não enviou remessa do mutuário' 126 | BK: 'Empresa não enviou remessa no vencimento' 127 | BL: 'Valor da parcela inválida' 128 | BM: 'Identificação do contrato inválida' 129 | BN: 'Operação de Consignação Incluída com Sucesso' 130 | BO: 'Operação de Consignação Alterada com Sucesso' 131 | BP: 'Operação de Consignação Excluída com Sucesso' 132 | BQ: 'Operação de Consignação Liquidada com Sucesso' 133 | CA: 'Código de Barras - Código do Banco Inválido' 134 | CB: 'Código de Barras - Código da Moeda Inválido' 135 | CC: 'Código de Barras - Dígito Verificador Geral Inválido' 136 | CD: 'Código de Barras - Valor do Título Divergente/Inválido' 137 | CE: 'Código de Barras - Campo Livre Inválido' 138 | CF: 'Valor do Documento Inválido' 139 | CG: 'Valor do Abatimento Inválido' 140 | CH: 'Valor do Desconto Inválido' 141 | CI: 'Valor de Mora Inválido' 142 | CJ: 'Valor da Multa Inválido' 143 | CK: 'Valor do IR Inválido' 144 | CL: 'Valor do ISS Inválido' 145 | CM: 'Valor do IOF Inválido' 146 | CN: 'Valor de Outras Deduções Inválido' 147 | CO: 'Valor de Outros Acréscimos Inválido' 148 | CP: 'Valor do INSS Inválido' 149 | HA: 'Lote Não Aceito' 150 | HB: 'Inscrição da Empresa Inválida para o Contrato' 151 | HC: 'Convênio com a Empresa Inexistente/Inválido para o Contrato' 152 | HD: 'Agência/Conta Corrente da Empresa Inexistente/Inválido para o Contrato' 153 | HE: 'Tipo de Serviço Inválido para o Contrato' 154 | HF: 'Conta Corrente da Empresa com Saldo Insuficiente' 155 | HG: 'Lote de Serviço Fora de Sequência' 156 | HH: 'Lote de Serviço Inválido' 157 | HI: 'Arquivo não aceito' 158 | HJ: 'Tipo de Registro Inválido' 159 | HK: 'Código Remessa / Retorno Inválido' 160 | HL: 'Versão de layout inválida' 161 | HM: 'Mutuário não identificado' 162 | HN: 'Tipo do benefício não permite empréstimo' 163 | HO: 'Beneficio cessado/suspenso' 164 | HP: 'Beneficio possui representante legal' 165 | HQ: 'Benefício é do tipo PA (Pensão alimentícia)' 166 | HR: 'Quantidade de contratos permitida excedida' 167 | HS: 'Benefício não pertence ao Banco informado' 168 | HT: 'Início do desconto informado já ultrapassado' 169 | HU: 'Número da parcela inválida' 170 | HV: 'Quantidade de parcela inválida' 171 | HW: 'Margem consignável excedida para o mutuário dentro do prazo do contrato' 172 | HX: 'Empréstimo já cadastrado' 173 | HY: 'Empréstimo inexistente' 174 | HZ: 'Empréstimo já encerrado' 175 | H1: 'Arquivo sem trailer' 176 | H2: 'Mutuário sem crédito na competência' 177 | H3: 'Não descontado – outros motivos' 178 | H4: 'Retorno de Crédito não pago' 179 | H5: 'Cancelamento de empréstimo retroativo' 180 | H6: 'Outros Motivos de Glosa' 181 | H7: 'Margem consignável excedida para o mutuário acima do prazo do contrato' 182 | H8: 'Mutuário desligado do empregador' 183 | H9: 'Mutuário afastado por licença' 184 | IA: 'Primeiro nome do mutuário diferente do primeiro nome do movimento do censo ou diferente da base de Titular do Benefício' 185 | TA: 'Lote Não Aceito - Totais do Lote com Diferença' 186 | YA: 'Título Não Encontrado' 187 | YB: 'Identificador Registro Opcional Inválido' 188 | YC: 'Código Padrão Inválido' 189 | YD: 'Código de Ocorrência Inválido' 190 | YE: 'Complemento de Ocorrência Inválido' 191 | YF: 'Alegação já Informada ' 192 | ZA: 'Agência / Conta do Favorecido Substituída' 193 | ZB: 'Divergência entre o primeiro e último nome do beneficiário versus primeiro e últimonome na Receita Federal' 194 | ZC: 'Confirmação de Antecipação de Valor' 195 | ZD: 'Antecipação Parcial de Valor' 196 | '5A': 'agendado sob lista de debito' 197 | '5B': 'pagamento não autoriza sob lista de debito' 198 | '5C': 'lista com mais de uma modalidade' 199 | '5D': 'lista com mais de uma data de pagamento' 200 | '5E': 'número de lista duplicado' 201 | '5F': 'lista de debito vencida e não autorizada' 202 | '5M': 'número de lista de debito invalida' 203 | ZE: 'Título bloqueado na base' 204 | ZF: 'Sistema em contingência – título valor maior que referência' 205 | ZG: 'Sistema em contingência – título vencido' 206 | ZH: 'Sistema em contingência – título indexado' 207 | ZI: 'Beneficiário divergente' 208 | ZJ: 'Limite de pagamentos parciais excedidos' 209 | ZK: 'Boleto já liquidado' 210 | -------------------------------------------------------------------------------- /layout/Bradesco/Pagamento/Constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ArquivoHeader: { 3 | REGISTRY_FIELD: 'registro', 4 | ARQUIVO_COD: { 5 | REMESSA: '1', 6 | RETORNO: '2' 7 | }, 8 | TIPO_INSC_EMPRESA: { 9 | ISENTO: '0', 10 | CPF: '1', 11 | CNPJ: '2', 12 | PIS_PASEP: '3', 13 | OUTRO: '9' 14 | } 15 | }, 16 | ArquivoTrailing: { 17 | TOTAL_LOTES_FIELD: 'qtde_lotes', 18 | REGISTRY_FIELD: 'registro' 19 | }, 20 | LoteHeader: { 21 | REGISTRY_FIELD: 'registro', 22 | TIPO_SERVICO: { 23 | COBRANCA: '01', 24 | BLOQUETO_ELETRONICO: '03', 25 | CONCILIACAO_BANCARIA: '04', 26 | DEBITOS: '05', 27 | CUSTODIA_CHEQUES: '06', 28 | GESTAO_CAIXA: '07', 29 | CONSULTA_MARGEM: '08', 30 | AVERBACAO_CONSIGNACAO: '09', 31 | PAGAMENTO_DIVIDENDOS: '10', 32 | MANUTENCAO_CONSIGNACAO: '11', 33 | CONSIGNACAO_PARCELAS: '12', 34 | GLOSA_CONSIGNACAO: '13', 35 | CONSULTA_TRIBUTOS_PAGAR: '14', 36 | PAGAMENTO_FORNECEDORES: '20', 37 | PAGAMENTO_CONTAS: '22', 38 | COMPROR: '25', 39 | COMPROR_ROTATIVO: '26', 40 | ALEGACAO_SACADO: '29', 41 | PAGAMENTO_SALARIOS: '30', 42 | PAGAMENTO_HONORARIOS: '32', 43 | PAGAMENTO_BOLSA_AUXILIO: '33', 44 | PAGAMNETO_PREBENDA: '34', 45 | VENDOR: '40', 46 | VENDOR_TERMO: '41', 47 | PAGAMENTO_SINISTROS: '50', 48 | PAGAMENTO_DESPESAS_VIAJANTE: '60', 49 | PAGAMENTO_AUTORIZADO: '70', 50 | PAGAMENTO_CREDENCIADOS: '75', 51 | PAGAMENTO_REMUNERACAO: '77', 52 | PAGAMENTO_REPRESENTANTES: '80', 53 | PAGAMENTO_BENEFICIOS: '90', 54 | PAGAMENTOS_DIVERSOS: '98', 55 | EXCLUSIVO_BRADESCO: '99' 56 | }, 57 | FORMA_LANCAMENTO: { 58 | CREDITO_CC: '01', // transferência para contas do Bradesco 59 | CEDITO_ADM: '02', 60 | DOCTO_CREDITO: '03', // DOC/TED 61 | CARTAO_SALARIO: '04', // Somente para tipo serviço 30 62 | CREDITO_POUPANCA: '05', 63 | OP_DISPOSICAO: '10', 64 | PGTO_CONTAS: '11', 65 | TED_OUTRA_TITULARIDADE: '41' 66 | } 67 | }, 68 | // ... 99 69 | LoteTrailing: { 70 | REGISTRY_FIELD: 'registro' 71 | }, 72 | Pagamento: { 73 | REGISTRY_FIELD: 'cod_seg_registro_lote', 74 | TIPO_MOVIMENTO: { // tipo de movimento a que o detalhe se destina 75 | INCLUSAO: 0, 76 | CONSULTA: 1, 77 | ESTORNO: 3, 78 | ALTERACAO: 5, 79 | LIQUIDACAO: 7, 80 | EXCLUSAO: 9 81 | }, 82 | CODIGO_MOVIMENTO: { // indica a movimentação a ser efetuada 83 | INCLUSAO: '00', // inclusão com registro detalhe 84 | INCLUSAO_COM_BLOQUEIO: '09' 85 | }, // inclusão com bloqueio 86 | COD_CAMARA_CENTRALIZADORA: { 87 | TED: '18', 88 | DOC: '700' 89 | } 90 | }, 91 | Detail: 'A', 92 | Segmentos: { 93 | A: 'Detail', 94 | B: 'Detail2', 95 | C: false, 96 | '5': false 97 | }, 98 | CodigosOcorrencias: { 99 | '00': 'Crédito ou Débito Efetivado', 100 | '01': 'Insuficiência de Fundos - Débito Não Efetuado', 101 | '02': 'Crédito ou Débito Cancelado pelo Pagador/Credor', 102 | '03': 'Débito Autorizado pela Agência - Efetuado', 103 | AA: 'Controle Inválido', 104 | AB: 'Tipo de Operação Inválido', 105 | AC: 'Tipo de Serviço Inválido', 106 | AD: 'Forma de Lançamento Inválida', 107 | AE: 'Tipo/Número de Inscrição Inválido', 108 | AF: 'Código de Convênio Inválido', 109 | AG: 'Agência/Conta Corrente/DV Inválido', 110 | AH: 'Nº Sequencial do Registro no Lote Inválido', 111 | AI: 'Código de Segmento de Detalhe Inválido', 112 | AJ: 'Tipo de Movimento Inválido', 113 | AK: 'Código da Câmara de Compensação do Banco Favorecido/Depositário Inválido', 114 | AL: 'Código do Banco Favorecido ou Depositário Inválido', 115 | AM: 'Agência Mantenedora da Conta Corrente do Favorecido Inválida', 116 | AN: 'Conta Corrente/DV do Favorecido Inválido', 117 | AO: 'Nome do Favorecido Não Informado', 118 | AP: 'Data Lançamento Inválido', 119 | AQ: 'Tipo/Quantidade da Moeda Inválido', 120 | AR: 'Valor do Lançamento Inválido', 121 | AS: 'Aviso ao Favorecido - Identificação Inválida', 122 | AT: 'Tipo/Número de Inscrição do Favorecido Inválido', 123 | AU: 'Logradouro do Favorecido Não Informado', 124 | AV: 'Nº do Local do Favorecido Não Informado', 125 | AW: 'Cidade do Favorecido Não Informada', 126 | AX: 'CEP/Complemento do Favorecido Inválido', 127 | AY: 'Sigla do Estado do Favorecido Inválida', 128 | AZ: 'Código/Nome do Banco Depositário Inválido', 129 | BA: 'Código/Nome da Agência Depositária Não Informado', 130 | BB: 'Seu Número Inválido', 131 | BC: 'Nosso Número Inválido', 132 | BD: 'Inclusão Efetuada com Sucesso', 133 | BE: 'Alteração Efetuada com Sucesso', 134 | BF: 'Exclusão Efetuada com Sucesso', 135 | BG: 'Agência/Conta Impedida Legalmente', 136 | BH: 'Empresa não pagou salário', 137 | BI: 'Falecimento do mutuário', 138 | BJ: 'Empresa não enviou remessa do mutuário', 139 | BK: 'Empresa não enviou remessa no vencimento', 140 | BL: 'Valor da parcela inválida', 141 | BM: 'Identificação do contrato inválida', 142 | BN: 'Operação de Consignação Incluída com Sucesso', 143 | BO: 'Operação de Consignação Alterada com Sucesso', 144 | BP: 'Operação de Consignação Excluída com Sucesso', 145 | BQ: 'Operação de Consignação Liquidada com Sucesso', 146 | CA: 'Código de Barras - Código do Banco Inválido', 147 | CB: 'Código de Barras - Código da Moeda Inválido', 148 | CC: 'Código de Barras - Dígito Verificador Geral Inválido', 149 | CD: 'Código de Barras - Valor do Título Divergente/Inválido', 150 | CE: 'Código de Barras - Campo Livre Inválido', 151 | CF: 'Valor do Documento Inválido', 152 | CG: 'Valor do Abatimento Inválido', 153 | CH: 'Valor do Desconto Inválido', 154 | CI: 'Valor de Mora Inválido', 155 | CJ: 'Valor da Multa Inválido', 156 | CK: 'Valor do IR Inválido', 157 | CL: 'Valor do ISS Inválido', 158 | CM: 'Valor do IOF Inválido', 159 | CN: 'Valor de Outras Deduções Inválido', 160 | CO: 'Valor de Outros Acréscimos Inválido', 161 | CP: 'Valor do INSS Inválido', 162 | HA: 'Lote Não Aceito', 163 | HB: 'Inscrição da Empresa Inválida para o Contrato', 164 | HC: 'Convênio com a Empresa Inexistente/Inválido para o Contrato', 165 | HD: 'Agência/Conta Corrente da Empresa Inexistente/Inválido para o Contrato', 166 | HE: 'Tipo de Serviço Inválido para o Contrato', 167 | HF: 'Conta Corrente da Empresa com Saldo Insuficiente', 168 | HG: 'Lote de Serviço Fora de Sequência', 169 | HH: 'Lote de Serviço Inválido', 170 | HI: 'Arquivo não aceito', 171 | HJ: 'Tipo de Registro Inválido', 172 | HK: 'Código Remessa / Retorno Inválido', 173 | HL: 'Versão de layout inválida', 174 | HM: 'Mutuário não identificado', 175 | HN: 'Tipo do benefício não permite empréstimo', 176 | HO: 'Beneficio cessado/suspenso', 177 | HP: 'Beneficio possui representante legal', 178 | HQ: 'Benefício é do tipo PA (Pensão alimentícia)', 179 | HR: 'Quantidade de contratos permitida excedida', 180 | HS: 'Benefício não pertence ao Banco informado', 181 | HT: 'Início do desconto informado já ultrapassado', 182 | HU: 'Número da parcela inválida', 183 | HV: 'Quantidade de parcela inválida', 184 | HW: 'Margem consignável excedida para o mutuário dentro do prazo do contrato', 185 | HX: 'Empréstimo já cadastrado', 186 | HY: 'Empréstimo inexistente', 187 | HZ: 'Empréstimo já encerrado', 188 | H1: 'Arquivo sem trailer', 189 | H2: 'Mutuário sem crédito na competência', 190 | H3: 'Não descontado – outros motivos', 191 | H4: 'Retorno de Crédito não pago', 192 | H5: 'Cancelamento de empréstimo retroativo', 193 | H6: 'Outros Motivos de Glosa', 194 | H7: 'Margem consignável excedida para o mutuário acima do prazo do contrato', 195 | H8: 'Mutuário desligado do empregador', 196 | H9: 'Mutuário afastado por licença', 197 | IA: 'Primeiro nome do mutuário diferente do primeiro nome do movimento do censo ou diferente da base de Titular do Benefício', 198 | TA: 'Lote Não Aceito - Totais do Lote com Diferença', 199 | YA: 'Título Não Encontrado', 200 | YB: 'Identificador Registro Opcional Inválido', 201 | YC: 'Código Padrão Inválido', 202 | YD: 'Código de Ocorrência Inválido', 203 | YE: 'Complemento de Ocorrência Inválido', 204 | YF: 'Alegação já Informada ', 205 | ZA: 'Agência / Conta do Favorecido Substituída', 206 | ZB: 'Divergência entre o primeiro e último nome do beneficiário versus primeiro e últimonome na Receita Federal', 207 | ZC: 'Confirmação de Antecipação de Valor', 208 | ZD: 'Antecipação Parcial de Valor', 209 | '5A': 'agendado sob lista de debito', 210 | '5B': 'pagamento não autoriza sob lista de debito', 211 | '5C': 'lista com mais de uma modalidade', 212 | '5D': 'lista com mais de uma data de pagamento', 213 | '5E': 'número de lista duplicado', 214 | '5F': 'lista de debito vencida e não autorizada', 215 | '5M': 'número de lista de debito invalida', 216 | ZE: 'Título bloqueado na base', 217 | ZF: 'Sistema em contingência – título valor maior que referência', 218 | ZG: 'Sistema em contingência – título vencido', 219 | ZH: 'Sistema em contingência – título indexado', 220 | ZI: 'Beneficiário divergente', 221 | ZJ: 'Limite de pagamentos parciais excedidos', 222 | ZK: 'Boleto já liquidado' 223 | } 224 | }; 225 | --------------------------------------------------------------------------------