Esempio n. 1
0
        /// <summary>
        /// Genera un documento XML para Resumen Diario.
        /// </summary>
        /// <param name="summaryHeaderEntity">Entidad de Resumen</param>
        /// <param name="version2">version 2</param>
        /// <returns>Retorna el XML generado.</returns>
        public XmlFileResult GenerarDocumentoSummary(SummaryHeader summaryHeaderEntity, bool version2 = false)
        {
            try
            {
                #region Filename
                var id          = $"RC-{DateTime.Today:yyyyMMdd}-{summaryHeaderEntity.CorrelativoArchivo}";
                var xmlFilename = summaryHeaderEntity.RucEmisor + "-" + id;
                #endregion

                #region Gen Summary
                AmountType.TlsDefaultCurrencyID = summaryHeaderEntity.CodigoMoneda;
                var summaryDoc = new SummaryDocumentsType
                {
                    ID = id,
                    CustomizationID = version2 ? "1.1" : "1.0", // 2018 = 1.1
                    ReferenceDate   = summaryHeaderEntity.FechaEmision,
                    IssueDate       = DateTime.Today.Date,
                    UBLExtensions   = new[]
                    {
                        new UBLExtensionType
                        {
                            ExtensionContent = new AdditionalsInformationType()
                        },
                    },
                    Signature = UtilsXmlDoc.GetSignature(summaryHeaderEntity),
                    AccountingSupplierParty = UtilsXmlDoc.GetInfoEmisor(summaryHeaderEntity),
                    SummaryDocumentsLine    = UtilsXmlDoc.GetSummaryLines(summaryHeaderEntity.DetallesDocumento, version2)
                };
                #endregion

                return(FromDocument(summaryDoc, xmlFilename));
            }
            catch (Exception ex)
            {
                return(FromException(ex));
            }
        }