/** * Efectua operaciones de finalizacion del recibo * @param boolean $UpdateSaldo Marca si Actualiza el Saldo del Credito */ function setFinalizarRecibo($UpdateSaldo = false, $tesoreria_cargada = false) { //generar Poliza a demanda $finalizado = true; //tranferencia.egresos cheque if (MODULO_CAJA_ACTIVADO == false) { $tesoreria_cargada = true; /* Forzar AML si Tesoreria esta Desactivado */ } /** * Modificacion de la condicion de socio por afectar al recibo en SI? */ if ($UpdateSaldo == true) { if ($this->mSumaDeRecibo == 0 or $this->mForceUpdateSaldos == true or !isset($this->mSumaDeRecibo) or $this->mSumaDeRecibo == false or $this->mSumaDeRecibo == '') { $sqlSUM = "SELECT\n\t\t\t\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real` * `operaciones_mvtos`.`valor_afectacion`) \tAS 'monto',\n\t\t\t\t\t\t\t\tCOUNT(`operaciones_mvtos`.`idoperaciones_mvtos`)\t\t\t\t\t\t\t\t\t\tAS 'numero',\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado`,\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`socio_afectado`\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`.`recibo_afectado` =" . $this->mCodigoDeRecibo . ")\n\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado` "; $TDRec = obten_filas($sqlSUM); $this->mSumaDeRecibo = $TDRec["monto"]; $this->mNumeroDeMvtos = $TDRec["numero"]; $this->mMessages .= "SUCESSACT\tMonto Actualizado a " . $this->mSumaDeRecibo . " y # Operaciones " . $this->mNumeroDeMvtos . "\r\n"; } if (!isset($this->mSumaDeRecibo)) { $this->mSumaDeRecibo = 0; } $sql = "UPDATE operaciones_recibos SET total_operacion=" . $this->mSumaDeRecibo . "\n \t\t\t\tWHERE\tidoperaciones_recibos= " . $this->mCodigoDeRecibo . "\t"; $xRs = my_query($sql); } if ($this->mSetGenerarPoliza == true) { //PolizaPorRecibo($this->mCodigoDeRecibo, GENERAR_POLIZAS_AL_CIERRE); } $this->mTotalRecibo = $this->mSumaDeRecibo; //-- AML if (MODULO_AML_ACTIVADO == true and $this->isPagable() == true and $tesoreria_cargada == true) { $xAml = new cAMLPersonas($this->mSocio); $xAml->init(); $xAml->setForceAlerts(); $xAmlO = new cAMLOperaciones(); $this->init(); if ($xAml->getEsPersonaVigilada() == true) { $tipo_de_pago_aml = $this->mTipoDePago; if (setNoMenorQueCero($this->mTipoOrigenAML) > 0) { $xRisK = new cPersonas_perfil_transaccional_tipos(); $xRisK->query()->initByID($this->mTipoOrigenAML); $tipo_de_pago_aml = strtolower($xRisK->tipo_de_exhibicion()->v(OUT_TXT)); $this->mMessages .= "WARN\tCambiar el perfil de pago de " . $this->mTipoDePago . " a {$tipo_de_pago_aml} \r\n"; } $res = $xAmlO->analizarOperacion($this->mSocio, 0, $this->mMoneda, $tipo_de_pago_aml, $this->getFechaDeRecibo(), $this->getCodigoDeRecibo(), $this->mTipoOrigenAML); if ($res == false) { $this->mMessages .= "OK\tAML Normal \r\n"; if (MODO_DEBUG == true) { $this->mMessages .= $xAmlO->getMessages(OUT_TXT); } } else { //REPORTAR $xAv = new cAML(); if ($xAmlO->getTipoDeReporte() == AML_REPORTE_INMEDIATO) { $xAv->setForceRegistroRiesgo(); $this->mMessages .= "WARN\tAML de Aviso Inmediato\r\n"; } $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $xAmlO->getTipoDeAlerta(), $xAmlO->getMessageAlert(), $this->mCodigoDeRecibo, $this->mFechaDeOperacion); } $this->mMessages .= $xAmlO->getMessages(OUT_TXT); //validar perfil transaccional $xAml->setVerificarPerfilTransaccional(); } //Validar si es person riesgosa $xSoc = $xAml->getOPersona(); if ($xSoc->getEsPersonaSDN() == true) { //REPORTAR operaciones con alto riesgo $idriesgo = AML_ID_OPERACIONES_PERSONAS_ALTO_RIESGO; //operaciones con criminales $xRiesgo = new cAml_risk_catalog(); $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo)); $xAv = new cAML(); $xAv->setForceRegistroRiesgo(); $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "ERROR\tOperaciones con persona ALTAMENTE RIESGOSA Recibo " . $this->mCodigoDeRecibo, $this->mCodigoDeRecibo, $this->getFechaDeRecibo()); $this->mMessages .= $xAv->getMessages(OUT_TXT); } if ($xSoc->getEsPersonaPoliticamenteExpuesta() == true) { //REPORTAR operaciones con PEPs $idriesgo = AML_ID_OPERACIONES_PERSONAS_PEP; //operaciones con criminales $xRiesgo = new cAml_risk_catalog(); $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo)); $xAv = new cAML(); $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "ERROR\tOperaciones con PEPS Recibo " . $this->mCodigoDeRecibo, $this->mCodigoDeRecibo, $this->getFechaDeRecibo()); $this->mMessages .= $xAv->getMessages(OUT_TXT); } if ($xSoc->getEsPersonaRiesgosa() == true) { //REPORTAR operaciones con PEPs $idriesgo = 101005; //operaciones con criminales $xRiesgo = new cAml_risk_catalog(); $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo)); $xAv = new cAML(); $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "ERROR\tOperaciones con Personas de Alto Riesgo.- Recibo " . $this->mCodigoDeRecibo, $this->mCodigoDeRecibo, $this->getFechaDeRecibo()); $this->mMessages .= $xAv->getMessages(OUT_TXT); } //Operaciones de una exhibicion 500 y USD if ($this->mMoneda != AML_CLAVE_MONEDA_LOCAL) { $idriesgo = AML_CLAVE_RIESGO_OPS_INDIVIDUALES; $xRiesgo = new cAml_risk_catalog(); $xMon = new cMonedas($this->mMoneda); $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo)); $unidades = $xMon->getEnDolares($this->getUnidadesOriginales()); if ($unidades >= $xRiesgo->unidades_ponderadas()->v()) { $xAv = new cAML(); $xAv->setForceRegistroRiesgo(); $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "Operaciones({$unidades}) excedidas de 500 USD en el recibo " . $this->mCodigoDeRecibo . " Moneda " . $this->mMoneda, $this->mCodigoDeRecibo, $this->getFechaDeRecibo()); $this->mMessages .= $xAv->getMessages(OUT_TXT); } else { $this->mMessages .= "OK\tNo hay modificacion para la Moneda " . $this->mMoneda . " por {$unidades} \r\n"; } } // Agregar Relevantes por 10000USD if ($this->isEfectivo() == true) { $idriesgo = AML_CLAVE_RIESGO_OPS_RELEVANTES; $xRiesgo = new cAml_risk_catalog(); $xMon = new cMonedas($this->mMoneda); $mmonto = $this->mMoneda == AML_CLAVE_MONEDA_LOCAL ? $this->getTotal() : $this->getUnidadesOriginales(); $xRiesgo->setData($xRiesgo->query()->initByID($idriesgo)); $unidades = $xMon->getEnDolares($mmonto); if ($unidades >= $xRiesgo->unidades_ponderadas()->v()) { $xAv = new cAML(); $xAv->setForceRegistroRiesgo(); $xAv->sendAlerts($this->mSocio, AML_OFICIAL_DE_CUMPLIMIENTO, $idriesgo, "Operaciones Relevantes por {$unidades} USD en el recibo " . $this->mCodigoDeRecibo . " Moneda " . $this->mMoneda, $this->mCodigoDeRecibo, $this->getFechaDeRecibo()); $this->mMessages .= $xAv->getMessages(OUT_TXT); } else { $this->mMessages .= "OK\tNo hay modificacion para la Moneda " . $this->mMoneda . " por {$unidades} \r\n"; } } if ($xAml->getEsPersonaVigilada() == true) { //Operaciones Internas Preocupantes por Usuario $xAml->setAnalizarTransaccionalidadPorNucleo($this->mCodigoDeRecibo, $this->mFechaDeOperacion, $this->mUsuario, true); } $this->mMessages .= $xAml->getMessages(OUT_TXT); } return $finalizado; }
function setVerificarPerfilTransaccional($fecha = false, $generar_avisos = false) { $xQL = new cSQLListas(); $mq = new MQL(); $xPerf = new cAMLPersonas_PerfilTransaccional($this->mClaveDePersona); $xF = new cFecha(); $fecha = $fecha == false ? fechasys() : $fecha; $fechaI6M = $xF->setRestarMeses(6, $fecha); //6 Meses $periodoI6M = date("Ym", $xF->getInt($fechaI6M)); //6 Meses $periodo_inicial = date("Ym", $xF->getInt($fecha)); $periodo_final = date("Ym", $xF->getInt($fecha)); $persona = $this->getCodigoDePersona(); $sql = $xQL->getAMLAcumuladoDeEgresos($periodo_inicial, $periodo_final, $persona); $datos = $mq->getDataRecord($sql); //checar datos si no existen en la consulta acumulada if (!isset($datos[SYS_MONTO]) or setNoMenorQueCero($datos[SYS_MONTO]) <= 0) { $sql = $xQL->getAMLAcumuladoDeEgresos_RT($periodo_inicial, $periodo_final, $persona); $datos = $mq->getDataRecord($sql); } $suma_efectivo = 0; $mes_activo = 0; $excedido = false; //setLog($sql); foreach ($datos as $row) { $tipo = strtolower($row[SYS_TIPO]); $moneda = strtoupper($row["moneda"]); $monto = $row[SYS_MONTO]; $numero = $row[SYS_NUMERO]; $mes = $row["periodo"]; $recibo = $row["recibo"]; $xDPerfil = $xPerf->concepto($tipo); $xMonto = new cCantidad($monto); $monto = $xMonto->v(); $pmonto = $xDPerfil->v(); //Monto permitido $montoDiff = $xMonto->diff($pmonto); $pnumero = $xDPerfil->getNumero(); if ($moneda != $xDPerfil->getClaveDeMoneda()) { $this->mMessages .= "ERROR\t{$tipo}|{$moneda}\tNo tiene Perfil para operar con la Moneda {$moneda} \r\n"; $excedido = true; } if ($monto > $pmonto) { $this->mMessages .= "ERROR\t{$tipo}|{$moneda}\tMonto excedido ({$montoDiff}) por de {$pmonto} tuvo operaciones por {$monto}\r\n"; $excedido = true; } else { $this->mMessages .= "OK\t{$tipo}|{$moneda}\tMonto Normal de {$pmonto} hizo operaciones por {$monto}\r\n"; } if ($numero > $pnumero) { $this->mMessages .= "ERROR\t{$tipo}|{$moneda}\tNumero excedido de {$pnumero} tuvo operaciones por {$numero}\r\n"; $excedido = true; } else { $this->mMessages .= "OK\t{$tipo}|{$moneda}\tNumero normal de {$pnumero} hizo operaciones por {$numero}\r\n"; } $mes_activo = $mes; if ($tipo == TESORERIA_COBRO_EFECTIVO) { $suma_efectivo = $monto; } } if (MODO_DEBUG == true) { $this->mMessages .= $xPerf->getMessages(OUT_TXT); } //$this->mMessages .= "OK\t \r\n"; //$efectivo = TESORERIA_COBRO_EFECTIVO . "-" . AML_CLAVE_MONEDA_LOCAL; //efectivo nacional //verificar pagos mayores a 500 USD //verificar pagos if ($excedido == true) { if ($this->mForceAvisos == true or $generar_avisos == true) { $xAml = new cAML(); $xAml->setForceAlerts(); $res = $xAml->sendAlerts($persona, AML_OFICIAL_DE_CUMPLIMIENTO, AML_DEBITOS_MAYORES_AL_PERFIL, $this->mMessages, $recibo, $fecha, false, 0, iDE_RECIBO); if ($res == false) { $this->mMessages .= "ERROR\tError al enviar alertas\r\n"; } $this->mMessages .= $xAml->getMessages(); } else { $this->mMessages .= "WARN\tNo se enviaron alertas\r\n"; } } return $excedido; }
function setActualizarNivelDeRiesgo($nivel = SYS_RIESGO_BAJO, $mensaje = "", $fecha = false) { $xNot = new cNotificaciones(); $xF = new cFecha(); $fecha = $xF->getFechaISO($fecha); $mensaje = $xNot->cleanString($mensaje); //AML.- Agregar aviso de cambio if ($nivel >= SYS_RIESGO_ALTO and MODULO_AML_ACTIVADO == true) { $xAml = new cAML(); $xAml->setForceAlerts(); $xAml->sendAlerts($this->mCodigo, AML_OFICIAL_DE_CUMPLIMIENTO, AML_RISK_INTERNAL_OPERATION, $mensaje, false, $fecha); //TODO: Exportar a asociada, falta relaciones exportar relaciones $this->getExportarAsociada(TPERSONAS_GENERALES, SVC_REMOTE_HOST); $this->getExportarAsociada(TPERSONAS_DIRECCIONES, SVC_REMOTE_HOST); $this->getExportarAsociada(TPERSONAS_ACTIVIDAD_ECONOMICA, SVC_REMOTE_HOST); $this->mMessages .= $xAml->getMessages(); } //Omitir AML en la actualizacion $this->setOmitirAML(true); $this->setUpdate(array("nivel_de_riesgo_aml" => $nivel)); //agregar una Noticiacion a la Persona de Nota $this->addMemo(MEMOS_TIPO_HISTORIAL, $mensaje, false, $fecha); }