コード例 #1
0
        public List <string> RecibeDocumentoElectronio(DocumentoElectronicoModel DocElec)
        {
            List <string> Respuesta;

            Respuesta = GeneraDocumentoXML(DocElec);

            return(Respuesta);
        }
コード例 #2
0
        public List <string> Post(DocumentoElectronicoModel DocumentoFE)
        {
            DocumentoElectronicoController Fact = new DocumentoElectronicoController();
            List <string> Respuesta             = new List <string>();

            try
            {
                Respuesta = Fact.RecibeDocumentoElectronio(DocumentoFE);

                //Respuesta[0]="0";
                //Respuesta.Add("Operacion Existosa");
                //Respuesta.Add("dahnsjdkasdbjkabdkjasbdjbajdkbajkdbajkdbasjkbdajkbdjbasjkbjkadbjkasd");
                return(Respuesta);
            }
            catch (Exception ex)
            {
                Respuesta.Add("1");
                Respuesta.Add(ex.Message);
                return(Respuesta);
            }
        }
コード例 #3
0
        private List <String> GeneraDocumentoXML(DocumentoElectronicoModel Doc)
        {
            //string[] Cabecera = Doc.Trama.EN.Split('|');

            XmlDocument xmlDoc     = new XmlDocument();
            XmlElement  xmlElement = xmlDoc.CreateElement("AdditionalInformation", "urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1");

            UBLExtensionType[] uBLExtensions = new UBLExtensionType[]
            {
                new UBLExtensionType
                {
                    ExtensionContent = xmlElement
                },
                new UBLExtensionType()
                {
                    ExtensionContent = xmlElement
                },
            };

            Invoice Factura_Boleta = new Invoice();
            {
                Factura_Boleta.UBLExtensions = uBLExtensions;
                Factura_Boleta.UBLVersionID  = new UBLVersionIDType
                {
                    Value = "2.1"
                };
                Factura_Boleta.ID = new IDType
                {
                    Value = "F001-1"
                };
                Factura_Boleta.CustomizationID = new CustomizationIDType
                {
                    Value = "2.0"
                };
                Factura_Boleta.IssueDate = new IssueDateType
                {
                    Value = Convert.ToDateTime("2017-05-14 15:42:20")
                };
                Factura_Boleta.IssueTime = new IssueTimeType
                {
                    Value = Convert.ToDateTime("2017-05-14 15:42:20"),
                };
                Factura_Boleta.DueDate = new DueDateType
                {
                    Value = Convert.ToDateTime("2017-05-15 15:42:20"),
                };
                Factura_Boleta.InvoiceTypeCode = new InvoiceTypeCodeType
                {
                    Value = "01"
                };
                Factura_Boleta.Note = new List <NoteType>
                {
                    new NoteType {
                        Value = "SETENTA Y UN MIL TRESCIENTOS CINCUENTICUATRO Y 99/100"
                    }
                }.ToArray();
                Factura_Boleta.DocumentCurrencyCode = new DocumentCurrencyCodeType
                {
                    Value = "PEN"
                };
                Factura_Boleta.LineCountNumeric = new LineCountNumericType
                {
                    Value = 1
                };
                Factura_Boleta.ProfileID = new ProfileIDType
                {
                    Value = "0101"
                };
                Factura_Boleta.OrderReference = new OrderReferenceType
                {
                    ID = new IDType()
                    {
                        Value = "XXXXX"
                    }
                };

                Factura_Boleta.Signature = SignatureTypes(Doc.Trama);
                Factura_Boleta.AccountingSupplierParty = SupplierPartyType(Doc.Trama);
                Factura_Boleta.AccountingCustomerParty = CustomerPartyType(Doc.Trama);
                Factura_Boleta.AllowanceCharge         = AllowanceChargeTypes();
                Factura_Boleta.TaxTotal           = TaxTotalType(Doc.Trama);
                Factura_Boleta.LegalMonetaryTotal = MonetaryTotal(Doc.Trama);
                Factura_Boleta.InvoiceLine        = InvoiceLine(Doc.Trama.ITEM);
            }

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Invoice));

            using (Stream stream = new FileStream(@"D:\" + Doc.Ruc + "-" + Doc.Local + "-" + Doc.TipoDocumento + "-" + Doc.NumDocumento + ".xml", FileMode.Create))
                using (XmlWriter xmlWriter = new XmlTextWriter(stream, Encoding.Unicode))
                {
                    xmlSerializer.Serialize(xmlWriter, Factura_Boleta);
                }

            return(new List <string>());
        }