private void SetInvoiceLine(InvoiceLineType InvoiceLine) { _InvoiceLine = InvoiceLine; if (InvoiceLine != null) { txtUrunAdi.Text = InvoiceLine.Item != null ? InvoiceLine.Item.Name.Value : ""; txtMarka.Text = InvoiceLine.Item.BrandName != null ? InvoiceLine.Item.BrandName.Value : ""; txtModel.Text = InvoiceLine.Item.ModelName != null ? InvoiceLine.Item.ModelName.Value : ""; txtAciklama.Text = InvoiceLine.Item.Description != null ? InvoiceLine.Item.Description.Value : ""; txtAliciKodu.Text = GetItemIdentification(InvoiceLine.Item.BuyersItemIdentification); txtUreticiKodu.Text = GetItemIdentification(InvoiceLine.Item.ManufacturersItemIdentification); txtSaticiKodu.Text = GetItemIdentification(InvoiceLine.Item.SellersItemIdentification); txtSatirNotu.Text = GetSatirNotu(InvoiceLine.Note); GetIskonto(InvoiceLine.AllowanceCharge); txtFiyat.Text = GetAmountType(InvoiceLine.Price.PriceAmount); txtMiktar.Text = InvoiceLine.InvoicedQuantity.Value.ToString(); txtBirim.Text = InvoiceLine.InvoicedQuantity.unitCode; GetKDV(InvoiceLine.TaxTotal); txtToplamTutar.Text = InvoiceLine.LineExtensionAmount.Value.ToString(); } }
private string XmlCreate() { InvoiceType res = new InvoiceType(); res .With(io => { #region Invoice io.UBLVersionID.Value = "2.1"; io.CustomizationID.Value = "TR1.2"; io.ProfileID.Value = "TEMELFATURA"; io.InvoiceTypeCode.Value = "SATIS"; io.ID.Value = "HKN0000000000001"; io.UUID.Value = Guid.NewGuid().ToString(); io.IssueDate.Value = DateTime.Now; io.IssueTime.Value = DateTime.Now; io.DocumentCurrencyCode.Value = "TRY"; io.LineCountNumeric.Value = 1; io.Note = new List <NoteType>(); NoteType oNewNote = new NoteType(); oNewNote.Value = "Test Dip Not"; io.Note.Add(oNewNote); //xslt base64 formatında gömme io.AdditionalDocumentReference = new List <DocumentReferenceType>(); DocumentReferenceType oNewAdd = new DocumentReferenceType(); oNewAdd.ID.Value = io.UUID.Value; oNewAdd.IssueDate.Value = DateTime.Now; oNewAdd.Attachment = new AttachmentType(); oNewAdd.Attachment .With(att => { att.EmbeddedDocumentBinaryObject = new EmbeddedDocumentBinaryObjectType(); att.EmbeddedDocumentBinaryObject.filename = io.UUID.Value + ".xslt"; att.EmbeddedDocumentBinaryObject.characterSetCode = "UTF-8"; att.EmbeddedDocumentBinaryObject.encodingCode = "Base64"; att.EmbeddedDocumentBinaryObject.mimeCode = "application/xml"; att.EmbeddedDocumentBinaryObject.Value = System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(System.Windows.Forms.Application.StartupPath + "/general.xslt")); }); io.AdditionalDocumentReference.Add(oNewAdd); //irsaliye bilgilerini ekleme io.DespatchDocumentReference = new List <DocumentReferenceType>(); DocumentReferenceType onewSip = new DocumentReferenceType(); onewSip.ID.Value = "A859552"; onewSip.IssueDate.Value = DateTime.Now; io.DespatchDocumentReference.Add(onewSip); //Sipariş bilgilerini ekleme io.OrderReference = new OrderReferenceType(); io.OrderReference.ID.Value = "32123"; io.OrderReference.IssueDate.Value = DateTime.Now; #endregion #region Signature //io.Signature = new List<SignatureType>(); //SignatureType oSig = new SignatureType(); //oSig // .With(sg => // { // sg.ID = new IDType(); // sg.ID.schemeID = "VKN_TCKN"; // sg.ID.Value = "1288331521"; // sg.SignatoryParty = new PartyType(); // sg.SignatoryParty // .With(sp => // { // sp.PartyIdentification = new List<PartyIdentificationType>(); // PartyIdentificationType oPartyIdent = new PartyIdentificationType(); // oPartyIdent.ID = new IDType(); // oPartyIdent.ID.schemeID = "VKN"; // oPartyIdent.ID.Value = oSirket.RegisterNumber; // sp.PartyIdentification.Add(oPartyIdent); // sp.PostalAddress = new AddressType(); // sp.PostalAddress // .With(pa => // { // pa.StreetName = new StreetNameType(); // pa.StreetName.Value = oSirket.Address; // //pa.BuildingNumber = new BuildingNumberType(); // //pa.BuildingNumber.Value = "21"; // pa.CitySubdivisionName = new CitySubdivisionNameType(); // pa.CitySubdivisionName.Value = oSirket.District; // pa.CityName = new CityNameType(); // pa.CityName.Value = oSirket.City; // //pa.PostalZone = new PostalZoneType(); // //pa.PostalZone.Value = "34100"; // pa.Country = new CountryType(); // pa.Country.Name.Value = oSirket.Country; // }); // }); // sg.DigitalSignatureAttachment = new AttachmentType(); // sg.DigitalSignatureAttachment.ExternalReference = new ExternalReferenceType(); // sg.DigitalSignatureAttachment.ExternalReference.URI.Value = "#Signature"; // }); //io.Signature.Add(oSig); #endregion #region AccountingSupplierParty io.AccountingSupplierParty = new SupplierPartyType(); io.AccountingSupplierParty .With(asp => { asp.Party = new PartyType(); asp.Party .With(pp => { pp.WebsiteURI = new WebsiteURIType(); pp.WebsiteURI.Value = "www.hakanuçar.com.tr"; pp.PartyIdentification = new List <PartyIdentificationType>(); pp.PartyIdentification.Add( new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "1234567801" } } ); //Firma diğer bilgiler pp.PartyIdentification.Add( new PartyIdentificationType { ID = new IDType { schemeID = "MERSISNO", Value = "4235234" } } ); pp.PartyName = new PartyNameType(); pp.PartyName.Name.Value = "Hakan UÇAR Bilgi İşlem"; pp.PostalAddress = new AddressType(); pp.PostalAddress .With(pa => { pa.ID = new IDType(); pa.ID.Value = "1234567801"; pa.StreetName = new StreetNameType(); pa.StreetName.Value = "KOZYATAĞI"; //pa.BuildingNumber = new BuildingNumberType(); //pa.BuildingNumber.Value = "21"; pa.CitySubdivisionName = new CitySubdivisionNameType(); pa.CitySubdivisionName.Value = "Beşiktaş"; pa.CityName = new CityNameType(); pa.CityName.Value = "İstanbul"; //pa.PostalZone = new PostalZoneType(); //pa.PostalZone.Value = "341000"; pa.Country = new CountryType(); pa.Country.Name.Value = "Türkiye"; }); pp.PartyTaxScheme = new PartyTaxSchemeType(); pp.PartyTaxScheme.TaxScheme = new TaxSchemeType(); pp.PartyTaxScheme.TaxScheme.Name = new NameType1(); pp.PartyTaxScheme.TaxScheme.Name.Value = "KOZYATAĞI"; pp.Contact = new ContactType(); pp.Contact .With(co => { co.Name = new NameType1(); co.Name.Value = "Hakan UÇAR"; co.Telephone = new TelephoneType(); co.Telephone.Value = "0592 558 5588"; co.Telefax = new TelefaxType(); co.Telefax.Value = "0592 558 5588"; co.ElectronicMail = new ElectronicMailType(); co.ElectronicMail.Value = "*****@*****.**"; }); }); }); #endregion #region AccountingCustomerParty io.AccountingCustomerParty = new CustomerPartyType(); string Senaryo = "0"; switch (Senaryo) { //Temel Fatura case "0": { #region customerinf io.AccountingCustomerParty .With(cus => { cus.Party = new PartyType(); cus.Party .With(cusp => { cusp.WebsiteURI = new WebsiteURIType(); cusp.WebsiteURI.Value = "www.hakanuçar.com.tr"; cusp.PartyIdentification = new List <PartyIdentificationType>(); PartyIdentificationType pi = new PartyIdentificationType(); pi.ID = new IDType(); pi.ID.schemeID = "VKN"; pi.ID.Value = "1234567801"; cusp.PartyIdentification.Add(pi); cusp.PartyName = new PartyNameType(); cusp.PartyName.Name.Value = "Hakan UÇAR bilgi İşlem"; cusp.PostalAddress = new AddressType(); cusp.PostalAddress .With(cupa => { cupa.ID = new IDType(); cupa.ID.Value = "1234567801"; cupa.StreetName = new StreetNameType(); cupa.StreetName.Value = "Kadıköy"; cupa.CityName = new CityNameType(); cupa.CityName.Value = "İstanbul"; cupa.CitySubdivisionName = new CitySubdivisionNameType(); cupa.CitySubdivisionName.Value = "Kadıköy"; cupa.Country = new CountryType(); cupa.Country.Name.Value = "Türkiye"; cupa.PostalZone = new PostalZoneType(); cupa.PostalZone.Value = "34000"; }); cusp.Contact = new ContactType(); cusp.Contact .With(cuc => { cuc.Name = new NameType1(); cuc.Name.Value = "Hakan UÇAR"; cuc.Telephone = new TelephoneType(); cuc.Telephone.Value = "0555 55 55 55"; cuc.Telefax = new TelefaxType(); cuc.Telefax.Value = "0555 55 55 55"; cuc.ElectronicMail = new ElectronicMailType(); cuc.ElectronicMail.Value = "*****@*****.**"; }); }); }); #endregion } break; //Ticari Fatura case "1": { #region customerinf io.AccountingCustomerParty .With(cus => { cus.Party = new PartyType(); cus.Party .With(cusp => { cusp.WebsiteURI = new WebsiteURIType(); cusp.WebsiteURI.Value = "www.hakanuçar.com.tr"; cusp.PartyIdentification = new List <PartyIdentificationType>(); PartyIdentificationType pi = new PartyIdentificationType(); pi.ID = new IDType(); pi.ID.schemeID = "VKN"; pi.ID.Value = "1234567801"; cusp.PartyIdentification.Add(pi); cusp.PartyName = new PartyNameType(); cusp.PartyName.Name.Value = "Hakan UÇAR bilgi İşlem"; cusp.PostalAddress = new AddressType(); cusp.PostalAddress .With(cupa => { cupa.ID = new IDType(); cupa.ID.Value = "1234567801"; cupa.StreetName = new StreetNameType(); cupa.StreetName.Value = "Kadıköy"; cupa.CityName = new CityNameType(); cupa.CityName.Value = "İstanbul"; cupa.CitySubdivisionName = new CitySubdivisionNameType(); cupa.CitySubdivisionName.Value = "Kadıköy"; cupa.Country = new CountryType(); cupa.Country.Name.Value = "Türkiye"; cupa.PostalZone = new PostalZoneType(); cupa.PostalZone.Value = "34000"; }); cusp.Contact = new ContactType(); cusp.Contact .With(cuc => { cuc.Name = new NameType1(); cuc.Name.Value = "Hakan UÇAR"; cuc.Telephone = new TelephoneType(); cuc.Telephone.Value = "0555 55 55 55"; cuc.Telefax = new TelefaxType(); cuc.Telefax.Value = "0555 55 55 55"; cuc.ElectronicMail = new ElectronicMailType(); cuc.ElectronicMail.Value = "*****@*****.**"; }); }); }); #endregion } break; //İhracat case "2": { #region ExportCustomerInfo io.AccountingCustomerParty .With(cus => { cus.Party = new PartyType(); cus.Party .With(cusp => { cusp.WebsiteURI = new WebsiteURIType(); cusp.WebsiteURI.Value = ""; cusp.PartyIdentification = new List <PartyIdentificationType>(); PartyIdentificationType pi = new PartyIdentificationType(); pi.ID = new IDType(); pi.ID.schemeID = "VKN"; pi.ID.Value = "1460415308"; cusp.PartyIdentification.Add(pi); cusp.PartyName = new PartyNameType(); cusp.PartyName.Name.Value = "Gümrük ve Ticaret Bakanlığı Gümrükler Genel Müdürlüğü- Bilgi İşlem Dairesi Başkanlığı"; cusp.PostalAddress = new AddressType(); cusp.PostalAddress .With(cupa => { //cupa.ID = new IDType(); //cupa.ID.Value = grd.DataTable.GetValue("Vergi No", grdRowIndex).ToString(); //cupa.StreetName = new StreetNameType(); //cupa.StreetName.Value = grd.DataTable.GetValue("Adres", grdRowIndex).ToString(); cupa.CityName = new CityNameType(); cupa.CityName.Value = "Ankara"; //cupa.CitySubdivisionName = new CitySubdivisionNameType(); //cupa.CitySubdivisionName.Value = grd.DataTable.GetValue("İlçe", grdRowIndex).ToString(); cupa.Country = new CountryType(); cupa.Country.Name.Value = "Türkiye"; }); cusp.PartyTaxScheme = new PartyTaxSchemeType(); cusp.PartyTaxScheme.TaxScheme = new TaxSchemeType(); cusp.PartyTaxScheme.TaxScheme.Name = new NameType1(); cusp.PartyTaxScheme.TaxScheme.Name.Value = "Ulus"; }); }); #endregion } break; //Yolcu Beraber Fatura case "3": { #region TaxFreeInfo //oInvoice.TaxFreeInfo = new TaxFreeInfo(); //oInvoice.TaxFreeInfo // .With(txfi => // { // txfi.TouristInfo = new TouristInfo(); //Turistin bilgilerinin girileceği alandır. // txfi.TouristInfo // .With(ti => // { // ti.Name = ""; //Bu alan turistin ad bilgisi girilir. // ti.SurName = ""; //Bu alan turistin soyad bilgisi girilir. // ti.PassportNo = ""; //Bu alan turistin pasaport numarası bilgisi girilir. // ti.PassportDate = DateTime.Now; //Bu alan turistin pasaport tarihi bilgisi girilir. // ti.CountryCode = ""; //Bu alan turistin ülke kodu bilgisi girilir.(örn:TR) // ti.FinancialAccountInfo = new FinancialAccountInfo(); //Bu alana turistin banka hesap bilgileri girilir. // ti.FinancialAccountInfo // .With(fa => // { // fa.BankName = ""; //Bu alan Banka Adı bilgisi girilir. // fa.BranchName = ""; //Bu alan Banka Şube Adı bilgisi girilir. // fa.CurrencyCode = ""; //Bu alan Para Birimi bilgisi girilir. // fa.ID = ""; //Bu alan Banka Hesap Numarası bilgisi girilir. // fa.PaymentNote = ""; //Bu alan Ödeme Notu bilgisi girilir. // }); // ti.AddressInfo = new AddressInfo(); //Bu alan turistin adres bilgileri girilir. // ti.AddressInfo // .With(ai => // { // ai.Address = ""; // ai.City = ""; // ai.Country = ""; // ai.District = ""; // ai.Fax = ""; // ai.Mail = ""; // ai.Phone = ""; // ai.PostalCode = ""; // ai.WebSite = ""; // }); // }); // txfi.TaxRepresentativeInfo = new TaxRepresentativeInfo(); //Aracı kurum bilgilerinin girileceği alandır. // txfi.TaxRepresentativeInfo // .With(tri => // { // tri.RegisterNumber = ""; //Bu alana Aracı Kurumun Vergi Kimlik Numarası girilir. // tri.Alias = ""; //Bu alana Aracı Kurumun Etiket bilgisi girilir. // tri.Address = new AddressInfo();//Bu alan turistin adres bilgileri girilir // tri.Address // .With(ai => // { // ai.Address = ""; // ai.City = ""; // ai.Country = ""; // ai.District = ""; // ai.Fax = ""; // ai.Mail = ""; // ai.Phone = ""; // ai.PostalCode = ""; // ai.WebSite = ""; // }); // }); // }); #endregion } break; //EArşiv Fatura case "4": { #region customerinf //oInvoice.CustomerInfo = new PartyInfo(); //oInvoice.CustomerInfo.Address = grd.DataTable.GetValue("Adres", grdRowIndex).ToString(); //oInvoice.CustomerInfo.City = grd.DataTable.GetValue("İl", grdRowIndex).ToString();//"İstanbul"; //oInvoice.CustomerInfo.Country = grd.DataTable.GetValue("Ülke", grdRowIndex).ToString();//"Türkiye"; //oInvoice.CustomerInfo.District = grd.DataTable.GetValue("İlçe", grdRowIndex).ToString();//"Ataşehir"; //oInvoice.CustomerInfo.Fax = grd.DataTable.GetValue("Fax", grdRowIndex).ToString();//"216 688 51 99"; //oInvoice.CustomerInfo.Mail = grd.DataTable.GetValue("Email", grdRowIndex).ToString();//"*****@*****.**"; //oInvoice.CustomerInfo.Name = grd.DataTable.GetValue("Muhatap Adı", grdRowIndex).ToString();//"NES Bilgi Teknolojileri"; //oInvoice.CustomerInfo.Phone = grd.DataTable.GetValue("Telefon", grdRowIndex).ToString();// "216 688 51 00"; //oInvoice.CustomerInfo.RegisterNumber = grd.DataTable.GetValue("Vergi No", grdRowIndex).ToString();// "1234567801"; //oInvoice.CustomerInfo.TaxOffice = grd.DataTable.GetValue("Vergi Dairesi", grdRowIndex).ToString();// "KOZYATAĞI"; //oInvoice.CustomerInfo.WebSite = grd.DataTable.GetValue("Web Sitesi", grdRowIndex).ToString();// "https://nesbilgi.com.tr/"; //oInvoice.CustomerInfo.ReceiverAlias = grd.DataTable.GetValue("Alıcı Posta Etiketi", grdRowIndex).ToString();// "urn:mail:[email protected]";/ #endregion } break; default: break; } #endregion if (Senaryo == "2") { #region BuyerCustomerParty io.BuyerCustomerParty = new CustomerPartyType(); io.BuyerCustomerParty .With(cus => { cus.Party = new PartyType(); cus.Party .With(cusp => { cusp.WebsiteURI = new WebsiteURIType(); cusp.WebsiteURI.Value = "www.hakanucar.com.tr"; cusp.PartyIdentification = new List <PartyIdentificationType>(); PartyIdentificationType pi = new PartyIdentificationType(); pi.ID = new IDType(); pi.ID.schemeID = "VKN"; pi.ID.Value = "1234567801"; cusp.PartyIdentification.Add(pi); cusp.PartyName = new PartyNameType(); cusp.PartyName.Name.Value = "Hakan UÇAR Bilişim"; cusp.PostalAddress = new AddressType(); cusp.PostalAddress .With(cupa => { cupa.ID = new IDType(); cupa.ID.Value = "1234567801"; cupa.StreetName = new StreetNameType(); cupa.StreetName.Value = "Meçhul bir yer"; cupa.CityName = new CityNameType(); cupa.CityName.Value = "İstanbul"; cupa.CitySubdivisionName = new CitySubdivisionNameType(); cupa.CitySubdivisionName.Value = "Beşiktaş"; cupa.Country = new CountryType(); cupa.Country.Name.Value = "Türkiye"; cupa.PostalZone = new PostalZoneType(); cupa.PostalZone.Value = "34000"; }); cusp.Contact = new ContactType(); cusp.Contact .With(cuc => { cuc.Name = new NameType1(); cuc.Name.Value = "Hakan UÇAR"; cuc.Telephone = new TelephoneType(); cuc.Telephone.Value = "555 55 55 55"; cuc.Telefax = new TelefaxType(); cuc.Telefax.Value = "555 55 55 55"; cuc.ElectronicMail = new ElectronicMailType(); cuc.ElectronicMail.Value = "*****@*****.**"; }); }); }); #endregion } #region PaymentTerms //Ödeme Koşulu io.PaymentTerms = new PaymentTermsType(); io.PaymentTerms.Note = new NoteType(); io.PaymentTerms.Note.Value = "60 gün vadeli"; #endregion #region TaxTotal //Vergiler io.TaxTotal = new List <TaxTotalType>(); io.TaxTotal .With(tt => { TaxTotalType ott = new TaxTotalType(); ott.TaxAmount = new TaxAmountType(); ott.TaxAmount.currencyID = "TRY"; ott.TaxAmount.Value = 180; ott.TaxSubtotal = new List <TaxSubtotalType>(); TaxSubtotalType oSubt = new TaxSubtotalType(); oSubt.TaxableAmount = new TaxableAmountType(); oSubt.TaxableAmount.currencyID = "TRY"; oSubt.TaxableAmount.Value = 1000; oSubt.TaxAmount = new TaxAmountType(); oSubt.TaxAmount.currencyID = "TRY"; oSubt.TaxAmount.Value = 180; oSubt.TaxCategory = new TaxCategoryType(); oSubt.TaxCategory.TaxScheme = new TaxSchemeType(); oSubt.TaxCategory.TaxScheme.TaxTypeCode = new TaxTypeCodeType(); oSubt.TaxCategory.TaxScheme.TaxTypeCode.Value = "0015"; ott.TaxSubtotal.Add(oSubt); tt.Add(ott); }); #endregion #region InvoiceLine io.InvoiceLine = new List <InvoiceLineType>(); InvoiceLineType il = new InvoiceLineType(); il .With(iol => { //Sıra No iol.ID = new IDType(); iol.ID.Value = "1"; //Kalem Tanımı iol.Item = new ItemType(); iol.Item.Name = new NameType1(); iol.Item.Name.Value = "HP X534 Yazıcı"; iol.Item.SellersItemIdentification = new ItemIdentificationType(); iol.Item.SellersItemIdentification.ID.Value = "KLM0012"; //Kalem Miktarı iol.InvoicedQuantity = new InvoicedQuantityType(); iol.InvoicedQuantity.unitCode = "C62"; iol.InvoicedQuantity.Value = 1; //Kalem Birim Fiyatı iol.Price = new PriceType(); iol.Price.PriceAmount = new PriceAmountType(); iol.Price.PriceAmount.currencyID = "TRY"; iol.Price.PriceAmount.Value = 1000; iol.Note = new List <NoteType>(); NoteType oKlmNote = new NoteType(); oNewNote.Value = "Test kalem notu"; iol.Note.Add(oKlmNote); //iskonto //iol.AllowanceCharge = new List<AllowanceChargeType>(); //iol.AllowanceCharge // .With(all => // { // AllowanceChargeType allc = new AllowanceChargeType(); // allc.ChargeIndicator = new ChargeIndicatorType(); // allc.ChargeIndicator.Value = false; // allc.MultiplierFactorNumeric = new MultiplierFactorNumericType(); // allc.MultiplierFactorNumeric.Value = 0.0M; // allc.Amount = new AmountType2(); // allc.Amount.currencyID = "TRY"; // allc.Amount.Value = 0M; // allc.BaseAmount = new BaseAmountType(); // allc.BaseAmount.currencyID = "TRY"; // allc.BaseAmount.Value = ((decimal)Services.ObjectToDouble(fech.Item("Quantity").Value)) * // ((decimal)Services.ObjectToDouble(fech.Item("Price").Value)); // all.Add(allc); // }); if (Senaryo == "2") { iol.Delivery = new List <DeliveryType>(); DeliveryType oDelivery = new DeliveryType(); oDelivery .With(d => { DeliveryTermsType dtt = new DeliveryTermsType(); dtt.ID.schemeID = "INCOTERMS"; dtt.ID.Value = "Teslim şartı"; d.DeliveryTerms.Add(dtt); d.DeliveryAddress .With(ai => { ai.StreetName = new StreetNameType(); ai.StreetName.Value = "Meçhul bir adres"; ai.CitySubdivisionName = new CitySubdivisionNameType(); ai.CitySubdivisionName.Value = "Beşiktaş"; ai.CityName = new CityNameType(); ai.CityName.Value = "İstanbul"; ai.Country = new CountryType(); ai.Country.Name.Value = "Türkiye"; }); d.Shipment .With(shp => { shp.ID.Value = "Gümrük tarkip numarası"; GoodsItemType oGItem = new GoodsItemType(); oGItem.RequiredCustomsID.Value = "GTIP"; shp.GoodsItem.Add(oGItem); ShipmentStageType oState = new ShipmentStageType(); oState.TransportModeCode.Value = "Gönderim şekli"; shp.ShipmentStage.Add(oState); TransportHandlingUnitType othlu = new TransportHandlingUnitType(); PackageType op = new PackageType(); op.ID.Value = "Kab numarası"; op.Quantity.Value = 1; //paket adedi op.PackagingTypeCode.Value = "Kabın cinsi"; othlu.ActualPackage.Add(op); shp.TransportHandlingUnit.Add(othlu); //di.PackageBrandName = fech.Item("U_PackageBrandName").Value.ToString() == "" ? grd.DataTable.GetValue("Kabın Markası", grdRowIndex).ToString() : fech.Item("U_PackageBrandName").Value.ToString(); //Bu alana Mal/Hizmetin bulunduğu Kabın Marka isim bilgisi girilir. }); }); iol.Delivery.Add(oDelivery); } //Vergi Toplam iol.TaxTotal = new TaxTotalType(); iol.TaxTotal .With(tx => { tx.TaxAmount = new TaxAmountType(); tx.TaxAmount.currencyID = "TRY"; tx.TaxAmount.Value = 180; //Vergiler tx.TaxSubtotal = new List <TaxSubtotalType>(); tx.TaxSubtotal .With(txs => { TaxSubtotalType sbt = new TaxSubtotalType(); sbt.TaxableAmount = new TaxableAmountType(); sbt.TaxableAmount.currencyID = "TRY"; sbt.TaxableAmount.Value = 1000; sbt.TaxAmount = new TaxAmountType(); sbt.TaxAmount.currencyID = "TRY"; sbt.TaxAmount.Value = 180; sbt.Percent = new PercentType1(); sbt.Percent.Value = 18; sbt.TaxCategory = new TaxCategoryType(); sbt.TaxCategory.TaxScheme = new TaxSchemeType(); sbt.TaxCategory.TaxScheme.Name = new NameType1(); sbt.TaxCategory.TaxScheme.Name.Value = "KDV"; sbt.TaxCategory.TaxScheme.TaxTypeCode = new TaxTypeCodeType(); sbt.TaxCategory.TaxScheme.TaxTypeCode.Value = "0015"; txs.Add(sbt); }); }); //Kalem Mal Hizmet Tutarı iol.LineExtensionAmount = new LineExtensionAmountType(); iol.LineExtensionAmount.currencyID = "TRY"; iol.LineExtensionAmount.Value = 1000; }); io.InvoiceLine.Add(il); #endregion #region LegalMonetaryTotal io.LegalMonetaryTotal = new MonetaryTotalType(); //Mal Hizmet Toplam Tutar io.LegalMonetaryTotal.LineExtensionAmount = new LineExtensionAmountType(); io.LegalMonetaryTotal.LineExtensionAmount.currencyID = "TRY"; io.LegalMonetaryTotal.LineExtensionAmount.Value = 1000; //Vergiler Hariç Tutar io.LegalMonetaryTotal.TaxExclusiveAmount = new TaxExclusiveAmountType(); io.LegalMonetaryTotal.TaxExclusiveAmount.currencyID = "TRY"; io.LegalMonetaryTotal.TaxExclusiveAmount.Value = 1000; //Vergiler Dahil Tutar io.LegalMonetaryTotal.TaxInclusiveAmount = new TaxInclusiveAmountType(); io.LegalMonetaryTotal.TaxInclusiveAmount.currencyID = "TRY"; io.LegalMonetaryTotal.TaxInclusiveAmount.Value = 1180; //iskonto io.LegalMonetaryTotal.AllowanceTotalAmount = new AllowanceTotalAmountType(); io.LegalMonetaryTotal.AllowanceTotalAmount.currencyID = "TRY"; io.LegalMonetaryTotal.AllowanceTotalAmount.Value = 0M; //Ödenecek Tutar io.LegalMonetaryTotal.PayableAmount = new PayableAmountType(); io.LegalMonetaryTotal.PayableAmount.currencyID = "TRY"; io.LegalMonetaryTotal.PayableAmount.Value = 1180; #endregion }); return(UblTrSerialize.UblSerialize(res)); }
static void Main(string[] args) { InvoiceType invoiceType = new InvoiceType(); XmlDocument xmlDocument = new XmlDocument(); XmlElement firma = xmlDocument.CreateElement("ext:firma", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); UBLExtensionType[] uBLExtensionTypes = new UBLExtensionType[] { new UBLExtensionType { ExtensionContent = firma } }; UBLVersionIDType uBLVersionIDType = new UBLVersionIDType(); uBLVersionIDType.Value = "2.1"; CustomizationIDType customizationIDType = new CustomizationIDType(); customizationIDType.Value = "2.0"; ProfileIDType profileIDType = new ProfileIDType(); profileIDType.schemeName = "SUNAT:Identificador de Tipo de Operación"; profileIDType.schemeAgencyName = "PE:SUNAT"; profileIDType.schemeURI = "urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo17"; profileIDType.Value = "0101"; InvoiceLineType[] invoiceLineTypes = new InvoiceLineType[] { new InvoiceLineType { ID = new IDType { Value = "1" } }, new InvoiceLineType { ID = new IDType { Value = "2" } } }; invoiceType.UBLVersionID = uBLVersionIDType; invoiceType.UBLExtensions = uBLExtensionTypes; invoiceType.CustomizationID = customizationIDType; invoiceType.ProfileID = profileIDType; invoiceType.InvoiceLine = invoiceLineTypes; XmlSerializer xmlSerializer = new XmlSerializer(typeof(InvoiceType)); XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); xmlSerializerNamespaces.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"); xmlSerializerNamespaces.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"); xmlSerializerNamespaces.Add("ccts", "urn:un:unece:uncefact:documentation:2"); xmlSerializerNamespaces.Add("ds", "http://www.w3.org/2000/09/xmldsig#"); xmlSerializerNamespaces.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); xmlSerializerNamespaces.Add("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"); xmlSerializerNamespaces.Add("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"); xmlSerializerNamespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); var oStringWriter = new StringWriter(); xmlSerializer.Serialize(XmlWriter.Create(oStringWriter), invoiceType, xmlSerializerNamespaces); string stringXML = oStringWriter.ToString(); System.IO.File.WriteAllText("XML_Sunat.xml", stringXML); }
//Informacion de las lineas del documento #region InvoiceLine /// <summary> /// Generacion de InvoiceLine /// </summary> /// <returns></returns> private InvoiceLineType[] InvoiceLine(List <ITEM> ITEM_collection) { Moneda = "PEN"; //string PESUNAT = "PE:SUNAT"; List <InvoiceLineType> Items_Respuesta = new List <InvoiceLineType>();; try { foreach (var item in ITEM_collection) { #region InvoiceLine string[] DE = item.DE.Split('|'); string[] DEDR = item.DEDR.Split('|'); List <string> DEIM_LIST = item.DEIM;//.Split('|'); string[] DEDI = item.DEDI.Split('|'); InvoiceLineType Linea = new InvoiceLineType(); { //numero de orden del item Linea.ID = new IDType() { Value = DE[1].ToString() }; //(InvoicedQuantity)cantidad de unidades del item Linea.InvoicedQuantity = new InvoicedQuantityType() { Value = Convert.ToDecimal(DE[4].ToString()), unitCode = DE[3].ToString(), unitCodeListID = "UN/ECE rec 20", unitCodeListAgencyName = "United Nations Economic Commission for Europe" }; //(LineExtensionAmount)Valor de Venta del item Linea.LineExtensionAmount = new LineExtensionAmountType() { Value = Convert.ToDecimal(DE[5].ToString()), currencyID = Moneda }; #region PricingReference Linea.PricingReference = new PricingReferenceType() { //AlternativeConditionPrice AlternativeConditionPrice = new PriceType[] { new PriceType() { //(PriceAmount) precoi de venta unitario/ valor referencial PriceAmount = new PriceAmountType() { Value = Convert.ToDecimal(DE[2].ToString()), currencyID = Moneda }, //(PriceTypeCode) codigo de tipo de precio PriceTypeCode = new PriceTypeCodeType() { Value = DE[7].ToString(), listName = "SUNAT:Indicador de Tipo de Precio", listAgencyName = ConstantesAtributo.PESUNAT, listURI = ConstantesAtributo.CATALOGO16 } } } }; #endregion #region Delivery #endregion //Descuentos o Recargos de la linea #region AllowanceCharge Linea.AllowanceCharge = new AllowanceChargeType[] { new AllowanceChargeType() { ChargeIndicator = new ChargeIndicatorType() { Value = DEDR[1].ToString() == "true"?true :false }, AllowanceChargeReasonCode = new AllowanceChargeReasonCodeType() { Value = DEDR[3].ToString() }, MultiplierFactorNumeric = new MultiplierFactorNumericType() { Value = Convert.ToDecimal(DEDR[4].ToString()) }, Amount = new AmountType2() { Value = Convert.ToDecimal(DEDR[2].ToString()), currencyID = Moneda }, BaseAmount = new BaseAmountType() { Value = Convert.ToDecimal(DEDR[5].ToString()), currencyID = Moneda } } }; #endregion //Monto de tributo del item #region TaxTotal List <TaxTotalType> taxTotals = new List <TaxTotalType>(); foreach (var DEIM_Item in DEIM_LIST) { string[] DEIM = DEIM_Item.Split('|'); TaxTotalType taxTotalType = new TaxTotalType() { //Monto de tributo del ítem TaxAmount = new TaxAmountType() { Value = Convert.ToDecimal(DEIM[1].ToString()), currencyID = Moneda }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType() { //Monto de la Operacion TaxableAmount = new TaxableAmountType() { Value = Convert.ToDecimal(DEIM[2].ToString()), currencyID = Moneda }, //Monto de Tributo por Item TaxAmount = new TaxAmountType() { Value = Convert.ToDecimal(DEIM[3].ToString()), currencyID = Moneda }, TaxCategory = new TaxCategoryType() { ID = new IDType() { Value = "S", schemeID = ConstantesAtributo.UNECE5305, schemeAgencyID = "6" }, Percent = new PercentType1 { Value = Convert.ToDecimal(DEIM[4].ToString()) }, TaxExemptionReasonCode = new TaxExemptionReasonCodeType() { Value = DEIM[6].ToString(), listAgencyName = ConstantesAtributo.PESUNAT, listName = "SUNAT:Codigo de Tipo de Afectación del IGV", listURI = ConstantesAtributo.CATALOGO07 }, TaxScheme = new TaxSchemeType() { ID = new IDType() { Value = DEIM[8].ToString(), }, Name = new NameType1() { Value = DEIM[9].ToString(), }, TaxTypeCode = new TaxTypeCodeType() { Value = DEIM[5].ToString() } } } } } }; taxTotals.Add(taxTotalType); } Linea.TaxTotal = taxTotals.ToArray(); #endregion #region Item Linea.Item = new ItemType() { Description = new DescriptionType[] { new DescriptionType() { Value = DEDI[1].ToString() } }, SellersItemIdentification = new ItemIdentificationType() { ID = new IDType() { Value = DE[6].ToString() } }, CommodityClassification = new CommodityClassificationType[] { new CommodityClassificationType() { ItemClassificationCode = new ItemClassificationCodeType() { Value = DEDI[6].ToString() } } } }; #endregion #region Price Linea.Price = new PriceType() { PriceAmount = new PriceAmountType() { Value = Convert.ToDecimal(DE[8].ToString()), } }; #endregion } #endregion Items_Respuesta.Add(Linea); } return(Items_Respuesta.ToArray()); } catch (Exception) { throw; } }
public void addInvoiceLine(string invId, string currencyID, string unitCode, decimal quantity, decimal lineExtensionAmount, decimal taxAmount, decimal taxableAmount, decimal percent, string itemName, decimal price) { InvoiceLineType invoiceLine = new InvoiceLineType { ID = new IDType { Value = invId }, Note = new NoteType[] { new NoteType { Value = "Note" } }, InvoicedQuantity = new InvoicedQuantityType { unitCode = unitCode, Value = quantity }, LineExtensionAmount = new LineExtensionAmountType { currencyID = currencyID, Value = lineExtensionAmount }, AllowanceCharge = new[] { new AllowanceChargeType { ChargeIndicator = new ChargeIndicatorType { Value = false }, //ıskonto false Amount = new AmountType2 { currencyID = currencyID, Value = 0.00M //suan ındırım yapmıyoruz }, BaseAmount = new BaseAmountType { currencyID = currencyID, Value = 0 } } }, TaxTotal = new TaxTotalType { TaxAmount = new TaxAmountType { currencyID = currencyID, Value = taxAmount }, TaxSubtotal = new[] { new TaxSubtotalType { TaxableAmount = new TaxableAmountType { currencyID = currencyID, Value = taxableAmount }, TaxAmount = new TaxAmountType { currencyID = currencyID, Value = taxAmount }, CalculationSequenceNumeric = new CalculationSequenceNumericType { Value = 1 }, Percent = new PercentType1 { Value = percent }, TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = nameof(EI.TaxType.KDV) }, TaxTypeCode = new TaxTypeCodeType { Value = "0015" } } } } } }, Item = new ItemType { Name = new NameType1 { Value = itemName } }, Price = new PriceType { PriceAmount = new PriceAmountType { currencyID = currencyID, Value = price } } }; listInvLine.Add(invoiceLine); }
public InvoiceType Convert2Invoice(InvoiceViewModel src) { var dest = new InvoiceType(); dest.ID = new IDType() { Value = src.ID }; dest.IssueDate = new IssueDateType() { Value = src.IssueDate }; dest.Note = new NoteType[] { new NoteType() { Value = src.Reason } }; dest.InvoiceTypeCode = new InvoiceTypeCodeType { Value = src.InvoiceType }; dest.AccountingSupplierParty = new SupplierPartyType { CustomerAssignedAccountID = new CustomerAssignedAccountIDType() { Value = src.Supplier.AccountID }, Party = new PartyType() { PartyName = new PartyNameType[] { new PartyNameType() { Name = new NameType1 { Value = src.Supplier.Name } } }, PartyTaxScheme = new PartyTaxSchemeType[] { new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { ID = new IDType { Value = src.Supplier.VAT } } } }, PostalAddress = new AddressType { StreetName = new StreetNameType { Value = src.Supplier.StreetName }, BuildingNumber = new BuildingNumberType { Value = src.Supplier.BuildingNumber }, CityName = new CityNameType { Value = src.Supplier.CityName }, PostalZone = new PostalZoneType { Value = src.Supplier.PostalZone } } } }; if (!string.IsNullOrEmpty(src.Supplier.IndustryClassificationCode)) { dest.AccountingSupplierParty.Party.IndustryClassificationCode = new IndustryClassificationCodeType { Value = src.Supplier.IndustryClassificationCode }; } var lines = new List <InvoiceLineType>(); foreach (var item in src.Lines) { var line = new InvoiceLineType(); line.ID = new IDType { Value = item.ID }; line.InvoicedQuantity = new InvoicedQuantityType { unitCode = item.UnitCode, Value = item.InvoicedQuantity }; line.Item = new ItemType { Name = new NameType1 { Value = item.ItemName } }; line.TaxTotal = new TaxTotalType[] { new TaxTotalType { TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType { TaxCategory = new TaxCategoryType { Percent = new PercentType1 { Value = item.VatPercentage } }, TaxAmount = new TaxAmountType { Value = item.TaxAmount } } } } }; lines.Add(line); } dest.InvoiceLine = lines.ToArray(); return(dest); }
void LlenarDetalle(En_ComprobanteElectronico Comprobante, ref InvoiceType invoice) { List <InvoiceLineType> oListaDetalle = new List <InvoiceLineType>(); foreach (En_ComprobanteDetalle oDet in Comprobante.ComprobanteDetalle) { List <DescriptionType> oListaDescripcion = new List <DescriptionType>(); DescriptionType oDescripcion = new DescriptionType(); oDescripcion.Value = oDet.Descripcion; oListaDescripcion.Add(oDescripcion); foreach (string oDes in oDet.MultiDescripcion) { DescriptionType oDescrip = new DescriptionType(); oDescrip.Value = oDes.ToString(); oListaDescripcion.Add(oDescrip); } List <TaxSubtotalType> oListaSubtotal = new List <TaxSubtotalType>(); foreach (En_ComprobanteDetalleImpuestos odetImpuesto in oDet.ComprobanteDetalleImpuestos) { TaxSubtotalType oSubTotal = new TaxSubtotalType(); oSubTotal = LlenarSubTotalDetalle(odetImpuesto.MontoBase, odetImpuesto.MontoTotalImpuesto, Comprobante.Moneda.Trim(), odetImpuesto.Porcentaje, odetImpuesto.CodigoInternacionalTributo, odetImpuesto.NombreTributo, odetImpuesto.CodigoTributo, odetImpuesto.AfectacionIGV); oListaSubtotal.Add(oSubTotal); } InvoiceLineType oInvoiceLine = new InvoiceLineType { ID = new IDType { Value = oDet.Item.ToString() }, InvoicedQuantity = new InvoicedQuantityType { unitCode = oDet.UnidadMedida.Trim().ToUpper(), unitCodeListAgencyName = "United Nations Economic Commission for Europe", unitCodeListID = "UN/ECE rec 20", Value = oDet.Cantidad }, LineExtensionAmount = new LineExtensionAmountType { Value = oDet.Total, currencyID = Comprobante.Moneda.Trim() }, PricingReference = new PricingReferenceType { AlternativeConditionPrice = new PriceType[] { new PriceType { PriceAmount = new PriceAmountType { Value = oDet.ValorVentaUnitarioIncIgv, currencyID = Comprobante.Moneda.Trim() }, PriceTypeCode = new PriceTypeCodeType { Value = oDet.CodigoTipoPrecio, listAgencyName = "PE:SUNAT", listName = "Tipo de Precio", listURI = "urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16" } } } }, TaxTotal = new TaxTotalType[] { new TaxTotalType { TaxAmount = new TaxAmountType { Value = oDet.ImpuestoTotal, currencyID = Comprobante.Moneda.Trim() }, TaxSubtotal = oListaSubtotal.ToArray() } }, Price = new PriceType { PriceAmount = new PriceAmountType { Value = oDet.ValorVentaUnitario, currencyID = Comprobante.Moneda.Trim() } }, Item = new ItemType { Description = oListaDescripcion.ToArray(), SellersItemIdentification = new ItemIdentificationType { ID = new IDType { Value = oDet.Codigo } }, CommodityClassification = new CommodityClassificationType[] { new CommodityClassificationType { CommodityCode = new CommodityCodeType { listAgencyName = "GS1 US", listID = "UNSPSC", listName = "Item Classification", Value = oDet.CodigoSunat } } } } }; oListaDetalle.Add(oInvoiceLine); } ; invoice.InvoiceLine = oListaDetalle.ToArray(); }
/// <summary> /// fatura kalem bilgilerinin doldurulması /// </summary> public InvoiceLineType[] GetInvoiceLines() { Random rnd = new Random(); int lineCount = rnd.Next(1, 10); List <InvoiceLineType> list = new List <InvoiceLineType>(); for (int i = 1; i <= lineCount; i++) { #region invoiceLine InvoiceLineType invoiceLine = new InvoiceLineType { ID = new IDType { Value = i.ToString() }, InvoicedQuantity = new InvoicedQuantityType { unitCode = "C62", Value = 10 }, LineExtensionAmount = new LineExtensionAmountType { currencyID = "TRY", Value = 20.00M }, AllowanceCharge = new[] { new AllowanceChargeType { ChargeIndicator = new ChargeIndicatorType { Value = false }, MultiplierFactorNumeric = new MultiplierFactorNumericType { Value = 0.05M }, Amount = new AmountType2 { currencyID = "TRY", Value = 1.00M }, BaseAmount = new BaseAmountType { currencyID = "TRY", Value = 20 } } }, TaxTotal = new TaxTotalType { TaxAmount = new TaxAmountType { currencyID = "TRY", Value = 0.19M }, TaxSubtotal = new[] { new TaxSubtotalType { TaxableAmount = new TaxableAmountType { currencyID = "TRY", Value = 19.00M }, TaxAmount = new TaxAmountType { currencyID = "TRY", Value = 0.19M }, CalculationSequenceNumeric = new CalculationSequenceNumericType { Value = 1 }, Percent = new PercentType1 { Value = 1 }, TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KDV" }, TaxTypeCode = new TaxTypeCodeType { Value = "0015" } } } } } }, Item = new ItemType { Name = new NameType1 { Value = "Kalem" } }, Price = new PriceType { PriceAmount = new PriceAmountType { currencyID = "TRY", Value = 2.00M } } }; #endregion list.Add(invoiceLine); } return(list.ToArray()); }
public static void EFaturaOlustur(EFatura EFatura, EFaturaAyarlar EFaturaAyarlar) { //https://ebelge.gib.gov.tr/anasayfa.html //https://ebelge.gib.gov.tr/efaturamevzuat.html > KILAVUZLAR //https://ebelge.gib.gov.tr/dosyalar/kilavuzlar/UBLTR_1.2.1_Kilavuzlar.zip //Bkz: BELGELER\UBL-TR Fatura - V 1.0.pdf Bkz: 2.3 Fatura Elemanları-Detay (SAYFA-10) //Bkz: KOD LİSTELERİ\UBL-TR Kod Listeleri - V 1.23.pdf //Bkz: ORTAK ELEMANLAR\UBL-TR Ortak Elemanlar - V 0.7.pdf using (var transaction = new TransactionScope()) { var invoiceType = new InvoiceType(); //invoiceType.UBLExtensions //Mali Mühür Bilgileri invoiceType.UBLVersionID = new UBLVersionIDType() { Value = "2.1" }; //indirdiğimiz UBLTR_1.2.1_Kilavuzlar.zip dosyasından oluşturduğumuz class versiyonu "UBL-2_1.cs" invoiceType.CustomizationID = new CustomizationIDType() { Value = "TR1.2" }; //Bkz Kılavuz => 2.3.3 invoiceType.ProfileID = new ProfileIDType() { Value = "EARSIVFATURA" }; //Bkz Kılavuz => 2.3.4 Bkz:Kod Listeleri => 2.2 Senaryo (ProfileID) invoiceType.ID = new IDType() { Value = EFatura.FaturaNo }; //Bkz Kılavuz => 2.3.5 13 haneli [EFatura Seri Sıra no] invoiceType.CopyIndicator = new CopyIndicatorType() { Value = false }; //Bkz Kılavuz => 2.3.6 Asıl:false Suret:true invoiceType.UUID = new UUIDType() { Value = Guid.NewGuid().ToString() }; //Bkz Kılavuz => 2.3.7 invoiceType.IssueDate = new IssueDateType() { Value = EFatura.TarihSaat }; //Bkz Kılavuz => 2.3.8 [Fatura Düzenlenme Tarihi] invoiceType.IssueTime = new IssueTimeType() { Value = EFatura.TarihSaat }; //Bkz Kılavuz => 2.3.9 [Fatura Düzenlenme Saati] invoiceType.InvoiceTypeCode = new InvoiceTypeCodeType() { Value = "SATIS" }; //Bkz Kılavuz => 2.3.10 Bkz:Kod Listeleri => 1.4 InvoiceTypeCode [Fatura Tipi] invoiceType.DocumentCurrencyCode = new DocumentCurrencyCodeType() { Value = "TRY" }; //Bkz Kılavuz => 2.3.12 [Para Birimi] invoiceType.LineCountNumeric = new LineCountNumericType() { Value = EFatura.FaturaKalemSayisi }; //Bkz Kılavuz => 2.3.18 [FaturaKalemSayisi] #region TaxTotal invoiceType.TaxTotal = new TaxTotalType[] { new TaxTotalType { TaxAmount = new TaxAmountType { Value = EFatura.KdvToplam }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType { TaxableAmount = new TaxableAmountType { currencyID = "TRY", Value = EFatura.NetToplam//Kdv Hariç Net Tutar }, TaxAmount = new TaxAmountType { currencyID = "TRY", Value = EFatura.KdvToplam }, CalculationSequenceNumeric = new CalculationSequenceNumericType { Value = 1 }, //Percent=new PercentType1{Value=18}//%18 Kdv için 18.0 girilmeli //TODO:Birden fazla KDV Oranına göre düzenle (1,8,18) gibi TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KDV" }, TaxTypeCode = new TaxTypeCodeType { Value = "0015" } //Bkz Kod Listesi=>1.9 TaxTypeCode VERGİ KODLARI LİSTESİ } } } } }, }; //Bkz Ortak Elemanlar => 2.2.61 #endregion #region Signature invoiceType.Signature = new[] { new SignatureType() { ID = new IDType { schemeID = "VKN_TCKN", Value = EFaturaAyarlar.EFaturaImzalayanTcKimlikNo }, SignatoryParty = new PartyType { PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = EFaturaAyarlar.EFaturaImzalayanTcKimlikNo } } }, PostalAddress = new AddressType {//zorunlu değil CityName = new CityNameType { Value = EFaturaAyarlar.EFaturaImzalayanAdresIlAd } //TODO:İmzayan kişinin diğer adres bilgilerini getir } }, DigitalSignatureAttachment = new AttachmentType { //EmbeddedDocumentBinaryObject //TODO:İmzalama İşlemi olduğu zaman eklenecek ExternalReference = new ExternalReferenceType { URI = new URIType { Value = "#Signature_" + EFatura.FaturaNo } } } } };//Bkz Kılavuz => 2.3.27 [E Faturayı İmzayan Bilgisi] #endregion #region AccountingSupplierParty invoiceType.AccountingSupplierParty = new SupplierPartyType { Party = new PartyType { PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = EFaturaAyarlar.EFaturaImzalayanTcKimlikNo } }, new PartyIdentificationType { ID = new IDType { schemeID = "MERSISNO", Value = EFaturaAyarlar.EFaturaKesenKurumMersisNo } } }, PostalAddress = new AddressType {//zorunlu değil CityName = new CityNameType { Value = EFaturaAyarlar.EFaturaImzalayanAdresIlAd } //TODO:İmzayan kişinin diğer adres bilgilerini getir }, //Person //TODO:Faturayı Kesen Şahış ise burayı doldur PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = EFaturaAyarlar.EFaturaKesenKurumVergiDairesi } } } } };//Bkz Kılavuz => 2.3.28 [FaturayıDüzenleyenTarafın Bilgileri] #endregion #region AccountingCustomerParty invoiceType.AccountingCustomerParty = new CustomerPartyType { Party = new PartyType { PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IDType { schemeID = "TCKN", Value = EFaturaAyarlar.EFaturaKesilenMusteriTcKimlikNo } } }, PartyName = new PartyNameType { Name = new NameType1 { Value = EFatura.CariAd } }, PostalAddress = new AddressType {//zorunlu değil //CityName = new CityNameType { Value = EFaturaAyarlar } //TODO:Müşterinin diğer adres bilgilerini getir }, Contact = new ContactType { ElectronicMail = new ElectronicMailType { Value = EFaturaAyarlar.EFaturaKesilenMusteriEmail }, Telephone = new TelephoneType { Value = EFaturaAyarlar.EFaturaKesilenMusteriTelefon } }, Person = new PersonType { FirstName = new FirstNameType { Value = EFaturaAyarlar.EFaturaKesilenMusteriAd }, FamilyName = new FamilyNameType { Value = EFaturaAyarlar.EFaturaKesilenMusteriSoyad } } } };//Bkz Kılavuz => 2.3.29 [Müşteri (Fatura Kesilen Cari) Bilgileri] #endregion #region LegalMonetaryTotal-ALT TOPLAMLAR invoiceType.LegalMonetaryTotal = new MonetaryTotalType { LineExtensionAmount = new LineExtensionAmountType { Value = EFatura.AraToplam }, TaxExclusiveAmount = new TaxExclusiveAmountType { Value = EFatura.NetToplam }, TaxInclusiveAmount = new TaxInclusiveAmountType { Value = EFatura.GenelToplam }, AllowanceTotalAmount = new AllowanceTotalAmountType { Value = EFatura.IskontoToplam }, //opsiyonel PayableAmount = new PayableAmountType { Value = EFatura.GenelToplam } }; #endregion #region Opsiyonel Alanlar invoiceType.Note = new[] { new NoteType { Value = Utility.SayiyiYaziyaCevir(EFatura.GenelToplam) }, new NoteType { Value = "İş bu fatura muhteviyatına 7 gün içerisinde itiraz edilmediği taktirde aynen kabul edilmiş sayılır." }, new NoteType { Value = $"Cari Kod:{EFatura.CariKod} Cari Ad:{EFatura.CariAd}" } };//Bkz Kılavuz => 2.3.11 invoiceType.AdditionalDocumentReference = new[] { new DocumentReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = EFatura.TarihSaat }, DocumentType = new DocumentTypeType { Value = "XSLT" }, Attachment = new AttachmentType { EmbeddedDocumentBinaryObject = new EmbeddedDocumentBinaryObjectType { characterSetCode = "UTF-8", encodingCode = "Base64", filename = "EFatura.xslt", mimeCode = "application/xml", Value = Encoding.UTF8.GetBytes(new StreamReader(new FileStream(EFaturaAyarlar.XsltDosyaYolu, FileMode.Open, FileAccess.Read), Encoding.UTF8).ReadToEnd()) } } }, new DocumentReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = EFatura.TarihSaat }, DocumentTypeCode = new DocumentTypeCodeType { Value = "SendingType" }, DocumentType = new DocumentTypeType { Value = "ELEKTRONIK" } } };//Bkz Kılavuz => 2.3.26 [xslt fatura tasarım dosyası] #endregion #region InvoiceLine- FATURA KALEMLERİ List <InvoiceLineType> ListInvoiceLineType = new List <InvoiceLineType>(); var iEFaturaDetay = 1; foreach (var EFaturaDetay in EFatura.EFaturaDetay) { var invoiceLineType = new InvoiceLineType { ID = new IDType { Value = iEFaturaDetay.ToString() }, InvoicedQuantity = new InvoicedQuantityType { unitCode = EFaturaDetay.Birim, Value = EFaturaDetay.Miktar }, LineExtensionAmount = new LineExtensionAmountType { Value = EFaturaDetay.NetTutar }, Item = new ItemType { Name = new NameType1 { Value = EFaturaDetay.StokKod + " " + EFaturaDetay.StokAd } }, Price = new PriceType { PriceAmount = new PriceAmountType { Value = EFaturaDetay.Fiyat } }, #region İskonto AllowanceCharge = new AllowanceChargeType[] { new AllowanceChargeType { ChargeIndicator = new ChargeIndicatorType { Value = false }, MultiplierFactorNumeric = new MultiplierFactorNumericType { Value = EFaturaDetay.IskontoYuzde }, Amount = new AmountType2 { Value = EFaturaDetay.IskontoTutar }, BaseAmount = new BaseAmountType { Value = EFaturaDetay.Tutar } } },//İskonto #endregion #region Vergi TaxTotal = new TaxTotalType { TaxAmount = new TaxAmountType { Value = EFaturaDetay.KdvTutar }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType { TaxableAmount = new TaxableAmountType { currencyID = "TRY", Value = EFaturaDetay.NetTutar//Kdv Hariç Net Tutar }, TaxAmount = new TaxAmountType { currencyID = "TRY", Value = EFaturaDetay.KdvTutar }, CalculationSequenceNumeric = new CalculationSequenceNumericType { Value = 1 }, Percent = new PercentType1 { Value = EFaturaDetay.KdvOran }, //%18 Kdv için 18.00 gir TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KDV" }, TaxTypeCode = new TaxTypeCodeType { Value = "0015" } //Bkz Kod Listesi=>1.9 TaxTypeCode VERGİ KODLARI LİSTESİ } } } } } #endregion }; ListInvoiceLineType.Add(invoiceLineType); iEFaturaDetay++; } invoiceType.InvoiceLine = ListInvoiceLineType.ToArray(); #endregion #region Xml Serialization #region XmlSerializerNamespaces var ns = new XmlSerializerNamespaces(); ns.Add(prefix: "cac", ns: "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"); ns.Add(prefix: "xsi", ns: "http://www.w3.org/2001/XMLSchema-instance"); ns.Add(prefix: "xades", ns: "http://uri.etsi.org/01903/v1.3.2#"); ns.Add(prefix: "udt", ns: "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"); ns.Add(prefix: "ubltr", ns: "urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents"); ns.Add(prefix: "qdt", ns: "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2"); ns.Add(prefix: "ext", ns: "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); ns.Add(prefix: "cbc", ns: "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"); ns.Add(prefix: "ccts", ns: "urn:un:unece:uncefact:documentation:2"); ns.Add(prefix: "ds", ns: "http://www.w3.org/2000/09/xmldsig#"); #endregion var xmlWriterSettings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }; var ms = new MemoryStream(); var writer = XmlWriter.Create(ms, xmlWriterSettings); var srl = new XmlSerializer(invoiceType.GetType()); srl.Serialize(writer, invoiceType, ns); ms.Flush(); ms.Seek(offset: 0, loc: SeekOrigin.Begin); var sr = new StreamReader(ms); var readXml = sr.ReadToEnd(); if (!Directory.Exists(EFaturaAyarlar.XmlDosyaKlasor)) { Directory.CreateDirectory(EFaturaAyarlar.XmlDosyaKlasor); } var path = Path.Combine(EFaturaAyarlar.XmlDosyaKlasor, EFatura.FaturaNo + ".xml"); //Her zaman üzerinde yazılacak using (var sWriter = new StreamWriter(path, append: false, encoding: Encoding.UTF8)) //Fatura SeriSıraNo daha okunabilir, sıralanabilir. { sWriter.Write(readXml); sWriter.Close(); } #endregion }//using transaction }
private void btnTamam_Click(object sender, EventArgs e) { _InvoiceLine = SatirDoldur(); DialogResult = DialogResult.OK; }
private InvoiceLineType SatirDoldur() { if (_InvoiceLine == null) { _InvoiceLine = new InvoiceLineType(); } var line = new InvoiceLineType { //Ürün Açıklamaları Item = CreateItemType(_InvoiceLine.Item), AllowanceCharge = CreateAllowanceCharge(_InvoiceLine.AllowanceCharge), //Birim Fiyat Price = new PriceType { PriceAmount = new PriceAmountType { Value = Convert.ToDecimal(txtFiyat.Text), currencyID = "TRL" } }, //Miktar InvoicedQuantity = new InvoicedQuantityType { unitCode = txtBirim.Text, Value = Convert.ToDecimal(txtMiktar.Text) }, //NIU =Adet //Not Note = new NoteType[] { new NoteType { Value = txtSatirNotu.Text } }, // KDV ve Diğer Vergiler TaxTotal = new TaxTotalType { TaxSubtotal = new TaxSubtotalType[] { //Vergi 1 KDV new TaxSubtotalType { Percent = new PercentType1 { Value = Convert.ToDecimal(txtKdvOrani.Text) }, TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { TaxTypeCode = new TaxTypeCodeType { Value = "0015" }, Name = new NameType1 { Value = "KDV" } }, TaxExemptionReason = new TaxExemptionReasonType { Value = "Tanıtım Ürünü" } }, TaxAmount = new TaxAmountType { Value = ((100 + Convert.ToDecimal(txtKdvOrani.Text)) / 100) * Convert.ToDecimal(txtFiyat.Text) * (Convert.ToDecimal(txtMiktar.Text)), currencyID = "TRL" }, PerUnitAmount = new PerUnitAmountType { Value = ((100 + Convert.ToDecimal(txtKdvOrani.Text)) / 100) * Convert.ToDecimal(txtFiyat.Text), currencyID = "TRL" }, } }, TaxAmount = new TaxAmountType { Value = Convert.ToDecimal(txtKdvTutar.Text) } }, ID = new IDType { Value = "1" }, LineExtensionAmount = new LineExtensionAmountType { Value = Convert.ToDecimal(txtToplamTutar.Text), currencyID = "TRL" } }; return(line); }
private InvoiceLineType[] InvoiceLineDoldur(int Master) { List <InvoiceLineType> Liste = new List <InvoiceLineType>(); using (VTContext db = new VTContext()) { var list = db.Detail.Where(x => x.MasterId == Master).ToList(); foreach (var item in list) { var veri = db.Database.SqlQuery <Stoklar>("SELECT Id,StokKodu,StokAdi FROM Stoklar where Id='" + item.StokId + "'").FirstOrDefault(); string _IL_ID = Convert.ToString(item.StokId); string _IL_StokCode = Convert.ToString(veri.StokKodu); string _IL_InvoicedQuantity = Convert.ToString(item.Miktar); string _IL_LineExtensionAmount = "0"; string _IL_TaxAmount = Convert.ToString(item.KdvOrani); string _IL_TaxableAmount = Convert.ToString(item.Kdv); string _IL_Percent = ""; string _IL_TaxCategory_Name = ""; string _IL_TaxCategory_TaxTypeCode = ""; string _IL_ItemName = veri.StokAdi; string _IL_Price = Convert.ToString(item.Tutar); string _IL_Birim = "C62"; string KdvIstisnasi = ""; string KdvIstisnasiCode = ""; _IL_ID = Convert.ToString(_IL_ID); _IL_StokCode = Convert.ToString(_IL_StokCode); _IL_InvoicedQuantity = Convert.ToString(_IL_InvoicedQuantity); _IL_LineExtensionAmount = Convert.ToString(_IL_LineExtensionAmount); _IL_TaxAmount = Convert.ToString(_IL_TaxAmount); _IL_TaxableAmount = Convert.ToString(_IL_TaxableAmount); _IL_Percent = Convert.ToString(_IL_Percent); _IL_TaxCategory_Name = Convert.ToString(_IL_TaxCategory_Name); _IL_TaxCategory_TaxTypeCode = Convert.ToString(_IL_TaxCategory_TaxTypeCode); _IL_ItemName = Convert.ToString(_IL_ItemName); _IL_Price = Convert.ToString(_IL_Price); _IL_Birim = Convert.ToString(_IL_Birim); KdvIstisnasi = Convert.ToString(KdvIstisnasi); KdvIstisnasiCode = Convert.ToString(KdvIstisnasiCode); InvoiceLineType lineItem = new InvoiceLineType() { ID = new IDType { Value = _IL_ID }, InvoicedQuantity = new InvoicedQuantityType { unitCode = _IL_Birim, Value = Math.Round(Convert.ToDecimal(_IL_InvoicedQuantity), 4) }, LineExtensionAmount = new LineExtensionAmountType { currencyID = "TRY", Value = Math.Round(Convert.ToDecimal(_IL_LineExtensionAmount), 4) }, AllowanceCharge = new AllowanceChargeType[] { new AllowanceChargeType() { ChargeIndicator = new ChargeIndicatorType { Value = false }, MultiplierFactorNumeric = new MultiplierFactorNumericType { Value = 0.00M }, Amount = new AmountType2 { currencyID = "TRY", Value = 0.00M }, BaseAmount = new BaseAmountType { currencyID = "TRY", Value = Math.Round(Convert.ToDecimal(_IL_TaxableAmount), 4) } } }, TaxTotal = new TaxTotalType { TaxAmount = new TaxAmountType { currencyID = "TRY", Value = Math.Round(Convert.ToDecimal(_IL_TaxAmount), 4) }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType() { TaxableAmount = new TaxableAmountType { currencyID = "TRY", Value = Math.Round(Convert.ToDecimal(_IL_TaxableAmount), 4) }, TaxAmount = new TaxAmountType { currencyID = "TRY", Value = Math.Round(Convert.ToDecimal(_IL_TaxAmount), 4) }, Percent = new PercentType1 { Value = Math.Round(Convert.ToDecimal(_IL_Percent), 4) }, TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KDV" }, TaxTypeCode = new TaxTypeCodeType { Value = "0015" } }, TaxExemptionReasonCode = new TaxExemptionReasonCodeType { Value = KdvIstisnasiCode }, TaxExemptionReason = new TaxExemptionReasonType { Value = KdvIstisnasi } } } }, }, Item = new ItemType { Name = new NameType1 { Value = _IL_ItemName }, SellersItemIdentification = new ItemIdentificationType { ID = new IDType { Value = _IL_StokCode.Replace(" ", "") } } }, Price = new PriceType { PriceAmount = new PriceAmountType { currencyID = "TRY", Value = Math.Round(Convert.ToDecimal(_IL_Price), 4) } } }; Liste.Add(lineItem); } } return(Liste.ToArray()); }
//Informacion de las lineas del documento #region InvoiceLine /// <summary> /// Generacion de InvoiceLine /// </summary> /// <returns></returns> private InvoiceLineType[] InvoiceLine() { List <InvoiceLineType> Items_Respuesta = new List <InvoiceLineType>(); //foreach (var item in ITEM_collection) //{ //} #region InvoiceLine //string[] DE = item.DE.Split('|'); //string[] DEDR = item.DEDR.Split('|'); //List<string> DEIM_LIST = item.DEIM; //string[] DEDI = item.DEDI.Split('|'); InvoiceLineType Linea = new InvoiceLineType(); { //numero de orden del item Linea.ID = new IDType() { Value = "Numero de Orden del Item" }; //(InvoicedQuantity)cantidad de unidades del item Linea.InvoicedQuantity = new InvoicedQuantityType() { Value = Convert.ToDecimal(3), unitCode = "Codigo Unitario", unitCodeListID = "UN/ECE rec 20", unitCodeListAgencyName = "United Nations Economic Commission for Europe" }; //(LineExtensionAmount)Valor de Venta del item Linea.LineExtensionAmount = new LineExtensionAmountType() { Value = Convert.ToDecimal(50), currencyID = ConstantesAtributo.PEN }; #region PricingReference Linea.PricingReference = new PricingReferenceType() { //AlternativeConditionPrice AlternativeConditionPrice = new PriceType[] { new PriceType() { //(PriceAmount) precoi de venta unitario/ valor referencial PriceAmount = new PriceAmountType() { Value = Convert.ToDecimal(50), currencyID = ConstantesAtributo.PEN }, //(PriceTypeCode) codigo de tipo de precio PriceTypeCode = new PriceTypeCodeType() { Value = "Codigo de Tipo de Precio", listName = "SUNAT:Indicador de Tipo de Precio", listAgencyName = ConstantesAtributo.PESUNAT, listURI = ConstantesAtributo.CATALOGO16 } } } }; #endregion #region Delivery #endregion //Descuentos o Recargos de la linea #region AllowanceCharge Linea.AllowanceCharge = new AllowanceChargeType[] { new AllowanceChargeType() { ChargeIndicator = new ChargeIndicatorType() { Value = true }, AllowanceChargeReasonCode = new AllowanceChargeReasonCodeType() { Value = "Codigo de cargo o descuento" }, MultiplierFactorNumeric = new MultiplierFactorNumericType() { Value = Convert.ToDecimal(0.13) }, Amount = new AmountType2() { Value = Convert.ToDecimal(20), currencyID = ConstantesAtributo.PEN }, BaseAmount = new BaseAmountType() { Value = Convert.ToDecimal(30), currencyID = ConstantesAtributo.PEN } } }; #endregion //Monto de tributo del item #region TaxTotal List <TaxTotalType> taxTotals = new List <TaxTotalType>(); //foreach (var DEIM_Item in DEIM_LIST) //{ // string[] DEIM = DEIM_Item.Split('|'); //} TaxTotalType taxTotalType = new TaxTotalType() { //Monto de tributo del ítem TaxAmount = new TaxAmountType() { Value = Convert.ToDecimal(50), currencyID = ConstantesAtributo.PEN }, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType() { //Monto de la Operacion TaxableAmount = new TaxableAmountType() { Value = Convert.ToDecimal(10), currencyID = ConstantesAtributo.PEN }, //Monto de Tributo por Item TaxAmount = new TaxAmountType() { Value = Convert.ToDecimal(15), currencyID = ConstantesAtributo.PEN }, TaxCategory = new TaxCategoryType() { ID = new IDType() { Value = "S", schemeID = ConstantesAtributo.UNECE5305, schemeAgencyID = "6" }, Percent = new PercentType1 { Value = Convert.ToDecimal(14) }, TaxExemptionReasonCode = new TaxExemptionReasonCodeType() { Value = "Codigo de tipo de afeectacion del igv", listAgencyName = ConstantesAtributo.PESUNAT, listName = "SUNAT:Codigo de Tipo de Afectación del IGV", listURI = ConstantesAtributo.CATALOGO07 }, TaxScheme = new TaxSchemeType() { ID = new IDType() { Value = "Codigo del tributo", }, Name = new NameType1() { Value = "Nombre del tributo", }, TaxTypeCode = new TaxTypeCodeType() { Value = "Codigo Internacional del producto" } } } } } }; taxTotals.Add(taxTotalType); Linea.TaxTotal = taxTotals.ToArray(); #endregion #region Item Linea.Item = new ItemType() { Description = new DescriptionType[] { new DescriptionType() { Value = "Descripcion del item" } }, SellersItemIdentification = new ItemIdentificationType() { ID = new IDType() { Value = "Codigo de producto" } }, CommodityClassification = new CommodityClassificationType[] { new CommodityClassificationType() { ItemClassificationCode = new ItemClassificationCodeType() { Value = "Catalogo 25 sunat" } } } }; #endregion #region Price Linea.Price = new PriceType() { PriceAmount = new PriceAmountType() { Value = Convert.ToDecimal(50), } }; #endregion } #endregion Items_Respuesta.Add(Linea); return(Items_Respuesta.ToArray()); }
private void FaturaOlustur(E_Fatura.Fatura FaturaBilgileri)//, List<E_Fatura.FaturaHareket> faturaHareketleri { InvoiceLineType[] FaturaHareketleri() { var x = 1; var lines = new List <InvoiceLineType>(); // var source = dataGridView1.Columns.Cast < FaturaHareketleri() >; // while (x >=30) // { var line = new InvoiceLineType { ID = new IDType { Value = x.ToString() }, Note = new[] { new NoteType { Value = "00001 - kkkkk" } }, InvoicedQuantity = new InvoicedQuantityType { unitCode = "C62", Value = 1 }, LineExtensionAmount = new LineExtensionAmountType { currencyID = "TRY", Value = 1000 }, AllowanceCharge = new[] { new AllowanceChargeType { ChargeIndicator = new ChargeIndicatorType { Value = false }, MultiplierFactorNumeric = new MultiplierFactorNumericType { Value = 10 }, Amount = new AmountType2 { currencyID = "TRY", Value = 100 }, BaseAmount = new BaseAmountType { currencyID = "TRY", Value = 1000 }, } }, TaxTotal = new TaxTotalType { TaxAmount = new TaxAmountType { currencyID = "TRY", Value = 180 }, TaxSubtotal = new[] { new TaxSubtotalType { TaxableAmount = new TaxableAmountType { currencyID = "TRY", Value = 1000 }, TaxAmount = new TaxAmountType { currencyID = "TRY", Value = 180 }, CalculationSequenceNumeric = new CalculationSequenceNumericType { Value = 1 }, Percent = new PercentType1 { Value = 18 }, TaxCategory = new TaxCategoryType { TaxScheme = new TaxSchemeType { TaxTypeCode = new TaxTypeCodeType { Value = "0015", name = "KDV" }, Name = new NameType1 { Value = "KDV" } }, } } } }, Item = new ItemType { Name = new NameType1 { Value = "Açıklama gir Stok Kod Adı neyin" } }, Price = new PriceType { PriceAmount = new PriceAmountType { currencyID = "TRY", Value = 200 } } }; // x++; lines.Add(line); // }; return(lines.ToArray()); }; var fatura = new InvoiceType { UBLVersionID = new UBLVersionIDType { Value = "2.1" }, CustomizationID = new CustomizationIDType { Value = "TR1.2" }, ProfileID = new ProfileIDType { Value = "TEMELFATURA" }, ID = new IDType { Value = FaturaBilgileri.FaturaNo }, CopyIndicator = new CopyIndicatorType { Value = false }, UUID = new UUIDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = FaturaBilgileri.Tarih }, IssueTime = new IssueTimeType { Value = FaturaBilgileri.Tarih }, InvoiceTypeCode = new InvoiceTypeCodeType { Value = "SATIS" }, // SATIS,IADE, Note = new[] { new NoteType { Value = "Açıklamalar" }, new NoteType { Value = "İş bu fatura muhteviyatına 7 gün içerisinde itiraz edilmediği taktirde aynen kabul edilmiş sayılır." }, new NoteType { Value = FaturaBilgileri.CariKod + " " + FaturaBilgileri.CariUnv } }, DocumentCurrencyCode = new DocumentCurrencyCodeType { Value = "TRY" }, LineCountNumeric = new LineCountNumericType { Value = 3 }, AdditionalDocumentReference = new[] { new DocumentReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = FaturaBilgileri.Tarih }, DocumentType = new DocumentTypeType { Value = "XSLT" }, Attachment = new AttachmentType { EmbeddedDocumentBinaryObject = new EmbeddedDocumentBinaryObjectType { characterSetCode = "UTF-8", encodingCode = "Base64", mimeCode = "application/xml", filename = "EArchiveInvoice.xslt", Value = Encoding.UTF8.GetBytes(new StreamReader(new FileStream(path: Application.StartupPath + "\\" + "EFatura.xslt", FileMode.Open, FileAccess.Read), Encoding.UTF8).ReadToEnd()) } } }, new DocumentReferenceType { ID = new IDType { Value = Guid.NewGuid().ToString() }, IssueDate = new IssueDateType { Value = FaturaBilgileri.Tarih }, DocumentTypeCode = new DocumentTypeCodeType { Value = "SendingType" }, DocumentType = new DocumentTypeType { Value = " ELEKTRONIK" } } }, Signature = new[] { new SignatureType { ID = new IDType { schemeID = "VKN_TCKN", Value = "7500263381" }, SignatoryParty = new PartyType { PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "7500263381" } } }, PostalAddress = new AddressType { Room = new RoomType { Value = "" }, BlockName = new BlockNameType { Value = "B Blok" }, BuildingName = new BuildingNameType { Value = "dd" }, BuildingNumber = new BuildingNumberType { Value = "35" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "Çanka" }, CityName = new CityNameType { Value = "ANAKATA" }, PostalZone = new PostalZoneType { Value = "78200" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } } }, DigitalSignatureAttachment = new AttachmentType { ExternalReference = new ExternalReferenceType { URI = new URIType { Value = "#Signature_" + FaturaBilgileri.FaturaNo } } } }, }, AccountingSupplierParty = new SupplierPartyType { Party = new PartyType { PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "VKN", Value = "7500263381" } }, new PartyIdentificationType { ID = new IDType { schemeID = "MERSISNO", Value = "368955457878" } }, }, PartyName = new PartyNameType { Name = new NameType1 { Value = "MSK YAZILIM" } }, PostalAddress = new AddressType { Room = new RoomType { Value = "" }, BlockName = new BlockNameType { Value = "B Blok" }, BuildingName = new BuildingNameType { Value = "dd" }, BuildingNumber = new BuildingNumberType { Value = "35" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "Çanka" }, CityName = new CityNameType { Value = "ANAKATA" }, PostalZone = new PostalZoneType { Value = "78200" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } }, WebsiteURI = new WebsiteURIType { Value = "www.mskyazilim.com" }, Contact = new ContactType { ElectronicMail = new ElectronicMailType { Value = "*****@*****.**" }, Telephone = new TelephoneType { Value = "05559963526" } }, PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KARABÜK VERGİ DAİRESİ" }, TaxTypeCode = new TaxTypeCodeType { Value = "078220" } } } }, }, AccountingCustomerParty = new CustomerPartyType { Party = new PartyType { PartyIdentification = new[] { new PartyIdentificationType { ID = new IDType { schemeID = "TCK", Value = "3498788" } }, }, PartyName = new PartyNameType { Name = new NameType1 { Value = "UZUNER PAZARLAMA" } }, PostalAddress = new AddressType { Room = new RoomType { Value = "" }, BlockName = new BlockNameType { Value = "C BLOK" }, BuildingName = new BuildingNameType { Value = "KEN" }, BuildingNumber = new BuildingNumberType { Value = "78" }, CitySubdivisionName = new CitySubdivisionNameType { Value = "ÜNİVERSİTE MAHALLESİ" }, CityName = new CityNameType { Value = "KARABÜK" }, PostalZone = new PostalZoneType { Value = "78200" }, Country = new CountryType { Name = new NameType1 { Value = "Türkiye" } } }, Contact = new ContactType { ElectronicMail = new ElectronicMailType { Value = "*****@*****.**" }, Telephone = new TelephoneType { Value = "037063526" } }, Person = new PersonType { FirstName = new FirstNameType { Value = "ISIM" }, FamilyName = new FamilyNameType { Value = "SOYISIM" } } // şahıslarda // PartyTaxScheme = new PartyTaxSchemeType { TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KARABÜK VERGİ DAİRESİ" }, TaxTypeCode = new TaxTypeCodeType { Value = "078220" } } }// Firmalarda }, }, TaxTotal = new[] { new TaxTotalType { TaxAmount = new TaxAmountType { Value = FaturaBilgileri.KdvTutar }, TaxSubtotal = new[] { new TaxSubtotalType { TaxableAmount = new TaxableAmountType { currencyID = "TRY", Value = FaturaBilgileri.NetTutar }, TaxAmount = new TaxAmountType { currencyID = "TRY", Value = FaturaBilgileri.KdvTutar }, CalculationSequenceNumeric = new CalculationSequenceNumericType { Value = 1 }, TransactionCurrencyTaxAmount = new TransactionCurrencyTaxAmountType { currencyID = "TRY", Value = FaturaBilgileri.KdvTutar }, Percent = new PercentType1 { Value = 18 }, // zorunlu değil TaxCategory = new TaxCategoryType { Name = new NameType1 { Value = "KDV" }, TaxScheme = new TaxSchemeType { Name = new NameType1 { Value = "KDV GERCEK" }, TaxTypeCode = new TaxTypeCodeType { Value = "0015" } } } } } } }, LegalMonetaryTotal = new MonetaryTotalType { LineExtensionAmount = new LineExtensionAmountType { currencyID = "TRY", Value = FaturaBilgileri.Tutar }, TaxExclusiveAmount = new TaxExclusiveAmountType { Value = FaturaBilgileri.NetTutar }, TaxInclusiveAmount = new TaxInclusiveAmountType { Value = FaturaBilgileri.ToplamTutar }, AllowanceTotalAmount = new AllowanceTotalAmountType { Value = FaturaBilgileri.Iskonto }, PayableAmount = new PayableAmountType { Value = FaturaBilgileri.ToplamTutar }, }, InvoiceLine = FaturaHareketleri() // InvoiceLine = FaturaHareketleri() }; var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }; var ms = new MemoryStream(); var write = XmlWriter.Create(ms, settings); var srl = new XmlSerializer(fatura.GetType()); srl.Serialize(write, fatura, XmlNameSpace()); ms.Flush(); ms.Seek(offset: 0, loc: SeekOrigin.Begin); var srRead = new StreamReader(ms); var readxml = srRead.ReadToEnd(); var path = Path.Combine(Application.StartupPath + "\\EFATURA\\" + fatura.ID.Value.ToString() + ".XML"); void FaturaOlus() { using (var sWrt = new StreamWriter(path, append: false, Encoding.UTF8)) { sWrt.Write(readxml); sWrt.Close(); } } if (!Directory.Exists(Application.StartupPath + "\\EFATURA")) { Directory.CreateDirectory(Application.StartupPath + "\\EFATURA"); } if (!File.Exists(Application.StartupPath + "\\EFATURA\\" + fatura.ID.Value.ToString() + ".XML")) { FaturaOlus(); } else if (MessageBox.Show("Dosya Daha önce var", "Dikka", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { FaturaOlus(); } XmlSerializerNamespaces XmlNameSpace() { var ns = new XmlSerializerNamespaces(); ns.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"); ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); ns.Add("xades", "http://uri.etsi.org/01903/v1.3.2#"); ns.Add("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"); ns.Add("ubltr", "urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents"); ns.Add("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"); ns.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); ns.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"); ns.Add("ccts", "urn:un:unece:uncefact:documentation:2"); ns.Add("ds", "http://www.w3.org/2000/09/xmldsig#"); return(ns); } }
public static InvoiceType Create() { string file = @"D:\temp\ROM\MultiJson\1_0014_ 12007011905_Invoice.json"; StreamReader r = new StreamReader(file); string jsonInvoice = r.ReadToEnd(); var invObject = JsonConvert.DeserializeObject <Rootobject>(jsonInvoice); var doc = new InvoiceType { UBLVersionID = "2.1", ID = invObject.Cards[0].InvoiceNumber.Trim(), IssueDate = "2009-12-15", InvoiceTypeCode = new CodeType { listID = "UN/ECE 1001 Subset", listAgencyID = "6", Value = "380" }, Note = new List <TextType>() { new TextType { languageID = "en", Value = "Ordered in our booth at the convention." } }, //TaxPointDate = "2009-11-30", //DocumentCurrencyCode = new CodeType //{ // listID = "ISO 4217 Alpha", // listAgencyID = "6", // Value = "EUR" //}, //AccountingCost = "Project cost code 123", InvoicePeriod = new List <PeriodType>() { new PeriodType { StartDate = "2009-11-01", EndDate = "2009-11-30" } }, OrderReference = new OrderReferenceType { ID = "123" }, //ContractDocumentReference = new List<DocumentReferenceType>() //{ // new DocumentReferenceType // { // ID = "Contract321", // DocumentType = "Framework agreement" // } //}, //AdditionalDocumentReference = new List<DocumentReferenceType>(), //AccountingSupplierParty = new SupplierPartyType(), //AccountingCustomerParty = new CustomerPartyType(), //PayeeParty = new PartyType(), Delivery = new List <DeliveryType>() { new DeliveryType { ActualDeliveryDate = "2009-12-15", DeliveryLocation = new LocationType { ID = new IdentifierType { schemeID = "GLN", schemeAgencyID = "9", Value = "6754238987648" }, Address = new AddressType { StreetName = "Deliverystreet", AdditionalStreetName = "Side door", BuildingNumber = "12", CityName = "DeliveryCity", PostalZone = "523427", CountrySubentity = "RegionC", Country = new CountryType { IdentificationCode = "BE" } } } } }, PaymentMeans = new List <PaymentMeansType>() { new PaymentMeansType { PaymentMeansCode = new CodeType { listID = "UN/ECE 4461", Value = "31" }, PaymentDueDate = "2009-12-31", PaymentChannelCode = "IBAN", PaymentID = new List <IdentifierType>() { new IdentifierType { Value = "Payref1" } }, PayeeFinancialAccount = new FinancialAccountType { ID = "DK1212341234123412", FinancialInstitutionBranch = new BranchType { FinancialInstitution = new FinancialInstitutionType { ID = "DKDKABCD" } } } } }, PaymentTerms = new List <PaymentTermsType>(), AllowanceCharge = new List <AllowanceChargeType>(), TaxTotal = new List <TaxTotalType>() { new TaxTotalType { TaxAmount = new AmountType { currencyID = "EUR", Value = 292.20M }, TaxSubtotal = new List <TaxSubtotalType>() { new TaxSubtotalType { TaxableAmount = new AmountType { currencyID = "EUR", Value = 1460.5M }, TaxAmount = new AmountType { currencyID = "EUR", Value = 292.1M }, TaxCategory = new TaxCategoryType { ID = new IdentifierType { schemeID = "UN/ECE 5305", schemeAgencyID = "6", Value = "S" }, Percent = 20M, TaxScheme = new TaxSchemeType { ID = new IdentifierType { schemeID = "UN/ECE 5153", schemeAgencyID = "6", Value = "VAT" } } } }, new TaxSubtotalType { TaxableAmount = new AmountType { currencyID = "EUR", Value = 1M }, TaxAmount = new AmountType { currencyID = "EUR", Value = 0.1M }, TaxCategory = new TaxCategoryType { ID = new IdentifierType { schemeID = "UN/ECE 5305", schemeAgencyID = "6", Value = "AA" }, Percent = 10M, TaxScheme = new TaxSchemeType { ID = new IdentifierType { schemeID = "UN/ECE 5153", schemeAgencyID = "6", Value = "VAT" } } } }, new TaxSubtotalType { TaxableAmount = new AmountType { currencyID = "EUR", Value = -25M }, TaxAmount = new AmountType { currencyID = "EUR", Value = 0M }, TaxCategory = new TaxCategoryType { ID = new IdentifierType { schemeID = "UN/ECE 5305", schemeAgencyID = "6", Value = "E" }, Percent = 0M, TaxExemptionReasonCode = new CodeType { listID = "CWA 15577", listAgencyID = "ZZZ", Value = "AAM" }, TaxExemptionReason = new List <TextType>() { new TextType { Value = "Exempt New Means of Transport" } }, TaxScheme = new TaxSchemeType { ID = new IdentifierType { schemeID = "UN/ECE 5153", schemeAgencyID = "6", Value = "VAT" } } } } }, } }, LegalMonetaryTotal = new MonetaryTotalType() //, //InvoiceLine = new List<InvoiceLineType>() //{ // new InvoiceLineType // { // ID = "1", // Note = new List<TextType>() // { // new TextType // { // Value = "Scratch on box" // } // }, // InvoicedQuantity = new QuantityType // { // unitCode = "C62", // Value = 1M // }, // LineExtensionAmount = new AmountType // { // currencyID = "EUR", // Value = 1273M // }, // AccountingCost = "BookingCode001", // OrderLineReference = new List<OrderLineReferenceType>() // { // new OrderLineReferenceType // { // LineID = "1" // } // }, // AllowanceCharge = new List<AllowanceChargeType>() // { // new AllowanceChargeType // { // ChargeIndicator = false, // AllowanceChargeReason = new List<TextType>() // { // new TextType // { // Value = "Damage" // } // }, // Amount = new AmountType // { // currencyID = "EUR", // Value = 12M // } // }, // new AllowanceChargeType // { // ChargeIndicator = true, // AllowanceChargeReason = new List<TextType>() // { // new TextType // { // Value = "Testing" // } // }, // Amount = new AmountType // { // currencyID = "EUR", // Value = 10M // } // } // }, // TaxTotal = new List<TaxTotalType>() // { // new TaxTotalType // { // TaxAmount = new AmountType // { // currencyID = "EUR", // Value = 254.6M // } // } // }, // Item = new ItemType // { // Description = new List<TextType>() // { // new TextType // { // languageID = "EN", // Value = @"Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM:3MB. Screen 1440x900" // } // }, // Name = "Labtop computer", // SellersItemIdentification = new ItemIdentificationType // { // ID = "JB007" // }, // StandardItemIdentification = new ItemIdentificationType // { // ID = new IdentifierType // { // schemeID = "GTIN", // schemeAgencyID = "9", // Value = "1234567890124" // } // }, // CommodityClassification = new List<CommodityClassificationType>() // { // new CommodityClassificationType // { // ItemClassificationCode = new CodeType // { // listAgencyID = "113", // listID = "UNSPSC", // Value = "12344321" // } // }, // new CommodityClassificationType // { // ItemClassificationCode = new CodeType // { // listAgencyID = "2", // listID = "CPV", // Value = "65434568" // } // } // }, // ClassifiedTaxCategory = new List<TaxCategoryType>() // { // new TaxCategoryType // { // ID = new IdentifierType // { // schemeID = "UN/ECE 5305", // schemeAgencyID = "6", // Value = "S" // }, // Percent = 20M, // TaxScheme = new TaxSchemeType // { // ID = new IdentifierType // { // schemeID = "UN/ECE 5153", // schemeAgencyID = "6", // Value = "VAT" // } // } // } // }, // AdditionalItemProperty = new List<ItemPropertyType>() // { // new ItemPropertyType // { // Name = "Color", // Value = "black" // } // }, // }, // Price = new PriceType // { // PriceAmount = new AmountType // { // currencyID = "EUR", // Value = 1273M // }, // BaseQuantity = new QuantityType // { // unitCode = "C62", // Value = 1M // }, // AllowanceCharge = new List<AllowanceChargeType>() // { // new AllowanceChargeType // { // ChargeIndicator = false, // AllowanceChargeReason = new List<TextType>() // { // new TextType // { // Value = "Contract" // } // }, // MultiplierFactorNumeric = 0.15M, // Amount = new AmountType // { // currencyID = "EUR", // Value = 225M // }, // BaseAmount = new AmountType // { // currencyID = "EUR", // Value = 1500M // } // } // }, // } // }, // new InvoiceLineType // { // ID = "2", // Note = new List<TextType>() // { // new TextType // { // Value = "Cover is slightly damaged." // } // }, // InvoicedQuantity = new QuantityType // { // unitCode = "C62", // Value = -1M // }, // LineExtensionAmount = new AmountType // { // currencyID = "EUR", // Value = -3.96M // }, // OrderLineReference = new List<OrderLineReferenceType>() // { // new OrderLineReferenceType // { // LineID = "5" // } // }, // TaxTotal = new List<TaxTotalType>() // { // new TaxTotalType // { // TaxAmount = new AmountType // { // currencyID = "EUR", // Value = -0.396M // } // } // }, // Item = new ItemType // { // Name = "Returned \"Advanced computing\" book", // SellersItemIdentification = new ItemIdentificationType // { // ID = "JB008" // }, // StandardItemIdentification = new ItemIdentificationType // { // ID = new IdentifierType // { // schemeID = "GTIN", // schemeAgencyID = "9", // Value = "1234567890125" // } // }, // CommodityClassification = new List<CommodityClassificationType>() // { // new CommodityClassificationType // { // ItemClassificationCode = new CodeType // { // listAgencyID = "113", // listID = "UNSPSC", // Value = "32344324" // } // }, // new CommodityClassificationType // { // ItemClassificationCode = new CodeType // { // listAgencyID = "2", // listID = "CPV", // Value = "65434567" // } // } // }, // ClassifiedTaxCategory = new List<TaxCategoryType>() // { // new TaxCategoryType // { // ID = new IdentifierType // { // schemeID = "UN/ECE 5305", // schemeAgencyID = "6", // Value = "AA" // }, // Percent = 10M, // TaxScheme = new TaxSchemeType // { // ID = new IdentifierType // { // schemeID = "UN/ECE 5153", // schemeAgencyID = "6", // Value = "VAT" // } // } // } // }, // }, // Price = new PriceType // { // PriceAmount = new AmountType // { // currencyID = "EUR", // Value = 3.96M // }, // BaseQuantity = new QuantityType // { // unitCode = "C62", // Value = 1M // } // } // } //} , }; doc.InvoiceLine = new List <InvoiceLineType>(); foreach (var lineItem in invObject.Cards[0].Items.InvoiceRows) { var invLine = new InvoiceLineType() { ID = lineItem.RowId.ToString(), InvoicedQuantity = new QuantityType() { unitCode = "", Value = 1 }, LineExtensionAmount = new AmountType() { Value = decimal.Parse(lineItem.Netto.Replace(",", ".")) } }; doc.InvoiceLine.Add(invLine); } doc.Xmlns = new System.Xml.Serialization.XmlSerializerNamespaces(new[] { new XmlQualifiedName("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"), new XmlQualifiedName("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"), }); return(doc); }