예제 #1
0
    protected void sValida_SAT(string[] sData)
    {
        string[] sCfdiData;
        sCfdiData = new string[22];
        string sCadena    = string.Empty;
        string sEstado    = string.Empty;
        string sNuevoArch = string.Empty;

        CFDIService.Acuse oAcuse = new CFDIService.Acuse();
        CFDIService.ConsultaCFDIServiceClient oConsulta = new CFDIService.ConsultaCFDIServiceClient();
        sCadena = "?re=" + sData[1] + "&rr=" + sData[2] + "&tt=" + sData[0] + "&id=" + sData[3] + "";
        oAcuse  = oConsulta.Consulta(sCadena);

        sCfdiData[0]  = sData[1];                        // RFC Emisor
        sCfdiData[1]  = sData[2];                        // RFC Receptor
        sCfdiData[2]  = sData[0];                        // Total
        sCfdiData[3]  = sData[3];                        // UUID
        sCfdiData[4]  = sData[4];                        // Ruta XML
        sCfdiData[5]  = sData[5];                        // Nombre archivo XML
        sCfdiData[6]  = oAcuse.CodigoEstatus.ToString(); // Estatus en SAT
        sCfdiData[7]  = oAcuse.Estado.ToString();        // Estado en SAT
        sCfdiData[8]  = sData[6];                        // Concepto -> cantidad
        sCfdiData[9]  = sData[7];                        // Concepto -> unidad
        sCfdiData[10] = sData[8];                        // Concepto -> descripcion
        sCfdiData[11] = sData[9];                        // Concepto -> valorunitario
        sCfdiData[12] = sData[10];                       // Concepto -> importe
        sCfdiData[13] = sData[11];                       // Subtotal
        sCfdiData[14] = sData[12];                       // Tasa IVA
        sCfdiData[15] = sData[13];                       // Importe de IVA
        sCfdiData[16] = sData[14];                       // Domicilio Fiscal Emisor
        sCfdiData[17] = sData[15];                       // Domicilio Fiscal Receptor
        sCfdiData[18] = sData[16];                       // Nombre emisor factura
        sCfdiData[19] = sData[17];                       // Nombre receptir factura
        sCfdiData[20] = sData[18];                       // Fecha emisión factura
        sCfdiData[21] = sData[19];                       // Fecha timbrado factura

        CodigoEstatusLabel.Text = oAcuse.CodigoEstatus.ToString();
        sEstado          = oAcuse.Estado.ToString();
        EstadoLabel.Text = oAcuse.Estado.ToString();

        sData_DBSave(sCfdiData);
    }
예제 #2
0
    protected void Valida_SAT(string[] sData)
    {
        string[] sCfdiData;
        sCfdiData = new string[9];
        string sCadena = string.Empty;

        CFDIService.Acuse oAcuse = new CFDIService.Acuse();
        CFDIService.ConsultaCFDIServiceClient oConsulta = new CFDIService.ConsultaCFDIServiceClient();
        sCadena = "?re=" + sData[1] + "&rr=" + sData[2] + "&tt=" + sData[4] + "&id=" + sData[3] + "";
        oAcuse  = oConsulta.Consulta(sCadena);

        sCfdiData[0] = sData[0]; // doc_id
        sCfdiData[1] = sData[1]; // rfc_e
        sCfdiData[2] = sData[2]; // rfc_r
        sCfdiData[3] = sData[3]; // uuid
        sCfdiData[4] = sData[4]; // total
        sCfdiData[5] = oAcuse.CodigoEstatus.ToString();
        sCfdiData[6] = oAcuse.Estado.ToString();

        UpdateDb(sCfdiData);
    }
