function jsaInitPeriodo($empresa, $periocidad, $periodo) { $xF = new cFecha(); $xEmp = new cEmpresas($empresa); $xEmp->init(); $tab = new TinyAjaxBehavior(); $DPer = $xEmp->getOPeriodo($periocidad); $empPeriodo = $xEmp->getPeriodo(); if ($periodo > $empPeriodo) { $fechaInicial = $xEmp->getFechaDeAviso($periocidad, false, $periodo, $periodo + 1); } else { $dias_dif = setNoMenorQueCero($periodo - $empPeriodo); $starD = $periocidad * $dias_dif + 1; $fechaInicial = $xF->setSumarDias($starD, $DPer->fecha_final()->v()); } $fechaFinal = $xF->setSumarDias($xEmp->getPeriocidadPref(), $fechaInicial); $tab->add(TabSetvalue::getBehavior("idfecha-10", $xF->getFechaMX($fechaInicial, "-"))); $tab->add(TabSetvalue::getBehavior("idfecha-11", $xF->getFechaMX($fechaFinal, "-"))); return $tab->getString(); }
$miFecha = parametro("fecha", fechasys()); $xF = new cFecha(0, $miFecha); //$xHFrm->addHElem( $txt ); $xHFrm->addHElem($xF->show(true)); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Inicio se semana==" . $xF->getFechaDeInicioDeSemana() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Inicio se nombre semana==" . $xF->getDayName($xF->getFechaDeInicioDeSemana()) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dias del Mes==" . $xF->getDiasDelMes() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, En Fecha Corta==" . $xF->getFechaCorta() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha Larga==" . $xF->getFechaLarga() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, En Fecha Mediana==" . $xF->getFechaMediana() . "</p>"); //$xHFrm->addHElem( ); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha Operativa Maxima==" . $xF->getFechaMaximaOperativa() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, El Mes Anterior==" . $xF->getFechaMesAnterior() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, dos meses atras==" . $xF->getFechaMesAnterior(false, 2) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha} - 30 Dias==" . $xF->setRestarDias(30) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha} + 30 Dias==" . $xF->setSumarDias(30) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha} + 2 meses==" . $xF->setSumarMeses(2) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha} - 2 meses==" . $xF->setRestarMeses(2) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Nombre del Dia==" . $xF->getDayName() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dia Inicial del mes==" . $xF->getDiaInicial() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Obtener Dia Habil==" . $xF->getDiaHabil() . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Dias desde el 31Dic2013==" . $xF->setRestarFechas($xF->get(), "2013-12-31") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Buscar Sabado(D6) para el dia de hoy==" . $xF->getDiaAbonoSemanal(6) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Buscar NOMBRE Sabado(D6) para el dia de hoy==" . $xF->getDayName($xF->getDiaAbonoSemanal(6)) . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-02") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-11") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-18") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-20") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-24") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-29") . "</p>"); $xHFrm->addHElem("<p class='aviso'>La {$miFecha}, Fecha de Pago Decenal 1==" . $xF->getDiaAbonoDecenal(10, 20, 30, "2014-03-31") . "</p>");
?> </td> </tr> <tr> <td><?php echo $xHP->lang("numero de", "pagos"); ?> </td> <td><input name="numpagos" type="number" value="2" id="idnumpagos" onblur="jsaValidarMontoDeCredito()" class="mny" size="4"/></td> <td><?php echo $xHP->lang("fecha de", "vencimiento"); ?> </td> <td id="idthvcto"><?php $xF0 = new cFecha(0); $xF0->set($xF0->setSumarDias(EACP_DIAS_MINIMO_CREDITO)); $xF0->show(false, "OPERATIVO"); ?> </td> </tr> <tr> <td><?php echo $xHP->lang("monto", "solicitado"); ?> </td> <td><input name="montosol" type ="number" value = "0.00" id="idmontosol" onchange="jsValidarMonto();jsaGetLetrasByNumero();" onblur=" jsaGetLetrasByNumero();" class="mny"/></td> <th colspan="2"><div id="idmontoletras" ></div></th> </tr> <tr> <td><?php
function setGuardarPerfilTransaccional($tipo, $pais, $monto, $numero, $observaciones, $fecha = false) { $fecha = $fecha == false ? fechasys() : $fecha; $xPT = new cPersonas_perfil_transaccional(); $xTT = new cPersonas_perfil_transaccional_tipos(); $xF = new cFecha(); $ql = new MQL(); $pais = strtoupper($pais); $persona = $this->mClaveDePersona; $id = $xPT->query()->getLastID(); $xPT->cantidad_calculada(0); $fv = $xF->setSumarDias(AML_KYC_PERFIL_VIGENCIA, $fecha); $xTT->setData($xTT->query()->initByID($tipo)); $ntipo = $xTT->nombre_del_perfil()->v(); //Eliminar perfil parecido.. $sql = "DELETE FROM personas_perfil_transaccional WHERE clave_de_persona = {$persona} AND clave_de_tipo_de_perfil = {$tipo} AND pais_de_origen='{$pais}' "; $ql->setRawQuery($sql); $xPT->afectacion($xTT->afectacion()->v()); $xPT->cantidad_maxima($monto); $xPT->clave_de_persona($persona); $xPT->clave_de_tipo_de_perfil($tipo); $xPT->fecha_de_calculo($xF->getInt($fecha)); $xPT->fecha_de_registro($xF->getInt($fecha)); $xPT->fecha_de_vencimiento($xF->getInt($fv)); $xPT->idpersonas_perfil_transaccional($id); $xPT->maximo_de_operaciones($numero); $xPT->observaciones($observaciones); $xPT->operaciones_calculadas(0); $xPT->pais_de_origen($pais); $ql = $xPT->query()->insert(); $id = $ql->save(); $this->mMessages .= $id == false ? "ERROR\tError al agregar el perfil tipo {$ntipo} por un monto de {$monto}\r\n" : "OK\tSe agrego el perfil {$id} de tipo {$ntipo} por un monto de {$monto}\r\n"; if (MODO_DEBUG == true) { $this->mMessages .= $ql->getMessages(OUT_TXT); } }
function calcular($fecha_inicial = false, $PrimerPago = false, $SegundoPago = false, $TercerPago = false) { $xCred = new cCredito($this->mClaveDeCredito); $xCred->init(); $xF = new cFecha(); $msg = ""; $FORMA_DE_PAGO = $xCred->getFormaDePago(); $PAGOS_AUTORIZADOS = $xCred->getPagosAutorizados(); $PERIOCIDAD_DE_PAGO = $xCred->getPeriocidadDePago(); $MONTO_AUTORIZADO = $xCred->getMontoAutorizado(); $SALDO_ACTUAL = $xCred->getSaldoActual(); $INTERES_PAGADO = $xCred->getInteresNormalPagado(); $MORA_PAGADO = $xCred->getInteresMoratorioPagado(); $xCred->initPagosEfectuados(); $CAPITAL_PAGADO = setNoMenorQueCero($MONTO_AUTORIZADO - $SALDO_ACTUAL); $SALDO_DE_PLAN = $xCred->getMontoAutorizado(); $TASA_NORMAL = $xCred->getTasaDeInteres(); $TASA_MORA = $xCred->getTasaDeMora(); $TASA_IVA = $xCred->getTasaIVA(); $DIVISOR_DE_INTS = EACP_DIAS_INTERES; $FECHA_DE_PAGO = $xCred->getFechaPrimeraParc(); $FECHA_INICIAL = $xCred->getFechaDeMinistracion(); $opciondia_1 = $PrimerPago; $opciondia_2 = $SegundoPago; $opciondia_3 = $TercerPago; //sanitiza la fecha de pago if ($FECHA_DE_PAGO == false) { $FECHA_DE_PAGO = $xF->setSumarDias($PERIOCIDAD_DE_PAGO, $FECHA_INICIAL); } if (($PERIOCIDAD_DE_PAGO > CREDITO_TIPO_PERIOCIDAD_CATORCENAL or $PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_CATORCENAL) and ($opciondia_1 == false or $opciondia_2 == false or $opciondia_3 == false)) { if ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_QUINCENAL) { $opciondia_1 = $opciondia_1 == false ? PQ_DIA_PRIMERA_QUINCENA : $opciondia_1; $opciondia_2 = $opciondia_2 == false ? PQ_DIA_SEGUNDA_QUINCENA : $opciondia_2; } elseif ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_DECENAL) { $opciondia_1 = $opciondia_1 == false ? 10 : $opciondia_1; $opciondia_2 = $opciondia_2 == false ? 20 : $opciondia_2; $opciondia_3 = $opciondia_3 == false ? 30 : $opciondia_3; } else { $opciondia_1 = $opciondia_1 == false ? PM_DIA_DE_PAGO : $opciondia_1; } } //pagos decenales entre el mes $arrPagos = array(); //obtener los dias de pago en el mes por tipo de pago $dia_de_pago = $xCred->getFechaDeMinistracion(); for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; switch ($PERIOCIDAD_DE_PAGO) { case CREDITO_TIPO_PERIOCIDAD_DIARIO: $dia_de_pago = $xF->getDiaHabil($xF->setSumarDias(1, $dia_de_pago)); $arrPagos[$letra][SYS_FECHA] = $dia_de_pago; $msg .= "OK\t{$letra}\tDIARIO\tFecha de pago a {$dia_de_pago}\r\n"; break; case CREDITO_TIPO_PERIOCIDAD_SEMANAL: break; case CREDITO_TIPO_PERIOCIDAD_DECENAL: break; case CREDITO_TIPO_PERIOCIDAD_CATORCENAL: //dias naturales, cada dos semanas? break; case CREDITO_TIPO_PERIOCIDAD_QUINCENAL: $dia_de_pago = $xF->setSumarDias(CREDITO_TIPO_PERIOCIDAD_QUINCENAL, $dia_de_pago); $dia_de_pago = $xF->getDiaAbonoQuincenal($opciondia_1, $opciondia_2, $dia_de_pago); $arrPagos[$letra][SYS_FECHA] = $dia_de_pago; $msg .= "OK\t{$letra}\tQUINCENAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}, {$opciondia_2}\r\n"; break; case CREDITO_TIPO_PERIOCIDAD_MENSUAL: $dia_de_pago = date("Y-m-", $xF->getInt($dia_de_pago)) . $opciondia_1; $dia_de_pago = $xF->setSumarMeses(1, $dia_de_pago); $dia_de_pago = $xF->getDiaHabil($dia_de_pago); $arrPagos[$letra][SYS_FECHA] = $dia_de_pago; $msg .= "OK\t{$letra}\tMENSUAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}\r\n"; break; case CREDITO_TIPO_PERIOCIDAD_BIMESTRAL: break; case CREDITO_TIPO_PERIOCIDAD_TRIMESTRAL: break; } } //$FORMULA_INT = new cFormula("interes_normal"); //dias de pago //si es empresa, tomar la fecha de la empresa semanal, quincenal, mensual, decenal //Iniciar los Pagos Actuales //$this->initParcsPendientes(); $DatosDePagados = $xCred->getListadoDePagos(); /* interes capital impuestos */ switch ($FORMA_DE_PAGO) { case CREDITO_TIPO_PAGO_PERIODICO: //parcialidad interes + capital break; case CREDITO_TIPO_PAGO_FLAT_PARCIAL: for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; $letraAnterior = setNoMenorQueCero($letra - 1); $PagoAnterior = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array(); $capital_pagado = isset($DPago[SYS_CAPITAL]) ? $DPago[SYS_CAPITAL] : 0; $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado; $interes_normal = $MONTO_AUTORIZADO * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS; $capital = $MONTO_AUTORIZADO / $PAGOS_AUTORIZADOS; $capital = setNoMenorQueCero($capital - $capital_pagado); $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0; $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado); $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal; if ($letra == $PAGOS_AUTORIZADOS) { if ($SALDO_DE_PLAN > 0) { $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN; $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n"; } } //determinar proxima fecha de pago $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n"; } break; case CREDITO_TIPO_PAGO_INTERES_PERIODICO: for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; $letraAnterior = setNoMenorQueCero($letra - 1); $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array(); $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0; $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado; $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array(); $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0; //datos del pago anterior $DLetraAnterior = isset($arrPagos[$letraAnterior]) ? $arrPagos[$letraAnterior] : array(); $DLetra = isset($arrPagos[$letra]) ? $arrPagos[$letra] : array(); $FechaAnterior = isset($DLetraAnterior[SYS_FECHA]) ? $DLetraAnterior[SYS_FECHA] : $xCred->getFechaDeMinistracion(); $FechaActual = isset($DLetra[SYS_FECHA]) ? $DLetra[SYS_FECHA] : false; $DIAS_TRANSCURRIDOS = $xF->setRestarFechas($FechaActual, $FechaAnterior); //INTERES NORMAL $interes_normal = $SALDO_DE_PLAN * $DIAS_TRANSCURRIDOS * $TASA_NORMAL / $DIVISOR_DE_INTS; $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado); $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal; if ($capital_pagado > 0) { $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n"; } if ($letra == $PAGOS_AUTORIZADOS) { if ($SALDO_DE_PLAN > 0) { $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN; $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n"; } } $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado}, Dias {$DIAS_TRANSCURRIDOS},Fecha : Actual {$FechaActual} Anterior {$FechaAnterior}\r\n"; } break; case CREDITO_TIPO_PAGO_INTERES_COMERCIAL: for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; $letraAnterior = setNoMenorQueCero($letra - 1); $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array(); $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0; $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado; $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array(); $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0; //INTERES NORMAL $interes_normal = $SALDO_DE_PLAN * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS; $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado); $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal; if ($capital_pagado > 0) { $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n"; } if ($letra == $PAGOS_AUTORIZADOS) { if ($SALDO_DE_PLAN > 0) { $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN; $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n"; } } $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n"; } break; } $NumeroPlan = $this->mNumeroDePlan; //$this->setEliminar(); //eliminar plan de pagos foreach ($arrPagos as $periodo) { } $this->mMessages .= $msg; return $msg; }
function setRegenerarSDPM($PFechaInicial, $PFechaFinal, $GenerarInteres = true, $incluirSinSaldo = false, $NumeroCuenta = false) { // $PFechaFinal = ""; $mBase = 3100; $xT = new cTipos(); $ql = new MQL(); $BySaldo = $incluirSinSaldo == false ? " AND captacion_cuentas.saldo_cuenta >=" . TOLERANCIA_SALDOS : ""; $ByCuentaSDPM = $NumeroCuenta == false ? "" : " AND `captacion_sdpm_historico`.`cuenta` = {$NumeroCuenta} "; $ByCuentaMvto = $NumeroCuenta == false ? "" : " AND `operaciones_mvtos`.`docto_afectado` = {$NumeroCuenta} "; $ByCuentaCta = $NumeroCuenta == false ? "" : " AND captacion_cuentas.numero_cuenta = {$NumeroCuenta} "; $msg = ""; $msg .= "==========================================================================================\r\n"; $msg .= "==================\tGenerando SDPM desde el {$PFechaInicial} al {$PFechaFinal}\r\n"; $msg .= "==========================================================================================\r\n"; $msg .= "Socio\tCuenta\tOPER\tEjercicio\tPeriodo\tFecha\tDias\tMonto\tSaldo\tSDPM\r\n"; $sqlM = "SELECT \n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion` AS 'fecha_operacion',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado` AS 'recibo_afectado',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado` AS 'docto_afectado',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`afectacion_real` AS 'afectacion_real',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`valor_afectacion`,\n\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`afectacion` AS 'afectacion'\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\t\t\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = \n\t\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro` \n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` ={$mBase})\n\t\t\t\t\t\t\t\t\t{$ByCuentaMvto}\n\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion` ASC"; $rsM = getRecordset($sqlM); $arrOps = array(); //Array de montos de operacion $arrRecs = array(); //Array de Recibos de Operacion while ($rwM = mysql_fetch_array($rsM)) { //clave cuenta fecha $cuenta = $rwM["docto_afectado"]; $fecha = $rwM["fecha_operacion"]; if (isset($arrOps[$cuenta . "-" . $fecha])) { $arrOps[$cuenta . "-" . $fecha] += $rwM["afectacion_real"] * $rwM["afectacion"]; } else { $arrOps[$cuenta . "-" . $fecha] = $rwM["afectacion_real"] * $rwM["afectacion"]; } $arrRecs[$cuenta . "-" . $fecha] = $rwM["recibo_afectado"]; //$msg .= "WARN\t$cuenta\tAgregar " . ($rwM["afectacion_real"] * $rwM["afectacion"] ) . "\r\n"; } //Eliminar periodos anteriores $sqlDF = "DELETE FROM captacion_sdpm_historico WHERE (fecha>='{$PFechaInicial}' AND fecha<='{$PFechaFinal}') {$ByCuentaSDPM} "; my_query($sqlDF); //FECHAS $xF = new cFecha(0); // $xTbl = new cSAFETabla(TCAPTACION_CUENTAS); $sqlCX = $xTbl->getQueryInicial() . " WHERE captacion_cuentas.tipo_cuenta = " . CAPTACION_TIPO_VISTA . " {$BySaldo} {$ByCuentaCta} "; $rs1 = getRecordset($sqlCX); while ($rw1 = mysql_fetch_array($rs1)) { $socio = $rw1["numero_socio"]; $cuenta = $rw1["numero_cuenta"]; $xCta = new cCuentaALaVista($cuenta, $socio); $xCta->init($rw1); $DCta = $xCta->getDatosInArray(); $FApertura = $DCta["fecha_apertura"]; $dias = $xF->setRestarFechas($PFechaFinal, $FApertura); $dias += 1; $sucursal = $DCta["sucursal"]; $FechaAnterior = $FApertura; $saldoAnterior = 0; $xF2 = new cFecha(1); for ($i = 0; $i <= $dias; $i++) { $OpFecha = $xF->setSumarDias($i, $FApertura); $xF->set($OpFecha); $OpFechaFin = $xF->getDiaFinal(); $OpMonto = isset($arrOps[$cuenta . "-" . $OpFecha]) ? $arrOps[$cuenta . "-" . $OpFecha] : 0; $idrecibo = isset($arrRecs[$cuenta . "-" . $OpFecha]) ? $arrRecs[$cuenta . "-" . $OpFecha] : DEFAULT_RECIBO; //si la operacion es mayor a cero o es FIN DE MES if ($OpMonto != 0 or $OpFecha == $OpFechaFin) { $diasTrans = $xF2->setRestarFechas($OpFecha, $FechaAnterior); $xF2->set($OpFecha); $ejercicio = $xF2->anno(); $periodo = $xF2->mes(); $sdpd = $saldoAnterior * $diasTrans; $nuevatasa = $xCta->getTasaAplicable(0, 0, $saldoAnterior); //corregir fecha $sqlUSPM = "INSERT INTO captacion_sdpm_historico\n\t\t\t\t\t\t\t\t\t\t(ejercicio, periodo, cuenta, fecha, dias, tasa, monto, recibo, numero_de_socio, sucursal)\n\t \t\t\t\t\t\t\t\tVALUES( {$ejercicio}, {$periodo}, {$cuenta}, '{$OpFecha}', {$diasTrans}, {$nuevatasa}, {$sdpd}, {$idrecibo}, {$socio}, '{$sucursal}') "; //si es valida la operacion, se actualizan if ($OpFecha >= $PFechaInicial and $OpFecha <= $PFechaFinal) { my_query($sqlUSPM); $msg .= "{$socio}\t{$cuenta}\t+SDPM\t{$ejercicio}\t{$periodo}\t{$OpFecha}\t{$diasTrans}\t{$OpMonto}\t{$saldoAnterior}\t{$sdpd}\r\n"; } else { $msg .= "{$socio}\t{$cuenta}\t=SDPM\t{$ejercicio}\t{$periodo}\t{$OpFecha}\t{$diasTrans}\t{$OpMonto}\t{$saldoAnterior}\t{$sdpd}\r\n"; } $FechaAnterior = $OpFecha; $saldoAnterior += $OpMonto; } } } //Agregar Movimientos Finales del MES. //FIXME: Corregir incidencias //opcional: agregar Interes if ($GenerarInteres == true) { $xRec = new cReciboDeOperacion(12, false); $recibo = $xRec->setNuevoRecibo(DEFAULT_SOCIO, 1, $PFechaFinal, 1, 12, "REGENERAR_INTERES_SDPM_{$PFechaFinal}", "NA", "ninguno", "NA", DEFAULT_GRUPO); $msg .= "==========================================================================================\r\n"; $msg .= "==================\tAGREGADO INTERES :: RECIBO {$recibo}\r\n"; $msg .= "==========================================================================================\r\n"; $_SESSION["recibo_en_proceso"] = $recibo; //sumar sdpm del mes por cuenta $sqlSDPM = "SELECT\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`numero_de_socio`,\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`cuenta`,\n\t\t\t\t\t\t\t\tSUM(`captacion_sdpm_historico`.`dias`) AS `dias_transcurridos`,\n\t\t\t\t\t\t\t\tSUM(`captacion_sdpm_historico`.`monto`) AS `sdpm`,\n\t\t\t\t\t\t\t\tROUND( (`captacion_sdpm_historico`.`monto` / `captacion_sdpm_historico`.`dias`), 2) AS `ultimo_saldo`,\n\t\t\t\t\t\t\t\tMAX(`captacion_sdpm_historico`.`fecha`) AS 'UltimaFecha'\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico` `captacion_sdpm_historico` \n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(`captacion_sdpm_historico`.`fecha` >= '{$PFechaInicial}')\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(`captacion_sdpm_historico`.`fecha` <= '{$PFechaFinal}')\n\t\t\t\t\t\t\t\t{$ByCuentaSDPM}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`cuenta`,\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`ejercicio`,\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`periodo`\n\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`fecha` DESC "; $rsCAP = $ql->getDataRecord($sqlSDPM); //setLog($sqlSDPM); foreach ($rsCAP as $rwC) { $socio = $rwC["numero_de_socio"]; $cuenta = $rwC["cuenta"]; $dias_de_calc = $rwC["dias_transcurridos"]; $sumaSDPM = $rwC["sdpm"]; $FechaI = $rwC["UltimaFecha"]; $promedio = $xT->cFloat($sumaSDPM / $dias_de_calc, 2); //XXX: Solucionar Tasa de Interes y hacer las rapida la consulta $xCta = new cCuentaDeCaptacion($cuenta); $xCta->init(); $subtipo = $xCta->getTipoDeSubproducto(); $tasa_nueva = obtentasa($promedio, CAPTACION_TIPO_VISTA, 0, $subtipo); $interes = $sumaSDPM * $tasa_nueva / EACP_DIAS_INTERES; $interes = $xT->cFloat($interes, 2); //agregar movimiento if ($interes > 0) { setNuevoMvto($socio, $cuenta, $recibo, $FechaI, $interes, 222, 1, "CALCULO_AUTOMATICO_DESDE_{$PFechaInicial}"); $msg .= "{$socio}\t{$cuenta}\tAGREGAR\tInteres por {$interes}, tasa {$tasa_nueva}, Promedio {$promedio}, SDPM {$sumaSDPM}, Dias {$dias_de_calc}\r\n"; } else { $msg .= "{$socio}\t{$cuenta}\tIGNORAR\tInteres por {$interes}, tasa {$tasa_nueva}, Promedio {$promedio}, SDPM {$sumaSDPM}, Dias {$dias_de_calc}\r\n"; } } } return $msg; }
$msg .= "ERROR\tEl credito Validado no es el mismo que intenta guardar(" . $xSoc->getUUID() . "|" . $_SESSION[SYS_UUID] . ")\r\n"; $sucess = false; } } else { $sucess = false; } 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));
/** * Funcion que agrega una nueva Cuenta * @param $origen Origen de la cuenta, lavado de dinero * @param $subproducto Subproducto al que pertenece * @param $socio * @param $observaciones * @param $credito * @param $mancomunado1 * @param $mancomunado2 * @param $grupo * @param $fecha_alta * @param $tipo_de_cuenta * @param $tipo_de_titulo * @param $DiasInvertidos * @param $tasa * @param $CuentaDeIntereses * @return unknown_type */ function setNuevaCuenta($origen, $subproducto, $socio, $observaciones = "", $credito = 1, $mancomunado1 = "", $mancomunado2 = "", $grupo = 99, $fecha_alta = false, $tipo_de_cuenta = 20, $tipo_de_titulo = 99, $DiasInvertidos = false, $tasa = false, $CuentaDeIntereses = false, $FechaVencimiento = false) { $xT = new cTipos(0); if ($this->mNumeroCuenta == false) { //Asigna una cuenta por estructura $cuenta = $xT->cSerial(2, $subproducto) . $xT->cSerial(DIGITOS_DE_CLAVE_DE_SOCIO, $socio) . "01"; $sqlNCta = "SELECT COUNT(numero_cuenta) AS 'cuentas'\n\t\t\t\t\t\t\t\t\tFROM captacion_cuentas\n\t\t\t\t\t\t\t\t\tWHERE numero_socio={$socio}"; $datos = obten_filas($sqlNCta); if (isset($datos["cuentas"]) or $datos["cuentas"] > 0) { $cuenta = $xT->cSerial(2, $subproducto) . $xT->cSerial(DIGITOS_DE_CLAVE_DE_SOCIO, $socio) . ($datos["cuentas"] + 1); $this->mMessages .= "WARN\tSe Presume al Numero de cuenta {$cuenta} por que el socio tiene " . $datos["cuentas"] . " cuentas\r\n"; } $this->mNumeroCuenta = $cuenta; unset($datos); } $idsolicitud = $credito; $idgrupo = $grupo; $observacion = $observaciones; $xF = new cFecha(); if ($DiasInvertidos == false) { $DiasInvertidos = $this->mDiasInvertidos; } $fechaalta = $fecha_alta == false ? $this->mFechaOperacion : $fecha_alta; if ($tasa == false) { $tasa = $this->mTasaInteres; } else { $this->mTasaInteres = $tasa; } if ($this->mSocioTitular != 0 and isset($this->mSocioTitular) and $this->mSocioTitular != false) { $idsocio = $this->mSocioTitular; } else { if (isset($socio) && $socio != false) { $idsocio = $socio; $this->mSocioTitular = $socio; } } if ($CuentaDeIntereses == false) { $CuentaDeIntereses = CTA_GLOBAL_CORRIENTE; } $FechaVencimiento = $FechaVencimiento == false ? $xF->setSumarDias($DiasInvertidos, $fechaalta) : $FechaVencimiento; $origencuenta = $origen; $tipotitulo = $tipo_de_titulo; $lacuenta = $this->mNumeroCuenta; $sucursal = getSucursal(); $fechabaja = "2029-12-31"; $estatus = 10; $man1 = $mancomunado1; $man2 = $mancomunado2; $subpdto = $subproducto; $sqlPdto = "SELECT * FROM captacion_subproductos\tWHERE idcaptacion_subproductos={$subpdto}"; $dPdto = obten_filas($sqlPdto); $tipocuenta = $dPdto["tipo_de_cuenta"]; $contrato = $dPdto["nombre_del_contrato"]; $iduser = $_SESSION["SN_b80bb7740288fda1f201890375a60c8f"]; $eacp = EACP_CLAVE; //verifica si existe la Cuenta $cuentas_existentes = $this->setContarCuenta(); // if ($cuentas_existentes > 0) { //sumar otro folio $lacuenta++; $this->mNumeroCuenta = $lacuenta; $cuentas_existentes = $this->setContarCuenta(); if ($cuentas_existentes > 0) { $lacuenta++; $this->mNumeroCuenta = $lacuenta; } } // Si es Inversion la Cuenta Estara Inactiva if ($tipocuenta == 20) { $estatus = 20; } $sqlNR = "INSERT INTO captacion_cuentas(\n\t\t\t\t\t\tnumero_cuenta, numero_socio, numero_grupo, numero_solicitud, tipo_cuenta,\n\t\t\t\t\t\tfecha_apertura, fecha_afectacion, fecha_baja, estatus_cuenta, saldo_cuenta,\n\t\t\t\t\t\teacp, idusuario, inversion_fecha_vcto, inversion_periodo, tasa_otorgada, dias_invertidos, observacion_cuenta, origen_cuenta,\n\t\t\t\t\t\ttipo_titulo, tipo_subproducto, nombre_mancomunado1, nombre_mancomunado2, minimo_mancomunantes, saldo_conciliado, fecha_conciliada,\n\t\t\t\t\t\tsucursal, ultimo_sdpm, oficial_de_captacion,\n\t\t\t\t\t\tcuenta_de_intereses)\n \t\t\t\t\tVALUES(\n\t\t\t\t\t\t{$lacuenta}, {$idsocio}, {$idgrupo}, {$idsolicitud}, {$tipocuenta},\n\t\t\t\t\t'{$fechaalta}', '{$fechaalta}', '{$fechabaja}', {$estatus}, 0,\n\t\t\t\t\t'{$eacp}', {$iduser},\n\t\t\t\t\t'{$FechaVencimiento}', 1, {$tasa}, {$DiasInvertidos}, '{$observacion}', {$origencuenta},\n\t\t\t\t\t{$tipotitulo}, {$subpdto}, '{$man1}', '{$man2}', 0, 0, '{$fechaalta}',\n\t\t\t\t\t'{$sucursal}', 0, {$iduser},\n\t\t\t\t\t{$CuentaDeIntereses})"; $r = my_query($sqlNR); if ($r["stat"] == true) { $this->mMessages .= "OK\tSe Agrego Existosamente la Cuenta {$lacuenta} del subproducto {$subpdto} \r\n"; $this->mSucess = true; $this->mSocioTitular = $idsocio; $this->mGrupoAsociado = $grupo; $this->mCreditoAsoc = $idsolicitud; $this->mNumeroCuenta = $lacuenta; $this->mDiasInvertidos = $DiasInvertidos; $this->mFechaVencimiento = $FechaVencimiento; } else { $this->mMessages .= "ERROR\tal Agregar la Cuenta {$lacuenta} del subproducto {$subpdto}\r\n"; if (MODO_DEBUG == true) { $this->mMessages .= $r["info"]; } $this->mSucess = false; } return $this->mNumeroCuenta; }
} //=================================================================================================================================== $TParcial = $parcialidad_ahorro + $parcialidad_capital + $parcialidad_cargo + $parcialidad_interes + $parcialidad_iva - $bonificaciones; $msgM .= "{$socio}\t{$solicitud}\tPer. {$letra}\t{$dias_normales},{$sumar_dias}\t" . getFMoney($saldo_inicial) . "\t" . getFMoney($saldo_final) . "\t" . getFMoney($parcialidad_capital) . ""; $msgM .= "\t" . getFMoney($parcialidad_interes) . "\t" . getFMoney($parcialidad_iva) . "\t" . getFMoney($parcialidad_cargo) . "\t" . getFMoney($parcialidad_ahorro) . "\t" . getFMoney($TParcial) . "\t{$fecha_de_referencia}\t{$fecha_de_pago}\r\n"; } //end FOR $fecha_final = $fecha_de_pago; $fecha_de_vencimiento = $fecha_final; $dias_netos = restarfechas($fecha_final, $fecha_ministracion); $dias_normales = $dias_netos; $interes_diario = $total_de_intereses / $dias_netos; //=================================================================================================================================== $OProd = $xCred->getOProductoDeCredito(); $OPer = $xCred->getOPeriocidad(); $fecha_de_mora = $xF->setSumarDias($OProd->getDiasTolerados() + 1, $fecha_de_vencimiento); $vencimiento_dinamico = $xF->setSumarDias($OPer->getDiasToleradosEnVencer(), $fecha_de_mora); $arrUpdate = array("plazo_en_dias" => $dias_netos, "dias_autorizados" => $dias_netos, "fecha_vencimiento" => $fecha_de_vencimiento, "monto_parcialidad" => $primera_parcialidad, "contrato_corriente_relacionado" => $cuenta_captacion, "tipo_de_pago" => $FormaDePago, "fecha_ministracion" => $fecha_ministracion, "interes_diario" => $interes_diario, "fecha_mora" => $fecha_de_mora, "fecha_vencimiento_dinamico" => $vencimiento_dinamico, "fecha_de_primer_pago" => $fecha_primer_abono); if ($xCred->getSaldoActual() == $xCred->getMontoAutorizado() or $xCred->getEsAfectable() == false) { $arrUpdate["ultimo_periodo_afectado"] = SYS_CERO; } //Pagos de solo interes if ($xCred->getPagosSinCapital() == true) { $arrUpdate["ultimo_periodo_afectado"] = $ultima_parcialidad; } $xCred->setUpdate($arrUpdate); // -------------------------------------------- Actualiza el Saldo del Recibo $xCred->init(); $xFRM->addHTML($xCred->getFicha(true, "", false, true)); $xFRM->addHTML($xPlan->getFicha()); $sqlparc = "SELECT periodo_socio AS 'parcialidad', MAX(fecha_afectacion) AS 'fecha_de_pago', SUM((afectacion_real * valor_afectacion)) AS 'total_parcialidad',\n\t\t\t\t\t MAX(saldo_anterior) AS 'saldo_anterior_', MIN(saldo_actual) AS 'saldo_actual_' FROM operaciones_mvtos\n\t\t\t\tWHERE recibo_afectado={$idrecibo} GROUP BY periodo_socio ORDER BY periodo_socio";
function getFechaDePago($fecha_de_referencia, $numeral) { $periocidad_pago = $this->mPeriocidadDePago; $tipo_de_plan = $this->mTipoDePlanDePago; $dia_1_ab = $this->mDiaDeAbono1; $dia_2_ab = $this->mDiaDeAbono2; $dia_3_ab = $this->mDiaDeAbono3; $xF = new cFecha(0, $fecha_de_referencia); $xF1 = new cFecha(1); if ($tipo_de_plan == CREDITO_TIPO_DIAS_DE_PAGO_NATURAL) { $fecha_de_pago = $numeral == 1 ? $fecha_de_referencia : $xF->setSumarDias($periocidad_pago, $fecha_de_referencia); } else { //$fecha_de_referencia = $xF->get(); if ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_DIARIO) { //obtener si no es festivo //if(!isset($fecha_de_pago)){$fecha_de_pago = $fecha_de_referencia;} $fecha_de_pago = $numeral == 1 ? $fecha_de_referencia : $xF->setSumarDias(1, $fecha_de_referencia); $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago); } elseif ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_SEMANAL) { //Obtiene el Dia de Ref + dias del periodo if ($numeral == 1) { //Si es primer pago, es el dia de abono $fecha_de_pago = $fecha_de_referencia; } else { $fecha_de_pago = $xF->setSumarDias($periocidad_pago); if ($this->mDiaDeAbono1 != false) { $fecha_de_pago = $xF->getDiaAbonoSemanal($this->mDiaDeAbono1, $fecha_de_pago); } } } elseif ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_DECENAL) { $desviacion = intval($periocidad_pago * 0.4); if ($numeral == 1) { //Si es primer pago, es el dia de abono $fecha_de_pago = $fecha_de_referencia; } else { $fecha_de_pago = $xF->setSumarDias($periocidad_pago); $fecha_calculada = $xF->getDiaAbonoDecenal($this->mDiaDeAbono1, $this->mDiaDeAbono2, $this->mDiaDeAbono3, $fecha_de_pago); $fecha_de_pago = $tipo_de_plan != FALLBACK_CREDITOS_DIAS_DE_PAGO ? $fecha_calculada : $fecha_de_pago; } } elseif ($periocidad_pago == CREDITO_TIPO_PERIOCIDAD_CATORCENAL) { //Obtiene el Dia de Ref + dias del periodo if ($numeral == 1) { //Si es primer pago, es el dia de abono $fecha_de_pago = $fecha_de_referencia; } else { $fecha_de_pago = $xF->setSumarDias($periocidad_pago); } } elseif ($periocidad_pago >= CREDITO_TIPO_PERIOCIDAD_QUINCENAL && $periocidad_pago < CREDITO_TIPO_PERIOCIDAD_MENSUAL) { //Obtiene el Dia de Ref + dias del periodo if ($numeral == 1) { //Si es primer pago, es el dia de abono $fecha_de_pago = $fecha_de_referencia; } else { $fecha_de_pago = $xF->setSumarDias($periocidad_pago); if ($tipo_de_plan != FALLBACK_CREDITOS_DIAS_DE_PAGO) { $fecha_de_pago = $xF->getDiaAbonoQuincenal($dia_1_ab, $dia_2_ab, $fecha_de_pago); } } // Tratamiento Mensual o mas, si es menor a la 1era Quincena, baja al dia dos, si no sube un mes al dia dos... } elseif ($periocidad_pago >= CREDITO_TIPO_PERIOCIDAD_MENSUAL && $periocidad_pago < CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) { //Obtiene el Dia de Ref + dias del periodo $fecha_de_pago = $numeral == 1 ? $fecha_de_referencia : $xF->setSumarDias($periocidad_pago); if ($tipo_de_plan != FALLBACK_CREDITOS_DIAS_DE_PAGO) { $fecha_de_pago = $xF->getDiaDeAbonoMensual($dia_1_ab, $fecha_de_pago); } } else { // Tratamiento 360 o Semanal $fecha_de_pago = $xF->setSumarDias($periocidad_pago); } } if ($this->mTipoCreditoSis != CREDITO_PRODUCTO_NOMINA) { $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago); $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago); $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago); $fecha_de_pago = $xF->getDiaHabil($fecha_de_pago); } //if(MODO_DEBUG == true){ $this->mMessages .= $xF->getMessages(); } return $fecha_de_pago; }
//<===== FIN_H $xHP = new cHPage("TR.Gastos en Efectivo"); $xF = new cFecha(); $xCaja = new cCaja(); if ($xCaja->getEstatus() == TESORERIA_CAJA_CERRADA) { header("location:../404.php?i=200"); } echo $xHP->getHeader(); $jscallback = parametro("callback"); $tiny = parametro("tiny"); $form = parametro("form"); $action = parametro("action", SYS_NINGUNO); $monto = parametro("monto", 0, MQL_FLOAT); $tipo_de_recibo = parametro("tiporecibo", 0, MQL_INT); $xJS = new jsBasicForm("frmgtosefvo"); $lowdate = $xF->setSumarDias(DIAS_PAGO_UNICOS); $ndia = $xF->dia(); $nmes = $xF->mes(); $nano = $xF->anno(); $xFRM = new cHForm("frm", "./"); $xBtn = new cHButton(); $xTxt = new cHText(); $xDate = new cHDate(); $xSel = new cHSelect(); ?> <script> function fechaminima() { document.frmgtosefvo.eldia0.value = <?php echo $ndia; ?> ;
$datos = explode("|", $bufer, 18); $xF = new cFecha(); $socio = $cT->cInt($datos[1]); $credito = false; //$cT->cInt($datos[1]); $monto = $cT->cFloat($datos[8]); $periocidad = $cT->cInt($arrPeriodos[trim($datos[7])]); $pagos = $cT->cInt($datos[6]); $ministracion = $xF->getFechaISO($datos[10]); $fechaSolicitado = $xF->getFechaISO($datos[5]); $descDestino = $cT->cChar($datos[9]); $tasa = $cT->cFloat($datos[15]); $tasa = $tasa / 100; $dias = $periocidad * $pagos; $aplicacion = $cT->cChar($datos[17]) == "S" ? 501 : 100; $vencimiento = $xF->setSumarDias($dias, $ministracion); //$cT->cFecha($datos[5]); $saldo = $cT->cFloat($datos[11]); $UltimaOperacion = fechasys(); //$cT->cFecha($datos[9]); $ContratoCorriente = CTA_GLOBAL_CORRIENTE; //$cT->cInt($datos[10]); //Eliminar créditos anteriores $Creds = new cCreditos_solicitud(); $rs = $Creds->query()->select()->exec("numero_socio={$socio}"); foreach ($rs as $data) { /*$Creds->setData($data); $solicitud = $Creds->numero_solicitud()->v(); $socio = $Creds->numero_socio()->v(); $xCred = new cCredito($solicitud, $socio); $msg .= $xCred->setDelete();*/
} $ql = new MQL(); /* * ==================================================================================================================================================== * Agregar codigo de actualizar menores a personas fisicas * ==================================================================================================================================================== */ $messages .= "=======================================================================================\r\n"; $messages .= "=========================\t\t" . EACP_NAME . " \r\n"; $messages .= "=========================\t\t" . getSucursal() . " \r\n"; $messages .= "=======================================================================================\r\n"; $messages .= "=========================\t\tINICIANDO EL CIERRE DE SISTEMA ====================\r\n"; $messages .= "=========================\t\tRECIBO: {$idrecibo}\t\t\t\t ====================\r\n"; //2011-01-26 : Agrega un recibo estadistico de control diario $xNRec = new cReciboDeOperacion(10); $diaSig = $xF->setSumarDias(1); $xIdNRec = $xNRec->setNuevoRecibo(DEFAULT_SOCIO, DEFAULT_CREDITO, $diaSig, 1, 10, "MOVIMIENTOS_ESTADISTICOS_DEL_DIA", "NA", "ninguno", "NA", DEFAULT_GRUPO); //actualiza la configuracion del sistema $xCx = new cConfiguration(); $xUtil = new cUtileriasParaOperaciones(); $xCx->set("numero_de_recibo_por_defecto", $xIdNRec); $messages .= date("Y-m-d") . "\tSe Agrego el Recibo {$xIdNRec} para ESTADISTICOS del proximo dia( {$diaSig} )\n"; //================================= $messages .= $xUtil->setEliminarRecibosDuplicados(); $x20 = setFoliosAlMaximo(); $messages .= date("Y-m-d") . "\tSe llevaron Folios al Maximo, los recibos quedaron en " . $x20["recibos"] . " \n"; $messages .= date("Y-m-d") . "\tSe llevaron la Cuenta de Polizas Contables al Maximo \n"; setSociosAlMaximo(); clearCacheSessions(); $messages .= date("Y-m-d") . "\tSe limpio la Cache de sessiones\n"; $messages .= date("Y-m-d") . "\tSe llevaron los socios al Maximo \n";
function setGenerarMvtoFinDeMes($fecha_inicial, $fecha_final, $NumeroDeCredito = false, $ForzarEnPeriodo = false) { /** * @var $ForzarPeriodo * se refiere a que debe actualizar el saldo conciliado segun los pagos acumulados a la fecha * */ $msg = "==\t\tGENERAR MOVIMIENTOS DEL FIN DE MES\t\t==\r\n"; $arrPagosF = array(); $arrPagosM = array(); $xQl = new MQL(); //$wByCredito = " AND ( (`creditos_solicitud`.`fecha_ministracion` >= '$fecha_inicial' ) AND (`creditos_solicitud`.`fecha_ministracion` <= '$fecha_final' ) ) "; $wByCredito = ""; $wByCredito = $NumeroDeCredito != false ? " AND (`creditos_solicitud`.`numero_solicitud` = {$NumeroDeCredito}) " : $wByCredito; $wByMvto = " AND fecha_operacion>='{$fecha_inicial}' AND fecha_operacion<='{$fecha_final}' "; $wByMvto = $NumeroDeCredito != false ? " AND docto_afectado = {$NumeroDeCredito} " : $wByMvto; //============================================================================== $fechaRec = fechasys(); $observaciones = "GENERADO_EN_LA_UTILERIA_888"; //============================================================================== $sqlDM = "DELETE FROM operaciones_mvtos WHERE tipo_operacion=999 {$wByMvto} "; // Agregado el 2012-01-17- Ya lo habia corregido??? my_query($sqlDM); //============================================================================== if ($ForzarEnPeriodo == true) { $sqlP = "SELECT\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`socio_afectado` AS `socio`,\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado` AS `documento`,\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`tipo_operacion` AS `operacion`,\n\t\t\t\t\t\t\t\tMAX(`operaciones_mvtos`.`fecha_operacion`) AS `fecha`,\n\t\t\t\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real`) AS `monto` \n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(`operaciones_mvtos`.`tipo_operacion` = 120) \n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(`operaciones_mvtos`.`fecha_operacion` <='{$fecha_final}')\n\t\t\t\t\t\t\t\t{$wByMvto}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado`,\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`tipo_operacion` "; $rsP = $xQl->getDataRecord($sqlP); $msg .= "============ ULTIMOS MVTOS HASTA LA FECHA {$fecha_final} \r\n"; foreach ($rsP as $rwP) { $mSocio = $rwP["socio"]; $mCredito = $rwP["documento"]; $mFecha = $rwP["fecha"]; $mMonto = $rwP["monto"]; $arrPagosF[$mCredito] = $mFecha; $arrPagosM[$mCredito] = $mMonto; $msg .= "{$mSocio}\t{$mCredito}\tFecha {$mFecha}\t Monto: {$mMonto}\r\n"; } } //============================================================================== $CRecibo = new cReciboDeOperacion(10, false); $sql = "SELECT SQL_CACHE\n\t\t\t\t\t`creditos_solicitud`.*,\n\t\t\t\t\t`creditos_tipoconvenio`.*,\n\t\t\t\t\t`creditos_periocidadpagos`.*,\n\t\t\t\t\t`creditos_estatus`.*,\n\t\t\t\t\t`creditos_solicitud`.`tasa_interes` AS `tasa_ordinaria_anual`,\n\t\t\t\t\t`creditos_solicitud`.`tipo_autorizacion` AS `tipo_de_autorizacion`,\n\t\t\t\t\t`creditos_solicitud`.`tasa_ahorro` AS `tasa_de_ahorro`\n\t\t\t\tFROM\n\t\t\t\t\t`creditos_tipoconvenio` `creditos_tipoconvenio`\n\t\t\t\t\t\tINNER JOIN `creditos_solicitud` `creditos_solicitud`\n\t\t\t\t\t\tON `creditos_tipoconvenio`.`idcreditos_tipoconvenio`\n\t\t\t\t\t\t= `creditos_solicitud`.`tipo_convenio`\n\t\t\t\t\t\t\tINNER JOIN `creditos_periocidadpagos`\n\t\t\t\t\t\t\t`creditos_periocidadpagos`\n\t\t\t\t\t\t\tON `creditos_periocidadpagos`.\n\t\t\t\t\t\t\t`idcreditos_periocidadpagos` =\n\t\t\t\t\t\t\t`creditos_solicitud`.`periocidad_de_pago`\n\t\t\t\t\t\t\t\tINNER JOIN `creditos_estatus`\n\t\t\t\t\t\t\t\t`creditos_estatus`\n\t\t\t\t\t\t\t\tON `creditos_estatus`.`idcreditos_estatus` =\n\t\t\t\t\t\t\t\t`creditos_solicitud`.`estatus_actual`\n\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(`creditos_solicitud`.`estatus_actual` !=50)\n\t\t\t\t\t\t\t\t{$wByCredito}\n\t\t\t\t\t\t\t\t "; $rsMx = $xQl->getDataRecord($sql); // mysql_query($sql, cnnGeneral() ); //$msg .= $sql ."\r\n" . $sqlDM . "\r\n"; $msg .= "============ GENERANDO MOVIMIENTOS 999: Saldos al Fin del mes \r\n"; $xF = new cFecha(); $recibo = $CRecibo->setNuevoRecibo(DEFAULT_SOCIO, DEFAULT_CREDITO, $fechaRec, 1, 10, $observaciones, DEFAULT_CHEQUE, "ninguno", DEFAULT_RECIBO_FISCAL, DEFAULT_GRUPO); $CRecibo->setNumeroDeRecibo($recibo); foreach ($rsMx as $rw) { //corregir cuando yo me acuerde //Corregi accion de forzado... que mas? $solicitud = $rw["numero_solicitud"]; $socio = $rw["numero_socio"]; $fechaMinistracion = $rw["fecha_ministracion"]; $montoMinistrado = $rw["monto_autorizado"]; //Datos a conciliar $fechaUltimoMvto = $rw["fecha_ultimo_mvto"]; $saldoActual = $rw["saldo_actual"]; $FechaInicial = $fechaMinistracion; if ($ForzarEnPeriodo == true) { $pagos = isset($arrPagosM[$solicitud]) ? $arrPagosM[$solicitud] : 0; $saldo = $montoMinistrado - $pagos; $fechaUltimoMvto = isset($arrPagosF[$solicitud]) ? $arrPagosF[$solicitud] : $fechaUltimoMvto; //notas_auditoria= '', fecha_revision='2011-10-23', //si la fecha de ministracion es mayor a la final, invalidad fecha y saldo a cero $saldo_conciliado = $fechaMinistracion > $fecha_final ? 0 : $saldo; $fecha_conciliada = $fechaMinistracion > $fecha_final ? $fechaMinistracion : $fechaUltimoMvto; $sqlUC = "UPDATE creditos_solicitud SET saldo_conciliado={$saldo_conciliado}, fecha_conciliada='{$fecha_conciliada}'\n\t\t\t\t\t\t\t\t\t \tWHERE numero_solicitud={$solicitud} "; $msg .= "{$socio}\t{$solicitud}\tActualizar Saldo a {$saldo_conciliado}, Fecha a {$fecha_conciliada}, Ministrado: {$montoMinistrado}, Monto Pagado: {$pagos}\r\n"; my_query($sqlUC); } $FechaFinal = $saldoActual <= TOLERANCIA_SALDOS ? $fechaUltimoMvto : fechasys(); $dias = $xF->setRestarFechas($FechaFinal, $FechaInicial); $monto = 1; //$saldoActual; //$msg .= "Dias $dias \r\n"; for ($i = 0; $i <= $dias; $i++) { $fecha = $xF->setSumarDias($i, $FechaInicial); $fin_de_mes = $xF->getDiaFinal($fecha); if ($fecha == $fin_de_mes) { //guardar solo los datos del fin de mes if ($fecha >= $fecha_inicial and $fecha <= $fecha_final) { $observaciones = "Cierre a {$fecha}, Fin de mes {$fin_de_mes}"; $operacion = $CRecibo->setNuevoMvto($fecha, $monto, OPERACION_CLAVE_FIN_DE_MES, 1, $observaciones, 0, TM_CARGO, $socio, $solicitud); $msg .= "{$i}\t{$socio}\t{$solicitud}\t{$fecha}\t{$fin_de_mes}\t{$saldoActual}\t{$operacion}\r\n"; } else { $msg .= "{$i}\t{$socio}\t{$solicitud}\t{$fecha}\t{$fin_de_mes}\t{$saldoActual}\tNO_REG\r\n"; } } } } $CRecibo->setFinalizarRecibo(); return $msg; }
function check5Cierres($fecha_final, $alCerrar = false) { $xF = new cFecha(); $fecha_inicio_sistema = FECHA_INICIO_OPERACIONES_SISTEMA; $dias_a_revisar = REVISAR_DIAS_DE_CIERRE; $fecha_inicial = $xF->setRestarDias($dias_a_revisar, $fecha_final); $res = array(); $ok = false; $xSuc = new cSucursal(); for ($i = 0; $i <= $dias_a_revisar; $i++) { $fecha = $xF->setSumarDias($i, $fecha_inicial); if ($xF->getInt($fecha_inicio_sistema) >= $xF->getInt($fecha)) { $this->mMessages .= "WARN\tFecha {$fecha} OMITIDO por ser menor al inicio de operaciones\r\n"; $res[$fecha] = true; $ok = true; } elseif ($xF->getInt($fecha) == $xF->getInt(fechasys())) { $this->mMessages .= "WARN\tFecha {$fecha} OMITIDO por ser Fecha Actual\r\n"; $res[$fecha] = true; $ok = true; if ($alCerrar == true) { if ((int) date("H") < (int) $xSuc->getHorarioDeCierre()) { //considerar si es dia festivo $this->mMessages .= "ERROR\tNO ES EL HORARIO MINIMO DE CIERRE PARA LA FECHA {$fecha} SON LAS " . date("H") . " HRS. DE " . $xSuc->getHorarioDeCierre() . ", MINIMO DE CIERRE\r"; $res[$fecha] = false; $ok = false; } } } else { //$this->mMessages .= "WARN\tFecha $fecha OMITIDO por ser menor al inicio de operaciones\r\n"; if ($this->checkCierre($fecha) == false) { $res[$fecha] = false; $ok = false; $this->mMessages .= "ERROR\tFecha {$fecha} No existe en el sistema\r\n"; if ($xF->getInt($fecha) == $xF->getInt($fecha_final)) { $this->mMessages .= "ERROR\tPROCESAR LA FECHA {$fecha_final}|{$fecha} LAS FECHAS SON LAS MISMAS A " . fechasys() . "\r\n"; $res[$fecha] = true; $ok = true; } } else { $res[$fecha] = true; $ok = true; $this->mMessages .= "OK\tFecha {$fecha} existente\r\n"; } } $xCaja = new cCaja(); if ($alCerrar == true) { if ($xCaja->getCajasAbiertas($fecha) > 0) { $ok = false; $res[$fecha] = false; $this->mMessages .= "OK\tFecha {$fecha} tiene cortes pendientes\r\n"; } } } unset($res[fechasys()]); foreach ($res as $dateme => $rs) { if ($dateme != SYS_ESTADO) { if ($rs == false) { $this->mMessages .= "ERROR\tFecha {$dateme} tiene cortes pendientes.-2\r\n"; $ok = false; } } } if (MODO_DEBUG == true) { setLog($this->mMessages); } $res[SYS_ESTADO] = $ok; return $res; }
function setProcesarProgramacion($id, $arrVars = false, $data = false, $fecha = false) { $xF = new cFecha(); $xT = new cTipos(); $xLog = new cCoreLog(); $arrVars = $arrVars == false ? $this->mArrVars : $arrVars; //idprograma, nombre_del_aviso, forma_de_creacion, programacion, destinatarios, microformato, tipo_de_medios, intent_check, intent_command $sql = "SELECT *\tFROM sistema_programacion_de_avisos WHERE idprograma={$id} LIMIT 0,1"; $d = $data == false ? obten_filas($sql) : $data; $mOb = new cSistema_programacion_de_avisos(); $mOb->setData($d); $emails = array(); $tels = array(); $enviar = false; $fecha = $fecha == false ? fechasys() : $fecha; $nombredia = $xF->getDayName(); $diadelmes = date("j", $xF->getInt()); $EnviarNota = true; $EnviarMail = true; $EnviarSMS = false; $xLoc = new cLocal(); //procesar cuerpo del contenido $arrVars["fecha"] = !isset($arrVars["fecha"]) ? $fecha : $arrVars["fecha"]; $arrVars["fecha_dia_siguiente"] = $xF->setSumarDias(1, $fecha); $arrVars["fecha_inicio_de_semana"] = $xF->getFechaDeInicioDeSemana($fecha); $arrVars["fecha_inicio_de_mes"] = $xF->getDiaInicial($fecha); //Dia de la semana inicial $arrVars["hora"] = date("H"); $arrVars["usuario"] = $xLoc->getNombreUsuario(); $arrVars["clave_de_usuario"] = !isset($arrVars["clave_de_usuario"]) ? getUsuarioActual() : $arrVars["clave_de_usuario"]; //interpretar DIA if (strtoupper($mOb->forma_de_creacion()->v()) == SYS_ALERTA_POR_EVENTO) { $enviar = true; } else { //if($mOb->programacion()) $programacion = strtoupper($mOb->programacion()->v()); $periodo = explode(":", $programacion); //INTERPRETAR DIA if ($periodo[0] == "PROGRAMACION_SEMANAL") { if (strpos($nombredia, $programacion) !== false) { $enviar = true; } } else { if ($periodo[0] == "PROGRAMACION_DIARIA") { $enviar = true; } else { if (isset($periodo[1])) { $dias = explode(",", $periodo[1]); foreach ($dias as $dias => $iddia) { $mes = $xF->mes(); $anno = $xF->anno(); if (date("Y-m-d", strtotime("{$anno}-{$mes}-{$iddia}")) == $fecha) { $enviar = true; } } } } } } //1.- extraer emails $destinatarios = explode("|", $mOb->destinatarios()->v()); foreach ($destinatarios as $key => $cnt) { if (trim($cnt) != "") { //1.1 Desfragmentar destinos $DS = explode(":", $cnt); $mdestino = isset($DS[0]) ? strtoupper($DS[0]) : ""; switch ($mdestino) { case "OFICIALES": if (isset($DS[1])) { $oficiales = explode(",", $DS[1]); foreach ($oficiales as $ofc => $ofkey) { $xOf = new cOficial($ofkey); $xOf->init(); $mail = $xOf->getEmail(); $emails[] = $mail; $xLog->add("OK\tOFICIAL\tAgregar mail {$mail} \r\n", $xLog->DEVELOPER); } } break; case "EMPRESAS": if (isset($DS[1])) { $empresas = explode(",", $DS[1]); foreach ($empresas as $emp => $empkey) { $xEmp = new cEmpresas($empkey); $xEmp->init(); //$mail = $xEmp->getEmailsDeEnvio(); //$emails[] = $mail; $emails = array_merge($emails, $xEmp->getEmailsDeEnvio()); $xLog->add("OK\tEMPRESAS\tAgregar mail de la empresa {$empkey} \r\n", $xLog->DEVELOPER); } } break; case "PERSONAS": if (isset($DS[1])) { $personas = explode(",", $DS[1]); foreach ($personas as $ofc => $ofkey) { $xSoc = new cSocio($ofkey); $xSoc->init(); $mail = $xSoc->getCorreoElectronico(); $emails[] = $mail; $xLog->add("OK\tPERSONA\tAgregar mail {$mail} \r\n", $xLog->DEVELOPER); if ($xT->cNumeroTelefonico($xSoc->getTelefonoPrincipal()) != false) { $EnviarSMS = true; $tels[] = $xT->cNumeroTelefonico($xSoc->getTelefonoPrincipal()); } } } break; case "CORREO": if (isset($DS[1])) { $personas = explode(",", $DS[1]); foreach ($personas as $ofc => $ofkey) { if (filter_var($ofkey, FILTER_VALIDATE_EMAIL)) { $emails[] = $ofkey; } $xLog->add("OK\tCORREO\tAgregar mail {$ofkey} \r\n", $xLog->DEVELOPER); } } break; } //1.1.1 Validar oficiales, empresas, personas //if(strpos("OFICIALES:", $needle)) } } $this->mMessages .= $xLog->getMessages(); $texto = $mOb->microformato()->v(); foreach ($arrVars as $variable => $valor) { $texto = str_replace("{" . $variable . "}", $valor, $texto); } if ($enviar == true) { $url = $mOb->intent_command()->v(OUT_TXT); //2 procesado del comando if (trim($url) == "") { $titulo = strtoupper($mOb->nombre_del_aviso()->v()); $xNot = new cNotificaciones(); //enviar mail normal if ($EnviarSMS == true) { foreach ($tels as $pitm => $ptel) { $xNot->sendSMS($ptel, $texto); } } if ($EnviarMail == true) { foreach ($emails as $itm => $pmail) { $xNot->sendMail($titulo, $texto, $pmail); } } } else { //execute command //rpttesoreria/corte_de_caja.rpt.php?on=2014-5-3&off=2014-5-3&cajero=todas&dependencia=todas $smail = ""; $xHO = new cHObject(); foreach ($arrVars as $variable => $valor) { $url = str_replace("{" . $variable . "}", $valor, $url); } foreach ($emails as $id => $rmail) { //$smail .= ($smail == "") ? "email$id=$rmail" : "&email$id=$rmail"; $smail .= "&email{$id}={$rmail}"; } //Iniciar session en contexto &on=$fecha&off=$fecha $xSysUser = new cSystemUser(); $xSysUser->init(); $url = $url . $smail . "&ctx=" . $xSysUser->getCTX(); if (MODO_DEBUG == true) { setLog($url); } $xHO->navigate($url); } } else { $this->mMessages .= "OK\tNo e envia el reporte\r\n"; } setLog($this->mMessages); $this->mObProgAv = $mOb; //return $this->mObProgAv; }