Skip to content

Commit

Permalink
nosso número deve retornar sem o digito e teste float
Browse files Browse the repository at this point in the history
  • Loading branch information
andersondanilo committed Apr 5, 2015
1 parent d67e20d commit 9d4d43c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Cnab/Retorno/Cnab240/Detalhe.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public function getNossoNumero()
);
}

if($this->codigo_banco == \Cnab\Banco::SANTANDER) {
// retira o dv
$nossoNumero = substr($nossoNumero, 0, -1);
}

return $nossoNumero;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cnab/Retorno/Cnab400/Detalhe.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function getNumeroDocumento()
}

/**
* Retorna o nosso número do boleto
* Retorna o nosso número do boleto (sem o digito)
* @return String
*/
public function getNossoNumero()
Expand Down
2 changes: 1 addition & 1 deletion src/Cnab/Retorno/IDetalhe.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getCarteira();
public function getAgencia();

/**
* Retorna o nosso número do boleto
* Retorna o nosso número do boleto (sem o digito)
* @return String
*/
public function getNossoNumero();
Expand Down
7 changes: 7 additions & 0 deletions tests/Cnab/Format/PictureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function testDecode()
// integer number
$this->assertEquals(200, Picture::decode('00200', '9(5)'));
$this->assertEquals(3, Picture::decode('3', '9(1)'));
$this->assertEquals(70.46, Picture::decode('07046', '9(3)V9(2)'));

// big integer number
$this->assertEquals('123456789123456', Picture::decode('000123456789123456', '9(15)'));
Expand All @@ -32,6 +33,12 @@ public function testEncode() {
$this->assertEquals('20050', Picture::encode(200.50, '9(3)V9(2)'));
$this->assertEquals('00250', Picture::encode(2.5, '9(3)V9(2)'));
$this->assertEquals('00205', Picture::encode(2.05, '9(3)V9(2)'));
$this->assertEquals('07046', Picture::encode(70.45999999999999, '9(3)V9(2)'));

$linha = new \Cnab\Format\Linha;
$field = new \Cnab\Format\Field($linha, 'valor_titulo', '9(3)V9(2)', 0, 4);
$field->set(70.45999999999999);
$this->assertEquals('07046', $field->getEncoded());

// integer number
$this->assertEquals('0200', Picture::encode(200, '9(4)'));
Expand Down

0 comments on commit 9d4d43c

Please sign in to comment.