コード例 #1
0
 public System.IAsyncResult BeginFEAutRequest(FEAuthRequest argAuth, FERequest Fer, System.AsyncCallback callback, object asyncState)
 {
     return(this.BeginInvoke("FEAutRequest", new object[] {
         argAuth,
         Fer
     }, callback, asyncState));
 }
コード例 #2
0
 public FEResponse FEAutRequest(FEAuthRequest argAuth, FERequest Fer)
 {
     object[] results = this.Invoke("FEAutRequest", new object[] {
         argAuth,
         Fer
     });
     return((FEResponse)(results[0]));
 }
コード例 #3
0
ファイル: RISConfigForm.cs プロジェクト: superwqc/Wingspan
        protected override object DecodeReportArgs(FERequest e)
        {
            if (e.Arguments == null || e.Arguments.Length == 0)
            {
                return(null);
            }
            switch (e.Title)
            {
            case RISConfigItemNames.IsSimpleMode:
                return((bool)e.Arguments[0]);

            case RISConfigItemNames.ExamLockValidTimeSpan:
            case RISConfigItemNames.FromPrintedToRejectedValidTimeSpan:
            {
                double outArg;
                if (!double.TryParse(e.Arguments[0].ToString(), out outArg))
                {
                    ErrorCodeHelper.Instance.ThrowException_Application(ECS3_Module.ConfigsModule, ECS4_ExceptionCode.InvalidRecord, string.Format("DecodeReportArgs failed. Title = '{0}' , Arguments = '{1}'", e.Title, e.Arguments[0]));
                }
                return(outArg);
            }

            case RISConfigItemNames.SimpleModeKey:
                return(e.Arguments[0] as string);

            case RISConfigItemNames.SimpleModeValue:
                return((bool)e.Arguments[0]);

            case RISConfigItemNames.OnDutyTimeBegin:
            case RISConfigItemNames.OnDutyTimeEnd:
            {
                DateTime outDateTime;
                if (DateTime.TryParse(e.Arguments[0].ToString(), out outDateTime))
                {
                    return(outDateTime);
                }
                return(null);
            }

            case RISConfigItemNames.OnDutyReviewUserCode: return(e.Arguments[0] as string);

            case RISConfigItemNames.PACSGatewayImplement:
            case RISConfigItemNames.HISGatewayImplement:
            case RISConfigItemNames.PatientIDGeneratorImplement:
            case RISConfigItemNames.AccessionNOGeneratorImplement:
            case RISConfigItemNames.DataPrinterImplement:
            case RISConfigItemNames.AETitleByWorkStation:
            case RISConfigItemNames.PACSGatewayUrl:
                return(e.Arguments[0] as string);

            case RISConfigItemNames.SelectedPKID:
                return(e.Arguments[0] as string);

            default:
                ErrorCodeHelper.Instance.ThrowException_Application(ECS3_Module.ConfigsModule, ECS4_ExceptionCode.InvalidRecord, string.Format("DecodeReportArgs failed. Title = '{0}' , Arguments = '{1}'", e.Title, e.Arguments[0]));
                return(null);
            }
        }
コード例 #4
0
 protected override object DecodeReportArgs(FERequest e)
 {
     switch (e.Title)
     {
         case UserPermissionMappingConfigItemNames.SelectedUserCode:
             return e.Arguments[0] as string;
         default:
             ErrorCodeHelper.Instance.ThrowException_Application(ECS3_Module.ConfigsModule, ECS4_ExceptionCode.InvalidRecord, "DecodeReportArgs failed.");
             return null;
     }
 }
