Esempio n. 1
0
 /// <summary>
 /// XMLs for venta (Include FAC, BOL, NCR, NDB).
 /// </summary>
 /// <param name="venta">The venta.</param>
 /// <returns>XmlResult.</returns>
 public XmlResult ToXml(CreditNoteHeader venta)
 {
     try
     {
         return(XmlForVentaInternal(venta));
     }
     catch (Exception e)
     {
         return(ForException(e));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Sends the specified venta.
        /// </summary>
        /// <param name="credit">The credit.</param>
        /// <returns>BillResult.</returns>
        public async Task <BillResult> Send(CreditNoteHeader credit)
        {
            var xmlRes = _xmlGenerator.ToXml(credit);

            if (!xmlRes.Success)
            {
                return(xmlRes);
            }

            return(await SendDoc(xmlRes.Path, xmlRes.Content));
        }
Esempio n. 3
0
        private XmlResult XmlForVentaInternal(CreditNoteHeader venta)
        {
            var res = _xmlGenerator.GenerarDocumentoCreditNote(venta);

            return(new XmlResult
            {
                Success = res.Success,
                Description = res.Error,
                Path = res.FileName,
                Content = res.Content,
                Code = res.Success ? null : CodeStatus.ConErrores
            });
        }
Esempio n. 4
0
        private string WorkingNotaCredito(Tuple <ventaDto, clienteDto, decimal> objs)
        {
            #region Entidades
            var objVenta = objs.Item1;
            var client   = objs.Item2;
            #endregion

            #region Gen Entidad Nota Credito
            Init();
            var notaCredit = new CreditNoteHeader(GetBaseNota(objVenta, client, objs.Item3))
            {
                TipoNota = (TipoNotaCreditoElectronica)Enum.ToObject(typeof(TipoNotaCreditoElectronica), objVenta.i_IdTipoNota ?? 1)
            };

            #endregion

            #region Generando XML
            var objOperationResult = new OperationResult2();
            var xmlResultPath      = new XmlDocGenerator(_cert).GenerarDocumentoCreditNote(ref objOperationResult, notaCredit);
            return(objOperationResult.Success ? xmlResultPath : string.Empty);

            #endregion
        }
Esempio n. 5
0
        /// <summary>
        /// Genera un documento XML para Notas de Credito.
        /// </summary>
        /// <param name="creditHeaderEntity">Entidad de Nota de Credito</param>
        /// <returns>Retorna el XML generado.</returns>
        public XmlFileResult GenerarDocumentoCreditNote(CreditNoteHeader creditHeaderEntity)
        {
            try
            {
                #region FileName
                string xmlFilename =
                    $"{creditHeaderEntity.RucEmisor}-07-{creditHeaderEntity.SerieDocumento}-{creditHeaderEntity.CorrelativoDocumento}";
                #endregion

                #region Gen CreditNote
                AmountType.TlsDefaultCurrencyID = creditHeaderEntity.CodigoMoneda;
                var creditDoc = new CreditNoteType
                {
                    ID                          = string.Concat(creditHeaderEntity.SerieDocumento, "-", creditHeaderEntity.CorrelativoDocumento),
                    IssueDate                   = creditHeaderEntity.FechaEmision,
                    DocumentCurrencyCode        = creditHeaderEntity.CodigoMoneda,
                    CustomizationID             = "1.0",
                    DespatchDocumentReference   = UtilsXmlDoc.DevuelveGuiasRemisionReferenciadas(creditHeaderEntity.GuiaRemisionReferencia),
                    AdditionalDocumentReference = UtilsXmlDoc.DevuelveDocumentosReferenciaNote(creditHeaderEntity),
                    DiscrepancyResponse         = new[]
                    {
                        new ResponseType
                        {
                            ReferenceID  = creditHeaderEntity.DocumentoRef,
                            ResponseCode = ((int)creditHeaderEntity.TipoNota).ToString("00"),
                            Description  = new TextType[]
                            {
                                creditHeaderEntity.Motivo
                            }
                        }
                    },
                    BillingReference = new[]
                    {
                        new BillingReferenceType
                        {
                            InvoiceDocumentReference = new DocumentReferenceType
                            {
                                ID = creditHeaderEntity.DocumentoRef,
                                DocumentTypeCode = ((int)creditHeaderEntity.TipoDocRef).ToString("00")
                            }
                        }
                    },
                    Signature = UtilsXmlDoc.GetSignature(creditHeaderEntity),
                    AccountingSupplierParty = UtilsXmlDoc.GetInfoEmisor(creditHeaderEntity),
                    AccountingCustomerParty = new CustomerPartyType
                    {
                        CustomerAssignedAccountID = creditHeaderEntity.NroDocCliente,
                        AdditionalAccountID       =
                            new IdentifierType[] { ((int)creditHeaderEntity.TipoDocumentoIdentidadCliente).ToString() },
                        Party = new PartyType
                        {
                            PostalAddress = string.IsNullOrWhiteSpace(creditHeaderEntity.DireccionCliente) ? null : new AddressType
                            {
                                StreetName = creditHeaderEntity.DireccionCliente
                            },
                            PartyLegalEntity = new[]
                            {
                                new PartyLegalEntityType
                                {
                                    RegistrationName = creditHeaderEntity.NombreRazonSocialCliente,
                                }
                            }
                        },
                    },
                    TaxTotal           = UtilsXmlDoc.DevuelveSubTotalImpuestos(creditHeaderEntity.Impuesto),
                    LegalMonetaryTotal = new MonetaryTotalType
                    {
                        ChargeTotalAmount = creditHeaderEntity.TotalCargos > 0 ? new AmountType {
                            Value = creditHeaderEntity.TotalCargos
                        } : null,
                        AllowanceTotalAmount = creditHeaderEntity.DescuentoGlobal > 0 ? new AmountType {
                            Value = creditHeaderEntity.DescuentoGlobal
                        } : null,
                        PayableAmount = creditHeaderEntity.Total
                    },
                    CreditNoteLine = UtilsXmlDoc.ToCredit(UtilsXmlDoc.DevuelveDetallesDelComprobante(creditHeaderEntity.DetallesDocumento)),
                };
                #region Ext
                var lisExt = new List <UBLExtensionType>(2);
                if (creditHeaderEntity.TotalTributosAdicionales != null)
                {
                    lisExt.Add(new UBLExtensionType
                    {
                        ExtensionContent = new AdditionalsInformationType //(mas informacion en el catalogo no 14 del manual.)
                        {
                            AdditionalInformation = new AdditionalInformationType {
                                AdditionalMonetaryTotal = UtilsXmlDoc.DevuelveTributosAdicionales(creditHeaderEntity.TotalTributosAdicionales),
                            }
                        }
                    });
                }
                lisExt.Add(new UBLExtensionType {
                    ExtensionContent = new AdditionalsInformationType()
                });
                creditDoc.UBLExtensions = lisExt.ToArray();
                #endregion
                creditDoc.AccountingSupplierParty.Party.PostalAddress = UtilsXmlDoc.ObtenerDireccion(creditHeaderEntity.DireccionEmisor);
                #endregion |

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