@TescilsizUzman Teşekkür ederim...
xmlOkuYaz uygulamasından ilham alarak E-Fatura içeriğini okuduk..
Küçük bir katkı da bizden olsun
Forma bir Memo, detay için de bir Strring grid koymanız yeterli...
xmlOkuYaz uygulamasından ilham alarak E-Fatura içeriğini okuduk..
Küçük bir katkı da bizden olsun
Forma bir Memo, detay için de bir Strring grid koymanız yeterli...
Kod: (Select All)
const
sFile = 'C:\Users\yazilim\Desktop\E092022000000732.xml'; //'C:\Users\idealist\Desktop\_iki_kalem.xml'; //'C:\Users\yazilim\Desktop\E092022000000732.xml'
procedure GetGonderenDetay( ANode : IXMLNode; ATitle : string = '' );
var
tmpNode : IXMLNode;
sAttributes,
sBaslik,
sDetay : string;
begin
Girinti := Girinti + 3;
tmpNode := ANode.ChildNodes.First;
repeat
if Assigned(tmpNode) then
begin
if (tmpNode.IsTextElement = true) Then
Begin
sAttributes := '';
if tmpNode.HasAttribute('schemeID') then
sAttributes := tmpNode.AttributeNodes.FindNode('schemeID').Text;
//sAttributes := ' ( Att : ' + tmpNode.AttributeNodes.FindNode('schemeID').Text + ' ) ';
//COUNT ile kontrol etmek için
//sAttributes := tmpNode.AttributeNodes.Get(0).Text;
(*
Form1.Memo1.Lines.Add( BoslukAt(Girinti)+ ' : '+tmpNode.LocalName+ ' -> '+
//' nodeName: '+ tmpNode.NodeName +
//' nodeValue: '+ tmpNode.NodeValue +
//' nodeXML:'+ tmpNode.XML +
sAttributes +
' Text: '+ tmpNode.Text);
*)
if sAttributes <> '' then
sBaslik := sAttributes
else
sBaslik := tmpNode.LocalName;
if Pos('cbc:',tmpNode.NodeName) > 0 then
sBaslik := ATitle + ' - ' + sBaslik;
sDetay := tmpNode.Text;
Form1.Memo1.Lines.Add( ' ' + sBaslik + ' : '+ sDetay); //+ ' T: ' + ATitle + ' T2 ' + tmpNode.NodeName+ ' ' );
End
Else
Begin
//Form1.Memo1.Lines.Add(BoslukAt(Girinti)+'- '+ tmpNode.LocalName);
GetGonderenDetay(tmpNode, Copy(tmpNode.NodeName, 5, Length(tmpNode.NodeName)) );
End;
tmpNode := tmpNode.NextSibling;//bir sonraki node ye atla...
end;
until tmpNode = Nil;
end;
procedure GetAliciDetay( ANode : IXMLNode; ATitle : string = '' );
var
tmpNode : IXMLNode;
sAttributes,
sBaslik,
sDetay,
sFaturaNo,
sVergiNo : string;
begin
Girinti := Girinti + 3;
tmpNode := ANode.ChildNodes.First;
repeat
if Assigned(tmpNode) then
begin
if (tmpNode.IsTextElement = true) Then
Begin
sAttributes := '';
if tmpNode.HasAttribute('schemeID') then
sAttributes := tmpNode.AttributeNodes.FindNode('schemeID').Text;
if sAttributes <> '' then
sBaslik := sAttributes
else
sBaslik := tmpNode.LocalName;
if Pos('cbc:',tmpNode.NodeName) > 0 then
sBaslik := ATitle + ' - ' + sBaslik;
sDetay := tmpNode.Text;
Form1.Memo1.Lines.Add( ' ' + sBaslik + ' : '+ sDetay); //+ ' T: ' + ATitle + ' T2 ' + tmpNode.NodeName+ ' ' );
End
Else
Begin
GetAliciDetay(tmpNode, Copy(tmpNode.NodeName, 5, Length(tmpNode.NodeName)) );
End;
tmpNode := tmpNode.NextSibling;//bir sonraki node ye atla...
end;
until tmpNode = Nil;
end;
const
colSira = 1;
colUrunKod = 2;
colBarkod = 3;
colUrunAdi = 4;
colMiktar = 5;
colBirim = 6;
colBirimFiyat = 7;
colDovizTipi = 8;
colKdvOran = 9;
colTutar = 10;
procedure TForm1.SetGrid;
begin
StringGrid1.ColCount := 11;
StringGrid1.RowCount := 2;
StringGrid1.Rows[1].Clear;
StringGrid1.Cols[colSira].Text := 'Sıra';
StringGrid1.Cols[colUrunKod].Text := 'Stok Kodu';
StringGrid1.Cols[colBarkod].Text := 'Barkod';
StringGrid1.Cols[colUrunAdi].Text := 'Stok Adı';
StringGrid1.Cols[colMiktar].Text := 'Miktar';
StringGrid1.Cols[colBirim].Text := 'Birim Kodu';
StringGrid1.Cols[colBirimFiyat].Text := 'Fiyat';
StringGrid1.Cols[colDovizTipi].Text := 'PB';
StringGrid1.Cols[colKdvOran].Text := 'KDV %';
StringGrid1.Cols[colTutar].Text := 'Tutar';
StringGrid1.ColWidths[0] := 10;
StringGrid1.ColWidths[colSira] := 35;
StringGrid1.ColWidths[colUrunKod] := 80;
StringGrid1.ColWidths[colBarkod] := 80;
StringGrid1.ColWidths[colUrunAdi] := 150;
StringGrid1.ColWidths[colMiktar] := 50;
StringGrid1.ColWidths[colBirim] := 50;
StringGrid1.ColWidths[colBirimFiyat] := 70;
StringGrid1.ColWidths[colDovizTipi] := 50;
StringGrid1.ColWidths[colKdvOran] := 50;
StringGrid1.ColWidths[colTutar] := 70;
end;
procedure GetSatir( ANode : IXMLNode; ATitle : string = '' );
var
tmpNode,
tmpSubNode,
tmpSubNode2 : IXMLNode;
sAttributes,
sBaslik,
sDetay,
sFaturaNo,
sVergiNo : string;
iRow : integer;
tmpGrd : TStringGrid;
begin
tmpNode := ANode.ChildNodes.First;
tmpGrd := Form1.StringGrid1;
iRow := tmpGrd.RowCount-1;
//tmpGrd.Cells[ colSira, iRow ] := tmpNode.ChildNodes.FindNode('cbc:ID').Text;
//tmpGrd.Cells[ colMiktar, iRow ] := tmpNode.ChildNodes.FindNode('cbc:InvoicedQuantity').Text;
//tmpGrd.Cells[ colUrunKod, iRow ] := tmpNode.ChildNodes.FindNode('cac:Item').ChildNodes.FindNode('cbc:Name').Text;
//tmpGrd.Cells[ colUrunAdi, iRow ] := tmpNode.ChildNodes.FindNode('cac:Item').ChildNodes.FindNode('cac:SellersItemIdentification').ChildNodes.FindNode('cbc:ID').Text;
repeat
if Assigned(tmpNode) then
begin
//if (tmpNode.IsTextElement = True) Then
begin
if ( tmpNode.NodeName = 'cbc:ID' ) and ( tmpNode.ParentNode.NodeName = 'cac:InvoiceLine' ) then //SIRA NO
begin
tmpGrd.Cells[ colSira, iRow ] := tmpNode.Text;
end
else if tmpNode.NodeName = 'cbc:InvoicedQuantity' then
begin
tmpGrd.Cells[ colMiktar, iRow ] := tmpNode.Text;
if tmpNode.HasAttribute('unitCode') then
tmpGrd.Cells[ colBirim, iRow ] := tmpNode.AttributeNodes.FindNode('unitCode').Text;
end
(*
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="C62">1</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="TRY">7350.7</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="TRY">588.06</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="TRY">7350.7</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="TRY">588.06</cbc:TaxAmount>
<cbc:Percent>8</cbc:Percent>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:Name>GERÇEK USULDE KATMA DEĞER VERGİSİ</cbc:Name>
<cbc:TaxTypeCode>0015</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Name>EĞİTİM BEDELİ</cbc:Name>
<cac:SellersItemIdentification>
<cbc:ID>UMSTJ</cbc:ID>
</cac:SellersItemIdentification>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="TRY">7350.7</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
*)
else if tmpNode.NodeName = 'cac:TaxTotal' then
begin
tmpSubNode := tmpNode.ChildNodes['cac:TaxSubtotal'].ChildNodes.First;
repeat
if Assigned(tmpSubNode) then
begin
if tmpSubNode.NodeName = 'cbc:TaxAmount' then
begin
tmpGrd.Cells[ colBirimFiyat, iRow ] := tmpSubNode.Text;
if tmpSubNode.HasAttribute('currencyID') then
tmpGrd.Cells[ colDovizTipi, iRow ] := tmpSubNode.AttributeNodes.FindNode('currencyID').Text;
end
else if tmpSubNode.NodeName = 'cbc:Percent' then
begin
tmpGrd.Cells[ colKdvOran, iRow ] := tmpSubNode.Text;
end
else if tmpSubNode.NodeName = 'cbc:TaxableAmount' then
begin
tmpGrd.Cells[ colTutar, iRow ] := tmpSubNode.Text;
end;
end;
tmpSubNode := tmpSubNode.NextSibling;//bir sonraki node ye atla...
until tmpSubNode = Nil;
end
else if tmpNode.NodeName = 'cac:Item' then
begin
tmpSubNode := tmpNode.ChildNodes.First;
repeat
if Assigned(tmpSubNode) then
begin
if tmpSubNode.NodeName = 'cac:SellersItemIdentification' then
begin
tmpSubNode2 := tmpSubNode.ChildNodes.First;
tmpGrd.Cells[ colUrunKod, iRow ] := tmpSubNode2.Text; // tmpSubNode.ChildNodes['cbc:ID'].Text;
end
else if tmpSubNode.NodeName = 'cac:ManufacturersItemIdentification' then
begin
tmpSubNode2 := tmpSubNode.ChildNodes.First;
tmpGrd.Cells[ colBarkod, iRow ] := tmpSubNode2.Text; //tmpSubNode.ChildNodes['cbc:ID'].Text;
end
else if tmpSubNode.NodeName = 'cbc:Name' then
begin
tmpGrd.Cells[ colUrunAdi, iRow ] := tmpSubNode.Text;
end;
end;
tmpSubNode := tmpSubNode.NextSibling;//bir sonraki node ye atla...
until tmpSubNode = Nil;
end;
end;
//else
begin
//GetSatir(tmpNode );
end;
tmpNode := tmpNode.NextSibling;//bir sonraki node ye atla...
end;
until tmpNode = Nil;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
D : IXMLDocument;
ANode: IXMLNode;
begin
SetGrid;
memo1.Lines.Clear;
D:= LoadXMLDocument(sFile);
D.Active := True ;
ANode:=D.DocumentElement.ChildNodes.First; // ilk node invoice tir
repeat
if Assigned(ANode)Then
begin
if (ANode.IsTextElement = False) Then
begin
if ANode.NodeName = 'cac:AccountingSupplierParty' then
begin
Memo1.Lines.Add( '------------ GÖNDERİCİ BİLGİLERİ -----------------------');
GetGonderenDetay( ANode );
Memo1.Lines.Add( '------------------------------------------------------------');
end;
if ANode.NodeName = 'cac:AccountingCustomerParty' then
begin
Memo1.Lines.Add( '');
Memo1.Lines.Add( '------------ ALICI BİLGİLERİ -----------------------');
GetAliciDetay( ANode );
Memo1.Lines.Add( '------------------------------------------------------------');
end;
if ANode.NodeName = 'cac:InvoiceLine' then
begin
//Memo1.Lines.Add( '');
//Memo1.Lines.Add( '------------ SATIR BİLGİLERİ -----------------------');
GetSatir( ANode );
Form1.StringGrid1.RowCount := Form1.StringGrid1.RowCount + 1;
//Memo1.Lines.Add( '------------------------------------------------------------');
end;
end;
ANode := ANode.NextSibling;//bir sonraki node ye atla...
End;
until ANode=Nil;
Form1.StringGrid1.RowCount := Form1.StringGrid1.RowCount - 1;
end;
Girdim İlim Meclisine,
Eyledim Kıldım Talep,
Dediler İlim Geride,
İlla Edep İlla Edep.
Yunus Emre
Eyledim Kıldım Talep,
Dediler İlim Geride,
İlla Edep İlla Edep.
Yunus Emre