コード例 #5
0
        //        protected static string FormatInt(int number) {
        //            return FormatInt(number, 8);
        //        }

        //        protected static string FormatInt(int number, int length) {
        //            return FormatDouble((double)number, length, 0);
        //        }

        //        protected static string FormatDouble(double number) {
        //            return FormatDouble(number, 15);
        //        }

        //        protected static string FormatDouble(double number, int length) {
        //            return FormatDouble(number, length, 2);
        //        }

        //        protected static string FormatDouble(double number, int length, int precision) {
        //            string formatter = String.Empty.PadLeft(length - precision, '0') + "." + String.Empty.PadLeft(precision, '0');
        //            return number.ToString(formatter).Replace(".", "").Replace(",", "");
        //        }
        #endregion

        public FERequest GenerarFERequest(long idCabecera)
        {
            //Cabecera
            FECabeceraRequest cabecera = new FECabeceraRequest();

            cabecera.id          = idCabecera;
            cabecera.cantidadreg = 1;
            cabecera.presta_serv = 1;             //TODO: por ahora todo lo que se facturan son servicios

            //Detalle
            FEDetalleRequest detalle = new FEDetalleRequest();

            detalle.tipo_doc  = 80;
            detalle.nro_doc   = Convert.ToInt64(comprobante.Cliente.CUIT.Replace("-", ""));
            detalle.tipo_cbte = Convert.ToInt32(comprobante.Tipo.Codigo);
            if (string.IsNullOrEmpty(comprobante.NroCbante))
            {
                comprobante.NroCbante = ObtenerNroComprobante();
            }
            detalle.punto_vta        = Convert.ToInt32(comprobante.NroCbante.Substring(0, 4));
            detalle.cbt_desde        = Convert.ToInt64(comprobante.NroCbante.Substring(5, 8));
            detalle.cbt_hasta        = Convert.ToInt64(comprobante.NroCbante.Substring(5, 8));
            detalle.imp_total        = comprobante.Total;
            detalle.imp_tot_conc     = 0;
            detalle.imp_neto         = comprobante.SubtotalNeto;
            detalle.impto_liq        = comprobante.Iva1 + comprobante.Iva2;
            detalle.impto_liq_rni    = 0;
            detalle.imp_op_ex        = 0;
            detalle.fecha_serv_desde = FormatDate(comprobante.Emision);           //TODO: verificar que sea la fecha correcta
            detalle.fecha_serv_hasta = FormatDate(comprobante.Emision);           //TODO: verificar que sea la fecha correcta
            detalle.fecha_cbte       = FormatDate(comprobante.Emision);
            detalle.fecha_venc_pago  = FormatDate(comprobante.Emision);           //TODO: verificar que sea la fecha correcta

            //Armado del FERequest
            FERequest result = new FERequest();

            result.Fecr    = cabecera;
            result.Fedr    = new FEDetalleRequest[1];
            result.Fedr[0] = detalle;

            return(result);
        }
