function getFactura($enviar = false, $out = OUT_PDF) { $ready = null; $xml = ""; $unidad = "NO APLICA"; $cantidad = 1; $mql = new MQL(); $xLis = new cSQLListas(); $xLoc = new cLocal(); $xPais = new cDomiciliosPaises(EACP_CLAVE_DE_PAIS); $xLog = new cCoreLog(); $sql = "SELECT * FROM `operaciones_archivo_de_facturas` WHERE `clave_de_recibo` = " . $this->mCodigoDeRecibo . " LIMIT 0,1"; $xArch = new cOperaciones_archivo_de_facturas(); $DFact = $mql->getDataRow($sql); if (isset($DFact["clave_de_recibo"])) { $xArch->setData($DFact); $this->mMessages .= "OK\tEl UUID existe " . $xArch->uuid()->v(OUT_TXT) . "\r\n"; if ($enviar == true) { if ($this->getOPersona() == null) { } else { $xSoc = $this->getOPersona(); $email = $xSoc->getCorreoElectronico(); $comprobante = PATH_FACTURAS . $xArch->uuid()->v(OUT_TXT); file_put_contents($comprobante . ".xml", base64_decode($xArch->contenido()->v(OUT_TXT))); file_put_contents($comprobante . ".pdf", base64_decode($xArch->impreso()->v(OUT_TXT))); $ready = $out == OUT_PDF ? base64_decode($xArch->impreso()->v(OUT_TXT)) : base64_decode($xArch->contenido()->v(OUT_TXT)); $xNotif = new cNotificaciones(); //PDF y XML $arrFil = array(); $arrFil["archivo1"]["path"] = $comprobante . ".pdf"; $arrFil["archivo2"]["path"] = $comprobante . ".xml"; $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, $email, $arrFil); //Enviar al Archivo mail $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, FACTURACION_MAIL_ARCHIVO, $arrFil); $this->mMessages .= $xNotif->getMessages(); } } else { $ready = $out == OUT_PDF ? $xArch->impreso()->v(OUT_TXT) : $xArch->contenido()->v(OUT_TXT); } } else { $xLog->add("WARN\tGenerando Nueva Factura\r\n", $xLog->DEVELOPER); //cargar Archivo $xPais->init(); if ($this->mReciboIniciado == false) { $this->init(); } if ($this->getOPersona() == null) { $xLog->add("ERROR\tAl cargar la Persona\r\n"); } else { $xFact = new cFacturaElectronica(); //datos de la emisora //persona iniciada $xSoc = $this->getOPersona(); $email = $xSoc->getCorreoElectronico(); $xFact->setEmisor(EACP_NAME, EACP_RFC, EACP_DOMICILIO_CALLE, EACP_DOMICILIO_NUM_EXT, EACP_DOMICILIO_NUM_INT, EACP_CODIGO_POSTAL, EACP_COLONIA, EACP_MUNICIPIO, EACP_ESTADO, $xPais->getNombre()); $xFact->setRegimenFiscal(EACP_REGIMEN_FISCAL); $calle = $xLoc->DomicilioCalle(); $numeroInt = $xLoc->DomicilioNumeroInterior(); $numeroExt = $xLoc->DomicilioNumeroExterior(); $codigoPostal = $xLoc->DomicilioCodigoPostal(); $colonia = $xLoc->DomicilioColonia(); $xSocDom = $xSoc->getODomicilio(); $pais = $xLoc->getNombreDePais(); $estado = $xLoc->DomicilioEstado(); $municipio = $xLoc->DomicilioMunicipio(); $tasa_iva = TASA_IVA; $xFact->setLugarDeExpedicion($xLoc->DomicilioCalle(), $xLoc->DomicilioNumeroExterior(), $xLoc->DomicilioNumeroInterior(), $xLoc->DomicilioCodigoPostal(), $xLoc->DomicilioColonia(), $xLoc->DomicilioMunicipio(), $xLoc->DomicilioEstado(), $xLoc->getNombreDePais()); if ($xSocDom == null) { $xLog->add("WARN\tNo hay domicilio Valido\r\n", $xLog->DEVELOPER); } else { $calle = $xSocDom->getCalle(); $numeroExt = $xSocDom->getNumeroExterior(); $numeroInt = $xSocDom->getNumeroInterior(); $codigoPostal = $xSocDom->getCodigoPostal(); $colonia = $xSocDom->getColonia(); $municipio = $xSocDom->getMunicipio(); $estado = $xSocDom->getEstado(); $pais = $xSocDom->getNombreDePais(); } //Cargar datos del Docto //$this->getOrigen(); $OTipoRec = $this->getOTipoRecibo(); if ($OTipoRec->getOrigen() == RECIBOS_ORIGEN_MIXTO or $OTipoRec->getOrigen() == RECIBOS_ORIGEN_COLOCACION) { $xCred = new cCredito($this->getCodigoDeDocumento()); $xCred->init(); $tasa_iva = $xCred->getTasaIVA(); $xLog->add("WARN\tLa tasa de IVA es {$tasa_iva}\r\n", $xLog->DEVELOPER); } $xFact->setReceptor($xSoc->getNombreCompleto(), $xSoc->getRFC(true, true), $calle, $numeroExt, $numeroInt, $codigoPostal, $colonia, $municipio, $estado, $pais); //Datos del pagos $formaDePago = "Pago en una sola exhibición"; $cuentaDePago = "No Identificado"; $arrEquiv = array(TESORERIA_COBRO_DOCTO => "Documentos", TESORERIA_COBRO_EFECTIVO => "Efectivo", TESORERIA_COBRO_INTERNO => "Documentos", TESORERIA_COBRO_MULTIPLE => "Documentos", TESORERIA_COBRO_NINGUNO => "Documentos", TESORERIA_COBRO_TRANSFERENCIA => "Transferencia", TESORERIA_COBRO_CHEQUE => "Cheque"); $metodoDePago = $arrEquiv[$this->getTipoDePago()]; //cargar equivalencias //TODO: Considerar cambios en otro de tipo de tributacion if ($this->getTipoDePago() == TESORERIA_COBRO_TRANSFERENCIA or $this->getTipoDePago() == TESORERIA_COBRO_CHEQUE) { $OCaja = $this->getOCaja(); $cuentaDePago = $OCaja->getCuentaBancoActivo(); } //Cheque, Transferencia, Depósito $xFact->setDatosDePago($formaDePago, $metodoDePago, $cuentaDePago); $sql = "SELECT\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado`,\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro`,\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`subclasificacion`,\n\t\t\t\t\t`operaciones_tipos`.`descripcion_operacion` AS `operacion`,\n\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion`,\n\t\t\t\t\t`operaciones_mvtos`.`afectacion_real` AS 'monto' \n\t\t\t\tFROM\n\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = \n\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro` \n\t\t\t\t\t\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos` \n\t\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\n\t\t\t\t\t\t\t`idoperaciones_tipos` \n\t\t\t\tWHERE\n\t\t\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` =11000) AND\n\t\t\t\t\t(`operaciones_mvtos`.`recibo_afectado` =" . $this->mCodigoDeRecibo . " )"; $iva = 0; $total = 0; $rs = $mql->getDataRecord($sql); foreach ($rs as $rows) { $descripcion = $rows["operacion"]; $valor = $rows["monto"]; $tipo = $rows["subclasificacion"]; $total += $valor; if ($tipo == 1000) { $iva += $rows["monto"]; } else { $xFact->addConcepto($cantidad, $unidad, $valor, $descripcion); } } //agregar IVA if ($iva > 0) { $xFact->addTrasladado("IVA", $tasa_iva, $iva); } $xml = $xFact->get(); $this->mOFactura = $xFact; if ($total <= 0) { $enviar = false; } } if ($enviar == true) { if ($this->mOFactura != null) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { if ($this->mOFactura->timbrar() == 1) { //ready = true $xNotif = new cNotificaciones(); //PDF y XML $arrFil = array(); $arrFil["archivo1"]["path"] = $this->mOFactura->getComprobante() . ".pdf"; $arrFil["archivo2"]["path"] = $this->mOFactura->getComprobante() . ".xml"; $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, $email, $arrFil); //Enviar al Archivo mail $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, FACTURACION_MAIL_ARCHIVO, $arrFil); //Guardar en DB $this->mOFactura->setArchivar($this->mCodigoDeRecibo); $xLog->add($xNotif->getMessages(), $xLog->DEVELOPER); $ready = $out == OUT_PDF ? $this->mOFactura->getPDF() : $this->mOFactura->getXML(); } } else { $xLog->add("WARN\tNo hay email valido para la Factura ({$email})\r\n", $xLog->DEVELOPER); } $xLog->add($this->mOFactura->getMessages(), $xLog->DEVELOPER); } } } $this->mMessages .= $xLog->getMessages(); return $ready; }
function setAnalizarNivelDeRiesgo() { if ($this->mOSocio == null) { $this->getOPersona(); } $riesgo = 1; $factores = 0; $this->mMessages .= "====\tPersona: " . $this->mClaveDePersona . "\t====\r\n"; //revisar matrices //revisar si es extranjero //Trabajar en localidades riesgosas, paises riesgosas if ($this->mOSocio->getEsExtranjero() == true) { $factores++; $riesgo += 50; //riesgo medio $this->mMessages .= "WARN\tRiesgo a {$riesgo} por ser Extranjero (Medio)\r\n"; } //si es persona moral, obetener datos del representante if ($this->mOSocio->getEsPersonaFisica() == false) { $xRels = $this->mOSocio->getORepresentanteLegal(); if ($xRels == null) { $factores++; $riesgo += 50; $this->mMessages .= "WARN\tRiesgo a {$riesgo} por no tener Representante Legal\r\n"; } } //validar perfil transaccional $xPer = new cAMLPersonas_PerfilTransaccional($this->mOSocio->getCodigo()); if ($xPer->getNumeroEntradas() <= 0) { $factores++; $riesgo += SYS_RIESGO_MEDIO; $this->mMessages .= "WARN\tRiesgo a {$riesgo} por no tener perfil trasaccional\r\n"; } //revisar su actividad economica $OAE = $this->mOSocio->getOActividadEconomica(); if ($OAE == null) { $factores++; $riesgo += 50; //riesgo medio por no tener info $this->mMessages .= "WARN\tRiesgo a {$riesgo} por no tener Actividad Economica (Medio)\r\n"; } else { $factores++; $riesgo += $OAE->getEsRiesgosa() == true ? $OAE->getRiesgoAMLAsociado() : 10; $this->mMessages .= "WARN\tRiesgo a {$riesgo} en Actividad Economica\r\n"; $this->mMessages .= $OAE->getMessages(); //checar si su domicilio no esta en paises //100% de actividades Riesgosas if ($OAE->getRiesgoAMLAsociado() >= SYS_RIESGO_ALTO) { $factores = 1; $riesgo = SYS_RIESGO_ALTO; } //actualiza el riesgo de la persona por pep if ($OAE->getGeneraPEP() == true) { $xOCat = new cPersonasCatalogoOtrosDatos(); $this->mOSocio->addOtrosParametros($xOCat->AML_PEP_PRINCIPAL, 1); } } //revisar su actividad economica idlocalidad o domicilio $ODom = $this->mOSocio->getODomicilio(); if ($ODom == null) { $factores++; $riesgo += 50; //riesgo medio por no tener info $this->mMessages .= "WARN\tRiesgo a {$riesgo} por no tener domicilio (Medio)\r\n"; } else { $factores++; //es pais riesgoso $pais = $ODom->getClaveDePais(); if ($pais != EACP_CLAVE_DE_PAIS) { $xPais = new cDomiciliosPaises($pais); $xPais->init(); $riesgoPais = $xPais->getRiesgoAMLAsociado(); $riesgo += $riesgoPais; if ($riesgoPais == SYS_RIESGO_ALTO) { $riesgo = $riesgoPais; $factores = 1; } $this->mMessages .= "WARN\tRiesgo a {$riesgo} agregado {$riesgoPais} del pais {$pais}\r\n"; } else { $riesgo += SYS_RIESGO_BAJO; $this->mMessages .= "WARN\tRiesgo a {$riesgo} agregado del pais {$pais}\r\n"; } } $riesgo = $riesgo / $factores; if ($riesgo > 10 and $riesgo <= 50) { $this->mMessages .= "WARN\tRiesgo a MEDIO por {$riesgo} con Factores {$factores} \r\n"; $riesgo = SYS_RIESGO_MEDIO; } else { if ($riesgo >= 51) { $this->mMessages .= "WARN\tRiesgo a ALTO por {$riesgo} con Factores {$factores} \r\n"; $riesgo = SYS_RIESGO_ALTO; } else { $this->mMessages .= "WARN\tRiesgo a BAJO por {$riesgo} con Factores {$factores} \r\n"; $riesgo = SYS_RIESGO_BAJO; } } //$this->mMessages .= "WARN\tRiesgo a $riesgo con Factores $factores \r\n"; //revisar los productos con riesgo return $riesgo; }
function getEsRiesgosa() { $sql = "SELECT * FROM `aml_riesgo_perfiles` WHERE `objeto_de_origen`='personas_actividad_economica_tipos' AND `valor_de_origen`='" . $this->getClaveDeActividad() . "' LIMIT 0,1"; $xQL = new MQL(); $res = false; $media = 0; if (MODULO_AML_ACTIVADO == true) { $data = $xQL->getDataRow($sql); if (isset($data["nivel_de_riesgo"])) { $res = true; $this->mAMLNivelRiesgo = $data["nivel_de_riesgo"]; $this->mMessages .= "WARN\tLa Actividad " . $this->getClaveDeActividad() . " ES " . $this->mAMLNivelRiesgo . " % RIESGOSA\r\n"; $media++; } else { $this->mMessages .= "OK\tLa Actividad " . $this->getClaveDeActividad() . " No se encontro en el catalogo\r\n"; } //riesgo geografico $pais = $this->getClaveDePais(); if ($pais != EACP_CLAVE_DE_PAIS) { $xPais = new cDomiciliosPaises($pais); $xPais->init(); $nivel = $xPais->getRiesgoAMLAsociado(); $media++; $this->mAMLNivelRiesgo += $this->mAMLNivelRiesgo; $this->mMessages .= "WARN\tEl Pais " . $pais . " en tabla es {$nivel}, queda en " . $this->mAMLNivelRiesgo . " % RIESGOSA\r\n"; } //riesgo por tipo $otipo = $this->getOTipo(); if ($otipo != null) { $nivel = $otipo->getNivelRiesgoAML(); $media++; $this->mAMLNivelRiesgo += $nivel; $this->mMessages .= "WARN\tEl tipo de Actividad " . $this->getClaveDeActividad() . " en tabla es {$nivel}, queda en " . $this->mAMLNivelRiesgo . " % RIESGOSA\r\n"; if ($otipo->getGeneraPEP() == true) { $media = 1; $this->mAMLNivelRiesgo = SYS_RIESGO_ALTO; $this->mMessages .= "WARN\tEl tipo de Actividad " . $this->getClaveDeActividad() . " es PEP, se lleva a ALTO, queda en " . $this->mAMLNivelRiesgo . " % RIESGOSA\r\n"; $this->mAMLGeneraPEP = true; } } $this->mAMLNivelRiesgo = $this->mAMLNivelRiesgo / $media; } return $res; }