function jsaSetPagarCredito($credito, $fecha, $observaciones)
{
    $msg = "";
    $xLng = new cLang();
    $xCred = new cCredito($credito);
    $xCred->init();
    $xdat = new cFecha(0);
    $fecha = $xdat->getFechaISO($fecha);
    //$xCred->setResetPersonaAsociada($fecha, $observaciones);
    //return $xLng->get(MSG_READY_SAVE);
    $xCred->setAbonoCapital($xCred->getSaldoActual(), $xCred->getPeriodoActual(), DEFAULT_CHEQUE, TESORERIA_COBRO_NINGUNO, DEFAULT_RECIBO_FISCAL, $observaciones, DEFAULT_GRUPO, $fecha);
    return $xCred->getMessages(OUT_HTML);
}
function jsaGetLetras($idcredito)
{
    $idcred = setNoMenorQueCero($idcredito);
    $xF = new cFecha();
    if ($idcred > DEFAULT_CREDITO) {
        $xCred = new cCredito($idcred);
        $xCred->init();
        if ($xCred->getEsAfectable() == false or $xCred->getSaldoActual() <= 0) {
            if (MODO_CORRECION == true) {
                $xTxt = new cHText();
                $xTxt->setDivClass("");
                return $xTxt->getNumero("idparcialidad", $xCred->getPeriodoActual() + 1, "TR.Numero de Parcialidad");
            } else {
                return $xCred->getMessages();
            }
        } else {
            if ($xCred->getPeriocidadDePago() == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
                //
                $xTxt = new cHText();
                $xTxt->setDivClass("");
                return $xTxt->getNumero("idparcialidad", $xCred->getPeriodoActual() + 1, "TR.Numero de Parcialidad");
            } else {
                $plan = $xCred->getNumeroDePlanDePagos();
                if ($plan != false) {
                    $xPlan = new cPlanDePagos($plan);
                    $xPlan->init();
                    $parcs = $xPlan->getParcsPendientes();
                    //$txt		= "";
                    $arrD = array();
                    foreach ($parcs as $p) {
                        //setLog( $p[SYS_NUMERO]. " " . $xF->getFechaDDMM($p[SYS_FECHA]) . " ". getFMoney($p[SYS_TOTAL]));
                        if (setNoMenorQueCero($p[SYS_TOTAL]) > 0) {
                            $arrD[$p[SYS_NUMERO]] = $p[SYS_NUMERO] . " " . $xF->getFechaDDMM($p[SYS_FECHA]) . " " . getFMoney($p[SYS_TOTAL]);
                        }
                    }
                    $xSel = new cHSelect();
                    $xSel->addOptions($arrD);
                    $xSel->setEnclose(false);
                    return $xSel->get("idparcialidad", "TR.Numero de Parcialidad", $xCred->getPeriodoActual() + 1);
                } else {
                    if (MODO_CORRECION == true) {
                        $xTxt = new cHText();
                        $xTxt->setDivClass("");
                        return $xTxt->getNumero("idparcialidad", $xCred->getPeriodoActual() + 1, "TR.Numero de Parcialidad");
                    }
                }
            }
        }
    }
}
 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;
 }
