Tworzenie i walidacja plików xml

0

Witam serdecznie. Jakiś czas temu zasięgałem porad w związku z plikiem JPK (wtedy tworzyłem JPK_VAT). Teraz tworzę plik JPK_FA i napotkałem na inny problem. Wartości logiczne występujące w pliku, Delphi zapisuje mi z dużej litery (True, False), a walidator zarówno ten z mojego programu, jak i aplikacji MF oczekuje małych liter (true, false). Pliku nie tworzę na piechotę, lecz korzystam z unit-u Schemat_JPK_FA1_v10.dcu. Podmiana na koniec w całym pliku stosownych ciągów do dodatkowy czas (przy większej ilości danych to może trochę trwać. Jak to podmienić jak najprościej?

with jpk.Faktura do
  for i:=1 to table14.recordcount do
  begin
   Add.Typ:='G';
   ...
   ...  
   ...
   Items[i-1].P_16:=false;
   Items[i-1].P_17:=false;
   Items[i-1].P_18:=false; 
   Items[i-1].P_19:=false; 
 ...

Przed zapisem na dysk przypisuję:

xml.DocumentElement:=jpk;
xml.SaveToFile(edit1.text);

Czyli w efekcie chciałem mieć:

<P_16>false</P_16>

<P_17>false</P_17>

<P_18>false</P_18>

<P_19>false</P_19>

a nie:

<P_16>False</P_16>

<P_17>False</P_17>

<P_18>False</P_18>

<P_19>False</P_19>

Liczę na wskazówkę. Pozdrawiam.

0

a co to jest za cudo Schemat_JPK_FA1_v10.dcu bo google tego nie zna

0

Przypadkowo skopiowałem nazwę z rozszerzeniem. Jest to unit, który wygenerowałem w delphi na podstawie schematu Schemat_JPK_FA(1)_v1-0.xsd (File -> New -> Other -> XML Data Binding).


{*******************************************************}
{                                                       }
{                   XML Data Binding                    }
{                                                       }
{         Generated on: 2017-09-04 00:26:08             }
{       Generated from: F:\Schemat_JPK_FA(1)_v1-0.xsd   }
{   Settings stored in: F:\Schemat_JPK_FA(1)_v1-0.xdb   }
{                                                       }
{*******************************************************}

unit Schemat_JPK_FA1_v10;

interface

uses xmldom, XMLDoc, XMLIntf;

type

{ Forward Decls }

  IXMLJPK = interface;
  IXMLTNaglowek = interface;
  IXMLPodmiot1 = interface;
  IXMLTIdentyfikatorOsobyNiefizycznej = interface;
  IXMLTAdresPolski = interface;
  IXMLFaktura = interface;
  IXMLFakturaList = interface;
  IXMLFakturaCtrl = interface;
  IXMLStawkiPodatku = interface;
  IXMLFakturaWiersz = interface;
  IXMLFakturaWierszList = interface;
  IXMLFakturaWierszCtrl = interface;
  IXMLNaglowek = interface;
  IXMLKodFormularza = interface;

{ IXMLJPK }

  IXMLJPK = interface(IXMLNode)
    ['{2FD31BC1-A612-4C00-8BAB-F7CCE9618F95}']
    { Property Accessors }
    function Get_Naglowek: IXMLNaglowek;
    function Get_Podmiot1: IXMLPodmiot1;
    function Get_Faktura: IXMLFakturaList;
    function Get_FakturaCtrl: IXMLFakturaCtrl;
    function Get_StawkiPodatku: IXMLStawkiPodatku;
    function Get_FakturaWiersz: IXMLFakturaWierszList;
    function Get_FakturaWierszCtrl: IXMLFakturaWierszCtrl;
    { Methods & Properties }
    property Naglowek: IXMLNaglowek read Get_Naglowek;
    property Podmiot1: IXMLPodmiot1 read Get_Podmiot1;
    property Faktura: IXMLFakturaList read Get_Faktura;
    property FakturaCtrl: IXMLFakturaCtrl read Get_FakturaCtrl;
    property StawkiPodatku: IXMLStawkiPodatku read Get_StawkiPodatku;
    property FakturaWiersz: IXMLFakturaWierszList read Get_FakturaWiersz;
    property FakturaWierszCtrl: IXMLFakturaWierszCtrl read Get_FakturaWierszCtrl;
  end;

{ IXMLTNaglowek }

  IXMLTNaglowek = interface(IXMLNode)
    ['{87F69DB3-9C42-4AFC-9E6E-A8EF730B5B8E}']
    { Property Accessors }
    function Get_KodFormularza: IXMLKodFormularza;
    function Get_WariantFormularza: ShortInt;
    function Get_CelZlozenia: ShortInt;
    function Get_DataWytworzeniaJPK: WideString;
    function Get_DataOd: WideString;
    function Get_DataDo: WideString;
    function Get_DomyslnyKodWaluty: WideString;
    function Get_KodUrzedu: WideString;
    procedure Set_WariantFormularza(Value: ShortInt);
    procedure Set_CelZlozenia(Value: ShortInt);
    procedure Set_DataWytworzeniaJPK(Value: WideString);
    procedure Set_DataOd(Value: WideString);
    procedure Set_DataDo(Value: WideString);
    procedure Set_DomyslnyKodWaluty(Value: WideString);
    procedure Set_KodUrzedu(Value: WideString);
    { Methods & Properties }
    property KodFormularza: IXMLKodFormularza read Get_KodFormularza;
    property WariantFormularza: ShortInt read Get_WariantFormularza write Set_WariantFormularza;
    property CelZlozenia: ShortInt read Get_CelZlozenia write Set_CelZlozenia;
    property DataWytworzeniaJPK: WideString read Get_DataWytworzeniaJPK write Set_DataWytworzeniaJPK;
    property DataOd: WideString read Get_DataOd write Set_DataOd;
    property DataDo: WideString read Get_DataDo write Set_DataDo;
    property DomyslnyKodWaluty: WideString read Get_DomyslnyKodWaluty write Set_DomyslnyKodWaluty;
    property KodUrzedu: WideString read Get_KodUrzedu write Set_KodUrzedu;
  end;

{ IXMLPodmiot1 }

  IXMLPodmiot1 = interface(IXMLNode)
    ['{C5114DDF-B26F-4F85-B720-25BC7C652EFF}']
    { Property Accessors }
    function Get_IdentyfikatorPodmiotu: IXMLTIdentyfikatorOsobyNiefizycznej;
    function Get_AdresPodmiotu: IXMLTAdresPolski;
    { Methods & Properties }
    property IdentyfikatorPodmiotu: IXMLTIdentyfikatorOsobyNiefizycznej read Get_IdentyfikatorPodmiotu;
    property AdresPodmiotu: IXMLTAdresPolski read Get_AdresPodmiotu;
  end;

{ IXMLTIdentyfikatorOsobyNiefizycznej }

  IXMLTIdentyfikatorOsobyNiefizycznej = interface(IXMLNode)
    ['{264E1238-68E8-40F3-8551-AAB81092C0A6}']
    { Property Accessors }
    function Get_NIP: WideString;
    function Get_PelnaNazwa: WideString;
    function Get_REGON: WideString;
    procedure Set_NIP(Value: WideString);
    procedure Set_PelnaNazwa(Value: WideString);
    procedure Set_REGON(Value: WideString);
    { Methods & Properties }
    property NIP: WideString read Get_NIP write Set_NIP;
    property PelnaNazwa: WideString read Get_PelnaNazwa write Set_PelnaNazwa;
    property REGON: WideString read Get_REGON write Set_REGON;
  end;

{ IXMLTAdresPolski }

  IXMLTAdresPolski = interface(IXMLNode)
    ['{8551C572-5F22-4AD2-903E-1E25C962BCC0}']
    { Property Accessors }
    function Get_KodKraju: WideString;
    function Get_Wojewodztwo: WideString;
    function Get_Powiat: WideString;
    function Get_Gmina: WideString;
    function Get_Ulica: WideString;
    function Get_NrDomu: WideString;
    function Get_NrLokalu: WideString;
    function Get_Miejscowosc: WideString;
    function Get_KodPocztowy: WideString;
    function Get_Poczta: WideString;
    procedure Set_KodKraju(Value: WideString);
    procedure Set_Wojewodztwo(Value: WideString);
    procedure Set_Powiat(Value: WideString);
    procedure Set_Gmina(Value: WideString);
    procedure Set_Ulica(Value: WideString);
    procedure Set_NrDomu(Value: WideString);
    procedure Set_NrLokalu(Value: WideString);
    procedure Set_Miejscowosc(Value: WideString);
    procedure Set_KodPocztowy(Value: WideString);
    procedure Set_Poczta(Value: WideString);
    { Methods & Properties }
    property KodKraju: WideString read Get_KodKraju write Set_KodKraju;
    property Wojewodztwo: WideString read Get_Wojewodztwo write Set_Wojewodztwo;
    property Powiat: WideString read Get_Powiat write Set_Powiat;
    property Gmina: WideString read Get_Gmina write Set_Gmina;
    property Ulica: WideString read Get_Ulica write Set_Ulica;
    property NrDomu: WideString read Get_NrDomu write Set_NrDomu;
    property NrLokalu: WideString read Get_NrLokalu write Set_NrLokalu;
    property Miejscowosc: WideString read Get_Miejscowosc write Set_Miejscowosc;
    property KodPocztowy: WideString read Get_KodPocztowy write Set_KodPocztowy;
    property Poczta: WideString read Get_Poczta write Set_Poczta;
  end;

{ IXMLFaktura }

  IXMLFaktura = interface(IXMLNode)
    ['{CB97E3B1-7DBB-4E13-A50A-25673CABFC56}']
    { Property Accessors }
    function Get_Typ: WideString;
    function Get_P_1: WideString;
    function Get_P_2A: WideString;
    function Get_P_3A: WideString;
    function Get_P_3B: WideString;
    function Get_P_3C: WideString;
    function Get_P_3D: WideString;
    function Get_P_4A: WideString;
    function Get_P_4B: WideString;
    function Get_P_5A: WideString;
    function Get_P_5B: WideString;
    function Get_P_6: WideString;
    function Get_P_13_1: WideString;
    function Get_P_14_1: WideString;
    function Get_P_13_2: WideString;
    function Get_P_14_2: WideString;
    function Get_P_13_3: WideString;
    function Get_P_14_3: WideString;
    function Get_P_13_4: WideString;
    function Get_P_14_4: WideString;
    function Get_P_13_5: WideString;
    function Get_P_14_5: WideString;
    function Get_P_13_6: WideString;
    function Get_P_13_7: WideString;
    function Get_P_15: WideString;
    function Get_P_16: Boolean;
    function Get_P_17: Boolean;
    function Get_P_18: Boolean;
    function Get_P_19: Boolean;
    function Get_P_19A: WideString;
    function Get_P_19B: WideString;
    function Get_P_19C: WideString;
    function Get_P_20: Boolean;
    function Get_P_20A: WideString;
    function Get_P_20B: WideString;
    function Get_P_21: Boolean;
    function Get_P_21A: WideString;
    function Get_P_21B: WideString;
    function Get_P_21C: WideString;
    function Get_P_22A: WideString;
    function Get_P_22B: WideString;
    function Get_P_22C: WideString;
    function Get_P_23: Boolean;
    function Get_P_106E_2: Boolean;
    function Get_P_106E_3: Boolean;
    function Get_P_106E_3A: WideString;
    function Get_RodzajFaktury: WideString;
    function Get_PrzyczynaKorekty: WideString;
    function Get_NrFaKorygowanej: WideString;
    function Get_OkresFaKorygowanej: WideString;
    function Get_ZALZaplata: WideString;
    function Get_ZALPodatek: WideString;
    procedure Set_Typ(Value: WideString);
    procedure Set_P_1(Value: WideString);
    procedure Set_P_2A(Value: WideString);
    procedure Set_P_3A(Value: WideString);
    procedure Set_P_3B(Value: WideString);
    procedure Set_P_3C(Value: WideString);
    procedure Set_P_3D(Value: WideString);
    procedure Set_P_4A(Value: WideString);
    procedure Set_P_4B(Value: WideString);
    procedure Set_P_5A(Value: WideString);
    procedure Set_P_5B(Value: WideString);
    procedure Set_P_6(Value: WideString);
    procedure Set_P_13_1(Value: WideString);
    procedure Set_P_14_1(Value: WideString);
    procedure Set_P_13_2(Value: WideString);
    procedure Set_P_14_2(Value: WideString);
    procedure Set_P_13_3(Value: WideString);
    procedure Set_P_14_3(Value: WideString);
    procedure Set_P_13_4(Value: WideString);
    procedure Set_P_14_4(Value: WideString);
    procedure Set_P_13_5(Value: WideString);
    procedure Set_P_14_5(Value: WideString);
    procedure Set_P_13_6(Value: WideString);
    procedure Set_P_13_7(Value: WideString);
    procedure Set_P_15(Value: WideString);
    procedure Set_P_16(Value: Boolean);
    procedure Set_P_17(Value: Boolean);
    procedure Set_P_18(Value: Boolean);
    procedure Set_P_19(Value: Boolean);
    procedure Set_P_19A(Value: WideString);
    procedure Set_P_19B(Value: WideString);
    procedure Set_P_19C(Value: WideString);
    procedure Set_P_20(Value: Boolean);
    procedure Set_P_20A(Value: WideString);
    procedure Set_P_20B(Value: WideString);
    procedure Set_P_21(Value: Boolean);
    procedure Set_P_21A(Value: WideString);
    procedure Set_P_21B(Value: WideString);
    procedure Set_P_21C(Value: WideString);
    procedure Set_P_22A(Value: WideString);
    procedure Set_P_22B(Value: WideString);
    procedure Set_P_22C(Value: WideString);
    procedure Set_P_23(Value: Boolean);
    procedure Set_P_106E_2(Value: Boolean);
    procedure Set_P_106E_3(Value: Boolean);
    procedure Set_P_106E_3A(Value: WideString);
    procedure Set_RodzajFaktury(Value: WideString);
    procedure Set_PrzyczynaKorekty(Value: WideString);
    procedure Set_NrFaKorygowanej(Value: WideString);
    procedure Set_OkresFaKorygowanej(Value: WideString);
    procedure Set_ZALZaplata(Value: WideString);
    procedure Set_ZALPodatek(Value: WideString);
    { Methods & Properties }
    property Typ: WideString read Get_Typ write Set_Typ;
    property P_1: WideString read Get_P_1 write Set_P_1;
    property P_2A: WideString read Get_P_2A write Set_P_2A;
    property P_3A: WideString read Get_P_3A write Set_P_3A;
    property P_3B: WideString read Get_P_3B write Set_P_3B;
    property P_3C: WideString read Get_P_3C write Set_P_3C;
    property P_3D: WideString read Get_P_3D write Set_P_3D;
    property P_4A: WideString read Get_P_4A write Set_P_4A;
    property P_4B: WideString read Get_P_4B write Set_P_4B;
    property P_5A: WideString read Get_P_5A write Set_P_5A;
    property P_5B: WideString read Get_P_5B write Set_P_5B;
    property P_6: WideString read Get_P_6 write Set_P_6;
    property P_13_1: WideString read Get_P_13_1 write Set_P_13_1;
    property P_14_1: WideString read Get_P_14_1 write Set_P_14_1;
    property P_13_2: WideString read Get_P_13_2 write Set_P_13_2;
    property P_14_2: WideString read Get_P_14_2 write Set_P_14_2;
    property P_13_3: WideString read Get_P_13_3 write Set_P_13_3;
    property P_14_3: WideString read Get_P_14_3 write Set_P_14_3;
    property P_13_4: WideString read Get_P_13_4 write Set_P_13_4;
    property P_14_4: WideString read Get_P_14_4 write Set_P_14_4;
    property P_13_5: WideString read Get_P_13_5 write Set_P_13_5;
    property P_14_5: WideString read Get_P_14_5 write Set_P_14_5;
    property P_13_6: WideString read Get_P_13_6 write Set_P_13_6;
    property P_13_7: WideString read Get_P_13_7 write Set_P_13_7;
    property P_15: WideString read Get_P_15 write Set_P_15;
    property P_16: Boolean read Get_P_16 write Set_P_16;
    property P_17: Boolean read Get_P_17 write Set_P_17;
    property P_18: Boolean read Get_P_18 write Set_P_18;
    property P_19: Boolean read Get_P_19 write Set_P_19;
    property P_19A: WideString read Get_P_19A write Set_P_19A;
    property P_19B: WideString read Get_P_19B write Set_P_19B;
    property P_19C: WideString read Get_P_19C write Set_P_19C;
    property P_20: Boolean read Get_P_20 write Set_P_20;
    property P_20A: WideString read Get_P_20A write Set_P_20A;
    property P_20B: WideString read Get_P_20B write Set_P_20B;
    property P_21: Boolean read Get_P_21 write Set_P_21;
    property P_21A: WideString read Get_P_21A write Set_P_21A;
    property P_21B: WideString read Get_P_21B write Set_P_21B;
    property P_21C: WideString read Get_P_21C write Set_P_21C;
    property P_22A: WideString read Get_P_22A write Set_P_22A;
    property P_22B: WideString read Get_P_22B write Set_P_22B;
    property P_22C: WideString read Get_P_22C write Set_P_22C;
    property P_23: Boolean read Get_P_23 write Set_P_23;
    property P_106E_2: Boolean read Get_P_106E_2 write Set_P_106E_2;
    property P_106E_3: Boolean read Get_P_106E_3 write Set_P_106E_3;
    property P_106E_3A: WideString read Get_P_106E_3A write Set_P_106E_3A;
    property RodzajFaktury: WideString read Get_RodzajFaktury write Set_RodzajFaktury;
    property PrzyczynaKorekty: WideString read Get_PrzyczynaKorekty write Set_PrzyczynaKorekty;
    property NrFaKorygowanej: WideString read Get_NrFaKorygowanej write Set_NrFaKorygowanej;
    property OkresFaKorygowanej: WideString read Get_OkresFaKorygowanej write Set_OkresFaKorygowanej;
    property ZALZaplata: WideString read Get_ZALZaplata write Set_ZALZaplata;
    property ZALPodatek: WideString read Get_ZALPodatek write Set_ZALPodatek;
  end;

{ IXMLFakturaList }

  IXMLFakturaList = interface(IXMLNodeCollection)
    ['{BF0E0BC1-6980-4FFE-8782-9F72851E07EE}']
    { Methods & Properties }
    function Add: IXMLFaktura;
    function Insert(const Index: Integer): IXMLFaktura;
    function Get_Item(Index: Integer): IXMLFaktura;
    property Items[Index: Integer]: IXMLFaktura read Get_Item; default;
  end;

{ IXMLFakturaCtrl }

  IXMLFakturaCtrl = interface(IXMLNode)
    ['{E7A7A411-6F31-4539-8DC1-B69977041AFA}']
    { Property Accessors }
    function Get_LiczbaFaktur: WideString;
    function Get_WartoscFaktur: WideString;
    procedure Set_LiczbaFaktur(Value: WideString);
    procedure Set_WartoscFaktur(Value: WideString);
    { Methods & Properties }
    property LiczbaFaktur: WideString read Get_LiczbaFaktur write Set_LiczbaFaktur;
    property WartoscFaktur: WideString read Get_WartoscFaktur write Set_WartoscFaktur;
  end;

{ IXMLStawkiPodatku }

  IXMLStawkiPodatku = interface(IXMLNode)
    ['{BA0E0B1D-C9E7-43CD-BD2C-D92E7FE4D928}']
    { Property Accessors }
    function Get_Stawka1: WideString;
    function Get_Stawka2: WideString;
    function Get_Stawka3: WideString;
    function Get_Stawka4: WideString;
    function Get_Stawka5: WideString;
    procedure Set_Stawka1(Value: WideString);
    procedure Set_Stawka2(Value: WideString);
    procedure Set_Stawka3(Value: WideString);
    procedure Set_Stawka4(Value: WideString);
    procedure Set_Stawka5(Value: WideString);
    { Methods & Properties }
    property Stawka1: WideString read Get_Stawka1 write Set_Stawka1;
    property Stawka2: WideString read Get_Stawka2 write Set_Stawka2;
    property Stawka3: WideString read Get_Stawka3 write Set_Stawka3;
    property Stawka4: WideString read Get_Stawka4 write Set_Stawka4;
    property Stawka5: WideString read Get_Stawka5 write Set_Stawka5;
  end;

{ IXMLFakturaWiersz }

  IXMLFakturaWiersz = interface(IXMLNode)
    ['{147B22B3-2305-445B-B2AC-2FDD22EA732C}']
    { Property Accessors }
    function Get_Typ: WideString;
    function Get_P_2B: WideString;
    function Get_P_7: WideString;
    function Get_P_8A: WideString;
    function Get_P_8B: WideString;
    function Get_P_9A: WideString;
    function Get_P_9B: WideString;
    function Get_P_10: WideString;
    function Get_P_11: WideString;
    function Get_P_11A: WideString;
    function Get_P_12: WideString;
    procedure Set_Typ(Value: WideString);
    procedure Set_P_2B(Value: WideString);
    procedure Set_P_7(Value: WideString);
    procedure Set_P_8A(Value: WideString);
    procedure Set_P_8B(Value: WideString);
    procedure Set_P_9A(Value: WideString);
    procedure Set_P_9B(Value: WideString);
    procedure Set_P_10(Value: WideString);
    procedure Set_P_11(Value: WideString);
    procedure Set_P_11A(Value: WideString);
    procedure Set_P_12(Value: WideString);
    { Methods & Properties }
    property Typ: WideString read Get_Typ write Set_Typ;
    property P_2B: WideString read Get_P_2B write Set_P_2B;
    property P_7: WideString read Get_P_7 write Set_P_7;
    property P_8A: WideString read Get_P_8A write Set_P_8A;
    property P_8B: WideString read Get_P_8B write Set_P_8B;
    property P_9A: WideString read Get_P_9A write Set_P_9A;
    property P_9B: WideString read Get_P_9B write Set_P_9B;
    property P_10: WideString read Get_P_10 write Set_P_10;
    property P_11: WideString read Get_P_11 write Set_P_11;
    property P_11A: WideString read Get_P_11A write Set_P_11A;
    property P_12: WideString read Get_P_12 write Set_P_12;
  end;

{ IXMLFakturaWierszList }

  IXMLFakturaWierszList = interface(IXMLNodeCollection)
    ['{47713984-CC80-4A06-A93E-863AEDE2DCF1}']
    { Methods & Properties }
    function Add: IXMLFakturaWiersz;
    function Insert(const Index: Integer): IXMLFakturaWiersz;
    function Get_Item(Index: Integer): IXMLFakturaWiersz;
    property Items[Index: Integer]: IXMLFakturaWiersz read Get_Item; default;
  end;

{ IXMLFakturaWierszCtrl }

  IXMLFakturaWierszCtrl = interface(IXMLNode)
    ['{C92212E0-FBC2-446A-B61E-BE8E73287BF8}']
    { Property Accessors }
    function Get_LiczbaWierszyFaktur: WideString;
    function Get_WartoscWierszyFaktur: WideString;
    procedure Set_LiczbaWierszyFaktur(Value: WideString);
    procedure Set_WartoscWierszyFaktur(Value: WideString);
    { Methods & Properties }
    property LiczbaWierszyFaktur: WideString read Get_LiczbaWierszyFaktur write Set_LiczbaWierszyFaktur;
    property WartoscWierszyFaktur: WideString read Get_WartoscWierszyFaktur write Set_WartoscWierszyFaktur;
  end;

{ IXMLNaglowek }

  IXMLNaglowek = interface(IXMLTNaglowek)
    ['{EAC65ED7-083F-4251-B352-EF1C032B7C0B}']
  end;

{ IXMLKodFormularza }

  IXMLKodFormularza = interface(IXMLNode)
    ['{EBE71B95-613B-4DEA-9A12-C239D1252935}']
    { Property Accessors }
    function Get_KodSystemowy: WideString;
    function Get_WersjaSchemy: WideString;
    procedure Set_KodSystemowy(Value: WideString);
    procedure Set_WersjaSchemy(Value: WideString);
    { Methods & Properties }
    property KodSystemowy: WideString read Get_KodSystemowy write Set_KodSystemowy;
    property WersjaSchemy: WideString read Get_WersjaSchemy write Set_WersjaSchemy;
  end;

{ Forward Decls }

  TXMLJPK = class;
  TXMLTNaglowek = class;
  TXMLPodmiot1 = class;
  TXMLTIdentyfikatorOsobyNiefizycznej = class;
  TXMLTAdresPolski = class;
  TXMLFaktura = class;
  TXMLFakturaList = class;
  TXMLFakturaCtrl = class;
  TXMLStawkiPodatku = class;
  TXMLFakturaWiersz = class;
  TXMLFakturaWierszList = class;
  TXMLFakturaWierszCtrl = class;
  TXMLNaglowek = class;
  TXMLKodFormularza = class;

{ TXMLJPK }

  TXMLJPK = class(TXMLNode, IXMLJPK)
  private
    FFaktura: IXMLFakturaList;
    FFakturaWiersz: IXMLFakturaWierszList;
  protected
    { IXMLJPK }
    function Get_Naglowek: IXMLNaglowek;
    function Get_Podmiot1: IXMLPodmiot1;
    function Get_Faktura: IXMLFakturaList;
    function Get_FakturaCtrl: IXMLFakturaCtrl;
    function Get_StawkiPodatku: IXMLStawkiPodatku;
    function Get_FakturaWiersz: IXMLFakturaWierszList;
    function Get_FakturaWierszCtrl: IXMLFakturaWierszCtrl;
  public
    procedure AfterConstruction; override;
  end;

{ TXMLTNaglowek }

  TXMLTNaglowek = class(TXMLNode, IXMLTNaglowek)
  protected
    { IXMLTNaglowek }
    function Get_KodFormularza: IXMLKodFormularza;
    function Get_WariantFormularza: ShortInt;
    function Get_CelZlozenia: ShortInt;
    function Get_DataWytworzeniaJPK: WideString;
    function Get_DataOd: WideString;
    function Get_DataDo: WideString;
    function Get_DomyslnyKodWaluty: WideString;
    function Get_KodUrzedu: WideString;
    procedure Set_WariantFormularza(Value: ShortInt);
    procedure Set_CelZlozenia(Value: ShortInt);
    procedure Set_DataWytworzeniaJPK(Value: WideString);
    procedure Set_DataOd(Value: WideString);
    procedure Set_DataDo(Value: WideString);
    procedure Set_DomyslnyKodWaluty(Value: WideString);
    procedure Set_KodUrzedu(Value: WideString);
  public
    procedure AfterConstruction; override;
  end;

{ TXMLPodmiot1 }

  TXMLPodmiot1 = class(TXMLNode, IXMLPodmiot1)
  protected
    { IXMLPodmiot1 }
    function Get_IdentyfikatorPodmiotu: IXMLTIdentyfikatorOsobyNiefizycznej;
    function Get_AdresPodmiotu: IXMLTAdresPolski;
  public
    procedure AfterConstruction; override;
  end;

{ TXMLTIdentyfikatorOsobyNiefizycznej }

  TXMLTIdentyfikatorOsobyNiefizycznej = class(TXMLNode, IXMLTIdentyfikatorOsobyNiefizycznej)
  protected
    { IXMLTIdentyfikatorOsobyNiefizycznej }
    function Get_NIP: WideString;
    function Get_PelnaNazwa: WideString;
    function Get_REGON: WideString;
    procedure Set_NIP(Value: WideString);
    procedure Set_PelnaNazwa(Value: WideString);
    procedure Set_REGON(Value: WideString);
  end;

{ TXMLTAdresPolski }

  TXMLTAdresPolski = class(TXMLNode, IXMLTAdresPolski)
  protected
    { IXMLTAdresPolski }
    function Get_KodKraju: WideString;
    function Get_Wojewodztwo: WideString;
    function Get_Powiat: WideString;
    function Get_Gmina: WideString;
    function Get_Ulica: WideString;
    function Get_NrDomu: WideString;
    function Get_NrLokalu: WideString;
    function Get_Miejscowosc: WideString;
    function Get_KodPocztowy: WideString;
    function Get_Poczta: WideString;
    procedure Set_KodKraju(Value: WideString);
    procedure Set_Wojewodztwo(Value: WideString);
    procedure Set_Powiat(Value: WideString);
    procedure Set_Gmina(Value: WideString);
    procedure Set_Ulica(Value: WideString);
    procedure Set_NrDomu(Value: WideString);
    procedure Set_NrLokalu(Value: WideString);
    procedure Set_Miejscowosc(Value: WideString);
    procedure Set_KodPocztowy(Value: WideString);
    procedure Set_Poczta(Value: WideString);
  end;

{ TXMLFaktura }

  TXMLFaktura = class(TXMLNode, IXMLFaktura)
  protected
    { IXMLFaktura }
    function Get_Typ: WideString;
    function Get_P_1: WideString;
    function Get_P_2A: WideString;
    function Get_P_3A: WideString;
    function Get_P_3B: WideString;
    function Get_P_3C: WideString;
    function Get_P_3D: WideString;
    function Get_P_4A: WideString;
    function Get_P_4B: WideString;
    function Get_P_5A: WideString;
    function Get_P_5B: WideString;
    function Get_P_6: WideString;
    function Get_P_13_1: WideString;
    function Get_P_14_1: WideString;
    function Get_P_13_2: WideString;
    function Get_P_14_2: WideString;
    function Get_P_13_3: WideString;
    function Get_P_14_3: WideString;
    function Get_P_13_4: WideString;
    function Get_P_14_4: WideString;
    function Get_P_13_5: WideString;
    function Get_P_14_5: WideString;
    function Get_P_13_6: WideString;
    function Get_P_13_7: WideString;
    function Get_P_15: WideString;
    function Get_P_16: Boolean;
    function Get_P_17: Boolean;
    function Get_P_18: Boolean;
    function Get_P_19: Boolean;
    function Get_P_19A: WideString;
    function Get_P_19B: WideString;
    function Get_P_19C: WideString;
    function Get_P_20: Boolean;
    function Get_P_20A: WideString;
    function Get_P_20B: WideString;
    function Get_P_21: Boolean;
    function Get_P_21A: WideString;
    function Get_P_21B: WideString;
    function Get_P_21C: WideString;
    function Get_P_22A: WideString;
    function Get_P_22B: WideString;
    function Get_P_22C: WideString;
    function Get_P_23: Boolean;
    function Get_P_106E_2: Boolean;
    function Get_P_106E_3: Boolean;
    function Get_P_106E_3A: WideString;
    function Get_RodzajFaktury: WideString;
    function Get_PrzyczynaKorekty: WideString;
    function Get_NrFaKorygowanej: WideString;
    function Get_OkresFaKorygowanej: WideString;
    function Get_ZALZaplata: WideString;
    function Get_ZALPodatek: WideString;
    procedure Set_Typ(Value: WideString);
    procedure Set_P_1(Value: WideString);
    procedure Set_P_2A(Value: WideString);
    procedure Set_P_3A(Value: WideString);
    procedure Set_P_3B(Value: WideString);
    procedure Set_P_3C(Value: WideString);
    procedure Set_P_3D(Value: WideString);
    procedure Set_P_4A(Value: WideString);
    procedure Set_P_4B(Value: WideString);
    procedure Set_P_5A(Value: WideString);
    procedure Set_P_5B(Value: WideString);
    procedure Set_P_6(Value: WideString);
    procedure Set_P_13_1(Value: WideString);
    procedure Set_P_14_1(Value: WideString);
    procedure Set_P_13_2(Value: WideString);
    procedure Set_P_14_2(Value: WideString);
    procedure Set_P_13_3(Value: WideString);
    procedure Set_P_14_3(Value: WideString);
    procedure Set_P_13_4(Value: WideString);
    procedure Set_P_14_4(Value: WideString);
    procedure Set_P_13_5(Value: WideString);
    procedure Set_P_14_5(Value: WideString);
    procedure Set_P_13_6(Value: WideString);
    procedure Set_P_13_7(Value: WideString);
    procedure Set_P_15(Value: WideString);
    procedure Set_P_16(Value: Boolean);
    procedure Set_P_17(Value: Boolean);
    procedure Set_P_18(Value: Boolean);
    procedure Set_P_19(Value: Boolean);
    procedure Set_P_19A(Value: WideString);
    procedure Set_P_19B(Value: WideString);
    procedure Set_P_19C(Value: WideString);
    procedure Set_P_20(Value: Boolean);
    procedure Set_P_20A(Value: WideString);
    procedure Set_P_20B(Value: WideString);
    procedure Set_P_21(Value: Boolean);
    procedure Set_P_21A(Value: WideString);
    procedure Set_P_21B(Value: WideString);
    procedure Set_P_21C(Value: WideString);
    procedure Set_P_22A(Value: WideString);
    procedure Set_P_22B(Value: WideString);
    procedure Set_P_22C(Value: WideString);
    procedure Set_P_23(Value: Boolean);
    procedure Set_P_106E_2(Value: Boolean);
    procedure Set_P_106E_3(Value: Boolean);
    procedure Set_P_106E_3A(Value: WideString);
    procedure Set_RodzajFaktury(Value: WideString);
    procedure Set_PrzyczynaKorekty(Value: WideString);
    procedure Set_NrFaKorygowanej(Value: WideString);
    procedure Set_OkresFaKorygowanej(Value: WideString);
    procedure Set_ZALZaplata(Value: WideString);
    procedure Set_ZALPodatek(Value: WideString);
  end;

{ TXMLFakturaList }

  TXMLFakturaList = class(TXMLNodeCollection, IXMLFakturaList)
  protected
    { IXMLFakturaList }
    function Add: IXMLFaktura;
    function Insert(const Index: Integer): IXMLFaktura;
    function Get_Item(Index: Integer): IXMLFaktura;
  end;

{ TXMLFakturaCtrl }

  TXMLFakturaCtrl = class(TXMLNode, IXMLFakturaCtrl)
  protected
    { IXMLFakturaCtrl }
    function Get_LiczbaFaktur: WideString;
    function Get_WartoscFaktur: WideString;
    procedure Set_LiczbaFaktur(Value: WideString);
    procedure Set_WartoscFaktur(Value: WideString);
  end;

{ TXMLStawkiPodatku }

  TXMLStawkiPodatku = class(TXMLNode, IXMLStawkiPodatku)
  protected
    { IXMLStawkiPodatku }
    function Get_Stawka1: WideString;
    function Get_Stawka2: WideString;
    function Get_Stawka3: WideString;
    function Get_Stawka4: WideString;
    function Get_Stawka5: WideString;
    procedure Set_Stawka1(Value: WideString);
    procedure Set_Stawka2(Value: WideString);
    procedure Set_Stawka3(Value: WideString);
    procedure Set_Stawka4(Value: WideString);
    procedure Set_Stawka5(Value: WideString);
  end;

{ TXMLFakturaWiersz }

  TXMLFakturaWiersz = class(TXMLNode, IXMLFakturaWiersz)
  protected
    { IXMLFakturaWiersz }
    function Get_Typ: WideString;
    function Get_P_2B: WideString;
    function Get_P_7: WideString;
    function Get_P_8A: WideString;
    function Get_P_8B: WideString;
    function Get_P_9A: WideString;
    function Get_P_9B: WideString;
    function Get_P_10: WideString;
    function Get_P_11: WideString;
    function Get_P_11A: WideString;
    function Get_P_12: WideString;
    procedure Set_Typ(Value: WideString);
    procedure Set_P_2B(Value: WideString);
    procedure Set_P_7(Value: WideString);
    procedure Set_P_8A(Value: WideString);
    procedure Set_P_8B(Value: WideString);
    procedure Set_P_9A(Value: WideString);
    procedure Set_P_9B(Value: WideString);
    procedure Set_P_10(Value: WideString);
    procedure Set_P_11(Value: WideString);
    procedure Set_P_11A(Value: WideString);
    procedure Set_P_12(Value: WideString);
  end;

{ TXMLFakturaWierszList }

  TXMLFakturaWierszList = class(TXMLNodeCollection, IXMLFakturaWierszList)
  protected
    { IXMLFakturaWierszList }
    function Add: IXMLFakturaWiersz;
    function Insert(const Index: Integer): IXMLFakturaWiersz;
    function Get_Item(Index: Integer): IXMLFakturaWiersz;
  end;

{ TXMLFakturaWierszCtrl }

  TXMLFakturaWierszCtrl = class(TXMLNode, IXMLFakturaWierszCtrl)
  protected
    { IXMLFakturaWierszCtrl }
    function Get_LiczbaWierszyFaktur: WideString;
    function Get_WartoscWierszyFaktur: WideString;
    procedure Set_LiczbaWierszyFaktur(Value: WideString);
    procedure Set_WartoscWierszyFaktur(Value: WideString);
  end;

{ TXMLNaglowek }

  TXMLNaglowek = class(TXMLTNaglowek, IXMLNaglowek)
  protected
    { IXMLNaglowek }
  end;

{ TXMLKodFormularza }

  TXMLKodFormularza = class(TXMLNode, IXMLKodFormularza)
  protected
    { IXMLKodFormularza }
    function Get_KodSystemowy: WideString;
    function Get_WersjaSchemy: WideString;
    procedure Set_KodSystemowy(Value: WideString);
    procedure Set_WersjaSchemy(Value: WideString);
  end;

{ Global Functions }

function GetJPK(Doc: IXMLDocument): IXMLJPK;
function LoadJPK(const FileName: WideString): IXMLJPK;
function NewJPK: IXMLJPK;

const
  TargetNamespace = 'http://jpk.mf.gov.pl/wzor/2016/03/09/03095/';

implementation

{ Global Functions }

function GetJPK(Doc: IXMLDocument): IXMLJPK;
begin
  Result := Doc.GetDocBinding('JPK', TXMLJPK, TargetNamespace) as IXMLJPK;
end;

function LoadJPK(const FileName: WideString): IXMLJPK;
begin
  Result := LoadXMLDocument(FileName).GetDocBinding('JPK', TXMLJPK, TargetNamespace) as IXMLJPK;
end;

function NewJPK: IXMLJPK;
begin
  Result := NewXMLDocument.GetDocBinding('JPK', TXMLJPK, TargetNamespace) as IXMLJPK;
end;

{ TXMLJPK }

procedure TXMLJPK.AfterConstruction;
begin
  RegisterChildNode('Naglowek', TXMLNaglowek);
  RegisterChildNode('Podmiot1', TXMLPodmiot1);
  RegisterChildNode('Faktura', TXMLFaktura);
  RegisterChildNode('FakturaCtrl', TXMLFakturaCtrl);
  RegisterChildNode('StawkiPodatku', TXMLStawkiPodatku);
  RegisterChildNode('FakturaWiersz', TXMLFakturaWiersz);
  RegisterChildNode('FakturaWierszCtrl', TXMLFakturaWierszCtrl);
  FFaktura := CreateCollection(TXMLFakturaList, IXMLFaktura, 'Faktura') as IXMLFakturaList;
  FFakturaWiersz := CreateCollection(TXMLFakturaWierszList, IXMLFakturaWiersz, 'FakturaWiersz') as IXMLFakturaWierszList;
  inherited;
end;

function TXMLJPK.Get_Naglowek: IXMLNaglowek;
begin
  Result := ChildNodes['Naglowek'] as IXMLNaglowek;
end;

function TXMLJPK.Get_Podmiot1: IXMLPodmiot1;
begin
  Result := ChildNodes['Podmiot1'] as IXMLPodmiot1;
end;

function TXMLJPK.Get_Faktura: IXMLFakturaList;
begin
  Result := FFaktura;
end;

function TXMLJPK.Get_FakturaCtrl: IXMLFakturaCtrl;
begin
  Result := ChildNodes['FakturaCtrl'] as IXMLFakturaCtrl;
end;

function TXMLJPK.Get_StawkiPodatku: IXMLStawkiPodatku;
begin
  Result := ChildNodes['StawkiPodatku'] as IXMLStawkiPodatku;
end;

function TXMLJPK.Get_FakturaWiersz: IXMLFakturaWierszList;
begin
  Result := FFakturaWiersz;
end;

function TXMLJPK.Get_FakturaWierszCtrl: IXMLFakturaWierszCtrl;
begin
  Result := ChildNodes['FakturaWierszCtrl'] as IXMLFakturaWierszCtrl;
end;

{ TXMLTNaglowek }

procedure TXMLTNaglowek.AfterConstruction;
begin
  RegisterChildNode('KodFormularza', TXMLKodFormularza);
  inherited;
end;

function TXMLTNaglowek.Get_KodFormularza: IXMLKodFormularza;
begin
  Result := ChildNodes['KodFormularza'] as IXMLKodFormularza;
end;

function TXMLTNaglowek.Get_WariantFormularza: ShortInt;
begin
  Result := ChildNodes['WariantFormularza'].NodeValue;
end;

procedure TXMLTNaglowek.Set_WariantFormularza(Value: ShortInt);
begin
  ChildNodes['WariantFormularza'].NodeValue := Value;
end;

function TXMLTNaglowek.Get_CelZlozenia: ShortInt;
begin
  Result := ChildNodes['CelZlozenia'].NodeValue;
end;

procedure TXMLTNaglowek.Set_CelZlozenia(Value: ShortInt);
begin
  ChildNodes['CelZlozenia'].NodeValue := Value;
end;

function TXMLTNaglowek.Get_DataWytworzeniaJPK: WideString;
begin
  Result := ChildNodes['DataWytworzeniaJPK'].Text;
end;

procedure TXMLTNaglowek.Set_DataWytworzeniaJPK(Value: WideString);
begin
  ChildNodes['DataWytworzeniaJPK'].NodeValue := Value;
end;

function TXMLTNaglowek.Get_DataOd: WideString;
begin
  Result := ChildNodes['DataOd'].Text;
end;

procedure TXMLTNaglowek.Set_DataOd(Value: WideString);
begin
  ChildNodes['DataOd'].NodeValue := Value;
end;

function TXMLTNaglowek.Get_DataDo: WideString;
begin
  Result := ChildNodes['DataDo'].Text;
end;

procedure TXMLTNaglowek.Set_DataDo(Value: WideString);
begin
  ChildNodes['DataDo'].NodeValue := Value;
end;

function TXMLTNaglowek.Get_DomyslnyKodWaluty: WideString;
begin
  Result := ChildNodes['DomyslnyKodWaluty'].Text;
end;

procedure TXMLTNaglowek.Set_DomyslnyKodWaluty(Value: WideString);
begin
  ChildNodes['DomyslnyKodWaluty'].NodeValue := Value;
end;

function TXMLTNaglowek.Get_KodUrzedu: WideString;
begin
  Result := ChildNodes['KodUrzedu'].Text;
end;

procedure TXMLTNaglowek.Set_KodUrzedu(Value: WideString);
begin
  ChildNodes['KodUrzedu'].NodeValue := Value;
end;

{ TXMLPodmiot1 }

procedure TXMLPodmiot1.AfterConstruction;
begin
  RegisterChildNode('IdentyfikatorPodmiotu', TXMLTIdentyfikatorOsobyNiefizycznej);
  RegisterChildNode('AdresPodmiotu', TXMLTAdresPolski);
  inherited;
end;

function TXMLPodmiot1.Get_IdentyfikatorPodmiotu: IXMLTIdentyfikatorOsobyNiefizycznej;
begin
  Result := ChildNodes['IdentyfikatorPodmiotu'] as IXMLTIdentyfikatorOsobyNiefizycznej;
end;

function TXMLPodmiot1.Get_AdresPodmiotu: IXMLTAdresPolski;
begin
  Result := ChildNodes['AdresPodmiotu'] as IXMLTAdresPolski;
end;

{ TXMLTIdentyfikatorOsobyNiefizycznej }

function TXMLTIdentyfikatorOsobyNiefizycznej.Get_NIP: WideString;
begin
  Result := ChildNodes['etd:NIP'].Text;
end;

procedure TXMLTIdentyfikatorOsobyNiefizycznej.Set_NIP(Value: WideString);
begin
  ChildNodes['etd:NIP'].NodeValue := Value;
end;

function TXMLTIdentyfikatorOsobyNiefizycznej.Get_PelnaNazwa: WideString;
begin
  Result := ChildNodes['etd:PelnaNazwa'].Text;
end;

procedure TXMLTIdentyfikatorOsobyNiefizycznej.Set_PelnaNazwa(Value: WideString);
begin
  ChildNodes['etd:PelnaNazwa'].NodeValue := Value;
end;

function TXMLTIdentyfikatorOsobyNiefizycznej.Get_REGON: WideString;
begin
  Result := ChildNodes['etd:REGON'].Text;
end;

procedure TXMLTIdentyfikatorOsobyNiefizycznej.Set_REGON(Value: WideString);
begin
  ChildNodes['etd:REGON'].NodeValue := Value;
end;

{ TXMLTAdresPolski }

function TXMLTAdresPolski.Get_KodKraju: WideString;
begin
  Result := ChildNodes['etd:KodKraju'].Text;
end;

procedure TXMLTAdresPolski.Set_KodKraju(Value: WideString);
begin
  ChildNodes['etd:KodKraju'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_Wojewodztwo: WideString;
begin
  Result := ChildNodes['etd:Wojewodztwo'].Text;
end;

procedure TXMLTAdresPolski.Set_Wojewodztwo(Value: WideString);
begin
  ChildNodes['etd:Wojewodztwo'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_Powiat: WideString;
begin
  Result := ChildNodes['etd:Powiat'].Text;
end;

procedure TXMLTAdresPolski.Set_Powiat(Value: WideString);
begin
  ChildNodes['etd:Powiat'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_Gmina: WideString;
begin
  Result := ChildNodes['etd:Gmina'].Text;
end;

procedure TXMLTAdresPolski.Set_Gmina(Value: WideString);
begin
  ChildNodes['etd:Gmina'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_Ulica: WideString;
begin
  Result := ChildNodes['etd:Ulica'].Text;
end;

procedure TXMLTAdresPolski.Set_Ulica(Value: WideString);
begin
  ChildNodes['etd:Ulica'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_NrDomu: WideString;
begin
  Result := ChildNodes['etd:NrDomu'].Text;
end;

procedure TXMLTAdresPolski.Set_NrDomu(Value: WideString);
begin
  ChildNodes['etd:NrDomu'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_NrLokalu: WideString;
begin
  Result := ChildNodes['etd:NrLokalu'].Text;
end;

procedure TXMLTAdresPolski.Set_NrLokalu(Value: WideString);
begin
  ChildNodes['etd:NrLokalu'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_Miejscowosc: WideString;
begin
  Result := ChildNodes['etd:Miejscowosc'].Text;
end;

procedure TXMLTAdresPolski.Set_Miejscowosc(Value: WideString);
begin
  ChildNodes['etd:Miejscowosc'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_KodPocztowy: WideString;
begin
  Result := ChildNodes['etd:KodPocztowy'].Text;
end;

procedure TXMLTAdresPolski.Set_KodPocztowy(Value: WideString);
begin
  ChildNodes['etd:KodPocztowy'].NodeValue := Value;
end;

function TXMLTAdresPolski.Get_Poczta: WideString;
begin
  Result := ChildNodes['etd:Poczta'].Text;
end;

procedure TXMLTAdresPolski.Set_Poczta(Value: WideString);
begin
  ChildNodes['etd:Poczta'].NodeValue := Value;
end;

{ TXMLFaktura }

function TXMLFaktura.Get_Typ: WideString;
begin
  Result := AttributeNodes['typ'].Text;
end;

procedure TXMLFaktura.Set_Typ(Value: WideString);
begin
  SetAttribute('typ', Value);
end;

function TXMLFaktura.Get_P_1: WideString;
begin
  Result := ChildNodes['P_1'].Text;
end;

procedure TXMLFaktura.Set_P_1(Value: WideString);
begin
  ChildNodes['P_1'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_2A: WideString;
begin
  Result := ChildNodes['P_2A'].Text;
end;

procedure TXMLFaktura.Set_P_2A(Value: WideString);
begin
  ChildNodes['P_2A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_3A: WideString;
begin
  Result := ChildNodes['P_3A'].Text;
end;

procedure TXMLFaktura.Set_P_3A(Value: WideString);
begin
  ChildNodes['P_3A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_3B: WideString;
begin
  Result := ChildNodes['P_3B'].Text;
end;

procedure TXMLFaktura.Set_P_3B(Value: WideString);
begin
  ChildNodes['P_3B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_3C: WideString;
begin
  Result := ChildNodes['P_3C'].Text;
end;

procedure TXMLFaktura.Set_P_3C(Value: WideString);
begin
  ChildNodes['P_3C'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_3D: WideString;
begin
  Result := ChildNodes['P_3D'].Text;
end;

procedure TXMLFaktura.Set_P_3D(Value: WideString);
begin
  ChildNodes['P_3D'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_4A: WideString;
begin
  Result := ChildNodes['P_4A'].Text;
end;

procedure TXMLFaktura.Set_P_4A(Value: WideString);
begin
  ChildNodes['P_4A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_4B: WideString;
begin
  Result := ChildNodes['P_4B'].Text;
end;

procedure TXMLFaktura.Set_P_4B(Value: WideString);
begin
  ChildNodes['P_4B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_5A: WideString;
begin
  Result := ChildNodes['P_5A'].Text;
end;

procedure TXMLFaktura.Set_P_5A(Value: WideString);
begin
  ChildNodes['P_5A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_5B: WideString;
begin
  Result := ChildNodes['P_5B'].Text;
end;

procedure TXMLFaktura.Set_P_5B(Value: WideString);
begin
  ChildNodes['P_5B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_6: WideString;
begin
  Result := ChildNodes['P_6'].Text;
end;

procedure TXMLFaktura.Set_P_6(Value: WideString);
begin
  ChildNodes['P_6'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_1: WideString;
begin
  Result := ChildNodes['P_13_1'].Text;
end;

procedure TXMLFaktura.Set_P_13_1(Value: WideString);
begin
  ChildNodes['P_13_1'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_14_1: WideString;
begin
  Result := ChildNodes['P_14_1'].Text;
end;

procedure TXMLFaktura.Set_P_14_1(Value: WideString);
begin
  ChildNodes['P_14_1'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_2: WideString;
begin
  Result := ChildNodes['P_13_2'].Text;
end;

procedure TXMLFaktura.Set_P_13_2(Value: WideString);
begin
  ChildNodes['P_13_2'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_14_2: WideString;
begin
  Result := ChildNodes['P_14_2'].Text;
end;

procedure TXMLFaktura.Set_P_14_2(Value: WideString);
begin
  ChildNodes['P_14_2'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_3: WideString;
begin
  Result := ChildNodes['P_13_3'].Text;
end;

procedure TXMLFaktura.Set_P_13_3(Value: WideString);
begin
  ChildNodes['P_13_3'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_14_3: WideString;
begin
  Result := ChildNodes['P_14_3'].Text;
end;

procedure TXMLFaktura.Set_P_14_3(Value: WideString);
begin
  ChildNodes['P_14_3'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_4: WideString;
begin
  Result := ChildNodes['P_13_4'].Text;
end;

procedure TXMLFaktura.Set_P_13_4(Value: WideString);
begin
  ChildNodes['P_13_4'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_14_4: WideString;
begin
  Result := ChildNodes['P_14_4'].Text;
end;

procedure TXMLFaktura.Set_P_14_4(Value: WideString);
begin
  ChildNodes['P_14_4'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_5: WideString;
begin
  Result := ChildNodes['P_13_5'].Text;
end;

procedure TXMLFaktura.Set_P_13_5(Value: WideString);
begin
  ChildNodes['P_13_5'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_14_5: WideString;
begin
  Result := ChildNodes['P_14_5'].Text;
end;

procedure TXMLFaktura.Set_P_14_5(Value: WideString);
begin
  ChildNodes['P_14_5'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_6: WideString;
begin
  Result := ChildNodes['P_13_6'].Text;
end;

procedure TXMLFaktura.Set_P_13_6(Value: WideString);
begin
  ChildNodes['P_13_6'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_13_7: WideString;
begin
  Result := ChildNodes['P_13_7'].Text;
end;

procedure TXMLFaktura.Set_P_13_7(Value: WideString);
begin
  ChildNodes['P_13_7'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_15: WideString;
begin
  Result := ChildNodes['P_15'].Text;
end;

procedure TXMLFaktura.Set_P_15(Value: WideString);
begin
  ChildNodes['P_15'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_16: Boolean;
begin
  Result := ChildNodes['P_16'].NodeValue;
end;

procedure TXMLFaktura.Set_P_16(Value: Boolean);
begin
  ChildNodes['P_16'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_17: Boolean;
begin
  Result := ChildNodes['P_17'].NodeValue;
end;

procedure TXMLFaktura.Set_P_17(Value: Boolean);
begin
  ChildNodes['P_17'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_18: Boolean;
begin
  Result := ChildNodes['P_18'].NodeValue;
end;

procedure TXMLFaktura.Set_P_18(Value: Boolean);
begin
  ChildNodes['P_18'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_19: Boolean;
begin
  Result := ChildNodes['P_19'].NodeValue;
end;

procedure TXMLFaktura.Set_P_19(Value: Boolean);
begin
  ChildNodes['P_19'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_19A: WideString;
begin
  Result := ChildNodes['P_19A'].Text;
end;

procedure TXMLFaktura.Set_P_19A(Value: WideString);
begin
  ChildNodes['P_19A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_19B: WideString;
begin
  Result := ChildNodes['P_19B'].Text;
end;

procedure TXMLFaktura.Set_P_19B(Value: WideString);
begin
  ChildNodes['P_19B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_19C: WideString;
begin
  Result := ChildNodes['P_19C'].Text;
end;

procedure TXMLFaktura.Set_P_19C(Value: WideString);
begin
  ChildNodes['P_19C'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_20: Boolean;
begin
  Result := ChildNodes['P_20'].NodeValue;
end;

procedure TXMLFaktura.Set_P_20(Value: Boolean);
begin
  ChildNodes['P_20'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_20A: WideString;
begin
  Result := ChildNodes['P_20A'].Text;
end;

procedure TXMLFaktura.Set_P_20A(Value: WideString);
begin
  ChildNodes['P_20A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_20B: WideString;
begin
  Result := ChildNodes['P_20B'].Text;
end;

procedure TXMLFaktura.Set_P_20B(Value: WideString);
begin
  ChildNodes['P_20B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_21: Boolean;
begin
  Result := ChildNodes['P_21'].NodeValue;
end;

procedure TXMLFaktura.Set_P_21(Value: Boolean);
begin
  ChildNodes['P_21'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_21A: WideString;
begin
  Result := ChildNodes['P_21A'].Text;
end;

procedure TXMLFaktura.Set_P_21A(Value: WideString);
begin
  ChildNodes['P_21A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_21B: WideString;
begin
  Result := ChildNodes['P_21B'].Text;
end;

procedure TXMLFaktura.Set_P_21B(Value: WideString);
begin
  ChildNodes['P_21B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_21C: WideString;
begin
  Result := ChildNodes['P_21C'].Text;
end;

procedure TXMLFaktura.Set_P_21C(Value: WideString);
begin
  ChildNodes['P_21C'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_22A: WideString;
begin
  Result := ChildNodes['P_22A'].Text;
end;

procedure TXMLFaktura.Set_P_22A(Value: WideString);
begin
  ChildNodes['P_22A'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_22B: WideString;
begin
  Result := ChildNodes['P_22B'].Text;
end;

procedure TXMLFaktura.Set_P_22B(Value: WideString);
begin
  ChildNodes['P_22B'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_22C: WideString;
begin
  Result := ChildNodes['P_22C'].Text;
end;

procedure TXMLFaktura.Set_P_22C(Value: WideString);
begin
  ChildNodes['P_22C'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_23: Boolean;
begin
  Result := ChildNodes['P_23'].NodeValue;
end;

procedure TXMLFaktura.Set_P_23(Value: Boolean);
begin
  ChildNodes['P_23'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_106E_2: Boolean;
begin
  Result := ChildNodes['P_106E_2'].NodeValue;
end;

procedure TXMLFaktura.Set_P_106E_2(Value: Boolean);
begin
  ChildNodes['P_106E_2'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_106E_3: Boolean;
begin
  Result := ChildNodes['P_106E_3'].NodeValue;
end;

procedure TXMLFaktura.Set_P_106E_3(Value: Boolean);
begin
  ChildNodes['P_106E_3'].NodeValue := Value;
end;

function TXMLFaktura.Get_P_106E_3A: WideString;
begin
  Result := ChildNodes['P_106E_3A'].Text;
end;

procedure TXMLFaktura.Set_P_106E_3A(Value: WideString);
begin
  ChildNodes['P_106E_3A'].NodeValue := Value;
end;

function TXMLFaktura.Get_RodzajFaktury: WideString;
begin
  Result := ChildNodes['RodzajFaktury'].Text;
end;

procedure TXMLFaktura.Set_RodzajFaktury(Value: WideString);
begin
  ChildNodes['RodzajFaktury'].NodeValue := Value;
end;

function TXMLFaktura.Get_PrzyczynaKorekty: WideString;
begin
  Result := ChildNodes['PrzyczynaKorekty'].Text;
end;

procedure TXMLFaktura.Set_PrzyczynaKorekty(Value: WideString);
begin
  ChildNodes['PrzyczynaKorekty'].NodeValue := Value;
end;

function TXMLFaktura.Get_NrFaKorygowanej: WideString;
begin
  Result := ChildNodes['NrFaKorygowanej'].Text;
end;

procedure TXMLFaktura.Set_NrFaKorygowanej(Value: WideString);
begin
  ChildNodes['NrFaKorygowanej'].NodeValue := Value;
end;

function TXMLFaktura.Get_OkresFaKorygowanej: WideString;
begin
  Result := ChildNodes['OkresFaKorygowanej'].Text;
end;

procedure TXMLFaktura.Set_OkresFaKorygowanej(Value: WideString);
begin
  ChildNodes['OkresFaKorygowanej'].NodeValue := Value;
end;

function TXMLFaktura.Get_ZALZaplata: WideString;
begin
  Result := ChildNodes['ZALZaplata'].Text;
end;

procedure TXMLFaktura.Set_ZALZaplata(Value: WideString);
begin
  ChildNodes['ZALZaplata'].NodeValue := Value;
end;

function TXMLFaktura.Get_ZALPodatek: WideString;
begin
  Result := ChildNodes['ZALPodatek'].Text;
end;

procedure TXMLFaktura.Set_ZALPodatek(Value: WideString);
begin
  ChildNodes['ZALPodatek'].NodeValue := Value;
end;

{ TXMLFakturaList }

function TXMLFakturaList.Add: IXMLFaktura;
begin
  Result := AddItem(-1) as IXMLFaktura;
end;

function TXMLFakturaList.Insert(const Index: Integer): IXMLFaktura;
begin
  Result := AddItem(Index) as IXMLFaktura;
end;
function TXMLFakturaList.Get_Item(Index: Integer): IXMLFaktura;
begin
  Result := List[Index] as IXMLFaktura;
end;

{ TXMLFakturaCtrl }

function TXMLFakturaCtrl.Get_LiczbaFaktur: WideString;
begin
  Result := ChildNodes['LiczbaFaktur'].Text;
end;

procedure TXMLFakturaCtrl.Set_LiczbaFaktur(Value: WideString);
begin
  ChildNodes['LiczbaFaktur'].NodeValue := Value;
end;

function TXMLFakturaCtrl.Get_WartoscFaktur: WideString;
begin
  Result := ChildNodes['WartoscFaktur'].Text;
end;

procedure TXMLFakturaCtrl.Set_WartoscFaktur(Value: WideString);
begin
  ChildNodes['WartoscFaktur'].NodeValue := Value;
end;

{ TXMLStawkiPodatku }

function TXMLStawkiPodatku.Get_Stawka1: WideString;
begin
  Result := ChildNodes['Stawka1'].Text;
end;

procedure TXMLStawkiPodatku.Set_Stawka1(Value: WideString);
begin
  ChildNodes['Stawka1'].NodeValue := Value;
end;

function TXMLStawkiPodatku.Get_Stawka2: WideString;
begin
  Result := ChildNodes['Stawka2'].Text;
end;

procedure TXMLStawkiPodatku.Set_Stawka2(Value: WideString);
begin
  ChildNodes['Stawka2'].NodeValue := Value;
end;

function TXMLStawkiPodatku.Get_Stawka3: WideString;
begin
  Result := ChildNodes['Stawka3'].Text;
end;

procedure TXMLStawkiPodatku.Set_Stawka3(Value: WideString);
begin
  ChildNodes['Stawka3'].NodeValue := Value;
end;

function TXMLStawkiPodatku.Get_Stawka4: WideString;
begin
  Result := ChildNodes['Stawka4'].Text;
end;

procedure TXMLStawkiPodatku.Set_Stawka4(Value: WideString);
begin
  ChildNodes['Stawka4'].NodeValue := Value;
end;

function TXMLStawkiPodatku.Get_Stawka5: WideString;
begin
  Result := ChildNodes['Stawka5'].Text;
end;

procedure TXMLStawkiPodatku.Set_Stawka5(Value: WideString);
begin
  ChildNodes['Stawka5'].NodeValue := Value;
end;

{ TXMLFakturaWiersz }

function TXMLFakturaWiersz.Get_Typ: WideString;
begin
  Result := AttributeNodes['typ'].Text;
end;

procedure TXMLFakturaWiersz.Set_Typ(Value: WideString);
begin
  SetAttribute('typ', Value);
end;

function TXMLFakturaWiersz.Get_P_2B: WideString;
begin
  Result := ChildNodes['P_2B'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_2B(Value: WideString);
begin
  ChildNodes['P_2B'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_7: WideString;
begin
  Result := ChildNodes['P_7'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_7(Value: WideString);
begin
  ChildNodes['P_7'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_8A: WideString;
begin
  Result := ChildNodes['P_8A'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_8A(Value: WideString);
begin
  ChildNodes['P_8A'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_8B: WideString;
begin
  Result := ChildNodes['P_8B'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_8B(Value: WideString);
begin
  ChildNodes['P_8B'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_9A: WideString;
begin
  Result := ChildNodes['P_9A'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_9A(Value: WideString);
begin
  ChildNodes['P_9A'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_9B: WideString;
begin
  Result := ChildNodes['P_9B'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_9B(Value: WideString);
begin
  ChildNodes['P_9B'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_10: WideString;
begin
  Result := ChildNodes['P_10'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_10(Value: WideString);
begin
  ChildNodes['P_10'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_11: WideString;
begin
  Result := ChildNodes['P_11'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_11(Value: WideString);
begin
  ChildNodes['P_11'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_11A: WideString;
begin
  Result := ChildNodes['P_11A'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_11A(Value: WideString);
begin
  ChildNodes['P_11A'].NodeValue := Value;
end;

function TXMLFakturaWiersz.Get_P_12: WideString;
begin
  Result := ChildNodes['P_12'].Text;
end;

procedure TXMLFakturaWiersz.Set_P_12(Value: WideString);
begin
  ChildNodes['P_12'].NodeValue := Value;
end;

{ TXMLFakturaWierszList }

function TXMLFakturaWierszList.Add: IXMLFakturaWiersz;
begin
  Result := AddItem(-1) as IXMLFakturaWiersz;
end;

function TXMLFakturaWierszList.Insert(const Index: Integer): IXMLFakturaWiersz;
begin
  Result := AddItem(Index) as IXMLFakturaWiersz;
end;
function TXMLFakturaWierszList.Get_Item(Index: Integer): IXMLFakturaWiersz;
begin
  Result := List[Index] as IXMLFakturaWiersz;
end;

{ TXMLFakturaWierszCtrl }

function TXMLFakturaWierszCtrl.Get_LiczbaWierszyFaktur: WideString;
begin
  Result := ChildNodes['LiczbaWierszyFaktur'].Text;
end;

procedure TXMLFakturaWierszCtrl.Set_LiczbaWierszyFaktur(Value: WideString);
begin
  ChildNodes['LiczbaWierszyFaktur'].NodeValue := Value;
end;

function TXMLFakturaWierszCtrl.Get_WartoscWierszyFaktur: WideString;
begin
  Result := ChildNodes['WartoscWierszyFaktur'].Text;
end;

procedure TXMLFakturaWierszCtrl.Set_WartoscWierszyFaktur(Value: WideString);
begin
  ChildNodes['WartoscWierszyFaktur'].NodeValue := Value;
end;

{ TXMLNaglowek }

{ TXMLKodFormularza }

function TXMLKodFormularza.Get_KodSystemowy: WideString;
begin
  Result := AttributeNodes['kodSystemowy'].Text;
end;

procedure TXMLKodFormularza.Set_KodSystemowy(Value: WideString);
begin
  SetAttribute('kodSystemowy', Value);
end;

function TXMLKodFormularza.Get_WersjaSchemy: WideString;
begin
  Result := AttributeNodes['wersjaSchemy'].Text;
end;

procedure TXMLKodFormularza.Set_WersjaSchemy(Value: WideString);
begin
  SetAttribute('wersjaSchemy', Value);
end;

end.
0

Częśc mojego kodu to:

procedure TForm30.Plik_JPK_FA;
var jpk:Schemat_JPK_FA1_v10.IXMLJPK;
    xml:IXMLDocument;
    i,j,k:integer;
    a,b,c,d :extended;
begin
 a:=0; b:=0;
 xml:=NewXMLDocument;
 xml.encoding:='utf-8';
 xml.options:=xml.options+[doNodeAutoIndent];
 jpk:=Schemat_JPK_FA1_v10.getjpk(xml);
 jpk.DeclareNamespace('etd','http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2016/01/25/eD/DefinicjeTypy/');
 with datamodule1, jpk do
 begin
  table14.filter:='do_data1>='+d1+' and do_data1<='+d2+' and (do_typ=1 or do_typ=2)';
  with Naglowek do
  begin
   KodFormularza.KodSystemowy:='JPK_FA (1)';
   KodFormularza.WersjaSchemy:='1-0';
   KodFormularza.Text:='JPK_FA';
   WariantFormularza:=1;
   CelZlozenia:=combobox4.itemindex+1;
   DataWytworzeniaJPK:=datetostr(date)+'T'+timetostr(time);
   DataOd:=d1;
   DataDo:=d2;
   DomyslnyKodWaluty:=table10['wa_symbol'];
   KodUrzedu:=table12['po_us'];
  end;
  with Podmiot1 do
  begin
   IdentyfikatorPodmiotu.NIP:=table12['po_nip'];
   IdentyfikatorPodmiotu.PelnaNazwa:=table12['po_nazwa1']+' '+table12['po_nazwa2'];
   if table12['po_regon']<>null then IdentyfikatorPodmiotu.REGON:=table12['po_regon'];
   table16.locate('kr_nr',table12['po_kraj'],[]);
   AdresPodmiotu.KodKraju:=table16['kr_kod'];
   table17.locate('wo_nr',table12['po_wojew'],[]);
   AdresPodmiotu.Wojewodztwo:=table17['wo_nazwa'];
   AdresPodmiotu.Powiat:=table12['po_powiat'];
   AdresPodmiotu.Gmina:=table12['po_gmina'];
   if table12['po_adres']<>null then AdresPodmiotu.Ulica:=table12['po_adres'];
   if table12['po_nrdomu']<>null then AdresPodmiotu.NrDomu:=table12['po_nrdomu'] else  AdresPodmiotu.NrDomu:='brak';
   if table12['po_nrlokal']<>null then AdresPodmiotu.NrLokalu:=table12['po_nrlokal'];
   AdresPodmiotu.Miejscowosc:=table12['po_miejsce'];
   AdresPodmiotu.KodPocztowy:=table12['po_kodpocz'];
   AdresPodmiotu.Poczta:=table12['po_poczta'];
  end;

  {w pętli pozycje faktury}
  table14.first;
  with Faktura do
  for i:=1 to table14.recordcount do
  begin
   table4.locate('ko_nr',table14['do_nrko'],[]); {*}
   Add.Typ:='G';
   Items[i-1].P_1:=table14['do_data1']; 
   Items[i-1].P_2A:=table14['do_nrdok1']; 
   Items[i-1].P_3A:=table4['ko_nazwa1'];
   if table4['ko_nazwa2']<>null then Items[i-1].P_3A:=Items[i-1].P_3A+' '+table4['ko_nazwa2'];
   Items[i-1].P_3B:=table4['ko_kodpocz']+' '+table4['ko_miejsce']+', '+table4['ko_adres']; {*}

   Items[i-1].P_3C:='Imię i nazwisko lub nazwa sprzedawcy';
   Items[i-1].P_3D:='Adres sprzedawcy';

   //Items[i-1].P_4A {*}
   //Items[i-1].P_4B:='1111111111'; //pole opcjonalne

   //Items[i-1].P_5A {*}
   if table4['ko_nip']<>null then Items[i-1].P_5B:=table4['ko_nip']; {*}
   //Items[i-1].P_6 {*}

   {w poszczególnych stawkach - uprościć do jakiejś jednej pętli}
   c:=0; d:=0;
   table11.filter:='st_nrdo='+inttostr(table14['do_nr'])+' and st_vat=23';
   if table11.recordcount>0 then
   begin
    for j:=1 to table11.recordcount do
    begin
     c:=c+(table11['st_ile1']*table11['st_cenasb']/(1+table11['st_vat']/100));
     d:=d+(table11['st_ile1']*table11['st_cenasb']*table11['st_vat']/(100+table11['st_vat']));
     table11.next;
    end;
    Items[i-1].P_13_1:=floattostrf(c,ffFixed,9,2); //netto 23%
    Items[i-1].P_14_1:=floattostrf(d,ffFixed,9,2); // vat 23%
   end;
   c:=0; d:=0;
   table11.filter:='st_nrdo='+inttostr(table14['do_nr'])+' and st_vat=8';
   if table11.recordcount>0 then
   begin
    for j:=1 to table11.recordcount do
    begin
     c:=c+(table11['st_ile1']*table11['st_cenasb']/(1+table11['st_vat']/100));
     d:=d+(table11['st_ile1']*table11['st_cenasb']*table11['st_vat']/(100+table11['st_vat']));
     table11.next;
    end;
    Items[i-1].P_13_2:=floattostrf(c,ffFixed,9,2); //netto 8%
    Items[i-1].P_14_2:=floattostrf(d,ffFixed,9,2); // vat 8%
   end;
   c:=0; d:=0;
   table11.filter:='st_nrdo='+inttostr(table14['do_nr'])+' and st_vat=5';
   if table11.recordcount>0 then
   begin
    for j:=1 to table11.recordcount do
    begin
     c:=c+(table11['st_ile1']*table11['st_cenasb']/(1+table11['st_vat']/100));
     d:=d+(table11['st_ile1']*table11['st_cenasb']*table11['st_vat']/(100+table11['st_vat']));
     table11.next;
    end;
    Items[i-1].P_13_3:=floattostrf(c,ffFixed,9,2); //netto 5%
    Items[i-1].P_14_3:=floattostrf(d,ffFixed,9,2); // vat 5%
   end;
   //Items[1].P_13_4
   //Items[1].P_14_4
   //Items[1].P_13_5
   //Items[1].P_14_5
   //Items[1].P_13_6
   //Items[1].P_13_7
   Items[i-1].P_15:=floattostrf(table14['do_wartosc'],ffFixed,9,2);
   Items[i-1].P_16:=false; 
   Items[i-1].P_17:=false; 
   Items[i-1].P_18:=false; 
   Items[i-1].P_19:=false; 
   //Items[1].P_19A
   //Items[1].P_19B
   //Items[1].P_19C
   Items[i-1].P_20:=false; {To właśnie w plik XML wpisuje mi jako 'False' i walidacja pokazuje błąd}
   //Items[1].P_20A
   //Items[1].P_20B
   Items[i-1].P_21:=false; {*}
   //Items[1].P_21A
   //Items[1].P_21B
   //Items[1].P_21C
   //Items[i-1].P_22A
   //Items[i-1].P_22B
   //Items[i-1].P_22C
   Items[i-1].P_23:=false; {*}
   Items[i-1].P_106E_2:=false; {*}
   //Items[i-1].P_106E_3
   //Items[1].P_106E_3A
   if table14['do_typ']=1 then Items[i-1].RodzajFaktury:='VAT' else Items[i-1].RodzajFaktury:='KOREKTA'; {*}
   //Items[1].PrzyczynaKorekty {*}
   //Items[1].NrFaKorygowanej {*}
   //Items[1].OkresFaKorygowanej {*}
   //Items[1].ZALZaplata {*}
   //Items[1].ZALPodatek {*}
   a:=a+table14['do_wartosc'];
   table14.next;
  end;

  FakturaCtrl.LiczbaFaktur:=inttostr(table14.recordcount); {*}
  FakturaCtrl.WartoscFaktur:=floattostrf(a,ffFixed,9,2); {};

  with StawkiPodatku do
  begin
   Stawka1:='0.23';
   Stawka2:='0.08';
   Stawka3:='0.05';
   Stawka4:='0.00';
   Stawka5:='0.00';
  end;

  table14.first; k:=0;
  with FakturaWiersz do
  for j:=1 to table14.recordcount do
  begin
   table11.filter:='st_nrdo='+inttostr(table14['do_nr']);
   for i:=1 to table11.recordcount do
   begin
    table1.locate('to_nr',table11['st_nrto'],[]); {*}
    inc(k);
    Add.Typ:='G';
    Items[k-1].P_2B:=table14['do_nrdok1']; {*}
    Items[k-1].P_7:=table1['to_nazwa2']; {*}
    Items[k-1].P_8A:=table1['jednostka']; {*}
    Items[k-1].P_8B:=floattostr(table11['st_ile1']); {*}
    Items[k-1].P_9A:=floattostrf(table11['st_cenasb']/(1+table11['st_vat']/100),fffixed,9,2); {}
    Items[k-1].P_9B:=floattostrf(table11['st_cenasb'],fffixed,9,2); {}
    //Items[k-1].P_10
    Items[k-1].P_11:=floattostrf(table11['st_ile1']*table11['st_cenasb']/(1+table11['st_vat']/100),fffixed,9,2); {}
    Items[k-1].P_11A:=floattostrf(table11['st_ile1']*table11['st_cenasb'],fffixed,9,2); {}

    Items[k-1].P_12:=floattostr(table11['st_vat']); {}

    b:=b+( table11['st_ile1']*table11['st_cenasb']/(1+table11['st_vat']/100) );
    table11.next;
   end;
   table14.next;
  end;

  FakturaWierszCtrl.LiczbaWierszyFaktur:=inttostr(k);
  FakturaWierszCtrl.WartoscWierszyFaktur:=floattostrf(b,fffixed,9,2);

 xml.DocumentElement:=jpk;
 xml.SaveToFile(edit1.text);
end;
0

Trochę długi ten kod, ale skopiowałem w całości. Na koniec dołożyłem taką pętlę:

for j:=1 to datamodule1.table14.recordcount do
 with xml.documentelement.childnodes[j] do
 for i:=0 to childnodes.count-1 do
 begin
  if childnodes[i].text='False' then childnodes[i].text:='false';
  if childnodes[i].text='True' then childnodes[i].text:='true';
 end;

ale przy dużych ilościach pozycji przekłada to się na dodatkowy czas generowania zwłaszcza, że ponieważ w dotychczasowych strukturach pliku nie trzymam kwot w poszczególnych stawkach VAT i je w w/w kodzie filtruję i sumuję.
Mam jeszcze jedno pytanie. Kod zamieszczony poniżej sprawdza plik XML:

function TForm30.walidacja;
var xml,xsd,e1,e2:variant;
    i:integer;
    ss:string;
    a,b:integer;
    c,d,pl:string;
begin
 a:=pos('>JPK_',memo1.text)+1;
 b:=pos('</KodFormularza',memo1.text)-1;
 c:=copy(memo1.text,a,b-a+1);
 if c='JPK_VAT' then
 begin
  d:='http://jpk.mf.gov.pl/wzor/2016/10/26/10261/';
  pl:='Schemat_JPK_VAT(2)_v1-0';
 end;
 if c='JPK_FA' then
 begin
  d:='http://jpk.mf.gov.pl/wzor/2016/03/09/03095/';
  pl:='Schemat_JPK_FA(1)_v1-0';
 end;
 pl:=path_1+'\Schematy xsd\'+pl+'.xsd';
 xml:=CreateOLEObject('MSXML2.DOMDocument.6.0');
 xsd:=CreateOLEObject('MSXML2.XMLSchemaCache.6.0');
 xsd.add(d,pl);
 xml.ValidateOnParse:=true;
 xml.schemas:=xsd;
 xml.setProperty('MultipleErrorMessages',true);
 xml.load(edit1.text);
 result:=xml.parseerror.errorcode=0;
 if result then showmessage('W pliku '+edit1.text+' nie znaleziono błędów.') else
 begin
  e1:=xml.parseError.allErrors;
  ss:='Walidacja wykazała błędy. Liczba błędów: '+inttostr(e1.length)+'.'+#13;
  for i:=0 to xml.ParseError.allErrors.length-1 do
  begin
   e2:=e1.item(i);
   ss:=ss+#13+'Linia: '+inttostr(e2.line)+' - '+e2.srctext+#13+e2.reason;
  end;
  showmessage(ss);
 end;
 xsd:=null;
 xml:=null;
end;

ale robi to ze strony internetowej a nie z pliku.
Co tu mam nie tak. Pozdrawiam.

3

musiałbyś wszystkie

procedure TXMLFaktura.Set_P_16(Value: Boolean);
begin
  ChildNodes['P_16'].NodeValue := Value;
end;

zamienić na

procedure TXMLFaktura.Set_P_16(Value: Boolean);
begin
  ChildNodes['P_16'].NodeValue := AnsiLowerCase(BoolToString(Value, True));
end;

Na koniec tylko dodam to co już pisałem odnośnie JPK - Niepoprawna zawartość generowanego pliku XML - co jest źle?

Co do sprawdzania to teoretycznie możesz ściągnąć wszystkie XSLe, do których są odwołania w pliku JPK (a potem wszystkie XSLe, do których są odwołania w ściągniętych XSLach i potem w tych ściągniętych i tak dalej) na dysk i podmienić w nich ścieżki na lokalne. Wg mnie gra nie warta ścieżki. Jeśli klient chce mieć sprawdzoną poprawność pliku to musi mieć internet i tyle. Przecież do wysłania też trzeba mieć internet więc sprawdzać można przed wysłaniem, jeśli sam wysyłasz pliki. A jeśli wysyłasz je programem z ministerstwa to on też sprawdza poprawność XMLa.

0

Dzięki serdeczne abrakadaber. Nie miałem jeszcze czasu, ale na pewno to zadziała. Jeśli chodzi o walidację, jest to logiczne, że skoro muszę wysłać to i tak muszę mieć internet. Miałem czyjeś demo programu do wysyłania i on nie potrzebował internetu. Stąd ten pomysł. Doróbki i przeróbki w moim programie i tak ograniczę tylko do generowania plików JPK (przynajmniej na razie, gdyż jestem za cienki do ogarnięcia spraw szyfrowania i td). Faktycznie na szczęście jest aplikacja MF. Jeszcze raz dzięki.

1 użytkowników online, w tym zalogowanych: 0, gości: 1