Eduardokum\LaravelBoleto\Util::fatorVencimento PHP Method

fatorVencimento() public static method

public static fatorVencimento ( $date, string $format = 'Y-m-d' ) : float
$date
$format string
return float
    public static function fatorVencimento($date, $format = 'Y-m-d')
    {
        $date = $date instanceof Carbon ? $date : Carbon::createFromFormat($format, $date)->setTime(0, 0, 0);
        return (new Carbon('1997-10-07'))->diffInDays($date);
    }

Same methods

Util::fatorVencimento ( Carbon\Carbon $date, string $format = 'Y-m-d' ) : integer

Usage Example

Example #1
0
 protected function gerarCodigoBarras()
 {
     if ($this->tipo == self::CEF_TIPO_POS11) {
         $this->codigoBarras = $this->getBanco();
         $this->codigoBarras .= $this->numeroMoeda;
         $this->codigoBarras .= Util::fatorVencimento($this->getDataVencimento());
         $this->codigoBarras .= Util::numberFormatValue($this->getValor(), 10, 0);
         $this->codigoBarras .= $this->gerarNossoNumero();
         $this->codigoBarras .= Util::numberFormatGeral($this->getAgencia(), 4, 0);
         $this->codigoBarras .= Util::numberFormatGeral($this->cedenteCodigo, 11, 0);
     } else {
         if ($this->tipo == self::CEF_TIPO_POS16) {
             $this->codigoBarras = $this->getBanco();
             $this->codigoBarras .= $this->numeroMoeda;
             $this->codigoBarras .= Util::fatorVencimento($this->getDataVencimento());
             $this->codigoBarras .= Util::numberFormatValue($this->getValor(), 10, 0);
             $this->codigoBarras .= substr($this->cedenteCodigo, -5);
             $this->codigoBarras .= $this->getAgencia();
             $this->codigoBarras .= 87;
             $this->codigoBarras .= $this->gerarNossoNumero();
         } else {
             throw new Exception("Tipo do bloqueto inválido");
         }
     }
     $r = Util::modulo11($this->codigoBarras, 9, 1);
     $dv = $r == 0 || $r == 1 || $r == 10 ? 1 : 11 - $r;
     $this->codigoBarras = substr($this->codigoBarras, 0, 4) . $dv . substr($this->codigoBarras, 4);
     $this->carteira = $this->carteiraDesc[$this->getCarteira()];
     return $this->codigoBarras;
 }
All Usage Examples Of Eduardokum\LaravelBoleto\Util::fatorVencimento