$oSel = new cSelect("");
$oUL = new cHUl();
$oTa = new cHTextArea();
$xCE = new cCreditos_estatus();
$xSelEA = $xCE->query()->html()->select($xCE->descripcion_estatus()->get());
$xCP = new cCreditos_periocidadpagos();
$xSelCP = $xCP->query()->html()->select($xCP->descripcion_periocidadpagos()->get());
$xCTP = new cCreditos_tipo_de_pago();
$xSelTP = $xCTP->query()->html()->select($xCTP->descripcion()->get());
$xPP = new cCreditos_tipoconvenio();
$xSelPP = $xPP->query()->html()->select($xPP->descripcion_tipoconvenio()->get());
$oFRM = new cHForm("frmrenegociar", "", "idfrmrenegociar");
$oFRM->addHElem($xSelPP->get("idpdto", "Producto Actual", $xCred->getClaveDeProducto()));
$oFRM->addHElem($xSelCP->get("idperiocidad", "Nueva Periocidad", $xCred->getPeriocidadDePago()));
$oFRM->addHElem($xSelTP->get("idtipopago", "Nuevo Tipo de Pago", $xCred->getTipoDePago()));
$oFRM->addHElem($oTxt->getDeMoneda("idmonto", "Monto a Renegociar", $xCred->getSaldoActual()));
$oFRM->addHElem($oTxt->getDeMoneda("idpagos", "Pagos nuevos", $xCred->getPagosAutorizados()));
$oFRM->addHElem($oTxt->getDeMoneda("idtasa", "Tasa Nueva", $xCred->getTasaDeInteres() * 100));
//$oFRM->addHElem( $oTxt->getDeMoneda("idinteres", "Interes a Renegociar", $xCred->getInteresNormalPorPagar() ) );
$oFRM->addHElem($oTa->get("idobservaciones", "", "Observaciones"));
$oFRM->addHTML("<p class='aviso' id='resultados'></p>");
$oFRM->addHTML($oUL->li("Se Clona el Credito")->li("Eliminar Plan de Pagos")->li("Reestructurar SDPM")->li("Recalcular Intereses Devengados")->li("Cambiar el Numero de Pagos")->li("Generar Movimiento de Fin de Mes")->end());
$oFRM->addHElem($oBtn->getBasic("Guardar", "jsGuardarCambios", "guardar", "idguardar"));
$oFRM->addHElem($oBtn->getBasic("Cancelar", "jsCancelarCambios", "cancelar", "idcancelar"));
echo $oFRM->get();
echo $xHP->setBodyEnd();
$jsb->show();
$jxc->drawJavaScript(false, true);
?>
<!-- HTML content -->
<script>
 $NombreOtorgante = $xCR->getNombreOtorgante();
 $CuentaActual = $rw["numero_solicitud"];
 $xTConv = new cProductoDeCredito($rw["tipo_convenio"]);
 $xTConv->init();
 $DTConv = $xTConv->getOtrosParametrosInArray();
 $TipoDeResponsabilidad = isset($DTConv["SIC_TIPO_DE_RESPONSABILIDAD"]) ? $DTConv["SIC_TIPO_DE_RESPONSABILIDAD"] : "I";
 //individual
 $TipoDeCuenta = isset($DTConv["SIC_TIPO_DE_CUENTA"]) ? $DTConv["SIC_TIPO_DE_CUENTA"] : "F";
 //Pagos fijos
 $TipoDeContrato = strtoupper($xCred->getOProductoDeCredito()->getTipoDeContratoCR());
 // isset($DTConv["SIC_TIPO_DE_CONTRATO"]) ? $DTConv["SIC_TIPO_DE_CONTRATO"] : "DESCONOCIDO";
 $ClaveUnidadMonetaria = "MX";
 $ValorActivoValuacion = 0;
 $NumeroDePagos = $xCred->getPagosAutorizados();
 $FrecuenciaDePagos = $xCR->getEPeriocidad($xCred->getPeriocidadDePago());
 $MontoPagar = $xCR->getMonto($xCred->getSaldoActual($FechaFinal));
 //Acabar, valor de la letra actual o saldo?
 $FechaAperturaCuenta = $xCR->getDate($xCred->getFechaDeMinistracion());
 $FechaUltimoPago = $xCR->getDate($xCred->getFechaUltimoDePago());
 //setLog("1....$FechaUltimoPago");
 if ($xF->getInt($xCred->getFechaUltimoDePago()) >= $xF->getInt($xCred->getFechaDeMinistracion())) {
     //$FechaUltimoPago		= $FechaAperturaCuenta;
     $xF100 = new cFecha();
     $FechaAperturaCuenta = $xCR->getDate($xF100->setRestarDias(2, $xCred->getFechaDeMinistracion()));
     $FechaUltimoPago = $xCR->getDate($xF100->setRestarDias(1, $xCred->getFechaDeMinistracion()));
     //setLog("2....$FechaUltimoPago");
 }
 $FechaUltimaCompra = $xCR->getDate($xCred->getFechaDeMinistracion());
 $FechaCierreCuenta = "";
 $FechaCorte = $FechaExtraccion;
 $Garantia = "";