예제 #3
0
    protected void sValida_SAT(string[] sData, string sQr)
    {
        string[] sCfdiData;
        sCfdiData = new string[9];
        string sCadena    = string.Empty;
        string sEstado    = string.Empty;
        string sNuevoArch = string.Empty;
        string delimStr1  = "?&";

        char[] delimiter1 = delimStr1.ToCharArray();
        string sDirCfdi   = string.Empty;
        string sEmisor    = "re=";

        char[] cEmisor   = sEmisor.ToCharArray();
        string sReceptor = "rr=";

        char[] cReceptor = sReceptor.ToCharArray();
        string sTotal    = "tt=";

        char[] cTotal = sTotal.ToCharArray();
        string sUuid  = "id=";

        char[] cUuid = sUuid.ToCharArray();
        string sUuId = "Id=";

        char[] cUuId = sUuId.ToCharArray();

        string[] split1 = null;
        string[] split2 = null;
        string[] split3 = null;
        string[] split4 = null;
        string[] split5 = null;

        CFDIService.Acuse oAcuse = new CFDIService.Acuse();
        CFDIService.ConsultaCFDIServiceClient oConsulta = new CFDIService.ConsultaCFDIServiceClient();

        if (sQr != string.Empty)
        {
            // Revisa si es versión QR 3.3
            if (sQr.Trim().StartsWith("https://verificacfdi.facturaelectronica.sat.gob.mx"))
            {
                split1 = sQr.Split(delimiter1, 7);

                if (split1[1] == "")
                {
                    // Versión alternativa QR 3.3
                    split2 = split1[2].Split(cUuid, 4);
                    if (split2[2] != "")
                    {
                        // Sería Id=
                        sCfdiData[3] = split2[2]; // UUID
                    }
                    else
                    {
                        // Sería id=
                        sCfdiData[3] = split2[3]; // UUID
                    }
                    split3 = split1[3].Split(cEmisor, 4);
                    split4 = split1[4].Split(cReceptor, 4);
                    split5 = split1[5].Split(cTotal, 4);

                    //sCfdiData[3] = split2[2]; // UUID
                    sCfdiData[0] = split3[3]; // RFC Emisor
                    sCfdiData[1] = split4[3]; // RFC Receptor
                    sCfdiData[2] = split5[3]; // Total
                }
                else
                {
                    // Versión original QR 3.3
                    split2 = split1[1].Split(cUuid, 4);
                    if (split2[1] == "")
                    {
                        split2 = split1[1].Split(cUuId, 4);
                    }
                    split3 = split1[2].Split(cEmisor, 4);
                    split4 = split1[3].Split(cReceptor, 4);
                    split5 = split1[4].Split(cTotal, 4);

                    sCfdiData[3] = split2[2]; // UUID
                    sCfdiData[0] = split3[3]; // RFC Emisor
                    sCfdiData[1] = split4[3]; // RFC Receptor
                    sCfdiData[2] = split5[3]; // Total
                }

                sCadena = "?re=" + sCfdiData[0] + "&rr=" + sCfdiData[1] + "&tt=" + sCfdiData[2] + "&id=" + sCfdiData[3] + "";
            }
            else
            {
                if (sQr.Trim().StartsWith("?re="))
                {
                    split1 = sQr.Split(delimiter1, 5);
                    split2 = split1[1].Split(cEmisor, 5);
                    split3 = split1[2].Split(cReceptor, 5);
                    split4 = split1[3].Split(cTotal, 5);
                    split5 = split1[4].Split(cUuid, 4);

                    sCfdiData[0] = split2[3]; // RFC Emisor
                    sCfdiData[1] = split3[3]; // RFC Receptor
                    sCfdiData[2] = split4[3]; // Total
                    sCfdiData[3] = split5[3]; // UUID

                    sCadena = "?re=" + sCfdiData[0] + "&rr=" + sCfdiData[1] + "&tt=" + sCfdiData[2] + "&id=" + sCfdiData[3] + "";
                }
                else
                {
                    TotalTextBox.Text      = "";
                    RfcETextBox.Text       = "";
                    RfcRTextBox.Text       = "";
                    UuidTextBox.Text       = "";
                    QrTextBox.Text         = "";
                    UploadStatusLabel.Text = "Código QR incorrecto. Capture datos manualmente.";
                    RfcETextBox.Focus();
                    return;
                }
            }
        }
        else
        {
            sCadena      = "?re=" + sData[1] + "&rr=" + sData[2] + "&tt=" + sData[0] + "&id=" + sData[3] + "";
            sCfdiData[0] = sData[1]; // RFC Emisor
            sCfdiData[1] = sData[2]; // RFC Receptor
            sCfdiData[2] = sData[0]; // Total
            sCfdiData[3] = sData[3]; // UUID
        }

        oAcuse = oConsulta.Consulta(sCadena);

        sCfdiData[4] = oAcuse.CodigoEstatus.ToString();
        sCfdiData[5] = oAcuse.Estado.ToString();

        TotalLabel.Text         = sCfdiData[2];
        RfcEmisorLabel.Text     = sCfdiData[0];
        RfcReceptorLabel.Text   = sCfdiData[1];
        UuidLabel.Text          = sCfdiData[3];
        CodigoEstatusLabel.Text = oAcuse.CodigoEstatus.ToString();
        sEstado          = oAcuse.Estado.ToString();
        EstadoLabel.Text = oAcuse.Estado.ToString();

        sData_DBSave(sCfdiData);
    }