Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions banks/bradesco/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
Expand All @@ -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
}
}
Expand Down
12 changes: 6 additions & 6 deletions banks/santander/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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]

Expand Down
6 changes: 3 additions & 3 deletions lib/boleto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'])
}

Expand Down
16 changes: 8 additions & 8 deletions lib/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand All @@ -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
}
}
Expand All @@ -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) {
Expand All @@ -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)
}

Expand Down