$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Inicio se nombre semana==" . $xF->getDayName($xF->getFechaDeInicioDeSemana()) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dias del Mes==" . $xF->getDiasDelMes() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, En Fecha Corta==" . $xF->getFechaCorta() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha Larga==" . $xF->getFechaLarga() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, En Fecha Mediana==" . $xF->getFechaMediana() . "</p>");
//$xHFrm->addHElem(  );
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha Operativa Maxima==" . $xF->getFechaMaximaOperativa() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, El Mes Anterior==" . $xF->getFechaMesAnterior() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, dos meses atras==" . $xF->getFechaMesAnterior(false, 2) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  - 30 Dias==" . $xF->setRestarDias(30) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  + 30 Dias==" . $xF->setSumarDias(30) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  + 2 meses==" . $xF->setSumarMeses(2) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}  - 2 meses==" . $xF->setRestarMeses(2) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Nombre del Dia==" . $xF->getDayName() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dia Inicial del mes==" . $xF->getDiaInicial() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Obtener Dia Habil==" . $xF->getDiaHabil() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dias desde el 31Dic2013==" . $xF->setRestarFechas($xF->get(), "2013-12-31") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Buscar Sabado(D6) para el dia de hoy==" . $xF->getDiaAbonoSemanal(6) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Buscar NOMBRE Sabado(D6) para el dia de hoy==" . $xF->getDayName($xF->getDiaAbonoSemanal(6)) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-02") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-11") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-18") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-20") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-24") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-29") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-31") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Obtener dias Loborales en el mes==" . $xF->getDiasHabilesEnRango("2014-03-31", "2014-03-01") . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Obtener entero del mes==" . $xF->getInt(fechasys()) . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, DIAS CORRIENTES DE MES" . $xF->getDiasCorrientesDeMes() . "</p>");
$xHFrm->addHElem("<p class='aviso'>La {$miFecha}, sumar  7 dias time stamp 84600==" . $xF->getFechaByInt($xF->getInt(fechasys()) + (7 + 1) * 84600) . "</p>");
$xHFrm->addHElem("<p class='aviso'>" . $xF->getMessages(OUT_HTML) . "</p>");
 function calcular($fecha_inicial = false, $PrimerPago = false, $SegundoPago = false, $TercerPago = false)
 {
     $xCred = new cCredito($this->mClaveDeCredito);
     $xCred->init();
     $xF = new cFecha();
     $msg = "";
     $FORMA_DE_PAGO = $xCred->getFormaDePago();
     $PAGOS_AUTORIZADOS = $xCred->getPagosAutorizados();
     $PERIOCIDAD_DE_PAGO = $xCred->getPeriocidadDePago();
     $MONTO_AUTORIZADO = $xCred->getMontoAutorizado();
     $SALDO_ACTUAL = $xCred->getSaldoActual();
     $INTERES_PAGADO = $xCred->getInteresNormalPagado();
     $MORA_PAGADO = $xCred->getInteresMoratorioPagado();
     $xCred->initPagosEfectuados();
     $CAPITAL_PAGADO = setNoMenorQueCero($MONTO_AUTORIZADO - $SALDO_ACTUAL);
     $SALDO_DE_PLAN = $xCred->getMontoAutorizado();
     $TASA_NORMAL = $xCred->getTasaDeInteres();
     $TASA_MORA = $xCred->getTasaDeMora();
     $TASA_IVA = $xCred->getTasaIVA();
     $DIVISOR_DE_INTS = EACP_DIAS_INTERES;
     $FECHA_DE_PAGO = $xCred->getFechaPrimeraParc();
     $FECHA_INICIAL = $xCred->getFechaDeMinistracion();
     $opciondia_1 = $PrimerPago;
     $opciondia_2 = $SegundoPago;
     $opciondia_3 = $TercerPago;
     //sanitiza la fecha de pago
     if ($FECHA_DE_PAGO == false) {
         $FECHA_DE_PAGO = $xF->setSumarDias($PERIOCIDAD_DE_PAGO, $FECHA_INICIAL);
     }
     if (($PERIOCIDAD_DE_PAGO > CREDITO_TIPO_PERIOCIDAD_CATORCENAL or $PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_CATORCENAL) and ($opciondia_1 == false or $opciondia_2 == false or $opciondia_3 == false)) {
         if ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_QUINCENAL) {
             $opciondia_1 = $opciondia_1 == false ? PQ_DIA_PRIMERA_QUINCENA : $opciondia_1;
             $opciondia_2 = $opciondia_2 == false ? PQ_DIA_SEGUNDA_QUINCENA : $opciondia_2;
         } elseif ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_DECENAL) {
             $opciondia_1 = $opciondia_1 == false ? 10 : $opciondia_1;
             $opciondia_2 = $opciondia_2 == false ? 20 : $opciondia_2;
             $opciondia_3 = $opciondia_3 == false ? 30 : $opciondia_3;
         } else {
             $opciondia_1 = $opciondia_1 == false ? PM_DIA_DE_PAGO : $opciondia_1;
         }
     }
     //pagos decenales entre el mes
     $arrPagos = array();
     //obtener los dias de pago en el mes por tipo de pago
     $dia_de_pago = $xCred->getFechaDeMinistracion();
     for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
         $letra = $i;
         switch ($PERIOCIDAD_DE_PAGO) {
             case CREDITO_TIPO_PERIOCIDAD_DIARIO:
                 $dia_de_pago = $xF->getDiaHabil($xF->setSumarDias(1, $dia_de_pago));
                 $arrPagos[$letra][SYS_FECHA] = $dia_de_pago;
                 $msg .= "OK\t{$letra}\tDIARIO\tFecha de pago a {$dia_de_pago}\r\n";
                 break;
             case CREDITO_TIPO_PERIOCIDAD_SEMANAL:
                 break;
             case CREDITO_TIPO_PERIOCIDAD_DECENAL:
                 break;
             case CREDITO_TIPO_PERIOCIDAD_CATORCENAL:
                 //dias naturales, cada dos semanas?
                 break;
             case CREDITO_TIPO_PERIOCIDAD_QUINCENAL:
                 $dia_de_pago = $xF->setSumarDias(CREDITO_TIPO_PERIOCIDAD_QUINCENAL, $dia_de_pago);
                 $dia_de_pago = $xF->getDiaAbonoQuincenal($opciondia_1, $opciondia_2, $dia_de_pago);
                 $arrPagos[$letra][SYS_FECHA] = $dia_de_pago;
                 $msg .= "OK\t{$letra}\tQUINCENAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}, {$opciondia_2}\r\n";
                 break;
             case CREDITO_TIPO_PERIOCIDAD_MENSUAL:
                 $dia_de_pago = date("Y-m-", $xF->getInt($dia_de_pago)) . $opciondia_1;
                 $dia_de_pago = $xF->setSumarMeses(1, $dia_de_pago);
                 $dia_de_pago = $xF->getDiaHabil($dia_de_pago);
                 $arrPagos[$letra][SYS_FECHA] = $dia_de_pago;
                 $msg .= "OK\t{$letra}\tMENSUAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}\r\n";
                 break;
             case CREDITO_TIPO_PERIOCIDAD_BIMESTRAL:
                 break;
             case CREDITO_TIPO_PERIOCIDAD_TRIMESTRAL:
                 break;
         }
     }
     //$FORMULA_INT			= new cFormula("interes_normal");
     //dias de pago
     //si es empresa, tomar la fecha de la empresa semanal, quincenal, mensual, decenal
     //Iniciar los Pagos Actuales
     //$this->initParcsPendientes();
     $DatosDePagados = $xCred->getListadoDePagos();
     /* interes capital impuestos */
     switch ($FORMA_DE_PAGO) {
         case CREDITO_TIPO_PAGO_PERIODICO:
             //parcialidad interes + capital
             break;
         case CREDITO_TIPO_PAGO_FLAT_PARCIAL:
             for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
                 $letra = $i;
                 $letraAnterior = setNoMenorQueCero($letra - 1);
                 $PagoAnterior = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array();
                 $capital_pagado = isset($DPago[SYS_CAPITAL]) ? $DPago[SYS_CAPITAL] : 0;
                 $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado;
                 $interes_normal = $MONTO_AUTORIZADO * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS;
                 $capital = $MONTO_AUTORIZADO / $PAGOS_AUTORIZADOS;
                 $capital = setNoMenorQueCero($capital - $capital_pagado);
                 $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0;
                 $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado);
                 $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal;
                 if ($letra == $PAGOS_AUTORIZADOS) {
                     if ($SALDO_DE_PLAN > 0) {
                         $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN;
                         $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n";
                     }
                 }
                 //determinar proxima fecha de pago
                 $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n";
             }
             break;
         case CREDITO_TIPO_PAGO_INTERES_PERIODICO:
             for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
                 $letra = $i;
                 $letraAnterior = setNoMenorQueCero($letra - 1);
                 $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array();
                 $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0;
                 $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado;
                 $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array();
                 $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0;
                 //datos del pago anterior
                 $DLetraAnterior = isset($arrPagos[$letraAnterior]) ? $arrPagos[$letraAnterior] : array();
                 $DLetra = isset($arrPagos[$letra]) ? $arrPagos[$letra] : array();
                 $FechaAnterior = isset($DLetraAnterior[SYS_FECHA]) ? $DLetraAnterior[SYS_FECHA] : $xCred->getFechaDeMinistracion();
                 $FechaActual = isset($DLetra[SYS_FECHA]) ? $DLetra[SYS_FECHA] : false;
                 $DIAS_TRANSCURRIDOS = $xF->setRestarFechas($FechaActual, $FechaAnterior);
                 //INTERES NORMAL
                 $interes_normal = $SALDO_DE_PLAN * $DIAS_TRANSCURRIDOS * $TASA_NORMAL / $DIVISOR_DE_INTS;
                 $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado);
                 $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal;
                 if ($capital_pagado > 0) {
                     $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n";
                 }
                 if ($letra == $PAGOS_AUTORIZADOS) {
                     if ($SALDO_DE_PLAN > 0) {
                         $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN;
                         $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n";
                     }
                 }
                 $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado}, Dias {$DIAS_TRANSCURRIDOS},Fecha : Actual {$FechaActual} Anterior {$FechaAnterior}\r\n";
             }
             break;
         case CREDITO_TIPO_PAGO_INTERES_COMERCIAL:
             for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) {
                 $letra = $i;
                 $letraAnterior = setNoMenorQueCero($letra - 1);
                 $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array();
                 $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0;
                 $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado;
                 $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array();
                 $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0;
                 //INTERES NORMAL
                 $interes_normal = $SALDO_DE_PLAN * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS;
                 $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado);
                 $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal;
                 if ($capital_pagado > 0) {
                     $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n";
                 }
                 if ($letra == $PAGOS_AUTORIZADOS) {
                     if ($SALDO_DE_PLAN > 0) {
                         $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN;
                         $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n";
                     }
                 }
                 $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n";
             }
             break;
     }
     $NumeroPlan = $this->mNumeroDePlan;
     //$this->setEliminar();
     //eliminar plan de pagos
     foreach ($arrPagos as $periodo) {
     }
     $this->mMessages .= $msg;
     return $msg;
 }
 function getFechaDePago($fecha_de_referencia, $numeral)
 {
     $periocidad_pago = $this->mPeriocidadDePago;
     $tipo_de_plan = $this->mTipoDePlanDePago;
     $dia_1_ab = $this->mDiaDeAbono1;
     $dia_2_ab = $this->mDiaDeAbono2;
     $dia_3_ab = $this->mDiaDeAbono3;
     $xF = new cFecha(0, $fecha_de_referencia);
     $xF1 = new cFecha(1);
     if ($tipo_de_plan == CREDITO_TIPO_DIAS_DE_PAGO_NATURAL) {
         $fecha_de_pago = $numeral == 1 ? $fecha_de_referencia : $xF->setSumarDias($periocidad_pago, $fecha_de_referencia);
     } else {
         //$fecha_de_referencia	= $xF->get();
         if ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_DIARIO) {
             //obtener si no es festivo
             //if(!isset($fecha_de_pago)){$fecha_de_pago = $fecha_de_referencia;}
             $fecha_de_pago = $numeral == 1 ? $fecha_de_referencia : $xF->setSumarDias(1, $fecha_de_referencia);
             $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago);
         } elseif ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_SEMANAL) {
             //Obtiene el Dia de Ref + dias del periodo
             if ($numeral == 1) {
                 //Si es primer pago, es el dia de abono
                 $fecha_de_pago = $fecha_de_referencia;
             } else {
                 $fecha_de_pago = $xF->setSumarDias($periocidad_pago);
                 if ($this->mDiaDeAbono1 != false) {
                     $fecha_de_pago = $xF->getDiaAbonoSemanal($this->mDiaDeAbono1, $fecha_de_pago);
                 }
             }
         } elseif ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_DECENAL) {
             $desviacion = intval($periocidad_pago * 0.4);
             if ($numeral == 1) {
                 //Si es primer pago, es el dia de abono
                 $fecha_de_pago = $fecha_de_referencia;
             } else {
                 $fecha_de_pago = $xF->setSumarDias($periocidad_pago);
                 $fecha_calculada = $xF->getDiaAbonoDecenal($this->mDiaDeAbono1, $this->mDiaDeAbono2, $this->mDiaDeAbono3, $fecha_de_pago);
                 $fecha_de_pago = $tipo_de_plan != FALLBACK_CREDITOS_DIAS_DE_PAGO ? $fecha_calculada : $fecha_de_pago;
             }
         } elseif ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_CATORCENAL) {
             //Obtiene el Dia de Ref + dias del periodo
             if ($numeral == 1) {
                 //Si es primer pago, es el dia de abono
                 $fecha_de_pago = $fecha_de_referencia;
             } else {
                 $fecha_de_pago = $xF->setSumarDias($periocidad_pago);
             }
         } elseif ($periocidad_pago >= CREDITO_TIPO_PERIOCIDAD_QUINCENAL && $periocidad_pago < CREDITO_TIPO_PERIOCIDAD_MENSUAL) {
             //Obtiene el Dia de Ref + dias del periodo
             if ($numeral == 1) {
                 //Si es primer pago, es el dia de abono
                 $fecha_de_pago = $fecha_de_referencia;
             } else {
                 $fecha_de_pago = $xF->setSumarDias($periocidad_pago);
                 if ($tipo_de_plan != FALLBACK_CREDITOS_DIAS_DE_PAGO) {
                     $fecha_de_pago = $xF->getDiaAbonoQuincenal($dia_1_ab, $dia_2_ab, $fecha_de_pago);
                 }
             }
             // Tratamiento Mensual o mas, si es menor a la 1era Quincena, baja al dia dos, si no sube un mes al dia dos...
         } elseif ($periocidad_pago >= CREDITO_TIPO_PERIOCIDAD_MENSUAL && $periocidad_pago < CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
             //Obtiene el Dia de Ref + dias del periodo
             $fecha_de_pago = $numeral == 1 ? $fecha_de_referencia : $xF->setSumarDias($periocidad_pago);
             if ($tipo_de_plan != FALLBACK_CREDITOS_DIAS_DE_PAGO) {
                 $fecha_de_pago = $xF->getDiaDeAbonoMensual($dia_1_ab, $fecha_de_pago);
             }
         } else {
             // Tratamiento 360 o Semanal
             $fecha_de_pago = $xF->setSumarDias($periocidad_pago);
         }
     }
     if ($this->mTipoCreditoSis != CREDITO_PRODUCTO_NOMINA) {
         $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago);
         $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago);
         $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago);
         $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago);
     }
     //if(MODO_DEBUG == true){ $this->mMessages	.= $xF->getMessages(); }
     return $fecha_de_pago;
 }
 /**
  * Genera un reinversion
  *
  * @param date $fecha		Fecha de Cierre se refiere a la fecha que que se efectua la Reinversion
  * @param boolean $cerrar	Cerrar, indica si se cierra la inversion.
  * @param float $tasa
  * @param int $dias
  * @return integer Numero de Recibo
  */
 function setReinversion($fecha = false, $cerrar = false, $tasa = false, $dias = false, $InversionParcial = false, $invertido = 0)
 {
     $recibo = false;
     $xF = new cFecha();
     //en Monto de la reinversion sera despues de los depositos (Saldo Actual)
     //si cerrar = false, no efectuar ninguno movimiento
     if ($cerrar == true) {
         $this->mPeriodoCuenta = setNoMenorQueCero($this->mPeriodoCuenta) + 1;
         $this->mDiasInvertidos = setNoMenorQueCero($dias) > 0 ? $dias : $this->mDiasInvertidos;
         //2012-01-09: correccion de dias menores a cero
         $this->mDiasInvertidos = $this->mDiasInvertidos < INVERSION_DIAS_MINIMOS ? INVERSION_DIAS_MINIMOS : $this->mDiasInvertidos;
         if ($tasa != false) {
             if ($tasa > $this->mTasaInteres) {
                 $this->mTasaInteres = $tasa;
                 $this->mMessages .= "WARN\tTASA\tSe respeta una Tasa Especial de {$tasa} sobre " . $this->mTasaInteres . " que tenia Anteriormente  \r\n";
             }
         }
         $grupo = $this->mGrupoAsociado;
         $observaciones = "REINVERSION AUTOMATICA # " . $this->mPeriodoCuenta;
         $recibo_fiscal = "NA";
         $tipo_de_pago = TESORERIA_COBRO_NINGUNO;
         $cheque = "NA";
         $tipo_de_recibo = 6;
         //OK: Verificar Monto de la Operacion
         $monto = ($InversionParcial == true and $invertido > 0) ? $invertido : $this->mNuevoSaldo;
         //verificar Nuevamente la Tasa
         $tasa = $this->mTasaInteres <= 0 ? $this->getTasaAplicable($this->mDiasInvertidos, 0, $monto) : $this->mTasaInteres;
         //algoritmo de tasa incremental
         eval($this->mModificadorTasa);
         $this->mTasaInteres = $tasa;
         if (setNoMenorQueCero($this->mSocioTitular) <= DEFAULT_SOCIO) {
             $this->initCuentaByCodigo();
         }
         //2014-09-09 .- validar si el recibo se inicia y tiene fecha de hoy
         if ($this->getOReciboInversion() == null) {
             //El recibo no existe
             $this->mMessages .= "WARN\tNo existe el Recibo de Inversion\r\n";
         } else {
             $dia_de_inversion = $this->getOReciboInversion()->getFechaDeRecibo();
             $recibo_anterior = $this->getOReciboInversion()->getCodigoDeRecibo();
             if ($xF->getInt($dia_de_inversion) == $xF->getInt($fecha)) {
                 $this->mMessages .= "WARN\tLa fecha de reinversion[{$fecha}] es igual al recibo anterior[{$recibo_anterior} - " . $dia_de_inversion . "] se Eliminara\r\n";
                 $this->getOReciboInversion()->setRevertir(true);
                 $this->mMessages .= $this->getOReciboInversion()->getMessages();
             }
         }
         if ($fecha == false) {
             if (isset($this->mFechaOperacion) and $this->mFechaOperacion != false) {
                 $fecha = $this->mFechaOperacion;
             } else {
                 $fecha = fechasys();
             }
         }
         //Corrige el Dia Inhabil
         //$this->mFechaVencimiento;
         //corrige la fecha de Vencimiento, si es menor a la actual
         if (strtotime($fecha) >= strtotime($this->mFechaVencimiento)) {
             $this->mMessages .= "WARN\tLa fecha de reinversion[{$fecha}] es mayor a la de vencimiento[" . $this->mFechaVencimiento . "]\r\n";
             if ($this->mDiasInvertidos > 0) {
                 $this->mFechaVencimiento = $xF->setSumarDias($this->mDiasInvertidos, $fecha);
             }
         }
         $this->mFechaVencimiento = $xF->getDiaHabil($this->mFechaVencimiento);
         $diasCalculados = $xF->setRestarFechas($this->mFechaVencimiento, $fecha);
         if ($diasCalculados > $this->mDiasInvertidos) {
             $this->mDiasInvertidos = $diasCalculados;
             $this->mMessages .= "WARN\tSe Actualizan los Dias de Inversion a {$diasCalculados}\r\n";
         }
         $socio = $this->mSocioTitular;
         //Inicializar el Recibo
         $CRecibo = new cReciboDeOperacion($tipo_de_recibo, true);
         //Agregar recibo si no hay
         if (setNoMenorQueCero($recibo) <= 0) {
             $recibo = $CRecibo->setNuevoRecibo($socio, $this->mNumeroCuenta, $this->mFechaOperacion, $this->mPeriodoCuenta, $tipo_de_recibo, $observaciones, $cheque, $tipo_de_pago, $recibo_fiscal, $grupo);
             //Checar si se agrego el recibo
             if (setNoMenorQueCero($recibo) > 0) {
                 $this->mMessages .= "SUCESS\tSe Agrego Exitosamente el Recibo {$recibo} de la Cuenta " . $this->mNumeroCuenta . " \r\n";
                 $this->mReciboDeReinversion = $recibo;
                 $this->mSucess = true;
             } else {
                 $this->mMessages .= "ERROR\tSe Fallo al Agregar el Recibo {$recibo} de la Cuenta " . $this->mNumeroCuenta . " \r\n";
                 $this->mSucess = false;
             }
         } else {
         }
         $this->mReciboDeReinversion = $recibo;
         //Calcular el Interes
         $interes = $monto * $this->mTasaInteres * $this->mDiasInvertidos / EACP_DIAS_INTERES;
         //OK: Ejecutar modificador de interes
         eval($this->mModificadorDeInteres);
         //si hay recibo, agregar
         if (setNoMenorQueCero($recibo) > 0) {
             //Agregar el Movimiento de Reinversion
             $CRecibo->setNuevoMvto($fecha, $monto, 223, $this->mPeriodoCuenta, $observaciones, 1, TM_ABONO, $socio, $this->mNumeroCuenta);
             $this->mMessages .= "OK\tEVENT\tAgregando la Reinversion por un Monto de {$monto} de la Cuenta " . $this->mNumeroCuenta . " con fecha {$fecha} \r\n";
             //Agregar el Movimiento de Interes
             $CRecibo->setNuevoMvto($this->mFechaVencimiento, $interes, 500, $this->mPeriodoCuenta, $observaciones, 1, TM_ABONO, $socio, $this->mNumeroCuenta);
             $CRecibo->setFinalizarRecibo(true);
             $this->mMessages .= $CRecibo->getMessages("txt");
             $this->mSucess = true;
             //Actualizar la Cuenta
             if ($InversionParcial == false and $invertido == 0) {
                 $this->setUpdateInversion();
             }
         } else {
             $this->mMessages .= "ERROR\tNo Existe Recibo con el cual trabajar({$recibo}) \r\n";
         }
         $this->mMessages .= $CRecibo->getMessages();
         return $recibo;
     }
 }
/**
 * Obtiene una fecha evaluada que es LABORABLE, seleccionando de una Tabla/DB datos previamente guardado
 * @param	date	$dia_a_evaluar		Fecha que se evalua
 * @return	date	Dia Laborable
 * @deprecated 2012.03.02
 */
function set_no_festivo($dia_a_evaluar)
{
    $xF = new cFecha(0, $dia_a_evaluar);
    $fecha = $xF->getDiaHabil($dia_a_evaluar);
    return $fecha;
}