diff --git a/banks/bradesco/index.js b/banks/bradesco/index.js index 944e8e4..e97899b 100644 --- a/banks/bradesco/index.js +++ b/banks/bradesco/index.js @@ -9,7 +9,7 @@ exports.options = { exports.dvBarra = function (barra) { var resto2 = formatters.mod11(barra, 9, 1) - return (resto2 == 0 || resto2 == 1 || resto2 == 10) ? 1 : 11 - resto2 + return (resto2 === 0 || resto2 === 1 || resto2 === 10) ? 1 : 11 - resto2 } exports.barcodeData = function (boleto) { @@ -94,10 +94,10 @@ exports.parseEDIFile = function (fileContent) { var line = lines[i] var registro = line.substring(0, 1) - if (registro == '0') { + if (registro === '0') { parsedFile['razao_social'] = line.substring(46, 76) parsedFile['data_arquivo'] = ediHelper.dateFromEdiDate(line.substring(94, 100)) - } else if (registro == '1') { + } else if (registro === '1') { var boleto = {} parsedFile['cnpj'] = formatters.removeTrailingZeros(line.substring(3, 17)) @@ -109,13 +109,13 @@ exports.parseEDIFile = function (fileContent) { var ocorrenciasStr = line.substring(318, 328) var motivosOcorrencia = [] - var isPaid = (parseInt(boleto['valor_pago']) >= parseInt(boleto['valor']) || boleto['codigo_ocorrencia'] == '06') + var isPaid = (parseInt(boleto['valor_pago']) >= parseInt(boleto['valor']) || boleto['codigo_ocorrencia'] === '06') for (var j = 0; j < ocorrenciasStr.length; j += 2) { var ocorrencia = ocorrenciasStr.substr(j, 2) motivosOcorrencia.push(ocorrencia) - if (ocorrencia != '00') { + if (ocorrencia !== '00') { isPaid = false } } diff --git a/banks/santander/index.js b/banks/santander/index.js index 59c68af..c5cdc1d 100644 --- a/banks/santander/index.js +++ b/banks/santander/index.js @@ -10,7 +10,7 @@ exports.options = { exports.dvBarra = function (barra) { var resto2 = formatters.mod11(barra, 9, 1) - return (resto2 == 0 || resto2 == 1 || resto2 == 10) ? 1 : 11 - resto2 + return (resto2 === 0 || resto2 === 1 || resto2 === 10) ? 1 : 11 - resto2 } exports.barcodeData = function (boleto) { @@ -99,16 +99,16 @@ exports.parseEDIFile = function (fileContent) { var line = lines[i] var registro = line.substring(7, 8) - if (registro == '0') { + if (registro === '0') { parsedFile['cnpj'] = line.substring(17, 32) parsedFile['razao_social'] = line.substring(72, 102) parsedFile['agencia_cedente'] = line.substring(32, 36) parsedFile['conta_cedente'] = line.substring(37, 47) parsedFile['data_arquivo'] = helper.dateFromEdiDate(line.substring(143, 152)) - } else if (registro == '3') { + } else if (registro === '3') { var segmento = line.substring(13, 14) - if (segmento == 'T') { + if (segmento === 'T') { var boleto = {} boleto['codigo_ocorrencia'] = line.substring(15, 17) @@ -120,11 +120,11 @@ exports.parseEDIFile = function (fileContent) { currentNossoNumero = formatters.removeTrailingZeros(line.substring(40, 52)) parsedFile.boletos[currentNossoNumero] = boleto - } else if (segmento == 'U') { + } else if (segmento === 'U') { parsedFile.boletos[currentNossoNumero]['valor_pago'] = formatters.removeTrailingZeros(line.substring(77, 92)) var paid = parsedFile.boletos[currentNossoNumero]['valor_pago'] >= parsedFile.boletos[currentNossoNumero]['valor'] - paid = paid && parsedFile.boletos[currentNossoNumero]['codigo_ocorrencia'] == '17' + paid = paid && parsedFile.boletos[currentNossoNumero]['codigo_ocorrencia'] === '17' boleto = parsedFile.boletos[currentNossoNumero] diff --git a/lib/boleto.js b/lib/boleto.js index 5eb2b53..5c74c60 100644 --- a/lib/boleto.js +++ b/lib/boleto.js @@ -12,7 +12,7 @@ var hashString = function (string) { var chr var len - if (string.length == 0) return hash + if (string.length === 0) return hash for (i = 0, len = string.length; i < len; i++) { chr = string.charCodeAt(i) hash = ((hash << 5) - hash) + chr @@ -80,9 +80,9 @@ Boleto.prototype.renderHTML = function (callback) { renderOptions['barcode_render_engine'] = Boleto.barcodeRenderEngine renderOptions['barcode_height'] = '50' - if (Boleto.barcodeRenderEngine == 'bmp') { + if (Boleto.barcodeRenderEngine === 'bmp') { renderOptions['barcode_data'] = barcode.bmpLineForBarcodeData(self['barcode_data']) - } else if (Boleto.barcodeRenderEngine == 'img') { + } else if (Boleto.barcodeRenderEngine === 'img') { renderOptions['barcode_data'] = barcode.binaryRepresentationForBarcodeData(self['barcode_data']) } diff --git a/lib/formatters.js b/lib/formatters.js index 62286a9..a967a01 100644 --- a/lib/formatters.js +++ b/lib/formatters.js @@ -23,7 +23,7 @@ exports.formatAmount = function (amount) { var newIntegers = '' for (var i = 0; i < integers.length; i++) { - if (i > 0 && (integers.length - i) % 3 == 0) newIntegers += '.' + if (i > 0 && (integers.length - i) % 3 === 0) newIntegers += '.' newIntegers += integers[i] } @@ -45,18 +45,18 @@ exports.mod11 = function (num, base, r) { var parcial = parseInt(num[i]) * fator soma += parcial - if (fator == base) { + if (fator === base) { fator = 1 } fator++ } - if (r == 0) { + if (r === 0) { soma *= 10 var digito = soma % 11 - return digito == 10 ? 0 : digito - } else if (r == 1) { + return digito === 10 ? 0 : digito + } else if (r === 1) { return soma % 11 } } @@ -72,11 +72,11 @@ exports.mod10 = function (num) { tempSum += parseInt(temp[j]) } total += tempSum - fator = (fator == 2) ? 1 : 2 + fator = (fator === 2) ? 1 : 2 } var resto = total % 10 - return (resto == 0) ? 0 : (10 - resto) + return (resto === 0) ? 0 : (10 - resto) } exports.fatorVencimento = function (date) { @@ -90,7 +90,7 @@ exports.dateFromEdiDate = function (ediDate) { } exports.removeTrailingZeros = function (string) { - while (string.charAt(0) == '0') { + while (string.charAt(0) === '0') { string = string.substring(1, string.length) }