function jsaVincularEmpresa($credito, $observaciones, $empresa)
{
    $msg = "";
    $xCred = new cCredito($credito);
    $xCred->init();
    $xdat = new cFecha(0);
    $fecha = $xdat->get();
    // FechaISO($fecha);
    $xCred->init();
    $socio = $xCred->getClaveDePersona();
    $xSoc = new cSocio($socio);
    $xSoc->init();
    $xCred->setCambioProducto(CREDITO_PRODUCTO_NOMINA);
    $xCred->setResetPersonaAsociada($fecha, $observaciones, $empresa);
    //Agregar operacion de desvinculacion
    $xRe = new cReciboDeOperacion(RECIBOS_TIPO_ESTADISTICO, false, DEFAULT_RECIBO);
    $xRe->init();
    $xRe->setNuevoMvto($fecha, $xCred->getSaldoActual(), OPERACION_CLAVE_VINCULACION, $xCred->getPeriodoActual(), "", 1, false, $socio, $credito, $fecha);
    $xRe->setFinalizarRecibo();
    $msg .= $xSoc->getMessages(OUT_TXT);
    $msg .= $xCred->getMessages(OUT_TXT);
    $msg .= $xRe->getMessages(OUT_TXT);
    $xF = new cFileLog();
    $xF->setWrite($msg);
    $xF->setClose();
    return $xF->getLinkDownload("Descarga de Log");
}
} else {
    $xCred = new cCredito($idsolicitud, $idsocio);
    $xCred->init();
    if ($xCred->getEstadoActual() == CREDITO_ESTADO_AUTORIZADO or $monto_cheque1 <= 0) {
        $recibo = $xCred->setMinistrar($recibo_fiscal, $cheque, $monto_cheque1, $cuenta_cheques, $cheque2, $cuenta_cheques2, $observaciones, $fecha);
        if (setNoMenorQueCero($recibo) > 0) {
            $xFRM->addHTML($xCred->getFichaDeSocio());
            $xFRM->addHTML($xCred->getFicha());
            $xFRM->OButton("TR.RECIBO DE MINISTRACION", "jsImprimirReciboMinistracion()", $xFRM->ic()->REPORTE, "id4");
            $xFRM->addToolbar($xBtn->getIrAlInicio(true));
            $uPagare = "elUrl='" . $xCred->getOProductoDeCredito()->getPathPagare($idsolicitud) . "';";
            $uContrato = "esUrl='" . $xCred->getPathDelContrato() . "';";
            if ($creditodescontado >= DEFAULT_CREDITO) {
                $xDCred = new cCredito($creditodescontado);
                $xDCred->init();
                $saldodesc = $xDCred->getSaldoActual($fecha);
                if ($saldodesc < $montocreditodesc) {
                    $montocreditodesc = $saldodesc;
                    $montocomision = $montocomision + ($montocreditodesc - $saldodesc);
                }
                $idrecibocap = $xDCred->setAbonoCapital($montocreditodesc, SYS_UNO, $cheque, TESORERIA_COBRO_DESCTO, $recibo_fiscal, $observaciones);
                if (setNoMenorQueCero($idrecibocap) > 0) {
                    $xRecCapt = new cReciboDeOperacion(false, false, $idrecibocap);
                    $xRecCapt->init();
                    if ($xRecCapt->setFinalizarRecibo(true) == true) {
                        $xFRM->OButton("TR.Recibo de Abono", "jsImprimirReciboCapital()", "imprimir");
                        $xFRM->addHTML($xRecCapt->getJsPrint(true, "jsImprimirReciboCapital"));
                        //finalizar tesoreria
                        $xRecCapt->setFinalizarTesoreria(array("cuenta" => $cuenta_cheques, "cheque" => $cheque));
                    }
                    $msg .= MODO_DEBUG == true ? $xRecCapt->getMessages() : "";
    $sqlcred = "SELECT numero_socio, numero_solicitud, saldo_actual, monto_autorizado FROM creditos_solicitud\t\tWHERE numero_socio={$persona} {$solo_con_saldos} ORDER BY fecha_ministracion, fecha_vencimiento DESC";
    $persona = $persona;
    $porSocio = true;
}
$xSoc = new cSocio($persona);
$xSoc->init();
echo $xSoc->getFicha(true);
echo "<hr />";
$mycred = getRecordset($sqlcred);
while ($rwc = mysql_fetch_array($mycred)) {
    $solicitud = $rwc["numero_solicitud"];
    $NCreditos++;
    $cFC = new cCredito($solicitud);
    $cFC->initCredito();
    $cFC->setForceVista($ExtInf);
    $sdoTemp = $cFC->getSaldoActual();
    echo $cFC->getFicha(true, "", true);
    $MontoAutorizado = $rwc["monto_autorizado"];
    echo "<hr />";
    $where = "";
    if ($f15 == "yes") {
        $where = " AND (operaciones_mvtos.docto_afectado={$solicitud}) {$SinEstadisticos} {$solo_este_mvto} {$varByFechas}";
    } else {
        $where = " AND (operaciones_mvtos.docto_afectado={$solicitud}) {$SinEstadisticos} {$solo_este_mvto} {$varByFechas}";
    }
    $sqlST = $xSQL->getEstadoDeCuentaDeCreditos($where);
    $trs = "";
    $cap = 0;
    $ints = 0;
    $otros = 0;
    $iva = 0;
 $dia_3_ab = 30;
 //==========================================================
 $xCred = new cCredito($solicitud);
 $xCred->init();
 $dsol = $xCred->getDatosDeCredito();
 $estatus = $xCred->getEstadoActual();
 $monto_autorizado = $xCred->getMontoAutorizado();
 $PAGOS_AUTORIZADOS = $xCred->getPagosAutorizados();
 $PERIOCIDAD_DE_PAGO = $xCred->getPeriocidadDePago();
 $socio = $xCred->getClaveDePersona();
 $DProducto = $xCred->getOProductoDeCredito();
 $tasa_ahorro = $DProducto->getTasaDeAhorro();
 $tasa_interes = $xCred->getTasaDeInteres();
 $dias_autorizados = $xCred->getDiasAutorizados();
 $saldo_historico = $xCred->getMontoAutorizado();
 $saldo_actual = $xCred->getSaldoActual();
 $MontoCubierto = $saldo_historico - $saldo_actual;
 //Cuanto ha abonado
 // ---------------------------------- Datos del Convenio -----------------------------------------
 $dias_tolerancia_no_pago = $DProducto->getDiasTolerados();
 $tasa_iva = $xCred->getTasaIVA();
 $iva_incluido = $DProducto->getTasaIncluyeIVA();
 $tipo_de_autorizacion = $xCred->getTipoDeAutorizacion();
 $tipo_de_integracion = $DProducto->getTipoDeIntegracion();
 $tipo_de_calculo = $xCred->getTipoDeCalculoDeInteres();
 $interes_normal_pagado = $xCred->getInteresNormalPagado();
 $credito_abonado = ($monto_autorizado > $saldo_actual + TOLERANCIA_SALDOS and $estatus < CREDITO_ESTADO_AUTORIZADO) ? true : false;
 // --------------------- DATOS OBTENIDOS DEL FORM
 $cuenta_captacion = isset($_POST["idcuenta"]) ? $_POST["idcuenta"] : DEFAULT_CUENTA_CORRIENTE;
 $observaciones = $_POST["observaciones"];
 $fecha_primer_abono = $_POST["elanno0"] . "-" . $_POST["elmes0"] . "-" . $_POST["eldia0"];
    $defaultAction = "o_3ac340832f29c11538fbe2d6f75e8bcc";
} else {
    if (isset($idNew)) {
        $DCred = explode(STD_LITERAL_DIVISOR, $idNew);
        $socio = $DCred[1];
        $credito = $DCred[2];
        //Inicializar el socio y el credito
        $xSocio = new cSocio($socio);
        $xSocio->init();
        $DTel = $xSocio->getTelefonos();
        $xCred = new cCredito($credito);
        $xCred->init();
        //TODO: Agregar Telefonos desde el New
        $telefono1 = $DTel[0];
        $telefono2 = $DTel[1];
        $deudaTotal = $xCred->getSaldoActual();
        $values = explode(STD_LITERAL_DIVISOR, "{$idNew}@{$deudaTotal}@{$telefono1}@{$telefono2}@{$fecha}@08:00@@pendiente@{$iduser}@{$sucursal}@{$eacp}");
    } else {
        $values = explode("@", "0@1@1@0.00@0@0@{$fecha}@08:00@@pendiente@{$iduser}@{$sucursal}@{$eacp}");
    }
}
switch ($o) {
    case "o_e0df5f3dfd2650ae5be9993434e2b2c0":
        //Insert
        //SQL INSERT
        $sql_insert = "INSERT INTO seguimiento_llamadas(numero_socio, numero_solicitud, deuda_total, telefono_uno, telefono_dos, fecha_llamada, hora_llamada, observaciones, estatus_llamada, oficial_a_cargo, sucursal, eacp)\r\n  \t\t\t\tVALUES({$v_numero_socio}, {$v_numero_solicitud}, {$v_deuda_total}, '{$v_telefono_uno}', '{$v_telefono_dos}', '{$v_fecha_llamada}', '{$v_hora_llamada}', '{$v_observaciones}', '{$v_estatus_llamada}', {$v_oficial_a_cargo}, '{$v_sucursal}', '{$v_eacp}')";
        my_query($sql_insert);
        echo "<html>\r\n        <body onLoad='javascript:history.back();'>\r\n        </body>\r\n    </html>";
        break;
    case "o_3ac340832f29c11538fbe2d6f75e8bcc":
        //update
 function init($arrData = false, $credito = false, $dataPagos = false)
 {
     $fecha = $this->mFechaDeCorte;
     $credito = $credito == false ? $this->mClaveDeCredito : $credito;
     $xCred = new cCredito($credito);
     $xCred->init($arrData);
     $xCred->initPagosEfectuados($dataPagos, $fecha);
     //setLog($dataPagos);
     $xSoc = new cSocio($xCred->getClaveDePersona());
     $xSoc->init();
     $this->mInfoLinea[1] = $this->getText($this->getClaveDeOtorgante());
     $this->mInfoLinea[2] = $this->getText($this->getNombreOtorgante());
     $this->mInfoLinea[3] = $this->getFechaDeReporte();
     $this->mInfoLinea[4] = $this->getText($xSoc->getApellidoPaterno());
     $this->mInfoLinea[5] = $this->getText($xSoc->getApellidoMaterno());
     $this->mInfoLinea[6] = "";
     $nombres = explode(" ", $xSoc->getNombre(), 2);
     $this->mInfoLinea[7] = isset($nombres[SYS_CERO]) ? $this->getText($nombres[SYS_CERO]) : "";
     $this->mInfoLinea[8] = isset($nombres[SYS_UNO]) ? $this->getText($nombres[SYS_UNO]) : "";
     $this->mInfoLinea[9] = $this->getDate($xSoc->getFechaDeNacimiento());
     $this->mInfoLinea[10] = $this->getText($xSoc->getRFC());
     $this->mInfoLinea[11] = isset($this->mTituloPersonal[$xSoc->getTipoGenero()]) ? $this->mTituloPersonal[$xSoc->getTipoGenero()] : "";
     //Hiber Tadeo
     $this->mInfoLinea[12] = $this->getEstadoCivil($xSoc->getEstadoCivil());
     $this->mInfoLinea[13] = $this->mEquivGenero[$xSoc->getTipoGenero()];
     //TODO: terminar defuncion/muerte de la persona
     $this->mInfoLinea[14] = "";
     $this->mInfoLinea[15] = "";
     $xDom = $xSoc->getODomicilio();
     if ($xDom == null) {
         for ($i = 16; $i <= 23; $i++) {
             $this->mInfoLinea[$i] = "";
         }
     } else {
         $this->mInfoLinea[16] = $this->getText($xDom->getCalleConNumero());
         $this->mInfoLinea[17] = "";
         $this->mInfoLinea[18] = $this->getText($xDom->getColonia());
         $this->mInfoLinea[19] = $this->getText($xDom->getMunicipio());
         $this->mInfoLinea[20] = $this->getText($xDom->getCiudad());
         $this->mInfoLinea[21] = $this->getText($xDom->getClaveDeEstadoEnSIC());
         $this->mInfoLinea[22] = $this->getText($xDom->getCodigoPostal());
         $xTel = $xSoc->getTelefonoPrincipal();
         //Hiber Tadeo
         $this->mInfoLinea[23] = $xTel == 0 ? "" : $xTel;
         //Hiber Tadeo
     }
     $xAE = $xSoc->getOActividadEconomica();
     if ($xAE == null) {
         $this->mInfoLinea[24] = $this->getText($xSoc->getRFC(true));
         //Para Finsureste debe de ser este RFC del cliente
         $this->mInfoLinea[33] = 0;
     } else {
         $this->mInfoLinea[24] = $this->getText($xSoc->getRFC(true));
         //Para Finsureste debe de ser este RFC del cliente//$this->getText($xAE->getNombreEmpresa());
         $this->mInfoLinea[33] = $this->getText($xDom->getCalleConNumero());
         //Para Finsureste debe de ser direccion del cliente //Hiber Tadeo Aca es direccion
     }
     //direccion 2
     $this->mInfoLinea[25] = "";
     $this->mInfoLinea[26] = $this->getText($xDom->getColonia());
     //Para Finsureste
     $this->mInfoLinea[27] = $this->getText($xDom->getMunicipio());
     //Para Finsureste
     $this->mInfoLinea[28] = $this->getText($xDom->getCiudad());
     //Para Finsureste
     $this->mInfoLinea[29] = $this->getText($xDom->getClaveDeEstadoEnSIC());
     //Para Finsureste
     $this->mInfoLinea[30] = $this->getText($xDom->getCodigoPostal());
     //Para Finsureste
     $this->mInfoLinea[31] = $xTel == 0 ? "" : $xTel;
     //Hiber Tadeo  //Para Finsureste
     $this->mInfoLinea[32] = "";
     $this->mInfoLinea[34] = $this->getClaveDeOtorgante();
     $this->mInfoLinea[35] = $this->getText($this->getNombreOtorgante());
     $this->mInfoLinea[36] = $xCred->getNumeroDeCredito();
     $this->mInfoLinea[38] = $this->getTipoDeCuenta($xCred->getTipoDePago());
     //datos del convenio
     $DConv = $xCred->getOProductoDeCredito();
     $this->mInfoLinea[37] = $this->getTipoDeResponsabilidad($DConv->getTipoDeIntegracion());
     $this->mInfoLinea[39] = $DConv->getTipoDeContratoCR();
     //"PL";//$DConv->getTipoDeContratoCR(); //Hiber Tadeo CL=LINEA DE CREDITO PL=PRESTAMO PERSONAL
     $this->mInfoLinea[40] = AML_CLAVE_MONEDA_LOCAL;
     //TODO: mejorar
     $this->mInfoLinea[41] = $xCred->getPagosAutorizados();
     if ($xCred->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
         //TODO: Parchar con el de TADEO
         $this->mInfoLinea[42] = "P";
     } else {
         $this->mInfoLinea[42] = $this->mEquivFrecPagos[$xCred->getPeriocidadDePago()];
     }
     $this->mInfoLinea[43] = $this->getDate($xCred->getFechaDeMinistracion());
     $this->mInfoLinea[44] = $this->getMonto($xCred->getMontoDeParcialidad());
     $this->mInfoLinea[45] = $this->getDate($xCred->getFechaUltimoDePago());
     $this->mInfoLinea[46] = $this->getDate($xCred->getFechaDeMinistracion());
     $this->mInfoLinea[47] = "";
     //$this->getDate("2029-12-31" );
     if ($xCred->getSaldoActual($fecha) <= TOLERANCIA_SALDOS) {
         $this->mInfoLinea[47] = $this->getDate($xCred->getFechaUltimoDePago());
     }
     $this->mInfoLinea[48] = $this->getFechaDeReporte();
     $DCapacidad = $xSoc->getOCapacidadDePago();
     $this->mInfoLinea[49] = $this->getMonto($DCapacidad->getMontoDeCreditoMaximo());
     $this->mInfoLinea[50] = $this->getMonto($xCred->getSaldoIntegrado($fecha));
     //$xCred->getSaldoActual();
     $this->mInfoLinea[51] = $this->getMonto($DCapacidad->getLimiteDeCredito());
     $this->mInfoLinea[52] = $this->getMonto($xCred->getSaldoVencido());
     //53 numero de pagos vencidos
     $this->mInfoLinea[53] = 0;
     //54 forma mop
     $this->mInfoLinea[54] = $xCred->getMOP($fecha);
     // ($this->mOut == OUT_CSV) ? "01" : "'01";
     //55 clave de observacion, segun catalogo
     $this->mInfoLinea[55] = "";
     //56 clave de otorgante anterior
     //57 nombre otorgante anterior
     $this->mInfoLinea[56] = "";
     $this->mInfoLinea[57] = "";
     $this->mInfoLinea[58] = "";
     //Numero de cuenta anterior en caso de cartera tranferida
     $this->mInfoLinea[59] = $xCred->getFechaDePrimerAtraso() == null ? "" : $this->getDate($xCred->getFechaDePrimerAtraso());
     //TODO: Fecha de Primera atraso
     $this->mInfoLinea[60] = $this->getMonto($xCred->getSaldoActual($fecha));
     //Saldo Insoluto del Principal
     $this->mInfoLinea[61] = $this->getMonto($xCred->getMontoUltimoPago());
     // $xCred->getMontoDeParcialidad();//0; //TODO: Monto de Ultimo pago
     if (MODO_DEBUG == true) {
         $this->mMessages .= $xCred->getMessages(OUT_TXT);
     }
 }
 function setReestructurarSDPM($SoloConSaldos = false, $credito = false, $forzarTodos = false, $fechaCorte = false, $fechaInicial = false, $EliminarTodo = true)
 {
     //FIXME: probar con saldo anterior
     $fechaCorte = $fechaCorte == false ? fechasys() : $fechaCorte;
     $msg = "";
     $wCredito1 = $credito != false ? "  `creditos_mvtos_asdpm`.`documento` = {$credito}" : " `documento` > 0 ";
     $wCredito2 = $credito != false ? "  numero_de_credito = {$credito} " : " numero_de_credito > 0";
     $ByRTM = $credito != false ? " " : " SQL_CACHE ";
     $wFecha1 = " AND (fecha >='{$fechaInicial}' AND fecha <='{$fechaCorte}' ) ";
     $wFecha2 = " AND (`fecha_actual` >= '{$fechaInicial}' AND `fecha_actual`<='{$fechaCorte}' ) ";
     $ql = new MQL();
     $arrEstatusD = array(OPERACION_CLAVE_MINISTRACION, 111, 114, 115);
     $arrEstatus = array(OPERACION_CLAVE_MINISTRACION => CREDITO_ESTADO_VIGENTE, 111 => CREDITO_ESTADO_VENCIDO, 114 => CREDITO_ESTADO_VIGENTE, 115 => CREDITO_ESTADO_MOROSO);
     //Eliminar el SDPM
     if ($EliminarTodo == true) {
         $DAction = $ql->setRawQuery("DELETE FROM creditos_sdpm_historico WHERE {$wCredito2} {$wFecha2} ");
         if (MODO_DEBUG == true) {
             $msg .= "WARN\tEliminando SDPM\r\n";
         }
     }
     if ($credito != false) {
         $ql->setRawQuery("DELETE FROM operaciones_mvtos WHERE docto_afectado={$credito} AND tipo_operacion = 420");
         if (MODO_DEBUG == true) {
             $msg .= "WARN\tEliminando Operaciones 420 del credito {$credito}\r\n";
         }
     }
     $msg .= "Socio\tCredito\tFecha\tMonto\tSaldo\tDias\tOperacion\tEstatus\tInteres\tMoratorios\r\n";
     //Generar saldos de credito por mes
     $sql = "SELECT {$ByRTM}\n\t\t`creditos_mvtos_asdpm`.`socio`,\n\t\t`creditos_mvtos_asdpm`.`documento`,\n\t\t`creditos_mvtos_asdpm`.`recibo`,\n\t\t`creditos_mvtos_asdpm`.`fecha`,\n\t\t`creditos_mvtos_asdpm`.`operacion`,\n\t\t`creditos_mvtos_asdpm`.`monto`,\n\t\t`creditos_mvtos_asdpm`.`afectacion`\n\t\tFROM `creditos_mvtos_asdpm`\tWHERE {$wCredito1} {$wFecha1} ";
     //setLog($sql);
     $rsM = $ql->getDataRecord($sql);
     $saldo = 0;
     $creditoA = 0;
     $xT = new cTipos();
     $xF = new cFecha();
     $FECHA_DE_ULTIMO_PAGO = "1998-01-01";
     $CREDITO_SALDO_ANTERIOR = 0;
     $MvtoAnterior = OPERACION_CLAVE_MINISTRACION;
     $ESTADO_ACTUAL = CREDITO_ESTADO_VIGENTE;
     $DIVISOR_DE_INTERESES = EACP_DIAS_INTERES;
     $DCred = array();
     $IsCredNew = true;
     $xCred = null;
     foreach ($rsM as $rw) {
         $socio = $xT->cInt($rw["socio"]);
         $credito = $xT->cInt($rw["documento"]);
         $fecha = $rw["fecha"];
         $nota = "";
         //
         $IsCredNew = true;
         if ($creditoA != $credito) {
             $saldo = 0;
             $FECHA_DE_ULTIMO_PAGO = $fecha;
             $ESTADO_ACTUAL = CREDITO_ESTADO_VIGENTE;
             $xCred = new cCredito($credito, $socio);
             $xCred->init();
             $DCred = $xCred->getDatosDeCredito();
             $CREDITO_SALDO_ANTERIOR = 0;
             //si es Ministracion
             if ($MvtoAnterior == OPERACION_CLAVE_MINISTRACION) {
                 $FECHA_DE_ULTIMO_PAGO = $xCred->getFechaDeMinistracion();
             }
             $msg .= "------------------------\tNUEVO_CREDITO : {$credito}------------------------------\r\n";
             if ($EliminarTodo == false) {
                 my_query("DELETE FROM creditos_sdpm_historico WHERE numero_de_credito = {$credito} {$wFecha2}");
             }
         } else {
             $IsCredNew = false;
         }
         $OProd = $xCred->getOProductoDeCredito();
         $recibo = $rw["recibo"];
         $operacion = $rw["operacion"];
         $afectacion = $rw["afectacion"];
         $monto = $xT->cFloat($rw["monto"], 2);
         $periocidad = $xCred->getPeriocidadDePago();
         $FechaVencimiento = $xCred->getFechaDeVencimiento();
         //(!isset( $DCred["fecha_vencimiento_dinamico"])) ? $xCred->getFechaDeVencimiento() : $DCred["fecha_vencimiento_dinamico"];
         $DiaInteresMax = $xF->setSumarDias(INTERES_DIAS_MAXIMO_A_DEVENGAR, $FechaVencimiento);
         $dias_transcurridos = $xF->setRestarFechas($fecha, $FECHA_DE_ULTIMO_PAGO);
         $saldo_calculado = $dias_transcurridos * $saldo;
         //No poner la afectacion
         $saldo += $xT->cFloat($monto * $afectacion, 2);
         // si es normal, calcular normal, si es mora: Calcular mora y normal, si es vencido: calcular normal y mora
         $interes = 0;
         $moratorio = 0;
         $TASA_NORMAL = $xCred->getTasaDeInteres();
         $TASA_MORA = $xCred->getTasaDeMora();
         $TIPO_DE_PAGO = $xCred->getTipoDePago();
         $PAGOS_SIN_CAPITAL = $xCred->getPagosSinCapital();
         $MONTO_ORIGINAL_DE_CREDITO = $xCred->getMontoAutorizado();
         $saldoBase = $xT->cFloat($saldo, 2);
         if ($operacion == OPERACION_CLAVE_PAGO_CAPITAL and $saldo == 0) {
             $saldoBase = $CREDITO_SALDO_ANTERIOR;
         }
         if ($MvtoAnterior == OPERACION_CLAVE_MINISTRACION) {
             $saldoBase = $CREDITO_SALDO_ANTERIOR;
             $saldo_calculado = $dias_transcurridos * $CREDITO_SALDO_ANTERIOR;
         }
         $SALDO_ACTUAL = $xCred->getSaldoActual();
         $BASE_NORMAL = $saldo_calculado;
         $BASE_MORA = $saldo_calculado;
         eval($OProd->getPreModInteres());
         //considerar si es un maximo de x dias devengar en vencidos
         switch ($ESTADO_ACTUAL) {
             case CREDITO_ESTADO_VIGENTE:
                 $interes = $BASE_NORMAL * $TASA_NORMAL / $DIVISOR_DE_INTERESES;
                 break;
             case CREDITO_ESTADO_VENCIDO:
                 //validar si tiene un maximo de dias transcurridos de devengado
                 if ($xF->getInt($fecha) <= $xF->getInt($DiaInteresMax)) {
                     $interes = $BASE_NORMAL * $TASA_NORMAL / $DIVISOR_DE_INTERESES;
                     $moratorio = $BASE_MORA * $TASA_MORA / $DIVISOR_DE_INTERESES;
                 } else {
                     $interes = 0;
                     $moratorio = 0;
                     $nota = "Despues del {$DiaInteresMax} no se acumula Interes, Vencimiento : {$FechaVencimiento}";
                 }
                 break;
             case CREDITO_ESTADO_MOROSO:
                 $interes = $BASE_NORMAL * $TASA_NORMAL / $DIVISOR_DE_INTERESES;
                 $moratorio = $BASE_MORA * $TASA_MORA / $DIVISOR_DE_INTERESES;
                 break;
         }
         //END_SWITCH
         $interes = $xT->cFloat($interes, 2);
         if ($periocidad == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
             $moratorio = $xT->cFloat($moratorio, 2);
             //0; //2012-04-10
         } else {
             //$moratorio			= 0;
         }
         eval($OProd->getPosModInteres());
         $msg .= "{$socio}\t{$credito}\t{$fecha}\t{$monto}\t{$saldo}\t{$dias_transcurridos}\t{$operacion}\t{$ESTADO_ACTUAL}\t{$interes}\t{$moratorio}\t{$nota}\r\n";
         if ($xF->getInt($fecha) <= $xF->getInt(SYS_FECHA_DE_MIGRACION)) {
             $interes = 0;
             $moratorio = 0;
             if (MODO_DEBUG == true) {
                 $msg .= "WARN\tOMITIR Interes {$interes} y MORA por {$moratorio} por estar antes de la migracion {$fecha}\r\n";
             }
         }
         if ($xF->getInt($fecha) <= $xF->getInt($fechaCorte)) {
             $msgSDPM = $xCred->addSDPM($interes, $moratorio, $FECHA_DE_ULTIMO_PAGO, $saldo, $ESTADO_ACTUAL, $fecha, $operacion, $saldo_calculado);
             //if(MODO_DEBUG == true){ $msg	.= $msgSDPM;	}
         }
         if ($saldo <= TOLERANCIA_SALDOS) {
             $msg .= "------------------------------------------------------\r\n";
         }
         $creditoA = $credito;
         $FECHA_DE_ULTIMO_PAGO = $fecha;
         $CREDITO_SALDO_ANTERIOR = $saldo;
         $MvtoAnterior = $operacion;
         /*
          * si existe la operacion de cambio de estatus, validar en el array, y actualizar el valor
          * Este estatus se aplicara en el siguiente
          */
         if (in_array($operacion, $arrEstatusD)) {
             $ESTADO_ACTUAL = $arrEstatus[$operacion];
         }
     }
     return $msg;
 }
$alerts = "";
//Movimientos que afectan al Capital
$cAfectCapital = new cBases(2004);
$aAfectCapital = $cAfectCapital->getMembers_InArray();
$mAfectCapital = 0;
$plan_de_pagos = false;
$socio = $xCred->getClaveDePersona();
$dcredito = $xCred->getDatosDeCredito();
$fecha_ministracion = $xCred->getFechaDeMinistracion();
// $dcredito["fecha_ministracion"];
$fecha_ult_mvto = $xCred->getFechaUltimoDePago();
$fecha_vencimiento = $xCred->getFechaDeVencimiento();
// $dcredito["fecha_vencimiento"];
$numero_de_pagos = $xCred->getPagosAutorizados();
$estatus_del_credito = $xCred->getEstadoActual();
$saldo_actual = $xCred->getSaldoActual();
$saldo_del_credito = $saldo_actual;
$interes_anticipado = $dcredito["sdo_int_ant"];
$grupo = $xCred->getClaveDeGrupo();
$OProducto = $xCred->getOProductoDeCredito();
//$OEstado					= $xCred->getOEstado();
$tasa_iva = $generarIVA == false ? 0 : $xCred->getTasaIVA();
$interes_normal_devengado = $xCred->getInteresNormalDevengado();
$interes_normal_pagado = $xCred->getInteresNormalPagado();
$interes_moratorio_pagado = $xCred->getInteresMoratorioPagado();
$interes_moratorio_devengado = $xCred->getInteresMoratorioDev();
$periocidad = $xCred->getPeriocidadDePago();
$ByLetra = "";
$solo_mora_corriente = $pago_total == true ? true : false;
//Corrige calculo de Interes.- Si es primer pago
$DInteres = $xCred->getInteresDevengado($fecha_operacion, $parcialidad, false, $solo_mora_corriente);
$interesanticipado = isset($SRC["c-anticipado"]) ? $SRC["c-anticipado"] : 0;
$ivaintereses = isset($SRC["c-ivaintereses"]) ? $SRC["c-ivaintereses"] : 0;
$ivaotros = isset($SRC["c-ivaotros"]) ? $SRC["c-ivaotros"] : 0;
$capital = isset($SRC["c-capital"]) ? $SRC["c-capital"] : 0;
$p_interescorriente = isset($SRC["p-corriente"]) ? $SRC["p-corriente"] : 0;
$p_interesremanente = isset($SRC["p-remanente"]) ? $SRC["p-remanente"] : 0;
$p_interesmoroso = isset($SRC["p-moroso"]) ? $SRC["p-moroso"] : 0;
$p_interesvencido = isset($SRC["p-vencido"]) ? $SRC["p-vencido"] : 0;
$p_interesanticipado = isset($SRC["p-anticipado"]) ? $SRC["p-anticipado"] : 0;
$p_ivaintereses = isset($SRC["p-ivaintereses"]) ? $SRC["p-ivaintereses"] : 0;
$p_ivaotros = isset($SRC["p-ivaotros"]) ? $SRC["p-ivaotros"] : 0;
$dsol = $xCred->getDatosDeCredito();
$estatus = $xCred->getEstadoActual();
$grupo = $dsol["grupo_asociado"];
$periocidad = $xCred->getPeriocidadDePago();
$nuevo_saldo = $xCred->getSaldoActual();
//Datos Fijos
$percont = EACP_PER_CONTABLE;
// Periodo Contable
$percbza = EACP_PER_COBRANZA;
// Periodo Cobranza.
$perseg = EACP_PER_SEGUIMIENTO;
// Period de Seguimiento.
$permens = date("m");
// Periodo de dias en el mes
$persem = date("N");
// Periodo de dias en la semana.
$peranual = date("Y");
// Ao Natural.
//Datos del Respeto al Plan de Pagos
$OPdto = $xCred->getOProductoDeCredito();