function jsaGetDatosDelCredito($credito, $socio)
{
    $cred = new cCredito($credito, $socio);
    $cred->initCredito();
    $DC = $cred->getDatosDeCredito();
    $tab = new TinyAjaxBehavior();
    $tab->add(TabSetValue::getBehavior('idMonto', $DC["saldo_actual"]));
    $tab->add(TabSetValue::getBehavior('idIntereses', $DC["interes_normal_devengado"]));
    $tab->add(TabSetValue::getBehavior('idTasa', $DC["tasa_interes"]));
    return $tab->getString();
}
 function setRevertir()
 {
     $sucess = true;
     $arrValuesRev = array("-1" => "1", "1" => "-1", "0" => "0");
     if ($this->mInit == false) {
         $this->init();
     }
     $rw = $this->mArrayData;
     $codigo = $rw["idoperaciones_mvtos"];
     $docto = $rw["docto_afectado"];
     $socio = $rw["socio_afectado"];
     $preservar_mvto = $rw["preservar_movimiento"];
     $CodeRevertir = $rw["formula_de_cancelacion"];
     $monto = $rw["afectacion_real"];
     $afectacion = $rw["valor_afectacion"];
     $recibo = $rw["recibo_afectado"];
     $colocacion = array();
     $captacion = array();
     //selecciona un comportamiento segun el Origen del Recibo
     switch ($this->mAplicadoA) {
         case "colocacion":
             //cargar datos del credito
             $Credito = new cCredito($docto, $socio);
             $Credito->initCredito();
             $colocacion = $Credito->getDatosDeCredito();
             break;
         case "captacion":
             //cargar datos de la cuenta
             $Cuenta = new cCuentaALaVista($docto);
             $Cuenta->initCuentaByCodigo();
             $captacion = $Cuenta->getDatosInArray();
             break;
         case "mixto":
             //cargar datos de la cuenta y del credito
             $Credito = new cCredito($docto, $socio);
             $Credito->initCredito();
             $colocacion = $Credito->getDatosDeCredito();
             $Cuenta = new cCuentaALaVista($docto);
             $Cuenta->initCuentaByCodigo();
             $captacion = $Cuenta->getDatosInArray();
             $this->mMessages .= "WARN\tEL Recibo es Mixto, se carga tanto Captacion como Colocacion\r\n";
             break;
         default:
             $this->mMessages .= "ERROR\tEL Recibo es " . $this->mAplicadoA . ", NO SE CARGA CODIGO\r\n";
             break;
     }
     eval($CodeRevertir);
     if ($preservar_mvto == '1') {
         $SQL_DM = "UPDATE operaciones_mvtos\n\t\t\t\t\t\tSET afectacion_estadistica=afectacion_real,\n\t\t\t\t\t\tafectacion_real = 0, afectacion_contable=0,\n\t\t\t\t\t\tafectacion_cobranza=0, valor_afectacion=0,\n\t\t\t\t\t\testatus_mvto = 99,\n\t\t\t\t\t\tdocto_neutralizador = " . DEFAULT_RECIBO . ",\n\t\t\t\t\t\trecibo_afectado\t= " . DEFAULT_RECIBO . "\n\t\t\t\t\t\tWHERE idoperaciones_mvtos = {$codigo}\n\t\t\t\t\t\t";
         $this->mMessages .= "Actualizando el Movimiento {$codigo}\r\n";
     } else {
         $SQL_DM = "DELETE FROM operaciones_mvtos\n\t\t\t\t\t\tWHERE idoperaciones_mvtos = {$codigo}";
         $this->mMessages .= "Eliminado el Movimiento {$codigo}\r\n";
     }
     my_query($SQL_DM);
 }