コード例 #6
0
        public static string GetCAE(Comprobantes comprobante, out string logError, out string nroComprobante)
        {
            comprobante.Empresa            = new Empresas();
            comprobante.Empresa.Cuit       = "33-67789425-9";
            comprobante.Empresa.DNOrigen   = "serialNumber=CUIT 33677894259,[email protected],CN=VISET,OU=VISET,O=VISET,ST=Buenos Aires,C=AR";
            comprobante.Empresa.DNDestino  = "CN=wsaahomo; O=afip; C=ar; serialNumber=CUIT 33693450239";
            comprobante.Empresa.Id         = Convert.ToInt32("2");
            comprobante.Empresa.SenderName = "VISET";
            comprobante.Empresa.CAI        = "CAI1455";
            comprobante.Empresa.CertificadoDestinoFileName = @"C:\Vero\Proyectos\MFD\MFDHOMO\Certificados\viset\CRT-root.cer";
            comprobante.Empresa.CertificadoFileName        = @"C:\Vero\Proyectos\MFD\MFDHOMO\Certificados\viset\viset.crt";
            comprobante.Empresa.CertificadoPassword        = "******";
            comprobante.Empresa.LoginTicketFileName        = @"C:\Vero\Proyectos\MFD\MFDHOMO\Certificados\viset\LoginTicketRequest.xml";


            logError = String.Empty;
            string       result      = String.Empty;
            LoginTickets loginTicket = GetLoginTicket(comprobante.Empresa);

            nroComprobante = "-1";
            if (loginTicket != null)
            {
                FEAuthRequest authRequest = new FEAuthRequest();
                authRequest.Token = loginTicket.Token;
                authRequest.Sign  = loginTicket.Sign;
                authRequest.cuit  = Convert.ToInt64(comprobante.Empresa.Cuit.Replace("-", ""));
                ComprobantesAdapter adapter  = new ComprobantesAdapter(comprobante);
                FERequest           request  = adapter.GenerarFERequest(comprobante.Id);
                Service             service  = new Service();
                FEResponse          response = service.FEAutRequest(authRequest, request);

                if (response.FedResp != null && response.FedResp[0].resultado == "R" && response.FedResp[0].motivo.StartsWith("11") && response.FedResp[0].cae == "NULL")
                {
                    //Caso en que falla por correlatividad de comprobantes
                    FERecuperaLastCMPResponse ultimoComEmitido = service.FERecuperaLastCMPRequest(authRequest, adapter.GenerarFELastCMPtype());
                    comprobante.NroCbante = comprobante.NroCbante.Substring(0, 5) + (ultimoComEmitido.cbte_nro + 1).ToString().PadLeft(8, '0');
                    adapter = new ComprobantesAdapter(comprobante);
                    request = new FERequest();
                    //Generación de otro ID
                    long idDate = DateTime.Now.Year * 10000000000;
                    idDate  += DateTime.Now.Month * 100000000;
                    idDate  += DateTime.Now.Day * 1000000;
                    idDate  += DateTime.Now.Hour * 10000;
                    idDate  += DateTime.Now.Minute * 100;
                    idDate  += DateTime.Now.Second;
                    request  = adapter.GenerarFERequest(idDate);
                    service  = new Service();
                    response = service.FEAutRequest(authRequest, request);
                }
                else
                {
                    if (response.FedResp != null && response.FedResp[0].resultado == "R" && !String.IsNullOrEmpty(response.FedResp[0].motivo))
                    {
                        ArrayList motivos = new ArrayList();
                        motivos.AddRange(response.FedResp[0].motivo.Split(";".ToCharArray()));
                        StringBuilder logMotivos = new StringBuilder();
                        if (motivos.Contains("01"))
                        {
                            logMotivos.Append("01 \"La cuit informada no corresponde a un responsable inscripto en el iva activo\\n");
                        }
                        if (motivos.Contains("02"))
                        {
                            logMotivos.Append("02 \"La cuit informada no se encuentra autorizada a emitir comprobantes electronicos originales o el periodo de inicio autorizado es posterior al de la generacion de la solicitud\"\n");
                        }
                        if (motivos.Contains("03"))
                        {
                            logMotivos.Append("03 \"La cuit informada registra inconvenientes con el domicilio fiscal\"\n");
                        }
                        if (motivos.Contains("04"))
                        {
                            logMotivos.Append("04 \"El punto de venta informado no se encuentra declarado para ser utilizado en el presente regimen\"\n");
                        }
                        if (motivos.Contains("05"))
                        {
                            logMotivos.Append("05 \"La fecha del comprobante indicada no puede ser anterior en mas de cinco dias, si se trata de una venta, o anterior o posterior en mas de diez dias, si se trata de una prestacion de servicios, consecutivos de la fecha de remision del archivo art. 22 De la rg nro 2177-\"\n");
                        }
                        if (motivos.Contains("06"))
                        {
                            logMotivos.Append("06 \"La cuit informada no se encuentra autorizada a emitir comprobantes clase \"a\"\"\n");
                        }
                        if (motivos.Contains("07"))
                        {
                            logMotivos.Append("07 \"Para la clase de comprobante solicitado -comprobante clase a- debera consignar en el campo codigo de documento identificatorio del comprador el codigo \"80\"\n");
                        }
                        if (motivos.Contains("08"))
                        {
                            logMotivos.Append("08 \"La cuit indicada en el campo nro de identificacion del comprador es invalida\"\n");
                        }
                        if (motivos.Contains("09"))
                        {
                            logMotivos.Append("09 \"La cuit indicada en el campo nro de identificacion del comprador no existe en el padron unico de contribuyentes\"\n");
                        }
                        if (motivos.Contains("10"))
                        {
                            logMotivos.Append("10 \"La cuit indicada en el campo nro de identificacion del comprador no corresponde a un responsable inscripto en el iva activo\"\n");
                        }
                        if (motivos.Contains("11"))
                        {
                            logMotivos.Append("11 \"El nro de comprobante desde informado no es correlativo al ultimo nro de comprobante registrado/hasta solicitado para ese tipo de comprobante y punto de venta\"\n");
                        }
                        if (motivos.Contains("12"))
                        {
                            logMotivos.Append("12 \"El rango informado se encuentra autorizado con anterioridad para la misma cuit, tipo de comprobante y punto de venta\"\n");
                        }
                        if (motivos.Contains("13"))
                        {
                            logMotivos.Append("13 \"La cuit indicada se encuentra comprendida en el regimen establecido por la resolucion general nro 2177 y/o en el titulo I de la resolucion general nro 1361 art. 24 De la rg nro 2177\"\n");
                        }
                        if (logMotivos.Length > 0)
                        {
                            logError = logMotivos.ToString();
                        }
                    }
                }
                nroComprobante = comprobante.NroCbante;
                try
                {
                    result = response.FedResp[0].cae;
                }
                catch (Exception ex)
                {
                    nroComprobante = "-1";
                    result         = ex.Message;
                }
            }
            return(result);
        }
