public override string ToString() { // TODO ArBy global culture, datetime format var formattedIssueDate = IssueDate.ToString("yyyy-MM-dd"); var formattedDueDate = DueDate.ToString("yyyy-MM-dd"); var formattedRedemptionDate = RedemptionDate != null?RedemptionDate.Value.ToString("yyyy-MM-dd") : "n/a"; return("Invoice(" + $"serial={Serial}, " + $"id={Id}, " + $"isPayed={IsPayed.ToString()}, " + $"issueDate={formattedIssueDate}, " + $"dueDate={formattedDueDate}, " + $"redemptionDate={formattedRedemptionDate}, " + $"supplier={Supplier}, " + $"receiver={Receiver}, " + $"total={Total.ToString(CultureInfo.InvariantCulture)}, " + $"subtotal={Subtotal.ToString(CultureInfo.InvariantCulture)}, " + $"discount={Discount.ToString(CultureInfo.InvariantCulture)}, " + $"payed={Payed.ToString(CultureInfo.InvariantCulture)}, " + $"due={Due.ToString(CultureInfo.InvariantCulture)}, " + $"items=[{string.Join(", ", Items)}], " + $"payments=[{string.Join(", ", Payments)}]" + ")"); }
public void Issue(IUserModel reader) { Status = Status.Taken; ReaderID = reader.ID; IssueDate = DateTime.Now; ReturnDate = IssueDate.AddMonths(LendingMonths); }
public override string ToString() { string type = Type == MovementDirection.Deposit ? "D" : "W"; return($"[{IssueDate.ToString("yyyy-MM-dd")}] " + $"({type}) CC Movement with {Issuer} no. {CardNumber} - {Amount} EUR"); }
public override string ToString() { string type = Type == MovementDirection.Deposit ? "D" : "W"; return($"[{IssueDate.ToString("yyyy-MM-dd")}] " + $"({type}) Cash Movement by {Executor} - {Amount} EUR"); }
public XDocument Serialize() { return(new XDocument(new XElement(EspdNames.Qarq + nameof(QualificationApplicationRequest), new XAttribute(XNamespace.Xmlns + "cbc", UblNames.Cbc), new XAttribute(XNamespace.Xmlns + "cac", UblNames.Cac), UBLVersionID.Serialize(nameof(UBLVersionID)), CustomizationID.Serialize(nameof(CustomizationID)), ProfileID.Serialize(nameof(ProfileID)), ProfileExecutionID.Serialize(nameof(ProfileExecutionID)), ID?.Serialize(nameof(ID)), CopyIndicator.Serialize(nameof(CopyIndicator)), UUID.Serialize(nameof(UUID)), ContractFolderID.Serialize(nameof(ContractFolderID)), IssueDate.Serialize(nameof(IssueDate)), IssueTime.Serialize(nameof(IssueTime)), VersionID.Serialize(nameof(VersionID)), PreviousVersionID.Serialize(nameof(PreviousVersionID)), ProcedureCode.Serialize(nameof(ProcedureCode)), QualificationApplicationTypeCode.Serialize(nameof(QualificationApplicationTypeCode)), WeightScoringMethodologyNote.Serialize(nameof(WeightScoringMethodologyNote)), WeightingTypeCode.Serialize(nameof(WeightingTypeCode)), ContractingParty?.Serialize(), ProcurementProject?.Serialize(), ProcurementProjectLots?.Select(lot => lot.Serialize()), TenderingCriteria?.Select(c => c.Serialize()), AdditionalDocumentReferences?.Select(d => d.Serialize()) ))); }
public DateTime?ConvertIssuedDate() { if (string.IsNullOrEmpty(IssueDate) || IssueDate.Length != 7) { return(null); } int year, month, day; if (!int.TryParse(IssueDate.Substring(0, 3), out year)) { return(null); } if (!int.TryParse(IssueDate.Substring(3, 2), out month)) { return(null); } if (!int.TryParse(IssueDate.Substring(5, 2), out day)) { return(null); } string datestr = string.Format("{0}/{1}/{2}", year + 1911, month, day); DateTime dt; if (!DateTime.TryParse(datestr, out dt)) { return(null); } return(dt); }
public override int GetHashCode() { int hash = 1; if (issueDate_ != null) { hash ^= IssueDate.GetHashCode(); } if (supplier_ != null) { hash ^= Supplier.GetHashCode(); } if (CustomerRef.Length != 0) { hash ^= CustomerRef.GetHashCode(); } if (Text.Length != 0) { hash ^= Text.GetHashCode(); } if (Currency.Length != 0) { hash ^= Currency.GetHashCode(); } if (Total != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Total); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private SortedDictionary <double, double> GetCashflows(DateTime evaluationDate) { SortedDictionary <double, double> cashflows = new SortedDictionary <double, double>(); double yearFrac; if (IsForward) { DateTime prevCashflowDate = IssueDate; DateTime cashflowDate = IssueDate.AddMonths(CouponGapMonth()); while (cashflowDate < MaturityDate) { yearFrac = (cashflowDate - evaluationDate).TotalDays / 365; if (yearFrac > 0) { cashflows.Add(yearFrac, CouponRate * (cashflowDate - prevCashflowDate).TotalDays / 365); } prevCashflowDate = cashflowDate; cashflowDate = cashflowDate.AddMonths(CouponGapMonth()); } yearFrac = (MaturityDate - evaluationDate).TotalDays / 365; if (yearFrac > 0) { cashflows.Add((MaturityDate - evaluationDate).TotalDays / 365, CouponRate * (MaturityDate - prevCashflowDate).TotalDays / 365); } } else { DateTime prevCashflowDate = MaturityDate.AddMonths(-CouponGapMonth()); DateTime cashflowDate = MaturityDate; while (prevCashflowDate > IssueDate) { yearFrac = (cashflowDate - evaluationDate).TotalDays / 365; if (yearFrac > 0) { cashflows.Add(yearFrac, CouponRate * (cashflowDate - prevCashflowDate).TotalDays / 365); } cashflowDate = prevCashflowDate; prevCashflowDate = prevCashflowDate.AddMonths(-CouponGapMonth()); } yearFrac = (IssueDate - evaluationDate).TotalDays / 365; if (yearFrac > 0) { cashflows.Add((IssueDate - evaluationDate).TotalDays / 365, CouponRate * (IssueDate - cashflowDate).TotalDays / 365); } } // Add principal if (cashflows.Count != 0) { double lastYearFrac = cashflows.Keys.Max(); cashflows[lastYearFrac] += 1; } return(cashflows); }
public IssueBook(int sid, int bid) { Sid = sid; Bid = bid; IssueDate = DateTime.Now; Returndate = IssueDate.AddDays(30); // TODO: this keyword are not used. //IssueDate = issueDate; //TODO: Set today's date as issue date //Returndate = returndate; // TODO: Calculate retrun date based on issue date }
private void WriteLicenseProperties(StringBuilder sb) { sb.AppendLine(HardwareIdentifier); sb.AppendLine(SerialNumber); sb.AppendLine(IssueDate.ToString(CultureInfo.InvariantCulture)); sb.AppendLine(ExpirationDate.ToString(CultureInfo.InvariantCulture)); foreach (var property in Properties) { sb.AppendLine(property.Key + ":" + property.Value); } }
public XElement Serialize() { return(new XElement(UblNames.Cac + nameof(AdditionalDocumentReference), ID.Serialize(nameof(ID)), UUID.Serialize(nameof(UUID)), IssueDate.Serialize(nameof(IssueDate)), IssueTime.Serialize(nameof(IssueTime)), DocumentTypeCode.Serialize(nameof(DocumentTypeCode)), DocumentType.Serialize(nameof(DocumentType)), Attachment?.Serialize())); }
public override string ToString() { string type = Type == MovementDirection.Deposit ? "D" : "W"; string direction = string.IsNullOrEmpty(FromBank) ? $"to {ToBank}" : $"from {FromBank}"; return($"[{IssueDate.ToString("yyyy-MM-dd")}] " + $"({type}) Transfert Movement {direction} - {Amount} EUR"); }
public virtual int _GetUniqueIdentifier() { var hashCode = 399326290; hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Message?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (IssueDate?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (RefRevision?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (RefGUID?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Issuer?.GetHashCode() ?? 0); return(hashCode); }
public VisaDataItem Copy() { var result = new VisaDataItem(); result.Number = Number; result.BirthPlace = BirthPlace; result.IssuePlace = IssuePlace; result.ApplicableCountry = ApplicableCountry; result.IssueDate = IssueDate?.Copy(); return(result); }
public bool Get(long DocProformaInvoice_ID) { string Err = null; Clear(); string sql = @"select dpi.IssueDate, dpi.DocDuration, dpi.DocDurationType, dpi.TermsOfPayment_ID, dpi.MethodOfPayment_ID, mop.Atom_BankAccount_ID, top.Description as TermsOfPayment_Description, mop.PaymentType, aba.TRR, ao.Name, ao.Tax_ID, ao.Registration_ID from DocProformaInvoice dpi left join TermsOfPayment top on dpi.TermsOfPayment_ID = top.ID left join MethodOfPayment mop on dpi.MethodOfPayment_ID = mop.ID left join Atom_BankAccount aba on mop.Atom_BankAccount_ID = aba.ID left join Atom_Bank ab on aba.Atom_Bank_ID = ab.ID left join Atom_Organisation ao on ab.Atom_Organisation_ID = ao.ID where dpi.ID = " + DocProformaInvoice_ID.ToString(); DataTable dt = new DataTable(); if (DBSync.DBSync.ReadDataTable(ref dt, sql, ref Err)) { if (dt.Rows.Count > 0) { m_IssueDate = DocProformaInvoice_AddOn.IssueDate.Set(dt.Rows[0]["IssueDate"]); m_Duration = DocProformaInvoice_AddOn.Duration.Set(dt.Rows[0]["DocDuration"], dt.Rows[0]["DocDurationType"]); m_TermsOfPayment = DocProformaInvoice_AddOn.TermsOfPayment.Set(dt.Rows[0]["TermsOfPayment_ID"], dt.Rows[0]["TermsOfPayment_Description"]); m_MethodOfPayment = DocProformaInvoice_AddOn.MethodOfPayment.Set(dt.Rows[0]["MethodOfPayment_ID"], dt.Rows[0]["PaymentType"], dt.Rows[0]["Name"], dt.Rows[0]["Tax_ID"], dt.Rows[0]["Registration_ID"], dt.Rows[0]["TRR"], dt.Rows[0]["Atom_BankAccount_ID"]); } return true; } else { LogFile.Error.Show("ERROR:TangentaDB:DocProformaInvoice_AddOn:Get:sql=" + sql + "\r\nErr=" + Err); return false; } }
public override int GetHashCode() { unchecked { var hashCode = (Id != null ? Id.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IssueDate.GetHashCode(); hashCode = (hashCode * 397) ^ DueDate.GetHashCode(); hashCode = (hashCode * 397) ^ RedemptionDate.GetHashCode(); hashCode = (hashCode * 397) ^ (Items != null ? Items.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Payments != null ? Payments.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Supplier != null ? Supplier.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Receiver != null ? Receiver.GetHashCode() : 0); return(hashCode); } }
public int CompareTo(Invoice other) { if (ReferenceEquals(this, other)) { return(0); } if (ReferenceEquals(null, other)) { return(1); } var serialNumberComparison = string.Compare(SerialNumber, other.SerialNumber, StringComparison.Ordinal); if (serialNumberComparison != 0) { return(serialNumberComparison); } var companyNameComparison = string.Compare(CompanyName, other.CompanyName, StringComparison.Ordinal); if (companyNameComparison != 0) { return(companyNameComparison); } var subtotalComparison = Subtotal.CompareTo(other.Subtotal); if (subtotalComparison != 0) { return(subtotalComparison); } var departmentComparison = Department.CompareTo(other.Department); if (departmentComparison != 0) { return(departmentComparison); } var issueDateComparison = IssueDate.CompareTo(other.IssueDate); if (issueDateComparison != 0) { return(issueDateComparison); } return(DueDate.CompareTo(other.DueDate)); }
public bool Equals(InvoiceDto other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } // TODO ArBy redemptionDate equality return(Equals(Id, other.Id) && IssueDate.Equals(other.IssueDate) && DueDate.Equals(other.DueDate) && RedemptionDate.Equals(other.RedemptionDate) && Equals(Items, other.Items) && Equals(Payments, other.Payments) && Equals(Supplier, other.Supplier) && Equals(Receiver, other.Receiver)); }
public XElement Serialize() { return(new XElement(UblNames.Cac + nameof(DocumentReference), ID.Serialize(nameof(ID)), CopyIndicator.Serialize(nameof(CopyIndicator)), UUID.Serialize(nameof(UUID)), IssueDate.Serialize(nameof(IssueDate)), IssueTime.Serialize(nameof(IssueTime)), DocumentTypeCode.Serialize(nameof(DocumentTypeCode)), DocumentType.Serialize(nameof(DocumentType)), XPath.Serialize(nameof(XPath)), LanguageID.Serialize(nameof(LanguageID)), LocaleCode.Serialize(nameof(LocaleCode)), VersionID.Serialize(nameof(VersionID)), DocumentStatusCode.Serialize(nameof(DocumentStatusCode)), DocumentDescription.Serialize(nameof(DocumentDescription)), Attachment?.Serialize(), ValidityPeriod?.Serialize(nameof(ValidityPeriod)), IssuerParty?.Serialize(nameof(IssuerParty)) )); }
public void MergeFrom(Invoice other) { if (other == null) { return; } if (other.issueDate_ != null) { if (issueDate_ == null) { IssueDate = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } IssueDate.MergeFrom(other.IssueDate); } if (other.supplier_ != null) { if (supplier_ == null) { Supplier = new global::Asgt.Type.Supplier(); } Supplier.MergeFrom(other.Supplier); } if (other.CustomerRef.Length != 0) { CustomerRef = other.CustomerRef; } if (other.Text.Length != 0) { Text = other.Text; } if (other.Currency.Length != 0) { Currency = other.Currency; } if (other.Total != 0F) { Total = other.Total; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public DOXAPI.Document asDocument(string customerID, string customerName, string filename) { // Convert local class object to DOX-Pro document object DOXAPI.Document docInv = new DOXAPI.Document(); docInv.DocType = flexInvoiceType; // Set documents fields according to doc-type docInv.Fields = new DOXAPI.Field[flexInvoiceType.Attributes.Length]; for (int i = 0; i < docInv.Fields.Length; i++) { DOXAPI.Field f = new DOXAPI.Field(); f.Attr = flexInvoiceType.Attributes[i]; switch (f.Attr.Name) { case "Customer ID": f.Value = customerID; break; case "Invoice No": f.Value = company + InvoiceNo; break; case "Packing Slips": f.Value = removeDuplicates(PackingSlips); break; case "Issue Date": f.Value = IssueDate; break; default: f.Value = null; break; } docInv.Fields[i] = f; } docInv.Title = InvoiceNo + "/" + IssueDate.ToShortDateString(); docInv.FileName = filename; return(docInv); }
public void ReadCard() { //read jpn1_1 file SetLength((short)jpn1_1.Length); SelectInfo(1, 1, 0, (short)jpn1_1.Length); jpn1_1 = ReadInfo((short)jpn1_1.Length); Name = ASCIIEncoding.ASCII.GetString(jpn1_1, 3, 150).Trim(); IC = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x111, 13); Sex = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x11e, 1) == "L" ? "Male" : "Female"; OldIC = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x11f, 8); BirthDate = ConvertBCDDate(jpn1_1, 0x127); BirthDateString = BirthDate.ToString("dd MMM yyyy"); BirthPlace = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x12b, 25).Trim(); IssueDate = ConvertBCDDate(jpn1_1, 0x144); IssueDateString = IssueDate.ToString("dd MMM yyyy"); Citizenship = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x148, 18).Trim(); Race = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x15a, 25).Trim(); Religion = ASCIIEncoding.ASCII.GetString(jpn1_1, 0x173, 11).Trim(); //read jpn1_2 file SetLength((short)jpn1_2.Length); SelectInfo(1, 2, 0, (short)jpn1_2.Length); jpn1_2 = ReadInfo((short)jpn1_2.Length); Photo = new MemoryStream(jpn1_2, 3, 4000); Photo.Seek(0, SeekOrigin.Begin); //read jpn1_4 file SetLength((short)jpn1_4.Length); SelectInfo(1, 4, 0, (short)jpn1_4.Length); jpn1_4 = ReadInfo((short)jpn1_4.Length); Address1 = ASCIIEncoding.ASCII.GetString(jpn1_4, 3, 30).Trim(); Address2 = ASCIIEncoding.ASCII.GetString(jpn1_4, 0x21, 30).Trim(); Address3 = ASCIIEncoding.ASCII.GetString(jpn1_4, 0x3f, 30).Trim(); Postcode = ConvertBCDPostcode(jpn1_4, 0x5d); City = ASCIIEncoding.ASCII.GetString(jpn1_4, 0x60, 25).Trim(); State = ASCIIEncoding.ASCII.GetString(jpn1_4, 0x79, 30).Trim(); }
// Rajdhani stoppped publishing epaper from 2016/09/16 // so we are removing this item from comboxboxItem in the UI public void RajdhaniInfo() { // http://rajdhani.com.np/epaper/898 example link that holds the link to pdf file in <iFrame> tag // map the user input date to the date id like 898 in the above link DateTime dateLinkedWith898id = new DateTime(2016, 09, 16); TimeSpan span = IssueDate.Subtract(dateLinkedWith898id); int dateDiff = span.Days; // dateDiff +ve if IssueDate is greater than 2016/09/16 is -ve is IssueDate is less than 2016/09/16 int dateId = (int)Math.Abs((decimal)898 + dateDiff); string linkToPdf = "http://rajdhani.com.np/epaper/" + dateId.ToString(); // use Html agility package to extract link pdf link from <iFrame> tag HtmlWeb web = new HtmlWeb(); HtmlDocument doc = web.Load(linkToPdf); DownloadLinkAndFileName = new List <Dictionary <string, string> >(); // select all iFrame tag using Xpath var iFrameTag = doc.DocumentNode.SelectNodes("//iframe"); if (iFrameTag != null) { foreach (var tag in iFrameTag) { string srcAttr = tag.Attributes["src"].Value; if (srcAttr.Substring(0).Contains(".pdf")) { DownloadLinkAndFileName.Add(new Dictionary <string, string> { { "dlLink", srcAttr }, { "filePathName", DownloadPath + "\\" + PaperName + "-" + _year + "-" + _month + "-" + _day + ".pdf" } }); } } } }
private void LableFill() { lblContactNo.Text = String.Empty; lblIssueDate.Text = String.Empty; Execute objExecute = new Execute(); string Query = "[dbo].[spGetIssueLableinfo]"; SqlParameter[] para = new SqlParameter[] { Execute.AddParameter("@intIssueHeaderID", Convert.ToInt32(cmbIssueNo.SelectedValue)), }; DataSet ds = (DataSet)objExecute.Executes(Query, ReturnType.DataSet, para, CommandType.StoredProcedure); if (ds.Tables[0].Rows.Count > 0) { int ContactNo = Convert.ToInt32(ds.Tables[0].Rows[0]["intContactNo"].ToString()); lblContactNo.Text = ContactNo.ToString(); DateTime IssueDate; IssueDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["dtIssueDate"].ToString()); lblIssueDate.Text = IssueDate.ToString("MM/dd/yyyy"); } }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsVoidedDocuments); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ds", EspacioNombres.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:xsi", EspacioNombres.xsi); #region UBLExtensions writer.WriteStartElement("ext:UBLExtensions"); { writer.WriteStartElement("ext:UBLExtension"); { writer.WriteStartElement("ext:ExtensionContent"); { #region Signature writer.WriteStartElement("cac:Signature"); { writer.WriteElementString("cbc:ID", Signature.Id); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); writer.WriteEndElement(); #endregion PartyName writer.WriteEndElement(); #endregion SignatoryParty #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); writer.WriteStartElement("cac:ExternalReference"); writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.Uri.Trim()); writer.WriteEndElement(); writer.WriteEndElement(); #endregion DigitalSignatureAttachment } writer.WriteEndElement(); #endregion Signature } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion UBLExtensions writer.WriteElementString("cbc:UBLVersionID", UblVersionId); writer.WriteElementString("cbc:CustomizationID", CustomizationId); writer.WriteElementString("cbc:ID", Id); writer.WriteElementString("cbc:ReferenceDate", ReferenceDate.ToString("yyyy-MM-dd")); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString("yyyy-MM-dd")); #region Signature writer.WriteStartElement("cac:Signature"); { writer.WriteElementString("cbc:ID", Signature.Id); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); { writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); { writer.WriteStartElement("cbc:Name"); writer.WriteCData(Signature.SignatoryParty.PartyName.Name); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion PartyName } writer.WriteEndElement(); #endregion SignatoryParty #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); { writer.WriteStartElement("cac:ExternalReference"); writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.Uri.Trim()); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion DigitalSignatureAttachment } writer.WriteEndElement(); #endregion Signature #region AccountingSupplierParty writer.WriteStartElement("cac:AccountingSupplierParty"); { writer.WriteElementString("cbc:CustomerAssignedAccountID", AccountingSupplierParty.CustomerAssignedAccountId); writer.WriteElementString("cbc:AdditionalAccountID", AccountingSupplierParty.AdditionalAccountId); #region Party writer.WriteStartElement("cac:Party"); { #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingSupplierParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion PartyLegalEntity } writer.WriteEndElement(); #endregion Party } writer.WriteEndElement(); #endregion AccountingSupplierParty #region VoidedDocumentsLines foreach (var item in VoidedDocumentsLines) { writer.WriteStartElement("sac:VoidedDocumentsLine"); { writer.WriteElementString("cbc:LineID", item.LineId.ToString()); writer.WriteElementString("cbc:DocumentTypeCode", item.DocumentTypeCode); writer.WriteElementString("sac:DocumentSerialID", item.DocumentSerialID); writer.WriteElementString("sac:DocumentNumberID", item.DocumentNumberID.ToString()); writer.WriteStartElement("sac:VoidReasonDescription"); writer.WriteCData(item.VoidReasonDescription); writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion VoidedDocumentsLines }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsSummaryDocuments); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ds", EspacioNombres.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:xsi", EspacioNombres.xsi); #region UBLExtensions { writer.WriteStartElement("ext:UBLExtensions"); #region UBLExtension { writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent { writer.WriteStartElement("ext:ExtensionContent"); // En esta zona va el certificado digital. writer.WriteEndElement(); } #endregion ExtensionContent writer.WriteEndElement(); } #endregion UBLExtension writer.WriteEndElement(); } #endregion UBLExtensions writer.WriteElementString("cbc:UBLVersionID", UblVersionId); writer.WriteElementString("cbc:CustomizationID", CustomizationId); writer.WriteElementString("cbc:ID", Id); writer.WriteElementString("cbc:ReferenceDate", ReferenceDate.ToString("yyyy-MM-dd")); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString("yyyy-MM-dd")); #region Signature writer.WriteStartElement("cac:Signature"); writer.WriteElementString("cbc:ID", Signature.Id); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); //writer.WriteStartElement("cbc:Name"); //writer.WriteCData(Signature.SignatoryParty.PartyName.Name); //writer.WriteEndElement(); writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); writer.WriteEndElement(); #endregion PartyName writer.WriteEndElement(); #endregion SignatoryParty #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); writer.WriteStartElement("cac:ExternalReference"); writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.Uri.Trim()); writer.WriteEndElement(); writer.WriteEndElement(); #endregion DigitalSignatureAttachment writer.WriteEndElement(); #endregion Signature #region AccountingSupplierParty writer.WriteStartElement("cac:AccountingSupplierParty"); writer.WriteElementString("cbc:CustomerAssignedAccountID", AccountingSupplierParty.CustomerAssignedAccountId); writer.WriteElementString("cbc:AdditionalAccountID", AccountingSupplierParty.AdditionalAccountId); #region Party writer.WriteStartElement("cac:Party"); #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingSupplierParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion PartyLegalEntity writer.WriteEndElement(); #endregion Party writer.WriteEndElement(); #endregion AccountingSupplierParty #region SummaryDocumentsLines foreach (var item in SummaryDocumentsLines) { writer.WriteStartElement("sac:SummaryDocumentsLine"); { writer.WriteElementString("cbc:LineID", item.LineId.ToString()); writer.WriteElementString("cbc:DocumentTypeCode", item.DocumentTypeCode); if (!string.IsNullOrEmpty(item.Id)) { writer.WriteElementString("cbc:ID", item.Id); } else { writer.WriteElementString("sac:DocumentSerialID", item.DocumentSerialId); writer.WriteElementString("sac:StartDocumentNumberID", item.StartDocumentNumberId.ToString()); writer.WriteElementString("sac:EndDocumentNumberID", item.EndDocumentNumberId.ToString()); } if (!string.IsNullOrEmpty(item.AccountingCustomerParty.AdditionalAccountId)) { writer.WriteStartElement("cac:AccountingCustomerParty"); { writer.WriteElementString("cbc:CustomerAssignedAccountID", item.AccountingCustomerParty.CustomerAssignedAccountId); writer.WriteElementString("cbc:AdditionalAccountID", item.AccountingCustomerParty.AdditionalAccountId); } writer.WriteEndElement(); } if (!string.IsNullOrEmpty(item.BillingReference.InvoiceDocumentReference.Id)) { writer.WriteStartElement("cac:BillingReference"); { writer.WriteStartElement("cac:InvoiceDocumentReference"); { writer.WriteElementString("cbc:ID", item.BillingReference.InvoiceDocumentReference.Id); writer.WriteElementString("cbc:DocumentTypeCode", item.BillingReference.InvoiceDocumentReference.DocumentTypeCode); } writer.WriteEndElement(); } writer.WriteEndElement(); } if (item.ConditionCode.HasValue) { writer.WriteStartElement("cac:Status"); { writer.WriteElementString("cbc:ConditionCode", item.ConditionCode.Value.ToString()); } writer.WriteEndElement(); } writer.WriteStartElement("sac:TotalAmount"); { writer.WriteAttributeString("currencyID", item.TotalAmount.CurrencyId); writer.WriteValue(item.TotalAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); foreach (var billing in item.BillingPayments) { writer.WriteStartElement("sac:BillingPayment"); { writer.WriteStartElement("cbc:PaidAmount"); { writer.WriteAttributeString("currencyID", item.TotalAmount.CurrencyId); writer.WriteValue(billing.PaidAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); writer.WriteElementString("cbc:InstructionID", billing.InstructionId); } writer.WriteEndElement(); } writer.WriteStartElement("cac:AllowanceCharge"); { writer.WriteElementString("cbc:ChargeIndicator", item.AllowanceCharge.ChargeIndicator ? "true" : "false"); writer.WriteStartElement("cbc:Amount"); { writer.WriteAttributeString("currencyID", item.AllowanceCharge.Amount.CurrencyId); writer.WriteValue(item.AllowanceCharge.Amount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } writer.WriteEndElement(); foreach (var taxTotal in item.TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxSubtotal { writer.WriteStartElement("cac:TaxSubtotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxCategory { writer.WriteStartElement("cac:TaxCategory"); #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); writer.WriteElementString("cbc:ID", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion TaxScheme writer.WriteEndElement(); } #endregion TaxCategory writer.WriteEndElement(); } #endregion TaxSubtotal writer.WriteEndElement(); } } writer.WriteEndElement(); } #endregion SummaryDocumentsLines }
public void WriteXml(XmlWriter writer) { // pagina 1 #region pagina1 #region Cabecera writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsInvoice); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ccts", EspacioNombres.ccts); writer.WriteAttributeString("xmlns:ds", Http.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:qdt", EspacioNombres.qdt); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:udt", EspacioNombres.udt); writer.WriteAttributeString("xmlns:xsi", Http.xsi); #endregion Cabecera var ext2 = UblExtensions.Extension2.ExtensionContent.AdditionalInformation; { #region UBLExtension writer.WriteStartElement("ext:UBLExtensions"); { writer.WriteStartElement("ext:UBLExtension"); { writer.WriteStartElement("ext:ExtensionContent"); { writer.WriteString("aa"); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion UBLExtension #endregion pagina1 // pagina 2 #region pagina2 #region UBLVersion writer.WriteElementString("cbc:UBLVersionID", UblVersionId); writer.WriteElementString("cbc:CustomizationID", CustomizationId); #region ProfileID writer.WriteStartElement("cbc:ProfileID"); { writer.WriteAttributeString("schemeName", Sunat.schemeName); writer.WriteAttributeString("schemeAgencyName", Sunat.peSunat); writer.WriteAttributeString("schemeURI", Sunat.catalogos + "17"); writer.WriteString("0101"); } writer.WriteEndElement(); #endregion ProfileID writer.WriteElementString("cbc:ID", Id); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString(Formatos.FormatoFecha)); writer.WriteElementString("cbc:IssueTime", IssueHora.ToString(Formatos.FormatoHora)); #region InvoiceTypeCode writer.WriteStartElement("cbc:InvoiceTypeCode"); { writer.WriteAttributeString("listAgencyName", Sunat.peSunat); writer.WriteAttributeString("listName", Sunat.TipoDocumento); writer.WriteAttributeString("listURI", Sunat.catalogos + "01"); writer.WriteAttributeString("listID", "0101"); writer.WriteString("01"); } writer.WriteEndElement(); #endregion InvoiceTypeCode #region Note writer.WriteStartElement("cbc:Note"); { writer.WriteAttributeString("languageLocaleID", "1000"); writer.WriteString(MontoEnLetras); } writer.WriteEndElement(); #endregion Note #region Note2 // writer.WriteStartElement("cbc:Note"); // { // writer.WriteAttributeString("languageLocaleID", "1000"); // writer.WriteString(NroPedido); // } // writer.WriteEndElement(); #endregion Note2 #region DocumentCurrencyCode writer.WriteStartElement("cbc:DocumentCurrencyCode"); { writer.WriteAttributeString("listID", Sunat.iso4217); writer.WriteAttributeString("listName", Sunat.currenty); writer.WriteAttributeString("listAgencyName", Sunat.unece); writer.WriteString("PEN"); } writer.WriteEndElement(); #endregion DocumentCurrencyCode writer.WriteElementString("cbc:LineCountNumeric", Convert.ToString(TotItem)); #endregion UBLVersion #region OrderReference if (!string.IsNullOrEmpty(OrderReference)) { writer.WriteStartElement("cac:OrderReference"); { writer.WriteElementString("cbc:ID", OrderReference); } writer.WriteEndElement(); } #endregion OrderReference #region Signature writer.WriteStartElement("cac:Signature"); { writer.WriteElementString("cbc:ID", "IDSignSP"); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty");; { writer.WriteStartElement("cac:PartyIdentification"); { writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); } writer.WriteEndElement(); writer.WriteStartElement("cac:PartyName"); { writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion SignatoryParty #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); { writer.WriteStartElement("cac:ExternalReference"); { writer.WriteElementString("cbc:URI", "#SignatureSP"); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion DigitalSignatureAttachment } writer.WriteEndElement(); #endregion Signature #region AccountingSupplierParty writer.WriteStartElement("cac:AccountingSupplierParty"); { #region Party writer.WriteStartElement("cac:Party"); { #region PartyIdentification writer.WriteStartElement("cac:PartyIdentification"); { #region ID writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", "6"); writer.WriteAttributeString("schemeName", Sunat.documentoIdentidad); writer.WriteAttributeString("schemeAgencyName", Sunat.peSunat); writer.WriteAttributeString("schemeURI", Sunat.catalogos + "06"); writer.WriteString(Signature.SignatoryParty.PartyIdentification.Id.Value); } writer.WriteEndElement(); #endregion ID } writer.WriteEndElement(); #endregion PartyIdentification #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteElementString("cbc:RegistrationName", Signature.SignatoryParty.PartyName.Name); writer.WriteStartElement("cac:RegistrationAddress"); { writer.WriteElementString("cbc:AddressTypeCode", AnexoSunat); // { // writer.WriteAttributeString ("schemeAgencyName", Sunat.peSunat); // writer.WriteAttributeString("schemeName", "Establecimientos anexos"); // writer.WriteString(AnexoSunat); // } // writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion PartyLegalEntity } writer.WriteEndElement(); #endregion Party } writer.WriteEndElement(); #endregion AccountingSupplierParty #endregion pagina2 // pagina 3 #region pagina3 #region AccountingCustomerParty writer.WriteStartElement("cac:AccountingCustomerParty"); { #region Party writer.WriteStartElement("cac:Party"); { #region PartyIdentification writer.WriteStartElement("cac:PartyIdentification"); { #region ID writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", "6"); writer.WriteAttributeString("schemeName", Sunat.documentoIdentidad); writer.WriteAttributeString("schemeAgencyName", Sunat.peSunat); writer.WriteAttributeString("schemeURI", Sunat.catalogos + "06"); writer.WriteString(AccountingCustomerParty.CustomerAssignedAccountId); } writer.WriteEndElement(); #endregion ID } writer.WriteEndElement(); #endregion PartyIdentification #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteElementString("cbc:RegistrationName", AccountingCustomerParty.Party.PartyLegalEntity.RegistrationName); } writer.WriteEndElement(); #endregion PartyLegalEntity } writer.WriteEndElement(); #endregion Party } writer.WriteEndElement(); #endregion AccountingCustomerParty if (DescuentoGlobal > 0) { writer.WriteStartElement("cac:AllowanceCharge"); { writer.WriteElementString("cbc:ChargeIndicator", "False"); writer.WriteElementString("cbc:AllowanceChargeReasonCode", "00"); writer.WriteElementString("cbc:MultiplierFactorNumeric", "0"); writer.WriteStartElement("cbc:Amount"); writer.WriteAttributeString("currencyID", "PEN"); writer.WriteString(Convert.ToString(DescuentoGlobal)); } writer.WriteEndElement(); } #region TaxTotal int vprimeravez = 0; writer.WriteStartElement("cac:TaxTotal"); { foreach (var taxTotal in TaxTotals) { #region TaxAmount if (vprimeravez == 0) { writer.WriteStartElement("cbc:TaxAmount"); { writer.WriteAttributeString("currencyID", taxTotal.Moneda); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); vprimeravez = 1; } #endregion TaxAmount #region TaxSubtotal if (taxTotal.TaxableAmount.Value > 0) { writer.WriteStartElement("cac:TaxSubtotal"); { #region TaxableAmount writer.WriteStartElement("cbc:TaxableAmount"); { writer.WriteAttributeString("currencyID", taxTotal.Moneda); writer.WriteString(taxTotal.TaxableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion TaxableAmount #region TaxAmount writer.WriteStartElement("cbc:TaxAmount"); { writer.WriteAttributeString("currencyID", taxTotal.Moneda); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion TaxAmount #region TaxCategory writer.WriteStartElement("cac:TaxCategory"); { #region ID writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", Sunat.iso5305); writer.WriteAttributeString("schemeName", Sunat.taxCategory); writer.WriteAttributeString("schemeAgencyName", Sunat.unece); writer.WriteString(taxTotal.TaxableAmount.CurrencyId); } writer.WriteEndElement(); #endregion ID #region TaxScheme writer.WriteStartElement("cac:TaxScheme"); { writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", Sunat.iso5153); writer.WriteAttributeString("schemeAgencyID", "6"); writer.WriteString(taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); } writer.WriteEndElement(); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); } writer.WriteEndElement(); #endregion TaxScheme } writer.WriteEndElement(); #endregion TaxCategory } writer.WriteEndElement(); } #endregion TaxSubtotal } } writer.WriteEndElement(); #endregion TaxTotal #endregion pagina3 // pagina 4 #region pagina4 #region LegalMonetaryTotal writer.WriteStartElement("cac:LegalMonetaryTotal"); { // if (LegalMonetaryTotal.LineExtensionAmount.Value > 0) // { // writer.WriteStartElement("cbc:LineExtensionAmount"); // { // writer.WriteAttributeString("currencyID", LegalMonetaryTotal.Moneda ); // writer.WriteValue(LegalMonetaryTotal.LineExtensionAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); // } // writer.WriteEndElement(); // } if (LegalMonetaryTotal.TaxInclusiveAmount.Value > 0) { writer.WriteStartElement("cbc:TaxInclusiveAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.Moneda); writer.WriteValue(LegalMonetaryTotal.TaxInclusiveAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } if (LegalMonetaryTotal.AllowanceTotalAmount.Value > 0) { writer.WriteStartElement("cbc:AllowanceTotalAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.Moneda); writer.WriteValue(LegalMonetaryTotal.AllowanceTotalAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } if (LegalMonetaryTotal.ChargeTotalAmount.Value > 0) { writer.WriteStartElement("cbc:ChargeTotalAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.Moneda); writer.WriteValue(LegalMonetaryTotal.ChargeTotalAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } if (LegalMonetaryTotal.PayableAmount.Value > 0) { writer.WriteStartElement("cbc:PayableAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.Moneda); writer.WriteValue(LegalMonetaryTotal.PayableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } } writer.WriteEndElement(); #endregion LegalMonetaryTotal foreach (var invoiceLine in InvoiceLines) { #region InvoiceLines writer.WriteStartElement("cac:InvoiceLine"); { writer.WriteElementString("cbc:ID", invoiceLine.Id.ToString()); #region InvoicedQuantity writer.WriteStartElement("cbc:InvoicedQuantity"); { writer.WriteAttributeString("unitCode", invoiceLine.InvoicedQuantity.UnitCode); writer.WriteAttributeString("unitCodeListID", Sunat.iso20); writer.WriteAttributeString("unitCodeListAgencyName", Sunat.unece); writer.WriteString(invoiceLine.InvoicedQuantity.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion InvoicedQuantity #region LineExtensionAmount writer.WriteStartElement("cbc:LineExtensionAmount"); { writer.WriteAttributeString("currencyID", invoiceLine.LineExtensionAmount.CurrencyId); writer.WriteString(invoiceLine.LineExtensionAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion LineExtensionAmount #region PricingReference writer.WriteStartElement("cac:PricingReference"); { #region AlternativeConditionPrice foreach (var item in invoiceLine.PricingReference.AlternativeConditionPrices) { writer.WriteStartElement("cac:AlternativeConditionPrice"); { #region PriceAmount writer.WriteStartElement("cbc:PriceAmount"); { writer.WriteAttributeString("currencyID", item.PriceAmount.CurrencyId); writer.WriteString(item.PriceAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion PriceAmount #region PriceTypeCode writer.WriteStartElement("cbc:PriceTypeCode"); { writer.WriteAttributeString("listName", Sunat.tipoPrecio); writer.WriteAttributeString("listAgencyName", Sunat.peSunat); writer.WriteAttributeString("listURI", Sunat.catalogos + "16"); writer.WriteString(item.PriceTypeCode); } writer.WriteEndElement(); #endregion PriceTypeCode } writer.WriteEndElement(); } #endregion AlternativeConditionPrice } writer.WriteEndElement(); #endregion PricingReference #region AllowanceCharge if (invoiceLine.AllowanceCharge.Amount.Value > 0) { writer.WriteStartElement("cac:AllowanceCharge"); { writer.WriteElementString("cbc:ChargeIndicator", invoiceLine.AllowanceCharge.ChargeIndicator.ToString().ToLower()); { #region Amount writer.WriteStartElement("cbc:Amount"); { writer.WriteAttributeString("currencyID", invoiceLine.AllowanceCharge.Amount.CurrencyId); writer.WriteValue(invoiceLine.AllowanceCharge.Amount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion Amount } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion AllowanceCharge // hasta aqui Ok #region TaxTotal foreach (var taxTotal in invoiceLine.TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); { #region TaxAmount writer.WriteStartElement("cbc:TaxAmount"); { writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion TaxAmount #region TaxSubtotal writer.WriteStartElement("cac:TaxSubtotal"); { #region TaxableAmount if (!string.IsNullOrEmpty(taxTotal.TaxableAmount.CurrencyId)) { writer.WriteStartElement("cbc:TaxableAmount"); { writer.WriteAttributeString("currencyID", taxTotal.TaxableAmount.CurrencyId); writer.WriteString(taxTotal.TaxableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } #endregion TaxableAmount #region TaxAmount writer.WriteStartElement("cbc:TaxAmount"); { writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion TaxAmount #region TaxCategory writer.WriteStartElement("cac:TaxCategory"); { #region ID writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", Sunat.iso5305); writer.WriteAttributeString("schemeName", Sunat.taxCategory); writer.WriteAttributeString("schemeAgencyName", Sunat.unece); writer.WriteString("S"); } writer.WriteEndElement(); #endregion ID writer.WriteElementString("cbc:Percent", (taxTotal.TaxSubtotal.Percent.ToString(Formatos.FormatoNumerico, Formato))); #region TaxExemptionReasonCode writer.WriteStartElement("cbc:TaxExemptionReasonCode"); { writer.WriteAttributeString("listAgencyName", Sunat.peSunat); writer.WriteAttributeString("listName", Sunat.AfectacionIgv); writer.WriteAttributeString("listURI", Sunat.catalogos + "07"); writer.WriteString(taxTotal.TaxSubtotal.TaxCategory.TaxExemptionReasonCode); } writer.WriteEndElement(); #endregion TaxExemptionReasonCode #region TaxScheme writer.WriteStartElement("cac:TaxScheme"); { #region ID writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", Sunat.iso5153); writer.WriteAttributeString("schemeName", Sunat.TaxIdentifier); writer.WriteAttributeString("schemeAgencyName", Sunat.unece); writer.WriteString(taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); } writer.WriteEndElement(); #endregion ID writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); } writer.WriteEndElement(); #endregion TaxScheme } writer.WriteEndElement(); #endregion TaxCategory } writer.WriteEndElement(); #endregion TaxSubtotal } writer.WriteEndElement(); } #endregion TaxTotal #region Item writer.WriteStartElement("cac:Item"); #region Description writer.WriteElementString("cbc:Description", invoiceLine.Item.Description); //writer.WriteStartElement("cbc:Description"); //writer.WriteCData(invoiceLine.Item.Description); //writer.WriteEndElement(); #endregion Description #region SellersItemIdentification writer.WriteStartElement("cac:SellersItemIdentification"); writer.WriteElementString("cbc:ID", invoiceLine.Item.SellersItemIdentification.Id); writer.WriteEndElement(); #endregion SellersItemIdentification #region AdditionalInformation if (!string.IsNullOrEmpty(invoiceLine.Item.AdditionalItemIdentification.Id)) { writer.WriteStartElement("cac:AdditionalItemIdentification"); writer.WriteElementString("cbc:ID", invoiceLine.Item.AdditionalItemIdentification.Id); writer.WriteEndElement(); } #endregion AdditionalInformation writer.WriteEndElement(); #endregion Item #region Price writer.WriteStartElement("cac:Price"); { writer.WriteStartElement("cbc:PriceAmount"); { writer.WriteAttributeString("currencyID", invoiceLine.Price.PriceAmount.CurrencyId); writer.WriteString(invoiceLine.Price.PriceAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion Price } writer.WriteEndElement(); #endregion InvoiceLines } #endregion pagina4 } }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsInvoice); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ccts", EspacioNombres.ccts); writer.WriteAttributeString("xmlns:ds", EspacioNombres.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:qdt", EspacioNombres.qdt); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:udt", EspacioNombres.udt); writer.WriteAttributeString("xmlns:xsi", EspacioNombres.xsi); #region UBLExtensions writer.WriteStartElement("ext:UBLExtensions"); #region UBLExtension var ext2 = UblExtensions.Extension2.ExtensionContent.AdditionalInformation; writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent writer.WriteStartElement("ext:ExtensionContent"); #region AdditionalInformation writer.WriteStartElement("sac:AdditionalInformation"); { #region AdditionalMonetaryTotal { foreach (var additionalMonetaryTotal in ext2.AdditionalMonetaryTotals) { writer.WriteStartElement("sac:AdditionalMonetaryTotal"); writer.WriteElementString("cbc:ID", additionalMonetaryTotal.Id); #region PayableAmount { writer.WriteStartElement("cbc:PayableAmount"); { writer.WriteAttributeString("currencyID", additionalMonetaryTotal.PayableAmount.CurrencyId); writer.WriteValue(additionalMonetaryTotal.PayableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } if (additionalMonetaryTotal.Percent > 0) { writer.WriteElementString("cbc:Percent", additionalMonetaryTotal.Percent.ToString(Formatos.FormatoNumerico)); } #endregion writer.WriteEndElement(); } } #endregion #region AdditionalProperty { foreach (var additionalProperty in ext2.AdditionalProperties) { writer.WriteStartElement("sac:AdditionalProperty"); writer.WriteElementString("cbc:ID", additionalProperty.Id); #region Value writer.WriteElementString("cbc:Value", additionalProperty.Value); #endregion writer.WriteEndElement(); } } #endregion #region SUNATEmbededDespatchAdvice // Para el caso de Factura-Guia. if (!string.IsNullOrEmpty(ext2.SunatEmbededDespatchAdvice.DeliveryAddress.Id)) { writer.WriteStartElement("sac:SUNATEmbededDespatchAdvice"); { #region DeliveryAddress writer.WriteStartElement("cac:DeliveryAddress"); { writer.WriteElementString("cbc:ID", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.Id); writer.WriteElementString("cbc:StreetName", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.StreetName); if (!string.IsNullOrEmpty(ext2.SunatEmbededDespatchAdvice.DeliveryAddress.CitySubdivisionName)) { writer.WriteElementString("cbc:CitySubdivisionName", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.CitySubdivisionName); } writer.WriteElementString("cbc:CityName", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.CityName); writer.WriteElementString("cbc:CountrySubentity", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.CountrySubentity); writer.WriteElementString("cbc:District", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.District); writer.WriteStartElement("cac:Country"); { writer.WriteElementString("cbc:IdentificationCode", ext2.SunatEmbededDespatchAdvice.DeliveryAddress.Country.IdentificationCode); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region OriginAddress writer.WriteStartElement("cac:OriginAddress"); { writer.WriteElementString("cbc:ID", ext2.SunatEmbededDespatchAdvice.OriginAddress.Id); writer.WriteElementString("cbc:StreetName", ext2.SunatEmbededDespatchAdvice.OriginAddress.StreetName); if (!string.IsNullOrEmpty(ext2.SunatEmbededDespatchAdvice.OriginAddress.CitySubdivisionName)) { writer.WriteElementString("cbc:CitySubdivisionName", ext2.SunatEmbededDespatchAdvice.OriginAddress.CitySubdivisionName); } writer.WriteElementString("cbc:CityName", ext2.SunatEmbededDespatchAdvice.OriginAddress.CityName); writer.WriteElementString("cbc:CountrySubentity", ext2.SunatEmbededDespatchAdvice.OriginAddress.CountrySubentity); writer.WriteElementString("cbc:District", ext2.SunatEmbededDespatchAdvice.OriginAddress.District); writer.WriteStartElement("cac:Country"); { writer.WriteElementString("cbc:IdentificationCode", ext2.SunatEmbededDespatchAdvice.OriginAddress.Country.IdentificationCode); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region SUNATCarrierParty writer.WriteStartElement("sac:SUNATCarrierParty"); { writer.WriteElementString("cbc:CustomerAssignedAccountID", ext2.SunatEmbededDespatchAdvice.SunatCarrierParty.CustomerAssignedAccountId); writer.WriteElementString("cbc:AdditionalAccountID", ext2.SunatEmbededDespatchAdvice.SunatCarrierParty.AdditionalAccountId); writer.WriteStartElement("cac:Party"); { writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteElementString("cbc:RegistrationName", ext2.SunatEmbededDespatchAdvice.SunatCarrierParty.Party.PartyLegalEntity.RegistrationName); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region DriverParty writer.WriteStartElement("sac:DriverParty"); { writer.WriteStartElement("cac:Party"); { writer.WriteStartElement("cac:PartyIdentification"); { writer.WriteElementString("cbc:ID", ext2.SunatEmbededDespatchAdvice.DriverParty.PartyIdentification.Id.Value); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region SUNATRoadTransport writer.WriteStartElement("sac:SUNATRoadTransport"); { writer.WriteElementString("cbc:LicensePlateID", ext2.SunatEmbededDespatchAdvice.SunatRoadTransport.LicensePlateId); writer.WriteElementString("cbc:TransportAuthorizationCode", ext2.SunatEmbededDespatchAdvice.SunatRoadTransport.TransportAuthorizationCode); writer.WriteElementString("cbc:BrandName", ext2.SunatEmbededDespatchAdvice.SunatRoadTransport.BrandName); } writer.WriteEndElement(); #endregion writer.WriteElementString("cbc:TransportModeCode", ext2.SunatEmbededDespatchAdvice.TransportModeCode); #region GrossWeightMeasure writer.WriteStartElement("cbc:GrossWeightMeasure"); { writer.WriteAttributeString("unitCode", ext2.SunatEmbededDespatchAdvice.GrossWeightMeasure.UnitCode); writer.WriteValue(ext2.SunatEmbededDespatchAdvice.GrossWeightMeasure.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion } writer.WriteEndElement(); } #endregion #region SUNATCosts if (!string.IsNullOrEmpty(ext2.SunatCosts.RoadTransport.LicensePlateId)) { writer.WriteStartElement("sac:SUNATCosts"); { writer.WriteStartElement("cac:RoadTransport"); { writer.WriteElementString("cbc:LicensePlateID", ext2.SunatCosts.RoadTransport.LicensePlateId); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion #region SUNATTransaction if (!string.IsNullOrEmpty(ext2.SunatTransaction.Id) && string.IsNullOrEmpty(ext2.SunatCosts.RoadTransport.LicensePlateId)) { writer.WriteStartElement("sac:SUNATTransaction"); { writer.WriteElementString("cbc:ID", ext2.SunatTransaction.Id); } writer.WriteEndElement(); } #endregion } writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region UBLExtension writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent writer.WriteStartElement("ext:ExtensionContent"); // En esta zona va el certificado digital. writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteElementString("cbc:UBLVersionID", UblVersionId); writer.WriteElementString("cbc:CustomizationID", CustomizationId); writer.WriteElementString("cbc:ID", Id); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString("yyyy-MM-dd")); writer.WriteElementString("cbc:InvoiceTypeCode", InvoiceTypeCode); writer.WriteElementString("cbc:DocumentCurrencyCode", DocumentCurrencyCode); #region DespatchDocumentReferences foreach (var reference in DespatchDocumentReferences) { writer.WriteStartElement("cac:DespatchDocumentReference"); { writer.WriteElementString("cbc:ID", reference.Id); writer.WriteElementString("cbc:DocumentTypeCode", reference.DocumentTypeCode); } writer.WriteEndElement(); } #endregion #region Signature writer.WriteStartElement("cac:Signature"); writer.WriteElementString("cbc:ID", Signature.Id); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); //writer.WriteStartElement("cbc:Name"); //writer.WriteCData(Signature.SignatoryParty.PartyName.Name); //writer.WriteEndElement(); writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); writer.WriteStartElement("cac:ExternalReference"); writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.Uri.Trim()); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region AccountingSupplierParty writer.WriteStartElement("cac:AccountingSupplierParty"); writer.WriteElementString("cbc:CustomerAssignedAccountID", AccountingSupplierParty.CustomerAssignedAccountId); writer.WriteElementString("cbc:AdditionalAccountID", AccountingSupplierParty.AdditionalAccountId); #region Party writer.WriteStartElement("cac:Party"); #region PartyName writer.WriteStartElement("cac:PartyName"); writer.WriteStartElement("cbc:Name"); writer.WriteCData(AccountingSupplierParty.Party.PartyName.Name); writer.WriteEndElement(); writer.WriteEndElement(); #endregion #region PostalAddress writer.WriteStartElement("cac:PostalAddress"); writer.WriteElementString("cbc:ID", AccountingSupplierParty.Party.PostalAddress.Id); writer.WriteElementString("cbc:StreetName", AccountingSupplierParty.Party.PostalAddress.StreetName); if (!string.IsNullOrEmpty(AccountingSupplierParty.Party.PostalAddress.CitySubdivisionName)) { writer.WriteElementString("cbc:CitySubdivisionName", AccountingSupplierParty.Party.PostalAddress.CitySubdivisionName); } writer.WriteElementString("cbc:CityName", AccountingSupplierParty.Party.PostalAddress.CityName); writer.WriteElementString("cbc:CountrySubentity", AccountingSupplierParty.Party.PostalAddress.CountrySubentity); writer.WriteElementString("cbc:District", AccountingSupplierParty.Party.PostalAddress.District); #region Country writer.WriteStartElement("cac:Country"); writer.WriteElementString("cbc:IdentificationCode", AccountingSupplierParty.Party.PostalAddress.Country.IdentificationCode); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingSupplierParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region AccountingCustomerParty writer.WriteStartElement("cac:AccountingCustomerParty"); writer.WriteElementString("cbc:CustomerAssignedAccountID", AccountingCustomerParty.CustomerAssignedAccountId); writer.WriteElementString("cbc:AdditionalAccountID", AccountingCustomerParty.AdditionalAccountId); #region Party writer.WriteStartElement("cac:Party"); #region cbc:PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingCustomerParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region PrepaidPayment if (PrepaidPayment != null) { writer.WriteStartElement("cac:PrepaidPayment"); { writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", PrepaidPayment.Id.SchemeId); writer.WriteValue(PrepaidPayment.Id.Value); } writer.WriteEndElement(); writer.WriteStartElement("cbc:PaidAmount"); { writer.WriteAttributeString("currencyID", PrepaidPayment.PaidAmount.CurrencyId); writer.WriteValue(PrepaidPayment.PaidAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); writer.WriteStartElement("cbc:InstructionID"); { writer.WriteAttributeString("schemeID", "6"); writer.WriteValue(PrepaidPayment.InstructionId); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion #region TaxTotal foreach (var taxTotal in TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxSubtotal { writer.WriteStartElement("cac:TaxSubtotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxCategory { writer.WriteStartElement("cac:TaxCategory"); #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); writer.WriteElementString("cbc:ID", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion #region LegalMonetaryTotal writer.WriteStartElement("cac:LegalMonetaryTotal"); { if (LegalMonetaryTotal.AllowanceTotalAmount.Value > 0) { writer.WriteStartElement("cbc:AllowanceTotalAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.AllowanceTotalAmount.CurrencyId); writer.WriteValue(LegalMonetaryTotal.AllowanceTotalAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } if (LegalMonetaryTotal.PrepaidAmount.Value > 0) { writer.WriteStartElement("cbc:PrepaidAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.PrepaidAmount.CurrencyId); writer.WriteValue(LegalMonetaryTotal.PrepaidAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } writer.WriteStartElement("cbc:PayableAmount"); { writer.WriteAttributeString("currencyID", LegalMonetaryTotal.PayableAmount.CurrencyId); writer.WriteValue(LegalMonetaryTotal.PayableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region InvoiceLines foreach (var invoiceLine in InvoiceLines) { writer.WriteStartElement("cac:InvoiceLine"); writer.WriteElementString("cbc:ID", invoiceLine.Id.ToString()); #region InvoicedQuantity writer.WriteStartElement("cbc:InvoicedQuantity"); writer.WriteAttributeString("unitCode", invoiceLine.InvoicedQuantity.UnitCode); writer.WriteValue(invoiceLine.InvoicedQuantity.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #endregion #region LineExtensionAmount writer.WriteStartElement("cbc:LineExtensionAmount"); writer.WriteAttributeString("currencyID", invoiceLine.LineExtensionAmount.CurrencyId); writer.WriteValue(invoiceLine.LineExtensionAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #endregion #region PricingReference writer.WriteStartElement("cac:PricingReference"); #region AlternativeConditionPrice foreach (var item in invoiceLine.PricingReference.AlternativeConditionPrices) { writer.WriteStartElement("cac:AlternativeConditionPrice"); #region PriceAmount writer.WriteStartElement("cbc:PriceAmount"); writer.WriteAttributeString("currencyID", item.PriceAmount.CurrencyId); writer.WriteValue(item.PriceAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #endregion writer.WriteElementString("cbc:PriceTypeCode", item.PriceTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); #endregion #region AllowanceCharge if (invoiceLine.AllowanceCharge.Amount.Value > 0) { writer.WriteStartElement("cac:AllowanceCharge"); writer.WriteElementString("cbc:ChargeIndicator", invoiceLine.AllowanceCharge.ChargeIndicator.ToString().ToLower()); #region Amount writer.WriteStartElement("cbc:Amount"); writer.WriteAttributeString("currencyID", invoiceLine.AllowanceCharge.Amount.CurrencyId); writer.WriteValue(invoiceLine.AllowanceCharge.Amount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #endregion writer.WriteEndElement(); } #endregion #region TaxTotal { foreach (var taxTotal in invoiceLine.TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxSubtotal writer.WriteStartElement("cac:TaxSubtotal"); #region TaxableAmount if (!string.IsNullOrEmpty(taxTotal.TaxableAmount.CurrencyId)) { writer.WriteStartElement("cbc:TaxableAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxableAmount.CurrencyId); writer.WriteString(taxTotal.TaxableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); } #endregion writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); if (taxTotal.TaxSubtotal.Percent > 0) { writer.WriteElementString("cbc:Percent", taxTotal.TaxSubtotal.Percent.ToString(Formatos.FormatoNumerico, Formato)); } #region TaxCategory writer.WriteStartElement("cac:TaxCategory"); //writer.WriteElementString("cbc:ID", invoiceLine.TaxTotal.TaxSubtotal.TaxCategory.ID); writer.WriteElementString("cbc:TaxExemptionReasonCode", taxTotal.TaxSubtotal.TaxCategory.TaxExemptionReasonCode); if (!string.IsNullOrEmpty(taxTotal.TaxSubtotal.TaxCategory.TierRange)) { writer.WriteElementString("cbc:TierRange", taxTotal.TaxSubtotal.TaxCategory.TierRange); } #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); writer.WriteElementString("cbc:ID", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); } } #endregion #region Item writer.WriteStartElement("cac:Item"); #region Description writer.WriteElementString("cbc:Description", invoiceLine.Item.Description); //writer.WriteStartElement("cbc:Description"); //writer.WriteCData(invoiceLine.Item.Description); //writer.WriteEndElement(); #endregion #region SellersItemIdentification writer.WriteStartElement("cac:SellersItemIdentification"); writer.WriteElementString("cbc:ID", invoiceLine.Item.SellersItemIdentification.Id); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region Price writer.WriteStartElement("cac:Price"); writer.WriteStartElement("cbc:PriceAmount"); writer.WriteAttributeString("currencyID", invoiceLine.Price.PriceAmount.CurrencyId); writer.WriteString(invoiceLine.Price.PriceAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); } #endregion }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsCreditNote); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ccts", EspacioNombres.ccts); writer.WriteAttributeString("xmlns:ds", EspacioNombres.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:qdt", EspacioNombres.qdt); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:udt", EspacioNombres.udt); writer.WriteAttributeString("xmlns:xsi", EspacioNombres.xsi); #region UBLExtensions { writer.WriteStartElement("ext:UBLExtensions"); #region UBLExtension { var ext2 = UBLExtensions.Extension2.ExtensionContent.AdditionalInformation; writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent { writer.WriteStartElement("ext:ExtensionContent"); #region AdditionalInformation { if (ext2.AdditionalMonetaryTotals.Count > 0) { writer.WriteStartElement("sac:AdditionalInformation"); } #region AdditionalMonetaryTotal { foreach (var additionalMonetaryTotal in ext2.AdditionalMonetaryTotals) { writer.WriteStartElement("sac:AdditionalMonetaryTotal"); writer.WriteElementString("cbc:ID", additionalMonetaryTotal.ID); #region PayableAmount { writer.WriteStartElement("cbc:PayableAmount"); writer.WriteAttributeString("currencyID", additionalMonetaryTotal.PayableAmount.currencyID); writer.WriteValue(additionalMonetaryTotal.PayableAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } } #endregion #region AdditionalProperty { foreach (var additionalProperty in ext2.AdditionalProperties) { writer.WriteStartElement("sac:AdditionalProperty"); writer.WriteElementString("cbc:ID", additionalProperty.ID.ToString()); #region Value writer.WriteElementString("cbc:Value", additionalProperty.Value); #endregion writer.WriteEndElement(); } } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion #region UBLExtension { writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent { writer.WriteStartElement("ext:ExtensionContent"); // En esta zona va el certificado digital. writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteElementString("cbc:UBLVersionID", UBLVersionID); writer.WriteElementString("cbc:CustomizationID", CustomizationID); writer.WriteElementString("cbc:ID", ID); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString("yyyy-MM-dd")); writer.WriteElementString("cbc:DocumentCurrencyCode", DocumentCurrencyCode); #region DiscrepancyResponse foreach (var discrepancy in DiscrepancyResponses) { writer.WriteStartElement("cac:DiscrepancyResponse"); { writer.WriteElementString("cbc:ReferenceID", discrepancy.ReferenceID); writer.WriteElementString("cbc:ResponseCode", discrepancy.ResponseCode); writer.WriteElementString("cbc:Description", discrepancy.Description); } writer.WriteEndElement(); } #endregion #region BillingReference foreach (var item in BillingReferences) { writer.WriteStartElement("cac:BillingReference"); { writer.WriteStartElement("cac:InvoiceDocumentReference"); { writer.WriteElementString("cbc:ID", item.InvoiceDocumentReference.ID); writer.WriteElementString("cbc:DocumentTypeCode", item.InvoiceDocumentReference.DocumentTypeCode); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion #region DespatchDocumentReference foreach (var item in DespatchDocumentReferences) { writer.WriteStartElement("cac:DespatchDocumentReference"); { writer.WriteElementString("cbc:ID", item.ID); writer.WriteElementString("cbc:DocumentTypeCode", item.DocumentTypeCode); } writer.WriteEndElement(); } #endregion #region AdditionalDocumentReference foreach (var item in AdditionalDocumentReferences) { writer.WriteStartElement("cac:AdditionalDocumentReference"); { writer.WriteElementString("cbc:ID", item.ID); writer.WriteElementString("cbc:DocumentTypeCode", item.DocumentTypeCode); } writer.WriteEndElement(); } #endregion #region Signature writer.WriteStartElement("cac:Signature"); writer.WriteElementString("cbc:ID", Signature.ID); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.ID.value); writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); //writer.WriteStartElement("cbc:Name"); //writer.WriteCData(Signature.SignatoryParty.PartyName.Name); //writer.WriteEndElement(); writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); writer.WriteStartElement("cac:ExternalReference"); writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.URI.Trim()); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region AccountingSupplierParty writer.WriteStartElement("cac:AccountingSupplierParty"); writer.WriteElementString("cbc:CustomerAssignedAccountID", AccountingSupplierParty.CustomerAssignedAccountID); writer.WriteElementString("cbc:AdditionalAccountID", AccountingSupplierParty.AdditionalAccountID.ToString()); #region Party writer.WriteStartElement("cac:Party"); #region PartyName writer.WriteStartElement("cac:PartyName"); writer.WriteStartElement("cbc:Name"); writer.WriteCData(AccountingSupplierParty.Party.PartyName.Name); writer.WriteEndElement(); writer.WriteEndElement(); #endregion #region PostalAddress writer.WriteStartElement("cac:PostalAddress"); writer.WriteElementString("cbc:ID", AccountingSupplierParty.Party.PostalAddress.ID); writer.WriteElementString("cbc:StreetName", AccountingSupplierParty.Party.PostalAddress.StreetName); writer.WriteElementString("cbc:CitySubdivisionName", AccountingSupplierParty.Party.PostalAddress.CitySubdivisionName); writer.WriteElementString("cbc:CityName", AccountingSupplierParty.Party.PostalAddress.CityName); writer.WriteElementString("cbc:CountrySubentity", AccountingSupplierParty.Party.PostalAddress.CountrySubentity); writer.WriteElementString("cbc:District", AccountingSupplierParty.Party.PostalAddress.District); #region Country writer.WriteStartElement("cac:Country"); writer.WriteElementString("cbc:IdentificationCode", AccountingSupplierParty.Party.PostalAddress.Country.IdentificationCode); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingSupplierParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region AccountingCustomerParty writer.WriteStartElement("cac:AccountingCustomerParty"); writer.WriteElementString("cbc:CustomerAssignedAccountID", AccountingCustomerParty.CustomerAssignedAccountID); writer.WriteElementString("cbc:AdditionalAccountID", AccountingCustomerParty.AdditionalAccountID.ToString()); #region Party writer.WriteStartElement("cac:Party"); #region cbc:PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingCustomerParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region TaxTotal foreach (var taxTotal in TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.currencyID); writer.WriteString(taxTotal.TaxAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); #region TaxSubtotal { writer.WriteStartElement("cac:TaxSubtotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.currencyID); writer.WriteString(taxTotal.TaxAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); #region TaxCategory { writer.WriteStartElement("cac:TaxCategory"); #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); writer.WriteElementString("cbc:ID", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.ID); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion #region LegalMonetaryTotal writer.WriteStartElement("cac:LegalMonetaryTotal"); writer.WriteStartElement("cbc:PayableAmount"); writer.WriteAttributeString("currencyID", LegalMonetaryTotal.PayableAmount.currencyID); writer.WriteValue(LegalMonetaryTotal.PayableAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); writer.WriteEndElement(); #endregion #region CreditNoteLines foreach (var creditNoteLine in CreditNoteLines) { writer.WriteStartElement("cac:CreditNoteLine"); writer.WriteElementString("cbc:ID", creditNoteLine.ID.ToString()); #region CreditedQuantity writer.WriteStartElement("cbc:CreditedQuantity"); { writer.WriteAttributeString("unitCode", creditNoteLine.CreditedQuantity.unitCode); writer.WriteValue(creditNoteLine.CreditedQuantity.Value.ToString(Constantes.FormatoNumerico)); } writer.WriteEndElement(); #endregion #region LineExtensionAmount writer.WriteStartElement("cbc:LineExtensionAmount"); { writer.WriteAttributeString("currencyID", creditNoteLine.LineExtensionAmount.currencyID); writer.WriteValue(creditNoteLine.LineExtensionAmount.value.ToString(Constantes.FormatoNumerico)); } writer.WriteEndElement(); #endregion #region PricingReference writer.WriteStartElement("cac:PricingReference"); #region AlternativeConditionPrice foreach (var item in creditNoteLine.PricingReference.AlternativeConditionPrices) { writer.WriteStartElement("cac:AlternativeConditionPrice"); #region PriceAmount writer.WriteStartElement("cbc:PriceAmount"); writer.WriteAttributeString("currencyID", item.PriceAmount.currencyID); writer.WriteValue(item.PriceAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); #endregion writer.WriteElementString("cbc:PriceTypeCode", item.PriceTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); #endregion #region AllowanceCharge if (creditNoteLine.AllowanceCharge.ChargeIndicator) { writer.WriteStartElement("cac:AllowanceCharge"); writer.WriteElementString("cbc:ChargeIndicator", creditNoteLine.AllowanceCharge.ChargeIndicator.ToString()); #region Amount writer.WriteStartElement("cbc:Amount"); writer.WriteAttributeString("currencyID", creditNoteLine.AllowanceCharge.Amount.currencyID); writer.WriteValue(creditNoteLine.AllowanceCharge.Amount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); #endregion writer.WriteEndElement(); } #endregion #region TaxTotal { foreach (var taxTotal in creditNoteLine.TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.currencyID); writer.WriteString(taxTotal.TaxAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); #region TaxSubtotal writer.WriteStartElement("cac:TaxSubtotal"); #region TaxableAmount if (!string.IsNullOrEmpty(taxTotal.TaxableAmount.currencyID)) { writer.WriteStartElement("cbc:TaxableAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxableAmount.currencyID); writer.WriteString(taxTotal.TaxableAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); } #endregion writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.currencyID); writer.WriteString(taxTotal.TaxAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); if (taxTotal.TaxSubtotal.Percent > 0) { writer.WriteElementString("cbc:Percent", taxTotal.TaxSubtotal.Percent.ToString(Constantes.FormatoNumerico)); } #region TaxCategory writer.WriteStartElement("cac:TaxCategory"); //writer.WriteElementString("cbc:ID", invoiceLine.TaxTotal.TaxSubtotal.TaxCategory.ID); writer.WriteElementString("cbc:TaxExemptionReasonCode", taxTotal.TaxSubtotal.TaxCategory.TaxExemptionReasonCode.ToString()); if (!string.IsNullOrEmpty(taxTotal.TaxSubtotal.TaxCategory.TierRange)) { writer.WriteElementString("cbc:TierRange", taxTotal.TaxSubtotal.TaxCategory.TierRange); } #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); writer.WriteElementString("cbc:ID", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.ID); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); } } #endregion #region Item writer.WriteStartElement("cac:Item"); #region Description writer.WriteElementString("cbc:Description", creditNoteLine.Item.Description); //writer.WriteStartElement("cbc:Description"); //writer.WriteCData(invoiceLine.Item.Description); //writer.WriteEndElement(); #endregion #region SellersItemIdentification writer.WriteStartElement("cac:SellersItemIdentification"); writer.WriteElementString("cbc:ID", creditNoteLine.Item.SellersItemIdentification.ID); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region Price writer.WriteStartElement("cac:Price"); writer.WriteStartElement("cbc:PriceAmount"); writer.WriteAttributeString("currencyID", creditNoteLine.Price.PriceAmount.currencyID); writer.WriteString(creditNoteLine.Price.PriceAmount.value.ToString(Constantes.FormatoNumerico)); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); } #endregion }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsDebitNote); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ccts", EspacioNombres.ccts); writer.WriteAttributeString("xmlns:ds", EspacioNombres.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:qdt", EspacioNombres.qdt); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:udt", EspacioNombres.udt); writer.WriteAttributeString("xmlns:xsi", EspacioNombres.xsi); var ext2 = UblExtensions.Extension2.ExtensionContent.AdditionalInformation; #region UBLExtensions { writer.WriteStartElement("ext:UBLExtensions"); #region UBLExtension { } #endregion UBLExtension #region UBLExtension { writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent { writer.WriteStartElement("ext:ExtensionContent"); // En esta zona va el certificado digital. writer.WriteEndElement(); } #endregion ExtensionContent writer.WriteEndElement(); } #endregion UBLExtension writer.WriteEndElement(); } #endregion UBLExtensions writer.WriteElementString("cbc:UBLVersionID", UblVersionId); writer.WriteElementString("cbc:CustomizationID", CustomizationId); writer.WriteElementString("cbc:ID", Id); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString("yyyy-MM-dd")); writer.WriteElementString("cbc:IssueTime", String.Format("{0:HH:mm:ss}", DateTime.Now)); writer.WriteStartElement("cbc:Note"); writer.WriteAttributeString("languageLocaleID", "1000"); //1000 Monto en letras writer.WriteValue(ext2.AdditionalProperties[0].Value); writer.WriteEndElement(); writer.WriteElementString("cbc:DocumentCurrencyCode", DocumentCurrencyCode); #region DiscrepancyResponse foreach (var discrepancy in DiscrepancyResponses) { writer.WriteStartElement("cac:DiscrepancyResponse"); { writer.WriteElementString("cbc:ReferenceID", discrepancy.ReferenceId); writer.WriteElementString("cbc:ResponseCode", discrepancy.ResponseCode); writer.WriteElementString("cbc:Description", discrepancy.Description); } writer.WriteEndElement(); } #endregion DiscrepancyResponse #region BillingReference foreach (var item in BillingReferences) { writer.WriteStartElement("cac:BillingReference"); { writer.WriteStartElement("cac:InvoiceDocumentReference"); { writer.WriteElementString("cbc:ID", item.InvoiceDocumentReference.Id); writer.WriteElementString("cbc:DocumentTypeCode", item.InvoiceDocumentReference.DocumentTypeCode); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion BillingReference #region DespatchDocumentReference foreach (var item in DespatchDocumentReferences) { writer.WriteStartElement("cac:DespatchDocumentReference"); { writer.WriteElementString("cbc:ID", item.Id); writer.WriteElementString("cbc:DocumentTypeCode", item.DocumentTypeCode); } writer.WriteEndElement(); } #endregion DespatchDocumentReference #region AdditionalDocumentReference foreach (var item in AdditionalDocumentReferences) { writer.WriteStartElement("cac:AdditionalDocumentReference"); { writer.WriteElementString("cbc:ID", item.Id); writer.WriteElementString("cbc:DocumentTypeCode", item.DocumentTypeCode); } writer.WriteEndElement(); } #endregion AdditionalDocumentReference #region Signature writer.WriteStartElement("cac:Signature"); writer.WriteElementString("cbc:ID", Signature.Id); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); //writer.WriteStartElement("cbc:Name"); //writer.WriteCData(Signature.SignatoryParty.PartyName.Name); //writer.WriteEndElement(); writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); writer.WriteEndElement(); #endregion PartyName writer.WriteEndElement(); #endregion SignatoryParty #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); writer.WriteStartElement("cac:ExternalReference"); writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.Uri.Trim()); writer.WriteEndElement(); writer.WriteEndElement(); #endregion DigitalSignatureAttachment writer.WriteEndElement(); #endregion Signature #region AccountingSupplierParty writer.WriteStartElement("cac:AccountingSupplierParty"); #region Party writer.WriteStartElement("cac:Party"); #region PartyIdentification writer.WriteStartElement("cac:PartyIdentification"); writer.WriteStartElement("cbc:ID"); writer.WriteAttributeString("schemeID", AccountingSupplierParty.AdditionalAccountId); //Codigo de identificacion de documento de contribuyente writer.WriteAttributeString("schemeName", PartyIdentification2.schemeName); writer.WriteAttributeString("schemeAgencyName", InvoiceTypeCode2.listAgencyName); writer.WriteAttributeString("schemeURI", PartyIdentification2.schemeURI); writer.WriteValue(AccountingSupplierParty.CustomerAssignedAccountId); writer.WriteEndElement(); writer.WriteEndElement(); #endregion PartyIdentification #region PartyName writer.WriteStartElement("cac:PartyName"); writer.WriteStartElement("cbc:Name"); writer.WriteCData(AccountingSupplierParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteEndElement(); #endregion #region PostalAddress /*writer.WriteStartElement("cac:PostalAddress"); * writer.WriteElementString("cbc:ID", AccountingSupplierParty.Party.PostalAddress.ID); * writer.WriteElementString("cbc:StreetName", AccountingSupplierParty.Party.PostalAddress.StreetName); * if (!string.IsNullOrEmpty(AccountingSupplierParty.Party.PostalAddress.CitySubdivisionName)) * writer.WriteElementString("cbc:CitySubdivisionName", AccountingSupplierParty.Party.PostalAddress.CitySubdivisionName); * writer.WriteElementString("cbc:CityName", AccountingSupplierParty.Party.PostalAddress.CityName); * writer.WriteElementString("cbc:CountrySubentity", AccountingSupplierParty.Party.PostalAddress.CountrySubentity); * writer.WriteElementString("cbc:District", AccountingSupplierParty.Party.PostalAddress.District); * #region Country * writer.WriteStartElement("cac:Country"); * writer.WriteElementString("cbc:IdentificationCode", * AccountingSupplierParty.Party.PostalAddress.Country.IdentificationCode); * writer.WriteEndElement(); #endregion * * writer.WriteEndElement();*/ #endregion #region PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingSupplierParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteStartElement("cac:RegistrationAddress"); writer.WriteElementString("cbc:AddressTypeCode", "0000"); //Código del domicilio fiscal sunat writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region AccountingCustomerParty writer.WriteStartElement("cac:AccountingCustomerParty"); #region Party writer.WriteStartElement("cac:Party"); #region PartyIdentification writer.WriteStartElement("cac:PartyIdentification"); writer.WriteStartElement("cbc:ID"); writer.WriteAttributeString("schemeID", AccountingCustomerParty.AdditionalAccountId); //Codigo de identificacion de documento de cliente writer.WriteAttributeString("schemeName", PartyIdentification2.schemeName); writer.WriteAttributeString("schemeAgencyName", InvoiceTypeCode2.listAgencyName); writer.WriteAttributeString("schemeURI", PartyIdentification2.schemeURI); writer.WriteValue(AccountingCustomerParty.CustomerAssignedAccountId); writer.WriteEndElement(); writer.WriteEndElement(); #endregion PartyIdentification #region cbc:PartyLegalEntity writer.WriteStartElement("cac:PartyLegalEntity"); writer.WriteStartElement("cbc:RegistrationName"); writer.WriteCData(AccountingCustomerParty.Party.PartyLegalEntity.RegistrationName); writer.WriteEndElement(); writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion #region TaxTotal foreach (var taxTotal in TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxSubtotal { writer.WriteStartElement("cac:TaxSubtotal"); writer.WriteStartElement("cbc:TaxableAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxableAmount.CurrencyId); writer.WriteString(taxTotal.TaxableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxCategory { writer.WriteStartElement("cac:TaxCategory"); #region ID writer.WriteStartElement("cbc:ID"); writer.WriteAttributeString("schemeID", "UN/ECE 5305"); writer.WriteAttributeString("schemeName", "Tax Category Identifier"); writer.WriteAttributeString("schemeAgencyName", "United Nations Economic Commission for Europe"); writer.WriteValue(taxTotal.TaxSubtotal.TaxCategory.Identifier); writer.WriteEndElement(); #endregion ID #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); writer.WriteStartElement("cbc:ID"); writer.WriteAttributeString("schemeID", "UN/ECE 5153"); writer.WriteAttributeString("schemeAgencyID", "6"); writer.WriteValue(taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); writer.WriteEndElement(); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion writer.WriteEndElement(); } #endregion #region RequestedMonetaryTotal writer.WriteStartElement("cac:RequestedMonetaryTotal"); writer.WriteStartElement("cbc:PayableAmount"); writer.WriteAttributeString("currencyID", RequestedMonetaryTotal.PayableAmount.CurrencyId); writer.WriteValue(RequestedMonetaryTotal.PayableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); writer.WriteEndElement(); #endregion RequestedMonetaryTotal #region DebitNoteLines foreach (var line in DebitNoteLines) { writer.WriteStartElement("cac:DebitNoteLine"); writer.WriteElementString("cbc:ID", line.Id.ToString()); #region DebitedQuantity writer.WriteStartElement("cbc:DebitedQuantity"); { //writer.WriteAttributeString("unitCode", line.DebitedQuantity.UnitCode); writer.WriteAttributeString("unitCode", line.DebitedQuantity.UnitCode); writer.WriteAttributeString("unitCodeListID", "UN/ECE rec 20"); writer.WriteAttributeString("unitCodeListAgencyName", "United Nations Economic Commission forEurope"); writer.WriteValue(line.DebitedQuantity.Value.ToString(Formatos.FormatoNumerico, Formato)); //writer.WriteValue(line.DebitedQuantity.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion DebitedQuantity #region LineExtensionAmount writer.WriteStartElement("cbc:LineExtensionAmount"); { writer.WriteAttributeString("currencyID", line.LineExtensionAmount.CurrencyId); writer.WriteValue(line.LineExtensionAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); #endregion LineExtensionAmount #region PricingReference writer.WriteStartElement("cac:PricingReference"); #region AlternativeConditionPrice foreach (var item in line.PricingReference.AlternativeConditionPrices) { writer.WriteStartElement("cac:AlternativeConditionPrice"); #region PriceAmount writer.WriteStartElement("cbc:PriceAmount"); writer.WriteAttributeString("currencyID", item.PriceAmount.CurrencyId); writer.WriteValue(item.PriceAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #endregion PriceAmount //writer.WriteElementString("cbc:PriceTypeCode", item.PriceTypeCode); writer.WriteStartElement("cbc:PriceTypeCode"); writer.WriteAttributeString("listName", "Tipo de Precio"); writer.WriteAttributeString("listAgencyName", "PE:SUNAT"); writer.WriteAttributeString("listURI", "urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16"); writer.WriteValue(item.PriceTypeCode); writer.WriteEndElement(); writer.WriteEndElement(); } #endregion AlternativeConditionPrice writer.WriteEndElement(); #endregion PricingReference #region AllowanceCharge if (line.AllowanceCharge.ChargeIndicator) { writer.WriteStartElement("cac:AllowanceCharge"); writer.WriteElementString("cbc:ChargeIndicator", line.AllowanceCharge.ChargeIndicator.ToString()); #region Amount writer.WriteStartElement("cbc:Amount"); writer.WriteAttributeString("currencyID", line.AllowanceCharge.Amount.CurrencyId); writer.WriteValue(line.AllowanceCharge.Amount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #endregion Amount writer.WriteEndElement(); } #endregion AllowanceCharge #region TaxTotal { foreach (var taxTotal in line.TaxTotals) { writer.WriteStartElement("cac:TaxTotal"); writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); #region TaxSubtotal writer.WriteStartElement("cac:TaxSubtotal"); #region TaxableAmount if (!string.IsNullOrEmpty(taxTotal.TaxableAmount.CurrencyId)) { writer.WriteStartElement("cbc:TaxableAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxableAmount.CurrencyId); writer.WriteString(taxTotal.TaxableAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); } #endregion TaxableAmount writer.WriteStartElement("cbc:TaxAmount"); writer.WriteAttributeString("currencyID", taxTotal.TaxSubtotal.TaxAmount.CurrencyId); writer.WriteString(taxTotal.TaxAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); if (taxTotal.TaxSubtotal.Percent > 0) { writer.WriteElementString("cbc:Percent", taxTotal.TaxSubtotal.Percent.ToString(Formatos.FormatoNumerico, Formato)); } #region TaxCategory writer.WriteStartElement("cac:TaxCategory"); //writer.WriteElementString("cbc:ID", invoiceLine.TaxTotal.TaxSubtotal.TaxCategory.ID); #region ID writer.WriteStartElement("cbc:ID"); writer.WriteAttributeString("schemeID", "UN/ECE 5305"); writer.WriteAttributeString("schemeName", "Tax Category Identifier"); writer.WriteAttributeString("schemeAgencyName", "United Nations Economic Commission for Europe"); writer.WriteValue(taxTotal.TaxSubtotal.TaxCategory.Identifier); writer.WriteEndElement(); #endregion ID writer.WriteElementString("cbc:Percent", ext2.AdditionalMonetaryTotals[1].Percent.ToString(Formatos.FormatoNumerico, Formato)); //writer.WriteElementString("cbc:TaxExemptionReasonCode", taxTotal.TaxSubtotal.TaxCategory.TaxExemptionReasonCode); writer.WriteStartElement("cbc:TaxExemptionReasonCode"); writer.WriteAttributeString("listAgencyName", "PE: SUNAT"); writer.WriteAttributeString("listName", "Afectacion del IGV"); writer.WriteAttributeString("listURI", "urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07"); writer.WriteValue(taxTotal.TaxSubtotal.TaxCategory.TaxExemptionReasonCode); writer.WriteEndElement(); if (!string.IsNullOrEmpty(taxTotal.TaxSubtotal.TaxCategory.TierRange)) { writer.WriteElementString("cbc:TierRange", taxTotal.TaxSubtotal.TaxCategory.TierRange); } #region TaxScheme { writer.WriteStartElement("cac:TaxScheme"); //writer.WriteElementString("cbc:ID", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); writer.WriteStartElement("cbc:ID"); writer.WriteAttributeString("schemeID", "UN/ECE 5153"); writer.WriteAttributeString("schemeAgencyID", "6"); writer.WriteValue(taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Id); writer.WriteEndElement(); writer.WriteElementString("cbc:Name", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.Name); writer.WriteElementString("cbc:TaxTypeCode", taxTotal.TaxSubtotal.TaxCategory.TaxScheme.TaxTypeCode); writer.WriteEndElement(); } #endregion TaxScheme writer.WriteEndElement(); #endregion TaxCategory writer.WriteEndElement(); #endregion TaxSubtotal writer.WriteEndElement(); } } #endregion TaxTotal #region Item writer.WriteStartElement("cac:Item"); #region Description writer.WriteElementString("cbc:Description", line.Item.Description); //writer.WriteStartElement("cbc:Description"); //writer.WriteCData(invoiceLine.Item.Description); //writer.WriteEndElement(); #endregion Description #region SellersItemIdentification writer.WriteStartElement("cac:SellersItemIdentification"); writer.WriteElementString("cbc:ID", line.Item.SellersItemIdentification.Id); writer.WriteEndElement(); #endregion SellersItemIdentification #region CommodityClassification if (line.ItemClassificationCode != null || line.ItemClassificationCode != "") { writer.WriteStartElement("cac:CommodityClassification"); writer.WriteStartElement("cbc:ItemClassificationCode"); writer.WriteAttributeString("listID", "UNSPSC"); writer.WriteAttributeString("listAgencyName", "GS1 US"); writer.WriteAttributeString("listName", "Item Classification"); writer.WriteValue(line.ItemClassificationCode);//82141601-SERVICIOS FOTOGRAFICOS, MONTAJE Y ENMARCADO 82141602 - MONTAJE DE EXPOSICION DE ARTICULOS writer.WriteEndElement(); writer.WriteEndElement(); } #endregion CommodityClassification writer.WriteEndElement(); #endregion Item #region Price writer.WriteStartElement("cac:Price"); writer.WriteStartElement("cbc:PriceAmount"); writer.WriteAttributeString("currencyID", line.Price.PriceAmount.CurrencyId); writer.WriteString(line.Price.PriceAmount.Value.ToString(Formatos.FormatoNumerico, Formato)); writer.WriteEndElement(); writer.WriteEndElement(); #endregion Price writer.WriteEndElement(); } #endregion DebitNoteLines }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("xmlns", EspacioNombres.xmlnsDespatchAdvice); writer.WriteAttributeString("xmlns:cac", EspacioNombres.cac); writer.WriteAttributeString("xmlns:cbc", EspacioNombres.cbc); writer.WriteAttributeString("xmlns:ccts", EspacioNombres.ccts); writer.WriteAttributeString("xmlns:ds", EspacioNombres.ds); writer.WriteAttributeString("xmlns:ext", EspacioNombres.ext); writer.WriteAttributeString("xmlns:qdt", EspacioNombres.qdt); writer.WriteAttributeString("xmlns:sac", EspacioNombres.sac); writer.WriteAttributeString("xmlns:udt", EspacioNombres.udt); writer.WriteAttributeString("xmlns:xsi", EspacioNombres.xsi); #region UBLExtensions writer.WriteStartElement("ext:UBLExtensions"); #region UBLExtension writer.WriteStartElement("ext:UBLExtension"); #region ExtensionContent writer.WriteStartElement("ext:ExtensionContent"); // En esta zona va el certificado digital. writer.WriteEndElement(); #endregion ExtensionContent writer.WriteEndElement(); #endregion UBLExtension writer.WriteEndElement(); #endregion UBLExtensions writer.WriteElementString("cbc:UBLVersionID", UblVersionId); writer.WriteElementString("cbc:CustomizationID", CustomizationId); writer.WriteElementString("cbc:ID", Id); writer.WriteElementString("cbc:IssueDate", IssueDate.ToString(Formatos.FormatoFecha)); writer.WriteElementString("cbc:DespatchAdviceTypeCode", DespatchAdviceTypeCode); if (!string.IsNullOrEmpty(Note)) { writer.WriteElementString("cbc:Note", Note); } #region OrderReference if (!string.IsNullOrEmpty(OrderReference.Id)) { writer.WriteStartElement("cac:OrderReference"); { writer.WriteElementString("cbc:ID", OrderReference.Id); writer.WriteStartElement("cbc:OrderTypeCode"); { writer.WriteAttributeString("name", OrderReference.OrderTypeCode.Name); writer.WriteValue(OrderReference.OrderTypeCode.Value); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion OrderReference #region AdditionalDocumentReference if (!string.IsNullOrEmpty(AdditionalDocumentReference.Id)) { writer.WriteStartElement("cac:AdditionalDocumentReference"); { writer.WriteElementString("cbc:ID", AdditionalDocumentReference.Id); writer.WriteElementString("cbc:DocumentTypeCode", AdditionalDocumentReference.DocumentTypeCode); } writer.WriteEndElement(); } #endregion AdditionalDocumentReference #region Signature writer.WriteStartElement("cac:Signature"); { writer.WriteElementString("cbc:ID", Signature.Id); #region SignatoryParty writer.WriteStartElement("cac:SignatoryParty"); { writer.WriteStartElement("cac:PartyIdentification"); writer.WriteElementString("cbc:ID", Signature.SignatoryParty.PartyIdentification.Id.Value); } writer.WriteEndElement(); #region PartyName writer.WriteStartElement("cac:PartyName"); { writer.WriteElementString("cbc:Name", Signature.SignatoryParty.PartyName.Name); } writer.WriteEndElement(); #endregion PartyName writer.WriteEndElement(); #endregion SignatoryParty #region DigitalSignatureAttachment writer.WriteStartElement("cac:DigitalSignatureAttachment"); { writer.WriteStartElement("cac:ExternalReference"); { writer.WriteElementString("cbc:URI", Signature.DigitalSignatureAttachment.ExternalReference.Uri.Trim()); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion DigitalSignatureAttachment } writer.WriteEndElement(); #endregion Signature #region DespatchSupplierParty writer.WriteStartElement("cac:DespatchSupplierParty"); { writer.WriteStartElement("cbc:CustomerAssignedAccountID"); { writer.WriteAttributeString("schemeID", DespatchSupplierParty.AdditionalAccountId); writer.WriteValue(DespatchSupplierParty.CustomerAssignedAccountId); } writer.WriteEndElement(); writer.WriteStartElement("cac:Party"); { writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteElementString("cbc:RegistrationName", DespatchSupplierParty.Party.PartyLegalEntity.RegistrationName); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion DespatchSupplierParty #region DeliveryCustomerParty writer.WriteStartElement("cac:DeliveryCustomerParty"); { writer.WriteStartElement("cbc:CustomerAssignedAccountID"); { writer.WriteAttributeString("schemeID", DeliveryCustomerParty.AdditionalAccountId); writer.WriteValue(DeliveryCustomerParty.CustomerAssignedAccountId); } writer.WriteEndElement(); writer.WriteStartElement("cac:Party"); { writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteElementString("cbc:RegistrationName", DeliveryCustomerParty.Party.PartyLegalEntity.RegistrationName); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); #endregion DeliveryCustomerParty #region SellerSupplierParty if (!string.IsNullOrEmpty(SellerSupplierParty.AdditionalAccountId)) { writer.WriteStartElement("cac:SellerSupplierParty"); { writer.WriteStartElement("cbc:CustomerAssignedAccountID"); { writer.WriteAttributeString("schemeID", SellerSupplierParty.AdditionalAccountId); writer.WriteValue(SellerSupplierParty.CustomerAssignedAccountId); } writer.WriteEndElement(); writer.WriteStartElement("cac:Party"); { writer.WriteStartElement("cac:PartyLegalEntity"); { writer.WriteElementString("cbc:RegistrationName", SellerSupplierParty.Party.PartyLegalEntity.RegistrationName); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion SellerSupplierParty #region Shipment writer.WriteStartElement("cac:Shipment"); { writer.WriteElementString("cbc:HandlingCode", Shipment.HandlingCode); writer.WriteElementString("cbc:Information", Shipment.Information); writer.WriteElementString("cbc:SplitConsignmentIndicator", Shipment.SplitConsignmentIndicator.ToString().ToLower()); writer.WriteStartElement("cbc:GrossWeightMeasure"); { writer.WriteAttributeString("unitCode", Shipment.GrossWeightMeasure.UnitCode); writer.WriteValue(Shipment.GrossWeightMeasure.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); writer.WriteElementString("cbc:TotalTransportHandlingUnitQuantity", Shipment.TotalTransportHandlingUnitQuantity.ToString()); #region ShipmentStages foreach (var shipmentStage in Shipment.ShipmentStages) { writer.WriteElementString("cbc:ID", shipmentStage.Id.ToString()); writer.WriteElementString("cbc:TransportModeCode", shipmentStage.TransportModeCode); writer.WriteStartElement("cac:TransitPeriod"); { writer.WriteElementString("cbc:StartDate", shipmentStage.TransitPeriodStartPeriod.ToString(Formatos.FormatoFecha)); } writer.WriteEndElement(); if (!string.IsNullOrEmpty(shipmentStage.CarrierParty.PartyIdentification.Id.Value)) { writer.WriteStartElement("cac:CarrierParty"); { writer.WriteStartElement("cac:PartyIdentification"); { writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", shipmentStage.CarrierParty.PartyIdentification.Id.SchemeId); writer.WriteValue(shipmentStage.CarrierParty.PartyIdentification.Id.Value); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteElementString("cbc:RegistrationName", shipmentStage.CarrierParty.PartyLegalEntity.RegistrationName); } writer.WriteEndElement(); } writer.WriteStartElement("cac:TransportMeans"); { writer.WriteStartElement("cac:RoadTransport"); { writer.WriteElementString("cbc:LicensePlateID", shipmentStage.TransportMeans.LicensePlateId); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("cac:DriverPerson"); { writer.WriteStartElement("cbc:ID"); { writer.WriteAttributeString("schemeID", shipmentStage.DriverPerson.Id.SchemeId); writer.WriteValue(shipmentStage.DriverPerson.Id.Value); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion ShipmentStages #region DeliveryAddress writer.WriteStartElement("cac:DeliveryAddress"); { writer.WriteElementString("cbc:ID", Shipment.DeliveryAddress.Id); writer.WriteElementString("cbc:StreetName", Shipment.DeliveryAddress.StreetName); } writer.WriteEndElement(); #endregion DeliveryAddress #region TransportHandlingUnit writer.WriteStartElement("cac:TransportHandlingUnit"); { // Se repite la misma placa del primer vehiculo writer.WriteElementString("cbc:ID", Shipment.ShipmentStages.First().TransportMeans.LicensePlateId); foreach (var transportEquipment in Shipment.TransportHandlingUnit.TransportEquipments) { if (string.IsNullOrEmpty(transportEquipment.Id)) { continue; } writer.WriteStartElement("cac:TransportEquipment"); { writer.WriteElementString("cbc:ID", transportEquipment.Id); } writer.WriteEndElement(); } } writer.WriteEndElement(); #endregion TransportHandlingUnit #region OriginAddress writer.WriteStartElement("cac:OriginAddress"); { writer.WriteElementString("cbc:ID", Shipment.OriginAddress.Id); writer.WriteElementString("cbc:StreetName", Shipment.OriginAddress.StreetName); } writer.WriteEndElement(); #endregion OriginAddress #region FirstArrivalPortLocation if (!string.IsNullOrEmpty(Shipment.FirstArrivalPortLocationId)) { writer.WriteStartElement("cac:FirstArrivalPortLocation"); { writer.WriteElementString("cbc:ID", Shipment.FirstArrivalPortLocationId); } writer.WriteEndElement(); } #endregion FirstArrivalPortLocation } writer.WriteEndElement(); #endregion Shipment #region DespatchLine foreach (var despatchLine in DespatchLines) { writer.WriteStartElement("cac:DespatchLine"); { writer.WriteElementString("cbc:ID", despatchLine.Id.ToString()); writer.WriteStartElement("cbc:DeliveredQuantity"); { writer.WriteAttributeString("unitCode", despatchLine.DeliveredQuantity.UnitCode); writer.WriteValue(despatchLine.DeliveredQuantity.Value.ToString(Formatos.FormatoNumerico, Formato)); } writer.WriteEndElement(); if (despatchLine.OrderLineReferenceId > 0) { writer.WriteStartElement("cac:OrderLineReference"); { writer.WriteElementString("cbc:LineID", despatchLine.OrderLineReferenceId.ToString()); } writer.WriteEndElement(); } writer.WriteStartElement("cac:Item"); { writer.WriteElementString("cbc:Description", despatchLine.Item.Description); writer.WriteStartElement("cac:SellersItemIdentification"); { writer.WriteElementString("cbc:ID", despatchLine.Item.SellersIdentificationId); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion DespatchLine }
private void Clear() { m_IssueDate = null; m_Duration = null; m_TermsOfPayment = null; m_MethodOfPayment = null; }
internal static IssueDate Set(object o) { if (o is DateTime) { IssueDate xIssueDate = new IssueDate(); xIssueDate.Date = (DateTime)o; return xIssueDate; } else { return null; } }
private void Clear() { m_IssueDate = null; m_TermsOfPayment = null; m_MethodOfPayment = null; m_PaymentDeadline = null; }