}
if ($sucess == true) {
    $grupo_asociado = $xSoc->getClaveDeGrupo();
    if ($periocidad == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
        $dias_solicitados = $xFecha->setRestarFechas($fecha_vencimiento, $fecha_ministracion);
    } elseif ($periocidad == CREDITO_TIPO_PERIOCIDAD_DIARIO) {
        $dias_solicitados = $xFecha->setRestarFechas($fecha_vencimiento, $fecha_ministracion);
        $numeropagos = $dias_solicitados - $xFecha->getDiasHabilesEnRango($fecha_vencimiento, $fecha_ministracion);
    } else {
        $dias_solicitados = $numeropagos * $periocidad;
        $fecha_vencimiento = $xFecha->setSumarDias($dias_solicitados, $fecha_ministracion);
    }
    $xConv = new cProductoDeCredito($tipoconvenio);
    $xConv->init();
    if (USE_OFICIAL_BY_PRODUCTO == true) {
        $oficial_de_seguimiento = $xConv->getOficialDeSeguimiento();
    }
    if ($esrenovado == true) {
        $TipoDeAutorizacion = CREDITO_AUTORIZACION_RENOVADO;
        $msg .= "WARN\tCredito marcado como Renovado \r\n";
    }
    $xCred = new cCredito();
    $result = $xCred->add($tipoconvenio, $persona, $contrato_corriente, $monto_solicitado, $periocidad, $numeropagos, $dias_solicitados, $rubro_destino, false, $grupo_asociado, $amp_destino, $observaciones, $oficial_de_credito, $fecha_solicitud, $tipo_de_pago, INTERES_POR_SALDO_INSOLUTO, false, $fecha_ministracion, $xSoc->getClaveDeEmpresa(), $TipoDeAutorizacion);
    if ($result == false) {
        $xFRM->addToolbar($xBtn->getRegresar("solicitud_de_credito.frm.php", true));
        $xFRM->addAviso($xHP->lang(MSG_ERROR_SAVE));
        $xFL = new cFileLog();
        $xFL->setWrite($xCred->getMessages(OUT_TXT));
        $xFL->setWrite($xSoc->getMessages());
        $xFL->setClose();
        $xFRM->addToolbar($xFL->getLinkDownload("Log de eventos", ""));