コード例 #7
0
        private static string GetCAE(Comprobantes comprobante, out string logError, out string nroComprobante, ref long idCabecera, bool autogenerarNroComprobante)
        {
            logError = String.Empty;
            string       result      = String.Empty;
            LoginTickets loginTicket = GetLoginTicket(comprobante.Empresa);

            nroComprobante = "-1";
            if (loginTicket != null)
            {
                Service service = new Service();
                //service.Timeout = 500000;
                FEAuthRequest authRequest = new FEAuthRequest();
                authRequest.Token = loginTicket.Token;
                authRequest.Sign  = loginTicket.Sign;
                authRequest.cuit  = Convert.ToInt64(comprobante.Empresa.Cuit.Replace("-", ""));
                ComprobantesAdapter adapter = new ComprobantesAdapter(comprobante, comprobante.Empresa);
                //if (autogenerarNroComprobante)
                //{
                //    FERecuperaLastCMPResponse ultimoComEmitido = service.FERecuperaLastCMPRequest(authRequest, adapter.GenerarFELastCMPtype());
                //    comprobante.NroCbante = comprobante.Empresa.PuntoDeVenta.Value.ToString().PadLeft(4, '0')+"-" + (ultimoComEmitido.cbte_nro + 1).ToString().PadLeft(8, '0');
                //}

                //idCabecera = comprobante.Id;
                FERequest  request  = adapter.GenerarFERequest(idCabecera);
                FEResponse response = null;
                try
                {
                    response = service.FEAutRequest(authRequest, request);
                }
                catch (Exception ex) {
                    throw ex;
                }

                if (autogenerarNroComprobante && response.FedResp != null && response.FedResp[0].resultado == "R" && response.FedResp[0].motivo.StartsWith("11") && response.FedResp[0].cae == "NULL")
                {
                    FERecuperaLastCMPResponse ultimoComEmitido = service.FERecuperaLastCMPRequest(authRequest, adapter.GenerarFELastCMPtype());
                    comprobante.NroCbante = comprobante.Empresa.PuntoDeVenta.Value.ToString().PadLeft(4, '0') + "-" + (ultimoComEmitido.cbte_nro + 1).ToString().PadLeft(8, '0');
                    //Caso en que falla por correlatividad de comprobantes
                    adapter = new ComprobantesAdapter(comprobante, comprobante.Empresa);
                    request = new FERequest();
                    ////Generación de otro ID
                    long idDate = DateTime.Now.Year * 10000000000;
                    idDate    += DateTime.Now.Month * 100000000;
                    idDate    += DateTime.Now.Day * 1000000;
                    idDate    += DateTime.Now.Hour * 10000;
                    idDate    += DateTime.Now.Minute * 100;
                    idDate    += DateTime.Now.Second;
                    idCabecera = idDate;
                    request    = adapter.GenerarFERequest(idCabecera);
                    service    = new Service();
                    response   = service.FEAutRequest(authRequest, request);
                }
                if (response.FedResp == null && response.RError != null)
                {
                    return(response.RError.perrmsg);
                }
                if (response.FedResp != null && response.FedResp[0].resultado == "R" && !String.IsNullOrEmpty(response.FedResp[0].motivo))
                {
                    ArrayList motivos = new ArrayList();
                    motivos.AddRange(response.FedResp[0].motivo.Split(";".ToCharArray()));
                    StringBuilder logMotivos = new StringBuilder();
                    if (motivos.Contains("01"))
                    {
                        logMotivos.Append("01 \"La cuit informada no corresponde a un responsable inscripto en el iva activo\\n");
                    }
                    if (motivos.Contains("02"))
                    {
                        logMotivos.Append("02 \"La cuit informada no se encuentra autorizada a emitir comprobantes electronicos originales o el periodo de inicio autorizado es posterior al de la generacion de la solicitud\"\n");
                    }
                    if (motivos.Contains("03"))
                    {
                        logMotivos.Append("03 \"La cuit informada registra inconvenientes con el domicilio fiscal\"\n");
                    }
                    if (motivos.Contains("04"))
                    {
                        logMotivos.Append("04 \"El punto de venta informado no se encuentra declarado para ser utilizado en el presente regimen\"\n");
                    }
                    if (motivos.Contains("05"))
                    {
                        logMotivos.Append("05 \"La fecha del comprobante indicada no puede ser anterior en mas de cinco dias, si se trata de una venta, o anterior o posterior en mas de diez dias, si se trata de una prestacion de servicios, consecutivos de la fecha de remision del archivo art. 22 De la rg nro 2177-\"\n");
                    }
                    if (motivos.Contains("06"))
                    {
                        logMotivos.Append("06 \"La cuit informada no se encuentra autorizada a emitir comprobantes clase \"a\"\"\n");
                    }
                    if (motivos.Contains("07"))
                    {
                        logMotivos.Append("07 \"Para la clase de comprobante solicitado -comprobante clase a- debera consignar en el campo codigo de documento identificatorio del comprador el codigo \"80\"\n");
                    }
                    if (motivos.Contains("08"))
                    {
                        logMotivos.Append("08 \"La cuit indicada en el campo nro de identificacion del comprador es invalida\"\n");
                    }
                    if (motivos.Contains("09"))
                    {
                        logMotivos.Append("09 \"La cuit indicada en el campo nro de identificacion del comprador no existe en el padron unico de contribuyentes\"\n");
                    }
                    if (motivos.Contains("10"))
                    {
                        logMotivos.Append("10 \"La cuit indicada en el campo nro de identificacion del comprador no corresponde a un responsable inscripto en el iva activo\"\n");
                    }
                    if (motivos.Contains("11"))
                    {
                        logMotivos.Append("11 \"El nro de comprobante desde informado no es correlativo al ultimo nro de comprobante registrado/hasta solicitado para ese tipo de comprobante y punto de venta\"\n");
                    }
                    if (motivos.Contains("12"))
                    {
                        logMotivos.Append("12 \"El rango informado se encuentra autorizado con anterioridad para la misma cuit, tipo de comprobante y punto de venta\"\n");
                    }
                    if (motivos.Contains("13"))
                    {
                        logMotivos.Append("13 \"La cuit indicada se encuentra comprendida en el regimen establecido por la resolucion general nro 2177 y/o en el titulo I de la resolucion general nro 1361 art. 24 De la rg nro 2177\"\n");
                    }
                    if (logMotivos.Length > 0)
                    {
                        logError = logMotivos.ToString();
                    }
                }
                nroComprobante = comprobante.NroCbante;
                service.Dispose();
                try
                {
                    result = response.FedResp[0].cae;
                    comprobante.IdCabeceraWS = idCabecera;
                    try
                    {
                        CaeCounter wsCaeCounter = new CaeCounter();
                        bool       produccion   = !service.Url.Contains("h**o");
                        wsCaeCounter.SetCAEByCUIT(comprobante.Empresa.Cuit, result, comprobante.NroCbante, idCabecera, produccion);
                    }
                    catch (Exception ex) {
                        string err = ex.Message;
                        //Por el momento no se hace nada si falla el wsCaeCounter
                    }
                }
                catch (Exception ex)
                {
                    nroComprobante = "-1";
                    result         = ex.Message;
                }
            }

            return(result);
        }