function jsaGetComisionPorApertura($idcredito)
{
    $xCred = new cCredito($idcredito);
    $xCred->init();
    $tasa = $xCred->getOProductoDeCredito()->getTasaComisionApertura();
    return round($xCred->getMontoAutorizado() * $tasa, 2);
}
 function initByCredito($ClaveCredito = false)
 {
     $ClaveCredito = $ClaveCredito == false ? $this->mCredito : $ClaveCredito;
     $xCred = new cCredito($ClaveCredito);
     $xCred->init();
     $this->mClaveDeCredito = $xCred->getNumeroDeCredito();
     $this->mClaveDePersona = $xCred->getClaveDePersona();
     $this->mClaveDeGrupo = $xCred->getClaveDeGrupo();
     $this->mClaveDeEmpresa = $xCred->getClaveDeEmpresa();
     $this->mTasaDeIVA = $xCred->getTasaIVA();
     $this->mTotalParciales = $xCred->getPagosAutorizados();
     if ($this->mDiasTolerancia == 0) {
         $DProducto = $xCred->getOProductoDeCredito();
         $this->mDiasTolerancia = $DProducto->getDiasTolerados();
     }
     if ($xCred->getNumeroDePlanDePagos() != false) {
         $this->mNumeroDePlan = $xCred->getNumeroDePlanDePagos();
         $this->init();
     }
     $this->mIsInit = true;
     $this->mMessages .= $xCred->getMessages(OUT_TXT);
     return $this->mNumeroDePlan;
 }
     ///$xLog->add("OK\t$icnt\tDatos del credito $idpersona|$idcredito SI existen \r\n", $xLog->DEVELOPER);
 } else {
     $xLog->add("WARN\t{$idpersona}-{$idcredito}\t{$sucres}\t{$icnt}\tDatos de Pago del credito {$idpersona}|{$idcredito} no existen \r\n", $xLog->DEVELOPER);
 }
 $ClaveActualOtorgante = $xCR->getClaveDeOtorgante();
 // ENTIDAD_CLAVE_SIC;
 $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()));
