/// <summary> /// XMLs for venta (Include FAC, BOL, NCR, NDB). /// </summary> /// <param name="venta">The venta.</param> /// <returns>XmlResult.</returns> public XmlResult ToXml(DebitNoteHeader venta) { try { return(XmlForVentaInternal(venta)); } catch (Exception e) { return(ForException(e)); } }
/// <summary> /// Sends the specified venta. /// </summary> /// <param name="debit">The debit.</param> /// <returns>BillResult.</returns> public async Task <BillResult> Send(DebitNoteHeader debit) { var xmlRes = _xmlGenerator.ToXml(debit); if (!xmlRes.Success) { return(xmlRes); } return(await SendDoc(xmlRes.Path, xmlRes.Content)); }
private XmlResult XmlForVentaInternal(DebitNoteHeader venta) { var res = _xmlGenerator.GenerarDocumentoDebitNote(venta); return(new XmlResult { Success = res.Success, Description = res.Error, Path = res.FileName, Content = res.Content, Code = res.Success ? null : CodeStatus.ConErrores }); }
private string WorkingNotaDebito(Tuple <ventaDto, clienteDto, decimal> objs) { #region Entidades var objVenta = objs.Item1; var client = objs.Item2; #endregion #region Gen Entidad Nota Credito Init(); var notaDebit = new DebitNoteHeader(GetBaseNota(objVenta, client, objs.Item3)) { TipoNota = (TipoNotaDebitoElectronica)Enum.ToObject(typeof(TipoNotaDebitoElectronica), objVenta.i_IdTipoNota ?? 1) }; #endregion #region Generando XML var objOperationResult = new OperationResult2(); var xmlResultPath = new XmlDocGenerator(_cert).GenerarDocumentoDebitNote(ref objOperationResult, notaDebit); return(objOperationResult.Success ? xmlResultPath : string.Empty); #endregion }
/// <summary> /// Genera un documento XML para Notas de Debito. /// </summary> /// <param name="debitHeaderEntity">Entidad de Nota de Debito</param> /// <returns>Retorna el XML generado.</returns> public XmlFileResult GenerarDocumentoDebitNote(DebitNoteHeader debitHeaderEntity) { try { #region FileName string xmlFilename = $"{debitHeaderEntity.RucEmisor}-08-{debitHeaderEntity.SerieDocumento}-{debitHeaderEntity.CorrelativoDocumento}"; #endregion #region Gen DebitNote AmountType.TlsDefaultCurrencyID = debitHeaderEntity.CodigoMoneda; var debitDoc = new DebitNoteType { ID = string.Concat(debitHeaderEntity.SerieDocumento, "-", debitHeaderEntity.CorrelativoDocumento), IssueDate = debitHeaderEntity.FechaEmision, DocumentCurrencyCode = debitHeaderEntity.CodigoMoneda, CustomizationID = "1.0", DespatchDocumentReference = UtilsXmlDoc.DevuelveGuiasRemisionReferenciadas(debitHeaderEntity.GuiaRemisionReferencia), AdditionalDocumentReference = UtilsXmlDoc.DevuelveDocumentosReferenciaNote(debitHeaderEntity), DiscrepancyResponse = new[] { new ResponseType { ReferenceID = debitHeaderEntity.DocumentoRef, ResponseCode = ((int)debitHeaderEntity.TipoNota).ToString("00"), Description = new TextType[] { debitHeaderEntity.Motivo } } }, BillingReference = new[] { new BillingReferenceType { InvoiceDocumentReference = new DocumentReferenceType { ID = debitHeaderEntity.DocumentoRef, DocumentTypeCode = ((int)debitHeaderEntity.TipoDocRef).ToString("00") } } }, Signature = UtilsXmlDoc.GetSignature(debitHeaderEntity), AccountingSupplierParty = UtilsXmlDoc.GetInfoEmisor(debitHeaderEntity), AccountingCustomerParty = new CustomerPartyType { CustomerAssignedAccountID = debitHeaderEntity.NroDocCliente, AdditionalAccountID = new IdentifierType[] { ((int)debitHeaderEntity.TipoDocumentoIdentidadCliente).ToString() }, Party = new PartyType { PostalAddress = string.IsNullOrWhiteSpace(debitHeaderEntity.DireccionCliente) ? null : new AddressType { StreetName = debitHeaderEntity.DireccionCliente }, PartyLegalEntity = new[] { new PartyLegalEntityType { RegistrationName = debitHeaderEntity.NombreRazonSocialCliente, } } }, }, TaxTotal = UtilsXmlDoc.DevuelveSubTotalImpuestos(debitHeaderEntity.Impuesto), RequestedMonetaryTotal = new MonetaryTotalType { ChargeTotalAmount = debitHeaderEntity.TotalCargos > 0 ? new AmountType { Value = debitHeaderEntity.TotalCargos } : null, AllowanceTotalAmount = debitHeaderEntity.DescuentoGlobal > 0 ? new AmountType { Value = debitHeaderEntity.DescuentoGlobal } : null, PayableAmount = debitHeaderEntity.Total }, DebitNoteLine = UtilsXmlDoc.ToDebit(UtilsXmlDoc.DevuelveDetallesDelComprobante(debitHeaderEntity.DetallesDocumento)), }; #region Ext var lisExt = new List <UBLExtensionType>(2); if (debitHeaderEntity.TotalTributosAdicionales != null) { lisExt.Add(new UBLExtensionType { ExtensionContent = new AdditionalsInformationType //(mas informacion en el catalogo no 14 del manual.) { AdditionalInformation = new AdditionalInformationType { AdditionalMonetaryTotal = UtilsXmlDoc.DevuelveTributosAdicionales(debitHeaderEntity.TotalTributosAdicionales), } } }); } lisExt.Add(new UBLExtensionType { ExtensionContent = new AdditionalsInformationType() }); debitDoc.UBLExtensions = lisExt.ToArray(); #endregion debitDoc.AccountingSupplierParty.Party.PostalAddress = UtilsXmlDoc.ObtenerDireccion(debitHeaderEntity.DireccionEmisor); #endregion | return(FromDocument(debitDoc, xmlFilename)); } catch (Exception ex) { return(FromException(ex)); } }