echo getRawHeader();
$sqlDic = new cSQLListas();
$idsolicitud = isset($_GET["solicitud"]) ? $_GET["solicitud"] : DEFAULT_CREDITO;
$entidad = EACP_NAME;
if ($idsolicitud == DEFAULT_CREDITO) {
    echo JS_CLOSE;
} else {
    $xCred = new cCredito($idsolicitud);
    $xCred->init();
    $siavales = isset($_GET["avales"]) ? $_GET["avales"] : SYS_NINGUNO;
    $sigarantias = isset($_GET["garantias"]) ? $_GET["garantias"] : SYS_NINGUNO;
    $sipatrimonio = isset($_GET["patrimonio"]) ? $_GET["patrimonio"] : SYS_NINGUNO;
    $siflujo = isset($_GET["flujo"]) ? $_GET["flujo"] : SYS_NINGUNO;
    $sihistorial = isset($_GET["historial"]) ? $_GET["historial"] : SYS_NINGUNO;
    $nowdate = fechasys();
    $rwc = $xCred->getDatosDeCredito();
    $fecha_de_solicitud = $rwc["fecha_solicitud"];
    // datos generales del socio
    $idsocio = $xCred->getClaveDePersona();
    // Numero de Socio
    $xSocio = new cSocio($idsocio);
    $xSocio->init();
    $mynom = $xSocio->getNombreCompleto();
    $thisdom = $xSocio->getDomicilio();
    $sqlconv = "SELECT * FROM creditos_tipoconvenio WHERE idcreditos_tipoconvenio =" . $xCred->getClaveDeConvenio();
    $dconv = obten_filas($sqlconv);
    $convenio = $dconv["descripcion_tipoconvenio"];
    $mod_del_conv = $dconv["tipo_de_integracion"];
    ?>
<!-- -->
<h2>SOLICITUD DE CR&Eacute;DITO [<?php 
function jsa_getDatosDeCredito($solicitud)
{
    $xCred = new cCredito($solicitud);
    $xCred->initCredito();
    $xF = new cFecha();
    $xT = new cTipos();
    $dCreds = $xCred->getDatosDeCredito();
    $periocidad = $xCred->getPeriocidadDePago();
    $FMinistracion = $xCred->getFechaDeMinistracion();
    $contrato_corriente = $xCred->getContratoCorriente();
    $xPlanGen = new cPlanDePagosGenerador();
    $xPlanGen->initPorCredito($solicitud);
    $FPrimerAb = $xPlanGen->getFechaDePrimerPago();
    $xF = new cFecha(0, $FMinistracion);
    $FM_d = $xF->dia();
    $FM_a = $xF->anno();
    $FM_m = $xF->mes();
    $xF2 = new cFecha(1, $FPrimerAb);
    $xF2->set($FPrimerAb);
    $PA_d = $xF2->dia();
    $PA_a = $xF2->anno();
    $PA_m = $xF2->mes();
    $tab = new TinyAjaxBehavior();
    //setLog("$PA_d --- $PA_m ---- $PA_a  - - - - - $FPrimerAb");
    $tab->add(TabSetvalue::getBehavior('ideldia1', $FM_d));
    $tab->add(TabSetvalue::getBehavior('idelmes1', $FM_m));
    $tab->add(TabSetvalue::getBehavior('idelanno1', $FM_a));
    $tab->add(TabSetvalue::getBehavior('ideldia0', $PA_d));
    $tab->add(TabSetvalue::getBehavior('idelmes0', $PA_m));
    $tab->add(TabSetvalue::getBehavior('idelanno0', $PA_a));
    $tab->add(TabSetvalue::getBehavior('idDescripcionSolicitud', $xCred->getShortDescription()));
    $tab->add(TabSetvalue::getBehavior('idcuenta', $contrato_corriente));
    //$xCred->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_CATORCENAL
    if ($xCred->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
        $tab->add(TabSetvalue::getBehavior('idFormaDePago', $xCred->getTipoDePago()));
        //setLog("El pago es " . $xCred->getPeriocidadDePago() );
        if ($xCred->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_CATORCENAL) {
            $tab->add(TabSetvalue::getBehavior('idtipo_plan_pagos', CREDITO_TIPO_DIAS_DE_PAGO_PERSONALIZADOS));
        }
    }
    return $tab->getString();
}
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 Common_c5fe0408555dbf392918c6f77a4d01b2($params)
{
    $stdDiv = STD_LITERAL_DIVISOR;
    $DPar = explode($stdDiv, $params, 10);
    //mensajes
    //grupo
    $xTip = new cTipos();
    //
    $socio = $xTip->cInt($DPar[0]);
    $credito = $xTip->cInt($DPar[1]);
    $letra = $xTip->cInt($DPar[2]);
    $capital = $xTip->cFloat($DPar[3]);
    $interes = $xTip->cFloat($DPar[4]);
    $iva = $xTip->cFloat($DPar[5]);
    $ahorro = $xTip->cFloat($DPar[6]);
    $nota = $xTip->cChar($DPar[7]);
    $numero = $xTip->cInt($DPar[8]);
    $limit = $xTip->cInt($DPar[9]);
    $msg = "====================== MOVIMIENTO {$numero} DE {$limit} ====================\r\n";
    //Datos del Credito
    $Cred = new cCredito($credito, $socio);
    $Cred->initCredito();
    $DCred = $Cred->getDatosDeCredito();
    $saldo = $DCred["saldo_actual"] - $capital;
    $contrato_captacion = $DCred["contrato_corriente_relacionado"];
    $grupo = $DCred["grupo_asociado"];
    $msg .= $Cred->getMessages();
    if (isset($_SESSION["recibo_en_proceso"])) {
        $recibo = $_SESSION["recibo_en_proceso"];
        $fecha = fechasys();
        $_SESSION["total_recibo_en_proceso"] += $capital + $interes + $ahorro;
        $xRec = new cReciboDeOperacion(200, false, $recibo);
        $xRec->setNumeroDeRecibo($recibo, true);
        $xRec->setNumeroDeRecibo($recibo, true);
        $DRec = $xRec->getDatosInArray();
        $cheque = $DRec["cheque_afectador"];
        $tipopago = $DRec["tipo_pago"];
        $recibofiscal = $DRec["recibo_fiscal"];
        $xRec->setGenerarPoliza();
        $msg .= "{$socio}\t{$credito}\tCREDITO\tMovimiento {$i} del Credito {$credito} del Socio {$socio} con Saldo {$saldo}\r\n ";
        $msg .= "{$socio}\t{$credito}\tMONTOS\tCapital: {$capital} || Interes: {$interes} || Ahorro: {$ahorro} \r\n";
        //Agregando Capital
        if ($capital > 0) {
            $xRec->setNuevoMvto($fecha, $capital, 120, $letra, $nota . ";SDO:" . $saldo, 1, TM_ABONO, $socio, $credito);
            $arrCred = array("saldo_actual" => $saldo);
            $Cred->setUpdate($arrCred);
        }
        //Agregando Interes
        if ($interes > 0) {
            $xRec->setNuevoMvto($fecha, $interes, 140, $letra, $nota, 1, TM_ABONO, $socio, $credito);
        }
        //agregando el IVA
        if ($interes > 0) {
            $xRec->setNuevoMvto($fecha, $iva, 151, $letra, $nota, 1, TM_ABONO, $socio, $credito);
        }
        //Agregando Ahorro
        if ($ahorro > 0) {
            $xC = new cCuentaALaVista($contrato_captacion);
            if (!isset($contrato_captacion) or $contrato_captacion == CTA_GLOBAL_CORRIENTE or $contrato_captacion == 0) {
                $contrato_captacion = $xC->setNuevaCuenta(2, 1, $socio, "CUENTA_AUTOMATICA", $credito);
                $msg .= "{$socio}\t{$credito}\tNuevaCta\tse dio de alta a la cuenta {$contrato_captacion}\r\n";
                //2011-nov-30 se agrego la actualizacion del contrato relacionado
                $arrCred = array("contrato_corriente_relacionado" => $contrato_captacion);
                $Cred->setUpdate($arrCred);
            }
            $xC = new cCuentaALaVista($contrato_captacion);
            $xC->setSocioTitular($socio);
            $xC->setReciboDeOperacion($recibo);
            $xC->setDeposito($ahorro, $cheque, $tipopago, $recibofiscal, $nota, $grupo, $fecha, $recibo);
            $msg .= $xC->getMessages("txt");
            $msg .= "{$socio}\t{$credito}\tAhorro\t El Saldo Quedo en " . $xC->getNuevoSaldo() . "\r\n";
        }
        $msg .= "{$socio}\t{$credito}\tObservacion\t {$nota}\r\n";
        $msg .= $xRec->getMessages("txt");
    } else {
        $msg .= "NO_SE_HA_DEFINIDO_UN_RECIBO";
    }
    $xLog = new cFileLog("log_de_recibo_" . $recibo);
    $xLog->setWrite($msg);
    $xLog->setClose();
    $MsgEnd = "";
    if ($numero == $limit) {
        $xRec->setForceUpdateSaldos();
        $xRec->setFinalizarRecibo(true);
        //$MsgEnd		.= "**** proceso terminado ****";
    }
    //retorna el id del control de origen para neutralizar
    return "-{$numero}";
}
 function setRepararPlanDePagos()
 {
     $msg = "";
     $msg .= "============= RECONSTRUYENDO LETRAS SISBANCS \r\n";
     //Selecciona todo los pagos segun letra, en una base
     $arrFechas = array();
     $arrMontos = array();
     $sqlLetras = "SELECT SQL_CACHE\n\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado`,\n\t\t\t\t\t\t\t`operaciones_mvtos`.`periodo_socio`,\n\t\t\t\t\t\t\tMAX(`operaciones_mvtos`.`fecha_afectacion`) AS 'fecha',\n\t\t\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real`) AS 'monto'\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\t\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros`\n\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`\n\t\t\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` =\n\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` = 2003)\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t(`operaciones_mvtos`.`afectacion_real` >0)\n\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado`,\n\t\t\t\t\t\t\t`operaciones_mvtos`.`periodo_socio`\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t\t\t\t`operaciones_mvtos`.`socio_afectado`,\n\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado`,\n\t\t\t\t\t\t\t`operaciones_mvtos`.`periodo_socio` ";
     $rsA = getRecordset($sqlLetras);
     while ($rw = mysql_fetch_array($rsA)) {
         $arrFechas[$rw["docto_afectado"] . "-" . $rw["periodo_socio"]] = $rw["fecha"];
         $arrMontos[$rw["docto_afectado"] . "-" . $rw["periodo_socio"]] = $rw["monto"];
     }
     $fecha_de_migracion = fechasys();
     //DELETE FROM sisbancs_amortizaciones WHERE credito = 0 AND parcialidad = 1
     $sql = "SELECT\n\t\t\t\t\t\t\t\t`sisbancs_amortizaciones`.*\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`sisbancs_amortizaciones` `sisbancs_amortizaciones` ";
     $rs = getRecordset($sql);
     $contar = 0;
     while ($rw = mysql_fetch_array($rs)) {
         $credito = $rw["credito"];
         $socio = $rw["credito"];
         $parcialidad = $rw["parcialidad"];
         $vencimiento = $rw["fecha_de_vencimiento"];
         $saldo_vigente = $rw["saldo_vigente"];
         $saldo_vencido = 0;
         $interes_vigente = $rw["interes_vigente"];
         $interes_vencido = 0;
         $interes_moratorio = 0;
         $dias_en_mora = 0;
         $estatus = $rw["estatus"];
         $fecha_de_abono = $rw["fecha_de_abono"];
         $iva_normal = 0;
         $iva_moratorio = 0;
         $tasa_normal = 0;
         $tasa_moratorio = 0;
         $monto_abonado = 0;
         $saldo_teorico = 0;
         $DCredito = array();
         //TODO: Actualizar sentencia de obtencion de IVA
         $msg .= "{$contar}\t{$credito}\t{$parcialidad}\t\t=================================================\r\n";
         //Actualizar le fecha de Pago
         if (isset($arrFechas["{$credito}-{$parcialidad}"])) {
             $fecha_de_abono = $arrFechas["{$credito}-{$parcialidad}"];
             $monto_abonado = $arrMontos["{$credito}-{$parcialidad}"];
             //Corrige las idioteces de reestructuras
             if (strtotime($vencimiento) > strtotime($fecha_de_abono)) {
                 $fecha_de_abono = $vencimiento;
                 $msg .= "{$contar}\t{$credito}\t{$parcialidad}\tERROR_DE_FECHA\tLa fecha de abono(" . getFechaMediana($fecha_de_abono) . ") es menor a la de vencimiento " . getFechaMediana($vencimiento) . " \r\n";
             }
             $saldo_teorico = $saldo_vigente - $monto_abonado;
             $msg .= "{$contar}\t{$credito}\t{$parcialidad}\tFECHA_DE_ABONO\tLa fecha de Abono Existente es " . getFechaMediana($fecha_de_abono) . " y suma de {$monto_abonado} (saldo teorico {$saldo_teorico})\r\n";
         }
         if (strtotime($vencimiento) < strtotime($fecha_de_migracion)) {
             $msg .= "{$contar}\t{$credito}\t{$parcialidad}\tFECHA_DE_VCTO\tLa Vencimiento (" . getFechaMediana($vencimiento) . ") es Menor a la Fecha de Migracion\r\n";
             $estatus = 2;
             $saldo_vencido = $saldo_vigente;
             $saldo_vigente = 0;
             $interes_vencido = $interes_vigente;
             $interes_vigente = 0;
             $xCred = new cCredito($credito, $socio);
             $xCred->init();
             $DCredito = $xCred->getDatosDeCredito();
             $tasa_moratorio = $DCredito["tasa_moratorio"];
             $dias_morosos = setNoMenorQueCero(restarfechas($fecha_de_migracion, $fecha_de_abono));
             $interes_moratorio = $saldo_vencido * $dias_morosos * $tasa_moratorio / EACP_DIAS_INTERES;
             $msg .= "{$contar}\t{$credito}\t{$parcialidad}\tINTERES_MORATORIO\tEl Interes Moratorio es {$interes_moratorio}, por {$dias_morosos} dias en Mora y Capital {$saldo_vencido}\r\n";
         }
         $iva_normal = ($interes_vigente + $interes_vencido) * 0.15;
         $iva_moratorio = $interes_moratorio * 0.15;
         $sqlUD = "UPDATE sisbancs_amortizaciones\n\t\t\t\t\t\t\t\t\t\t\t\t    SET  fecha_de_abono='{$fecha_de_abono}', saldo_vigente={$saldo_vigente},\n\t\t\t\t\t\t\t\t\t\t\t\t\tsaldo_vencido={$saldo_vencido}, interes_vigente={$interes_vigente}, interes_vencido={$interes_vencido},\n\t\t\t\t\t\t\t\t\t\t\t\t\tsaldo_interes_vencido=0, interes_moratorio={$interes_moratorio}, estatus={$estatus},\n\t\t\t\t\t\t\t\t\t\t\t\t\tiva_interes_normal={$iva_normal}, iva_interes_moratorio={$iva_moratorio}\n\t\t\t\t\t\t\t\t\t\t\t\t    WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\tcredito={$credito}, parcialidad={$parcialidad} ";
         my_query($sqlUD);
         $contar++;
     }
     return $msg;
 }
 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);
 }
 $ahorro = round($xT->cFloat($cadena[6]), 2);
 $observaciones = $xT->cChar($cadena[7]);
 $total = $capital + $ahorro + $interes + $iva;
 if (isset($socio) and isset($credito) and !empty($socio) and !empty($credito)) {
     $DSoc = new cSocio($socio);
     $SocioExiste = $DSoc->existe($socio);
     $CreditoExiste = $DSoc->existeCredito($credito);
     if ($SocioExiste == true and $CreditoExiste == true) {
         $DSoc->init();
         $nombre = $DSoc->getNombreCompleto();
         $nombre = substr($nombre, 0, 25);
         //Verificar el Saldo del Credito
         $CCred = new cCredito($credito, $socio);
         //echo "$credito ---- $socio<br>";
         $CCred->init();
         $DCred = $CCred->getDatosDeCredito();
         $saldo = $DCred["saldo_actual"];
         if (!isset($saldo) or $saldo == 0) {
             //$socio 		= "";
             if ($saldo != 0 && $capital != 0) {
                 $msg .= "{$iReg}\t{$socio}\t{$credito}\tDIF1\tEL Saldo({$saldo}) es menor al abono({$capital}), difiere por " . getFMoney($saldo - $capital) . " \r\n ";
             }
             $saldo = 0;
             $diferencias += $capital;
             $capital = 0;
             $total = $capital + $ahorro + $interes;
             $cls = " class='warn' ";
         }
         if ($saldo < $capital) {
             $msg .= "{$iReg}\t{$socio}\t{$credito}\tDIF2\tEL Saldo({$saldo}) es menor al abono({$capital}) , difiere por " . getFMoney($saldo - $capital) . " \r\n ";
             if ($saldo < 0) {
 //<----------------------------------------------------------
 $variable_monto_del_recibo = number_format($totaloperacion, 2, '.', ',');
 $variable_monto_del_recibo_en_letras = convertirletras($totaloperacion);
 $variable_fecha_del_recibo = "";
 $variable_tipo_de_pago = "";
 $xCajero = new cSystemUser(getUsuarioActual());
 $variable_nombre_del_cajero = $xCajero->getNombreCompleto();
 $variable_observacion_del_recibo = "";
 $xSuc = new cSucursal(getSucursal());
 $xSuc->init();
 $DSuc = $xSuc->getDatosInArray();
 $variable_lugar = $DSuc["municipio"] . ", " . $DSuc["estado"];
 $variable_marca_de_tiempo = date("Ymd:His");
 /* -----------------Verifica si es solicitud, si es imprime el saldo actual */
 if ($origen == "colocacion" or $origen == "mixto") {
     $DD = $cCred->getDatosDeCredito();
     if ($DD != false and is_array($DD)) {
         $sdoctacred = $DD["saldo_actual"];
         $sdov = $DD["saldo_vencido"];
         $nota = "Capital Insoluto: \$ " . getFMoney($sdoctacred) . "|";
         $tipoDocto = eltipo("creditos_modalidades", $DD["tipo_credito"]);
         $estatDocto = eltipo("creditos_estatus", $DD["estatus_actual"]);
     }
 }
 //inicializa variables vacias
 $svar_info_cred = "_NO_APLICA_";
 $variable_lista_beneficiados = "_NO_APLICA_";
 $tipo_de_credito = "_NO_APLICA_";
 $monto_ministrado = "_NO_APLICA_";
 $tasa_interes_mensual_ordinario = "_NO_APLICA_";
 $fecha_de_vencimiento = "_NO_APLICA_";
 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;
 }
    }
}
$xCred = new cCredito($solicitud, $socio);
$xCred->init();
$xLetra = null;
$tds = "";
$esp_tds = "";
$mMvtos = array();
$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();
$interescorriente = isset($SRC["c-corriente"]) ? $SRC["c-corriente"] : 0;
$interesremanente = isset($SRC["c-remanente"]) ? $SRC["c-remanente"] : 0;
$interesmoroso = isset($SRC["c-moroso"]) ? $SRC["c-moroso"] : 0;
$interesvencido = isset($SRC["c-vencido"]) ? $SRC["c-vencido"] : 0;
$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.