function jsGetCreditosByCriteria($convenio, $estatus, $periocidad, $oficial)
{
    $ByConvenio = "";
    $ByEstatus = "";
    $ByPeriocidad = "";
    $ByOficial = "";
    $ByInclude = "";
    if ($estatus != "todas") {
        $ByEstatus = " AND\n\t\t(`creditos_solicitud`.`estatus_actual` = {$estatus}) ";
    }
    if ($oficial != "todas") {
        $ByOficial = "\tAND\n\t(`creditos_solicitud`.`oficial_credito` = {$oficial})";
    }
    if ($convenio != "todas") {
        $ByConvenio = "\t AND\n\t(`creditos_solicitud`.`tipo_convenio` ={$convenio}) ";
    }
    if ($periocidad != "todas") {
        $ByPeriocidad = " AND (`creditos_solicitud`.`periocidad_de_pago` ={$periocidad})";
    }
    $sqlCred = "SELECT\n\t`socios_general`.`codigo`,\n\tCONCAT(\n\t\t`socios_general`.`apellidopaterno`, ' ',\n\t\t`socios_general`.`apellidomaterno`, ' ',\n\t\t`socios_general`.`nombrecompleto`\n\t\t)\tAS 'nombre',\n\t`creditos_solicitud`.`grupo_asociado`,\n\t`creditos_solicitud`.`contrato_corriente_relacionado`,\n\n\t`creditos_solicitud`.`numero_solicitud`,\n\t`creditos_solicitud`.`tipo_convenio`,\n\t`creditos_solicitud`.`fecha_ministracion`,\n\t`creditos_solicitud`.`fecha_vencimiento`,\n\t`creditos_solicitud`.`pagos_autorizados`,\n\t`creditos_solicitud`.`saldo_actual`,\n\t`creditos_solicitud`.`monto_parcialidad` ,\n\t`creditos_solicitud`.`ultimo_periodo_afectado`,\n\t`creditos_solicitud`.`tasa_ahorro`,\n\t`creditos_solicitud`.`periocidad_de_pago`\nFROM\n\t`socios_general` `socios_general`\n\t\tINNER JOIN `creditos_solicitud` `creditos_solicitud`\n\t\tON `socios_general`.`codigo` = `creditos_solicitud`.`numero_socio`\nWHERE\n\t(`creditos_solicitud`.`saldo_actual` >=" . TOLERANCIA_SALDOS . ")\n\t{$ByEstatus}\n\t{$ByInclude}\n\t{$ByPeriocidad}\n\t{$ByConvenio}\n\t{$ByOficial}\n\t";
    $rs = mysql_query($sqlCred, cnnGeneral());
    $tds = "";
    $xTbl = "";
    $ix = 0;
    $SqlConv = "SELECT\n\t\t\t\t\t\t\t`creditos_tipoconvenio`.`idcreditos_tipoconvenio`,\n\t\t\t\t\t\t\t`creditos_tipoconvenio`.`descripcion_tipoconvenio`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`creditos_tipoconvenio` `creditos_tipoconvenio`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t(`creditos_tipoconvenio`.`idcreditos_tipoconvenio` !=99) ";
    $SConvenio = new cSelect("c-{$ix}-conv", "i-{$ix}-conv", $SqlConv);
    $SConvenio->setEsSql();
    while ($rw = mysql_fetch_array($rs)) {
        //Informacion del credito
        $socio = $rw["codigo"];
        $nombre = htmlentities($rw["nombre"]);
        $credito = $rw["numero_solicitud"];
        $grupo = $rw["grupo_asociado"];
        $contrato = $rw["contrato_corriente_relacionado"];
        $convenio = $rw["tipo_convenio"];
        $ministrado = $rw["fecha_ministracion"];
        $vencimiento = $rw["fecha_vencimiento"];
        $pagos = $rw["pagos_autorizados"];
        $saldo = $rw["saldo_actual"];
        $parcialidad = $rw["monto_parcialidad"];
        $periodo = $rw["ultimo_periodo_afectado"];
        $tasa_ahorro = $rw["tasa_ahorro"];
        $vperiocidad = $rw["periocidad_de_pago"];
        $Cred = new cCredito($credito, $socio);
        //opciones Especiales
        $CtrlGroup = "hidden";
        $CtrlAhorro = "text";
        $CtrlPeriocidad = "text";
        //Convenio
        $SConvenio->setOptionSelect($convenio);
        $SConvenio->addEvent("onchange", "markMe", $ix);
        $iConv = $SConvenio->show();
        $DConv = $Cred->getDatosDeProducto($convenio);
        $clase_grupal = $DConv["tipo_de_integracion"];
        $OConv = $Cred->getOProductoDeCredito($convenio);
        //Variaciones de los controles
        if ($OConv->getEsProductoDeGrupos() == true) {
            $CtrlGroup = "text";
        }
        if ($tasa_ahorro == 0) {
            $CtrlAhorro = "hidden";
        }
        if ($vperiocidad == 360) {
            $CtrlPeriocidad = "hidden";
        }
        $tds .= "<tr>\n\t\t\t\t\t\t<td><input type='hidden' id='i-{$ix}-soc' name='c-{$ix}-soc' value='{$socio}' />{$socio}</td>\n\t\t\t\t\t\t<td>{$nombre}</td>\n\t\t\t\t\t\t<td><input type='hidden' id='i-{$ix}-cred' name='c-{$ix}-cred' value='{$credito}' />{$credito}</td>\n\t\t\t\t\t\t<td><input type='{$CtrlGroup}' id='i-{$ix}-grup' name='c-{$ix}-grup' value='{$grupo}' size='3' class='mny' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<td><input type='{$CtrlAhorro}' id='i-{$ix}-capt' name='c-{$ix}-capt' value='{$contrato}' size='10' class='mny' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<td>{$iConv}</td>\n\t\t\t\t\t\t<td><input type='text' id='i-{$ix}-fminis' name='c-{$ix}-fminis' value='{$ministrado}' size='10' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<td><input type='text' id='i-{$ix}-fvenc' name='c-{$ix}-fvenc' value='{$vencimiento}' size='10' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<td><input type='{$CtrlPeriocidad}' id='i-{$ix}-pagos' name='c-{$ix}-pagos' value='{$pagos}' size='3' class='mny' /></td>\n\t\t\t\t\t\t<td><input type='text' id='i-{$ix}-saldo' name='c-{$ix}-saldo' value='{$saldo}' size='12' class='mny' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<td><input type='text' id='i-{$ix}-parc' name='c-{$ix}-parc' value='{$parcialidad}' size='10' class='mny' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<td><input type='{$CtrlPeriocidad}' id='i-{$ix}-per' name='c-{$ix}-per' value='{$periodo}' size='3' class='mny' onchange=\"markMe({$ix})\" /></td>\n\t\t\t\t\t\t<th><input type=\"checkbox\"  id=\"chk-{$ix}\" /></th>\n\t\t\t\t\t</tr>";
        $ix++;
    }
    $xTbl = "<table width='100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Socio</th>\n\t\t\t\t\t<th>Nombre</th>\n\t\t\t\t\t<th>Num.<br/>Solicitud</th>\n\t\t\t\t\t<th>Grupo</th>\n\t\t\t\t\t<th>Contrato<br />de Ahorro</th>\n\t\t\t\t\t<th>Convenio</th>\n\t\t\t\t\t<th>Ministracion</th>\n\t\t\t\t\t<th>Vencimiento</th>\n\t\t\t\t\t<th>Pagos</th>\n\t\t\t\t\t<th>Saldo</th>\n\t\t\t\t\t<th>Parcialidad</th>\n\t\t\t\t\t<th>#Letra</th>\n\t\t\t\t\t<th></th>\n\t\t\t\t</tr>\n\t\t\t\t<tbody>\n\t\t\t\t\t{$tds}\n\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t\t<input type='hidden' name='cCount' id='idCount' value = '{$ix}' />";
    return $xTbl;
}
$montocomision = parametro("idmontocomisiondescontado", 0, MQL_FLOAT);
$xHP->init();
$xFRM = new cHForm("frmacciones", "./");
if ($idsolicitud <= 0 or $monto_cheque1 <= 0) {
    echo JS_CLOSE;
} 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");
 //$DatosPlanAnterior			= false;
 $OPCION_ANUAL_FLAT = true;
 $decenales = array();
 $dia_1_ab = PQ_DIA_PRIMERA_QUINCENA;
 $dia_2_ab = PQ_DIA_SEGUNDA_QUINCENA;
 $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();
 //Tabs
 $xHTabs = new cHTabs();
 $xBtn = new cHButton("");
 $xCred = new cCredito($idsolicitud);
 if ($xCred->init() == false) {
     $idsocio = getPersonaEnSession();
     $oFrm->addToolbar($xBtn->getRegresar("../index.xul.php?p=frmcreditos/creditos.panel.frm.php", true));
     $oFrm->addCreditBasico();
     $oFrm->addSubmit();
     $oFrm->addAviso($xCred->getMessages());
     //echo $oFrm->get();
 } else {
     if (setNoMenorQueCero($idsocio) <= 0) {
         $idsocio = $xCred->getClaveDePersona();
     }
     $xOPdto = $xCred->getOProductoDeCredito();
     if ($idsocio != $xCred->getClaveDePersona()) {
         $msg = "ERROR\tLa Persona {$idsocio} no es la propietaria del credito, el credito marca " . $xCred->getClaveDePersona() . "\r\n";
         $oFrm->addToolbar($xBtn->getRegresar("../index.xul.php?p=frmcreditos/creditos.panel.frm.php", true));
         $oFrm->addAviso($msg);
     } else {
         $oFrm->addHTML($xCred->getFichaDeSocio(true));
         $oFrm->addHTML($xCred->getFicha(true, "", true));
         $codigo_de_oficial = $xCred->getClaveDeOficialDeCredito();
         if (MODO_DEBUG == true) {
             $oFrm->addToolbar($xBtn->getBasic("TR.EDICION_AVANZADA", "jsActualizarCreditoRAW()", "aviso", "edit-credito2", false));
             $oFrm->addToolbar($xBtn->getBasic("TESTING", "var xG=new Gen();xG.w({url:'../unit/core.creditos.test.php?credito={$idsolicitud}'})", "checar", "test-cred", false));
         }
         $oFrm->addCreditoComandos($idsolicitud);
         $oFrm->addToolbar($xBtn->getBasic("TR.ACTUALIZAR DATOS", "jsActualizarCredito()", "editar", "edit-credito", false));
         $oFrm->addToolbar($xBtn->getBasic("TR.IMPRIMIR PAGARE", "printpagare()", "dinero", "view-pagare", false));
function getListadoDeGrupoParaGuardar($solicitud, $socio)
{
    $xNot = new cHNotif();
    $xCred = new cCredito($solicitud, $socio);
    $xCred->initCredito();
    $DCred = $xCred->getDatosDeCredito();
    $OConv = $xCred->getOProductoDeCredito();
    $grupo = $xCred->getClaveDeGrupo();
    $body = "";
    $elements = 0;
    $avisos = "";
    if ($OConv->getEsProductoDeGrupos() == true) {
        $body .= "<p class='aviso'>SE HA DETECTADO QUE ESTE CREDITO ES DEL GRUPO {$grupo}</p>";
        $xGrp = new cGrupo($grupo);
        $DPlan = $xGrp->getDatosDePlaneacionInArray();
        $recibo = $DPlan["idoperaciones_recibos"];
        $presidenta = $xGrp->getRepresentanteCodigo();
        $tds = "";
        if (isset($recibo)) {
            $body .= "<p class='aviso'>SE CARGAN DATOS DE LA PLANEACION # {$recibo}</p>";
            $sql = "SELECT\n\t\t\t\t\t`operaciones_mvtos`.`tipo_operacion`,\n\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado`,\n\t\t\t\t\t`socios_general`.`codigo`,\n\t\t\t\t\tCONCAT(`socios_general`.`apellidopaterno`, ' ',\n\t\t\t\t\t`socios_general`.`apellidomaterno`, ' ',\n\t\t\t\t\t`socios_general`.`nombrecompleto`) AS 'nombre',\n\t\t\t\t\t`operaciones_mvtos`.`afectacion_real` AS 'monto',\n\t\t\t\t\t`operaciones_mvtos`.`detalles`\n\t\t\t\tFROM\n\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\t\t\tINNER JOIN `socios_general` `socios_general`\n\t\t\t\t\t\tON `operaciones_mvtos`.`socio_afectado` = `socios_general`.`codigo`\n\t\t\t\tWHERE\n\t\t\t\t\t(`operaciones_mvtos`.`tipo_operacion` =112) AND\n\t\t\t\t\t(`operaciones_mvtos`.`recibo_afectado` ={$recibo})";
            $rs = mysql_query($sql, cnnGeneral());
            while ($rw = mysql_fetch_array($rs)) {
                $socio = $rw["codigo"];
                $tds .= "\n\t\t\t\t\t\t\t<tr id=\"tr-{$grupo}-{$socio}\">\n\t\t\t\t\t\t\t\t<th>" . $socio . " <input type=\"hidden\" id=\"socio-{$grupo}-{$socio}\" value=\"" . $socio . "\" /></th>\n\t\t\t\t\t\t\t\t<td>" . htmlentities($rw["nombre"]) . "</td>\n\t\t\t\t\t\t\t\t<td><input type=\"text\" id=\"monto-{$grupo}-{$socio}\" value=\"" . $rw["monto"] . "\" class='mny' onchange=\"jsUpdateAutorizacion();\" maxlength=\"20\" /></td>\n\t\t\t\t\t\t\t\t<td><input type=\"text\" id=\"detalles-{$grupo}-{$socio}\" value=\"" . htmlentities($rw["detalles"]) . "\" maxlength=\"60\" /></td>\n\t\t\t\t\t\t\t</tr>";
                $elements++;
            }
            $body .= "<fieldset>\n\t\t\t\t\t\t\t<legend>|&nbsp;&nbsp;GUARDAR DATOS DE LA AUTORIZACION POR GRUPO&nbsp;&nbsp;|</legend>\n\t\t\t\t\t\t\t\t<table width='100%' align='center'>\n\t\t\t\t\t\t\t<th>Socio(a)</th>\n\t\t\t\t\t\t\t<th>Nombre Completo</th>\n\t\t\t\t\t\t\t<th>Monto Autorizado</th>\n\t\t\t\t\t\t\t<th>Observaciones</th>\n\t\t\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t\t\t{$tds}\n\t\t\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t\t\t\t<th colspan='4'><a class='button' id='icmdGoGroup' onclick='jsSavePlaneacion({$elements})'>Guardar Autorizacion Grupal y Enviar Autorizacion</a></th>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</fieldset>";
            //Crear el recibo
            $fecha = fechasys();
            $oficial = elusuario($_SESSION["SN_b80bb7740288fda1f201890375a60c8f"]);
            $xRec = setNuevorecibo($presidenta, $solicitud, $fecha, 1, 40, "CREDITO_DE_GRUPO_ELABORADO_POR_{$oficial}", DEFAULT_CHEQUE, DEFAULT_TIPO_PAGO, DEFAULT_RECIBO_FISCAL, $grupo);
            $body .= "<p class='aviso'>Se Crea el Recibo # {$xRec} para Trabajar</p>";
            if (isset($_SESSION["recibo_en_proceso"])) {
                $body .= "<p class='aviso'>Se Ha Liberado el Recibo # " . $_SESSION["recibo_en_proceso"] . " para Trabajar con # {$xRec}</p>";
                unset($_SESSION["recibo_en_proceso"]);
            }
            $_SESSION["recibo_en_proceso"] = $xRec;
        }
    } else {
        //XXX: COOOOOOOOOOOOOOOOOOOOOOOOOOOREGIR
        $body .= $xNot->get("Credito Sin problemas<input type='hidden' id='idesautorizado' />");
    }
    $body .= $avisos;
    return $body;
}
 function setCredito($credito)
 {
     $this->mDocumento = $credito;
     $xFDE = new cFecha();
     $xLng = new cLang();
     $cCred = new cCredito($credito);
     $cCred->init();
     $idsolicitud = $credito;
     $DCred = $cCred->getDatosDeCredito();
     $DProd = $cCred->getOProductoDeCredito();
     $OOParam = new cProductoDeCreditoOtrosDatosCatalogo();
     $numero_de_socio = $cCred->getClaveDePersona();
     $this->mPersona = $numero_de_socio;
     $cSoc = new cSocio($numero_de_socio);
     $cSoc->init();
     $svar_info_cred = "";
     $tblInfCred = new cFicha(iDE_CREDITO, $idsolicitud);
     $this->setPersona($numero_de_socio);
     $svar_info_cred = $tblInfCred->show(true);
     //Lista de Beneficiados
     $lst_beneficiados = "";
     $this->getListadoDeAvales($idsolicitud);
     $SQLCBen = "SELECT `socios_relacionestipos`.`descripcion_relacionestipos` AS 'relacion', `socios_relaciones`.`nombres`,\t`socios_relaciones`.`apellido_paterno`,\t`socios_relaciones`.`apellido_materno`,\n\t\t\t`socios_consanguinidad`.`descripcion_consanguinidad` AS 'consaguinidad'\n\t\t\tFROM `socios_relaciones` `socios_relaciones` INNER JOIN `socios_consanguinidad` `socios_consanguinidad` ON `socios_relaciones`.`consanguinidad` = `socios_consanguinidad`.`idsocios_consanguinidad`\n\t\t\tINNER JOIN `socios_relacionestipos` `socios_relacionestipos` ON `socios_relaciones`.`tipo_relacion` = `socios_relacionestipos`.`idsocios_relacionestipos`\n\t\t\tWHERE (`socios_relaciones`.`socio_relacionado` ={$numero_de_socio}) AND (`socios_relaciones`.`credito_relacionado` ={$idsolicitud})\tAND\t(`socios_relaciones`.`tipo_relacion`=11)";
     $tblCBen = new cTabla($SQLCBen);
     $lst_beneficiados = $tblCBen->Show();
     $firmas_de_avales = $this->mFirmasAvales;
     // $cSoc->getCoResponsables("firmas", "avales", $idsolicitud );
     //Plan de Pago segun SQL
     $splan_pagos = $cCred->getPlanDePago(OUT_HTML, true, true);
     //==================================================================================
     $fichas_de_avales = $this->mFichasAvales;
     //$cCred->getAvales_InText();
     $fecha_larga_de_documento = $xFDE->getFechaLarga($cCred->getFechaDeMinistracion());
     $fichas_de_respsolidarios = "";
     //TODO: FALTA
     //Otros Datos
     $monto_ministrado = $cCred->getMontoAutorizado();
     $tasa_interes_mensual_ordinario = round($cCred->getTasaDeInteres() / 12 * 100, 2);
     $tasa_interes_anual_ordinario = $cCred->getTasaDeInteres();
     $fecha_de_vencimiento = $cCred->getFechaDeVencimiento();
     $fecha_de_ministracion = $cCred->getFechaDeMinistracion();
     $tasa_garantia_liquida = $DCred["porciento_garantia_liquida"] * 100;
     $monto_garantia_liquida = $monto_ministrado * $tasa_garantia_liquida;
     $tasa_interes_mensual_moratorio = round($cCred->getTasaDeMora() / 12 * 100, 2);
     $dias_del_credito = $cCred->getDiasAutorizados();
     $meses_del_credito = sprintf("%02d", ceil($dias_del_credito / 30.416666666666668));
     $periocidad = $cCred->getPeriocidadDePago();
     //Tipo de Credito por SQL
     $SQLTCred = "SELECT * FROM creditos_modalidades WHERE idcreditos_modalidades=" . $DCred["tipo_credito"];
     $tipo_de_credito = mifila($SQLTCred, "descripcion_modalidades");
     //Datos del Grupo Solidarios por SQL
     $SQLGAsoc = "SELECT * FROM socios_grupossolidarios WHERE idsocios_grupossolidarios=" . $DCred["grupo_asociado"];
     $InfoGrupo = obten_filas($SQLGAsoc);
     $nombre_rep_social = $InfoGrupo["representante_nombrecompleto"];
     $codigo_rep_social = $InfoGrupo["representante_numerosocio"];
     $nombre_voc_vigila = $InfoGrupo["vocalvigilancia_nombrecompleto"];
     $nombre_del_grupo = $InfoGrupo["nombre_gruposolidario"];
     $domicilio_rep_social = domicilio($codigo_rep_social);
     $tabla_asociadas = "";
     $lista_asociadas = "";
     $tasa_de_cat = $cCred->getCAT();
     $DPeriocidad = new cPeriocidadDePago($cCred->getPeriocidadDePago());
     $DPeriocidad->init();
     $monto_con_interes = "";
     $monto_con_interes_letras = "";
     if ($DCred["grupo_asociado"] != DEFAULT_GRUPO) {
         $SQL_get_grupo = "SELECT `socios_general`.`codigo`, CONCAT(`socios_general`.`nombrecompleto`, ' ', `socios_general`.`apellidopaterno`, ' ', `socios_general`.`apellidomaterno`) AS 'nombre_completo'\n\t\t\t\t\t\t\t\t\tFROM `socios_general` `socios_general` WHERE (`socios_general`.`grupo_solidario` =" . $DCred["grupo_asociado"] . ")";
         $rsg = getRecordset($SQL_get_grupo);
         while ($rwt = mysql_fetch_array($rsg)) {
             $lista_asociadas .= ", " . $rwt["nombre_completo"];
         }
     }
     if (EACP_INCLUDE_INTERES_IN_PAGARE == true) {
         if ($periocidad == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
             $monto_con_interes = $cCred->getMontoAutorizado() + $cCred->getInteresDiariogenerado() * $cCred->getDiasAutorizados();
         } else {
             $sqlInt = "SELECT `operaciones_mvtos`.`docto_afectado`, `operaciones_mvtos`.`tipo_operacion`, COUNT(`operaciones_mvtos`.`idoperaciones_mvtos`) AS `mvtos`,\n\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real` *\t`eacp_config_bases_de_integracion_miembros`.`afectacion`) AS 'monto'\n\t\t\t\t\tFROM `operaciones_mvtos` `operaciones_mvtos` INNER JOIN `eacp_config_bases_de_integracion_miembros`\t`eacp_config_bases_de_integracion_miembros`\n\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `eacp_config_bases_de_integracion_miembros`.`miembro` WHERE (`operaciones_mvtos`.`docto_afectado` = {$idsolicitud})\n\t\t\t\t\tAND (`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` = 2601)\n\t\t\t\t\tGROUP BY `operaciones_mvtos`.`docto_afectado`, `eacp_config_bases_de_integracion_miembros`.`codigo_de_base`\n\t\t\t\t\tORDER BY `eacp_config_bases_de_integracion_miembros`.`codigo_de_base`, `operaciones_mvtos`.`fecha_afectacion`, `operaciones_mvtos`.`socio_afectado`\t";
             $xF = obten_filas($sqlInt);
             $monto_con_interes = $xF["monto"];
         }
         $monto_con_interes_letras = convertirletras($monto_con_interes);
         $monto_con_interes = getFMoney($monto_con_interes);
     }
     $this->mArr["variable_informacion_del_credito"] = $cCred->getFicha();
     //"variable_lista_de_beneficiados" 		=> $lst_beneficiados,
     $this->mArr["variable_tipo_de_credito"] = $tipo_de_credito;
     $this->mArr["variable_monto2_ministrado_con_intereses_en_letras"] = $monto_con_interes_letras;
     $this->mArr["variable_monto2_ministrado_con_intereses"] = $monto_con_interes;
     $this->mArr["variable_monto_ministrado"] = getFMoney($monto_ministrado);
     $this->mArr["variable_tasa_mensual_de_interes_ordinario"] = $tasa_interes_mensual_ordinario;
     $this->mArr["variable_credito_fecha_de_vencimiento"] = $xFDE->getFechaMediana($fecha_de_vencimiento);
     $this->mArr["variable_monto_garantia_liquida"] = getFMoney($monto_garantia_liquida);
     $this->mArr["variable_tasa_mensual_de_interes_moratorio"] = $tasa_interes_mensual_moratorio . "";
     $this->mArr["variable_tasa_de_garantia_liquida"] = $tasa_garantia_liquida . "";
     $this->mArr["variable_plan_de_pagos"] = $splan_pagos;
     $this->mArr["variable_docto_fecha_larga_actual"] = $fecha_larga_de_documento;
     $this->mArr["variable_nombre_de_la_representante_social"] = $nombre_rep_social;
     $this->mArr["variable_listado_de_integrantes"] = $lista_asociadas;
     $this->mArr["variable_nombre_de_la_vocal_de_vigilancia"] = $nombre_voc_vigila;
     $this->mArr["variable_nombre_del_grupo_solidario"] = $nombre_del_grupo;
     $this->mArr["variable_domicilio_de_la_representante_social"] = $domicilio_rep_social;
     $this->mArr["variable_meses_de_duracion_del_credito"] = $meses_del_credito;
     $this->mArr["variable_en_letras_monto_ministrado"] = convertirletras($monto_ministrado);
     $this->mArr["variable_credito_fecha_de_ministracion"] = $xFDE->getFechaCorta($fecha_de_ministracion);
     $this->mArr["variable_tasa_cat"] = $tasa_de_cat;
     $this->mArr["variable_credito_periocidad"] = $DPeriocidad->getNombre();
     $this->mArr["variable_credito_monto_parcialidad_fija"] = getFMoney($cCred->getMontoDeParcialidad());
     $this->mArr["variable_credito_numero_de_pagos"] = $cCred->getPagosAutorizados();
     $this->mArr["variable_tasa_anual_de_interes_moratorio"] = $cCred->getTasaDeInteres() * 2 * 100 . "%";
     $this->mArr["variable_tasa_anual_de_interes_ordinario"] = $cCred->getTasaDeInteres() * 100 . "%";
     //sobreescribir datos de la empresa
     $xEmp = new cEmpresas($cCred->getClaveDeEmpresa());
     $xEmp->init();
     $this->mArr["variable_nombre_de_la_empresa"] = $xEmp->getNombre();
     $this->mArr["variable_nombre_de_empresa"] = $xEmp->getNombre();
     $this->mArr["variable_fecha_de_primer_pago"] = $xFDE->getFechaMediana($cCred->getFechaPrimeraParc());
     $this->mArr["variable_avales_en_fichas"] = $fichas_de_avales;
     $this->mArr["variable_firmas_de_avales"] = $firmas_de_avales;
     $this->mArr["variable_avales_autorizacion_central_riesgo"] = $this->mFichaRiesgoAv;
     $this->mArr["variable_fecha_ultimo_abono"] = $xFDE->getFechaLarga($cCred->getFechaUltimaParc());
     $this->mArr["variable_fecha_de_primer_abono"] = $xFDE->getFechaMediana($cCred->getFechaPrimeraParc());
     //$this->mArr["variable_fecha_de_primer_abono"]						=
     $this->mArr["variable_en_letras_tasa_mensual_de_interes_moratorio"] = convertirletras_porcentaje($tasa_interes_mensual_moratorio);
     $this->mArr["variable_lista_de_avales_con_domicilio"] = $this->mLAvalesConDir;
     /*variable_aval1_nombre_completo variable_aval1_domicilio_completo variable_aval1_domicilio_localidad variable_aval1_domicilio_municipio*/
     //Cargar Avales
     $this->mArr["variable_listado_de_garantias"] = $this->getListadoDeGarantias();
     //$this->mArr["variable_modalidad_de_credito"]					= $cCred->getOEstado()
     $this->mArr["variable_estado_de_credito"] = $cCred->getOEstado()->descripcion_estatus()->v(OUT_TXT);
     //$this->mArr["variable_credito_num_de_pago_actual"]				= $cCred->getPeriodoActual();
     $this->mArr["variable_contrato_id_legal"] = $DProd->getOtrosParametros($OOParam->CONTRATO_ID_LEGAL);
     $this->mArr["variable_producto_comision_apertura"] = $DProd->getOtrosParametros($OOParam->TASA_DE_COMISION_AP);
 }
 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;
 }