function consultarDatosFiscales($cedulaRuc, $usuario, $key) { LogController::logWebServiceIn('Llamada a web service: ' . __FILE__ . ' - ' . __FUNCTION__, compact('cedulaRuc', 'usuario', 'key')); $webServiceCore = new WebServiceCore(); $wsdl = "http://datosec.com/app/datosfiscales/consultaDeDatos.php?wsdl"; $operation = "consultaDeDatos"; $namespace = "http://datosec.com/app/datosfiscales/consultaDeDatos.php"; $soapAction = "http://datosec.com/app/datosfiscales/consultaDeDatos.php"; $params = array('cedulaRUC' => $cedulaRuc, 'accesoAutorizacion' => "999", 'accesoNegocio' => "1001", 'accesoEstablecimiento' => "1001", 'plan' => "1001", 'usuario' => $usuario, 'key' => $key); $datosCliente = $webServiceCore->callWebService($wsdl, $operation, $namespace, $soapAction, $params, true); return json_encode($datosCliente); }
public function getFactura() { $input = Request::createFromGlobals(); $handlerFlowSettingsCore = new \FlowSettingsCore(); $handlerWebServiceCore = new \WebServiceCore(); $returnArray = array(); $codigo_cliente = $input->codigo_cliente; $numero_factura = $input->numero_factura; $clase_reclamo = $input->clase_reclamo; if ($this->isTestEnv()) { $datosFactura = $this->getTestData(); } else { $wsdl = $handlerFlowSettingsCore->getSettingValue(FLOW_RECLAMOS, "REC_WS_FACTURAS_WSDL"); $operation = $handlerFlowSettingsCore->getSettingValue(FLOW_RECLAMOS, "REC_WS_FACTURAS_OPERATION"); $namespace = $handlerFlowSettingsCore->getSettingValue(FLOW_RECLAMOS, "REC_WS_FACTURAS_NAMESPACE"); $soapAction = $handlerFlowSettingsCore->getSettingValue(FLOW_RECLAMOS, "REC_WS_FACTURAS_SOAPACTION"); $params = array("Ccust" => $codigo_cliente, "Nfactura" => $numero_factura); $datosFactura = $handlerWebServiceCore->callWebService($wsdl, $operation, $namespace, $soapAction, $params, true); } if ($datosFactura) { $mensaje = $datosFactura["Mensaje"]; if (!$this->isTestEnv()) { $datosFactura["Longvarchar"] = json_decode($datosFactura["Longvarchar"]); } $datosFactura = $datosFactura["Longvarchar"]; if ($mensaje == "") { // Determinar si la factura es extemporánea $datosFactura->infoFactura->extemporaneo = false; $tiempoMax = 0; if ($datosFactura->infoFactura->pais != "ECU") { $tiempoArray = explode(",", FlowSettingsCore::get(FLOW_RECLAMOS, "REC_TIM_EXTEMPORANEAS_EXP")); } else { $tiempoArray = explode(",", FlowSettingsCore::get(FLOW_RECLAMOS, "REC_TIM_EXTEMPORANEAS_VL")); } foreach ($tiempoArray as $record) { $recordArray = explode("|", $record); if ($recordArray[0] == $clase_reclamo) { $tiempoMax = $recordArray[1]; } } $tiempoMax = $tiempoMax * 24 * 60 * 60; $emisionArray = explode('/', $datosFactura->infoFactura->fechaEmision); if (strtotime($emisionArray[2] . '-' . $emisionArray[1] . '-' . $emisionArray[0]) + $tiempoMax < time()) { // VALIDAR LA FECHA $datosFactura->infoFactura->extemporaneo = true; } // Determinar cuántos reclamos se han ingresado para esta factura $datosFactura->infoFactura->num_reclamos = ReclamoDetalle::where('factura', $numero_factura)->count(); // Devolver número de factura $datosFactura->infoFactura->numero_factura = $numero_factura; // Traer lista de productos comerciales $productosComercialesArray = explode(",", FlowSettingsCore::get(FLOW_RECLAMOS, "REC_PRO_CLASEPROD_COMERCIAL")); // Agregar valores por defecto para cabecera y líneas $datosFactura->infoFactura->total_factura_reclamo = 0; foreach ($datosFactura->detalles as &$linea) { $linea->cantidad_reclamo = 0; $linea->producto_cambiado = false; $linea->lote = ''; $linea->comercial = '0'; if (in_array($linea->clase, $productosComercialesArray)) { $linea->comercial = '1'; } // Valores por defecto para producto cambiado $linea->id_no_facturado = ''; $linea->cantidad_no_facturado = 0; $linea->lote_no_facturado = ''; $linea->valor_no_facturado = 0; } $factura = $datosFactura; } else { $factura = null; } } else { $mensaje = "Error de comunicación: No se pueden traer los datos de la factura"; $factura = null; } $returnArray["mensaje"] = $mensaje; $returnArray["factura"] = $factura; return json_encode($returnArray); }