Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2e2e8ce6

Von Udo Spallek vor etwa 18 Jahren hinzugefügt

  • ID 2e2e8ce6a0eda4e2a09c9554be9bf76390cdda60
  • Vorgänger c245aea5
  • Nachfolger e8f2a732

Ustva Version überarbeitet

Unterschiede anzeigen:

bin/mozilla/ustva.pl
89 89

  
90 90
  print qq|
91 91
<body>
92

  
93 92
<form method=post action=$form->{script}>
94 93

  
95 94
<input type=hidden name=title value="$form->{title}">
......
626 625
      };
627 626

  
628 627
    }
629
    print qq|<select id="zeitraum" name="duetyp" title="|
628
    print qq|<select id="zeitraum" name="period" title="|
630 629
  . $locale->text('Select a period') . qq|" >|;
631 630

  
632 631
    my $key = '';
......
642 641
  } elsif ($form->{FA_voranmeld} eq 'quarter') {
643 642

  
644 643
    # Vorauswahl bei quartalsweisem Voranmeldungszeitraum
645
    my %liste = ('A'  => $locale->text('1. Quarter'),
646
                 'B'  => $locale->text('2. Quarter'),
647
                 'C'  => $locale->text('3. Quarter'),
648
                 'D'  => $locale->text('4. Quarter'),
644
    my %liste = ('41'  => $locale->text('1. Quarter'),
645
                 '42'  => $locale->text('2. Quarter'),
646
                 '43'  => $locale->text('3. Quarter'),
647
                 '44'  => $locale->text('4. Quarter'),
649 648
                 '13' => $locale->text('Yearly'),);
650 649

  
651 650
    my $yy = $form->{year} * 10000;
......
677 676
      };
678 677
    }
679 678

  
680
    print qq|<select id="zeitraum" name="duetyp" title="|
679
    print qq|<select id="zeitraum" name="period" title="|
681 680
      . $locale->text('Select a period') . qq|" >|;
682 681
    my $key = '';
683 682
    foreach $key (sort keys %liste) {
......
693 692
  } else {
694 693

  
695 694
    # keine Vorauswahl bei Voranmeldungszeitraum
696
    print qq|<select id="zeitraum" name="duetyp" title="|
695
    print qq|<select id="zeitraum" name="period" title="|
697 696
      . $locale->text('Select a period') . qq|" >|;
698 697

  
699
    my %listea = ('A' => '1. Quarter',
700
                  'B' => '2. Quarter',
701
                  'C' => '3. Quarter',
702
                  'D' => '4. Quarter',);
698
    my %listea = ('41' => '1. Quarter',
699
                  '42' => '2. Quarter',
700
                  '43' => '3. Quarter',
701
                  '44' => '4. Quarter',);
703 702

  
704 703
    my %listeb = ('01' => 'January',
705 704
                  '02' => 'February',
......
769 768
  #$disabled='' if ($form->{elster} eq '1' );
770 769
  if ($form->{elster} eq '1') {
771 770
    $format .=
772
        qq|<option value=elster>|
771
        qq|<option value=elsterwinston>|
773 772
      . $locale->text('ELSTER Export nach Winston')
774
      . qq|</option>|;
773
      . qq|</option>|
774
      . qq|<option value=elstertaxbird>|
775
      . $locale->text('ELSTER Export nach Taxbird')
776
      . qq|</option>|;      
775 777
  }
776 778

  
777 779
  #$format .= qq|<option value=elster>|.$locale->text('ELSTER Export nach Winston').qq|</option>|;
......
795 797
  # form vars initialisieren
796 798
  my @anmeldungszeitraum =
797 799
    qw('0401' '0402' '0403' '0404' '0405' '0405' '0406' '0407' '0408' '0409' '0410' '0411' '0412' '0441' '0442' '0443' '0444');
798
  my $item = '';
799
  foreach $item (@anmeldungszeitraum) {
800
  foreach my $item (@anmeldungszeitraum) {
800 801
    $form->{$item} = "";
801 802
  }
802
  if ($form->{reporttype} eq "custom") {
803 803

  
804 804
    #forgotten the year --> thisyear
805 805
    if ($form->{year} !~ m/^\d\d\d\d$/) {
......
813 813
    }
814 814

  
815 815
    #yearly report
816
    if ($form->{duetyp} eq "13") {
816
    if ($form->{period} eq "13") {
817 817
      $form->{fromdate} = "$form->{year}0101";
818 818
      $form->{todate}   = "$form->{year}1231";
819 819
    }
820 820

  
821 821
    #Quater reports
822
    if ($form->{duetyp} eq "A") {
822
    if ($form->{period} eq "41") {
823 823
      $form->{fromdate} = "$form->{year}0101";
824 824
      $form->{todate}   = "$form->{year}0331";
825 825
      $form->{'0441'}   = "X";
826 826
    }
827
    if ($form->{duetyp} eq "B") {
827
    if ($form->{period} eq "42") {
828 828
      $form->{fromdate} = "$form->{year}0401";
829 829
      $form->{todate}   = "$form->{year}0630";
830 830
      $form->{'0442'}   = "X";
831 831
    }
832
    if ($form->{duetyp} eq "C") {
832
    if ($form->{period} eq "43") {
833 833
      $form->{fromdate} = "$form->{year}0701";
834 834
      $form->{todate}   = "$form->{year}0930";
835 835
      $form->{'0443'}   = "X";
836 836
    }
837
    if ($form->{duetyp} eq "D") {
837
    if ($form->{period} eq "44") {
838 838
      $form->{fromdate} = "$form->{year}1001";
839 839
      $form->{todate}   = "$form->{year}1231";
840 840
      $form->{'0444'}   = "X";
......
842 842

  
843 843
    #Monthly reports
844 844
  SWITCH: {
845
      $form->{duetyp} eq "01" && do {
845
      $form->{period} eq "01" && do {
846 846
        $form->{fromdate} = "$form->{year}0101";
847 847
        $form->{todate}   = "$form->{year}0131";
848 848
        $form->{'0401'}   = "X";
849 849
        last SWITCH;
850 850
      };
851
      $form->{duetyp} eq "02" && do {
851
      $form->{period} eq "02" && do {
852 852
        $form->{fromdate} = "$form->{year}0201";
853 853

  
854 854
        #this works from 1901 to 2099, 1900 and 2100 fail.
......
857 857
        $form->{"0402"} = "X";
858 858
        last SWITCH;
859 859
      };
860
      $form->{duetyp} eq "03" && do {
860
      $form->{period} eq "03" && do {
861 861
        $form->{fromdate} = "$form->{year}0301";
862 862
        $form->{todate}   = "$form->{year}0331";
863 863
        $form->{"0403"}   = "X";
864 864
        last SWITCH;
865 865
      };
866
      $form->{duetyp} eq "04" && do {
866
      $form->{period} eq "04" && do {
867 867
        $form->{fromdate} = "$form->{year}0401";
868 868
        $form->{todate}   = "$form->{year}0430";
869 869
        $form->{"0404"}   = "X";
870 870
        last SWITCH;
871 871
      };
872
      $form->{duetyp} eq "05" && do {
872
      $form->{period} eq "05" && do {
873 873
        $form->{fromdate} = "$form->{year}0501";
874 874
        $form->{todate}   = "$form->{year}0531";
875 875
        $form->{"0405"}   = "X";
876 876
        last SWITCH;
877 877
      };
878
      $form->{duetyp} eq "06" && do {
878
      $form->{period} eq "06" && do {
879 879
        $form->{fromdate} = "$form->{year}0601";
880 880
        $form->{todate}   = "$form->{year}0630";
881 881
        $form->{"0406"}   = "X";
882 882
        last SWITCH;
883 883
      };
884
      $form->{duetyp} eq "07" && do {
884
      $form->{period} eq "07" && do {
885 885
        $form->{fromdate} = "$form->{year}0701";
886 886
        $form->{todate}   = "$form->{year}0731";
887 887
        $form->{"0407"}   = "X";
888 888
        last SWITCH;
889 889
      };
890
      $form->{duetyp} eq "08" && do {
890
      $form->{period} eq "08" && do {
891 891
        $form->{fromdate} = "$form->{year}0801";
892 892
        $form->{todate}   = "$form->{year}0831";
893 893
        $form->{"0408"}   = "X";
894 894
        last SWITCH;
895 895
      };
896
      $form->{duetyp} eq "09" && do {
896
      $form->{period} eq "09" && do {
897 897
        $form->{fromdate} = "$form->{year}0901";
898 898
        $form->{todate}   = "$form->{year}0930";
899 899
        $form->{"0409"}   = "X";
900 900
        last SWITCH;
901 901
      };
902
      $form->{duetyp} eq "10" && do {
902
      $form->{period} eq "10" && do {
903 903
        $form->{fromdate} = "$form->{year}1001";
904 904
        $form->{todate}   = "$form->{year}1031";
905 905
        $form->{"0410"}   = "X";
906 906
        last SWITCH;
907 907
      };
908
      $form->{duetyp} eq "11" && do {
908
      $form->{period} eq "11" && do {
909 909
        $form->{fromdate} = "$form->{year}1101";
910 910
        $form->{todate}   = "$form->{year}1130";
911 911
        $form->{"0411"}   = "X";
912 912
        last SWITCH;
913 913
      };
914
      $form->{duetyp} eq "12" && do {
914
      $form->{period} eq "12" && do {
915 915
        $form->{fromdate} = "$form->{year}1201";
916 916
        $form->{todate}   = "$form->{year}1231";
917 917
        $form->{"0412"}   = "X";
918 918
        last SWITCH;
919 919
      };
920 920
    }
921
  }
922 921

  
923 922
  # using dates in ISO-8601 format: yyyymmmdd  for Postgres...
924 923
  USTVA->ustva(\%myconfig, \%$form);
......
929 928
  $form->{todate} = $form->current_date($myconfig) unless $form->{todate};
930 929
  $form->{todate} = $locale->date(\%myconfig, $form->{todate}, 0, 0, 0);
931 930

  
932
  $form->{period} =
931
  $form->{longperiod} =
933 932
    $locale->date(\%myconfig, $form->current_date(\%myconfig), 1, 0, 0);
934 933

  
935 934
  # if there are any dates construct a where
936 935
  if ($form->{fromdate} || $form->{todate}) {
937 936

  
938
    unless ($form->{todate}) {
939
      $form->{todate} = $form->current_date($myconfig);
940
    }
937
    $form->{todate} = $form->current_date($myconfig)  unless ($form->{todate});
941 938

  
942 939
    my $longtodate  = $locale->date($myconfig, $form->{todate}, 1, 0, 0);
943 940
    my $shorttodate = $locale->date($myconfig, $form->{todate}, 0, 0, 0);
......
946 943
    my $shortfromdate = $locale->date($myconfig, $form->{fromdate}, 0, 0, 0);
947 944

  
948 945
    $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
949
    $form->{period}      =
946
    $form->{longperiod}      =
950 947
        $locale->text('for Period')
951 948
      . qq|<br>\n$longfromdate |
952 949
      . $locale->text('bis')
......
965 962
      $locale->date(\%myconfig, $form->{comparetodate}, 0, 0, 0);
966 963

  
967 964
    $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
968
    $form->{period} .=
965
    $form->{longperiod} .=
969 966
        "<br>\n$longcomparefromdate "
970 967
      . $locale->text('bis')
971 968
      . qq| $longcomparetodate|;
......
992 989
    $form->{co_city} =~ s/\\n//g;
993 990
  }
994 991

  
995
  if (   $form->{format} eq 'pdf'
996
      or $form->{format} eq 'postscript') {
992
  if ( $form->{format} eq 'pdf' or $form->{format} eq 'postscript') {
993

  
994
    $form->{IN} = "$form->{type}-$form->{year}.tex";
995

  
997 996
    $form->{padding} = "~~";
998 997
    $form->{bold}    = "\textbf{";
999 998
    $form->{endbold} = "}";
......
1007 1006

  
1008 1007
    # Zahlenformatierung f?r Latex USTVA Formulare
1009 1008
    if (   $myconfig{numberformat} eq '1.000,00'
1010
        or $myconfig{numberformat} eq '1000,00') {
1009
           or $myconfig{numberformat} eq '1000,00') {
1011 1010
      foreach $number (@numbers) {
1012 1011
        $form->{$number} =~ s/,/~~/g;
1013 1012
      }
......
1018 1017
        $form->{$number} =~ s/\./~~/g;
1019 1018
      }
1020 1019
    }
1020
    if ( $form->{period} eq '13'){ #Catch yearly USTE for now, not yet implemented.
1021
      $form->header;
1022
      USTVA::error(
1023
        $locale->text(
1024
        'Impossible to create yearly Tax Report as PDF or Postscript<br \> Not yet implemented!'
1025
        )
1026
      );
1027
    }
1028
      
1029
  } elsif ( $form->{format} eq 'html') { # Formatierungen f?r HTML Ausgabe
1021 1030

  
1022
    # Formatierungen f?r HTML Ausgabe
1023
      } elsif ($form->{format} eq 'html') {
1031
    $form->{IN} = $form->{type} . '.html';
1024 1032
    $form->{padding} = "&nbsp;&nbsp;";
1025 1033
    $form->{bold}    = "<b>";
1026 1034
    $form->{endbold} = "</b>";
1027 1035
    $form->{br}      = "<br>";
1028 1036
    $form->{address} =~ s/\\n/<br \/>/g;
1029 1037

  
1030
  }
1038
  } elsif ($form->{format} =~ /^elster/) {
1031 1039

  
1032
  if ($form->{format} eq 'elster') {
1033
    if ($form->{duetyp} eq '13') {
1040
    if ( $form->{period} eq '13' ) {
1034 1041
      $form->header;
1035 1042
      USTVA::info(
1036 1043
        $locale->text(
1037
          'Impossible to create yearly Tax Report via Winston.<br \> Not yet implemented!'
1038
        ));
1039
    } else {
1040
      &create_winston();
1044
        'Impossible to create yearly Tax Report via Winston or Taxbird.<br \> Not yet implemented!'
1045
      ));
1041 1046
    }
1042
  } else {
1043
    $form->{templates} = $myconfig{templates};
1044
    $form->{templates} = "doc" if ($form->{type} eq 'help');
1045

  
1046
    $form->{IN} = "$form->{type}";
1047
    $form->{IN} = "$form->{help}" if ($form->{type} eq 'help');
1048
    $form->{IN} = 'USTE'
1049
      if (   $form->{duetyp} eq '13'
1050
          && $form->{format} ne 'html');
1051 1047

  
1052
    if ($form->{IN} eq 'USTE') {
1053
      $form->header;
1054
      USTVA::info(
1055
        $locale->text(
1056
          'Impossible to create yearly Tax Report as PDF or PS.<br \> Not yet implemented!'
1057
        ));
1048
    if ( $form->{format} eq 'elsterwinston' ) {
1049

  
1050
      $form->{IN} = 'winston.xml';
1051
     
1052
      # Build Winston filename
1053
      my $file = 'U';     # 1. char 'U' = USTVA
1054
      $file .= $form->{period};
1055
      #4. and 5. char = year modulo 100
1056
      $file .= sprintf("%02d", $form->{year} % 100);
1057
      #6. to 18. char = Elstersteuernummer
1058
      #Beispiel: Steuernummer in Bayern
1059
      #111/222/33334 ergibt f?r UStVA Jan 2004: U01049111022233334
1060
      $file .= $form->{elsterFFFF};
1061
      $file .= $form->{elstersteuernummer};
1062
      #file suffix
1063
      $file .= '.xml';
1064
      $form->{tmpfile} = $file;
1058 1065
    }
1059 1066

  
1060
    $form->{IN} .= "-$form->{year}"
1061
      if (   $form->{format} eq 'pdf'
1062
          or $form->{format} eq 'postscript');
1067
    if ( $form->{format} eq 'elstertaxbird' ) {
1068

  
1069
      $form->{IN} = 'taxbird.txb';
1070
     
1071
      $form->{tmpfile} = "USTVA-" . $form->{period} 
1072
      . sprintf("%02d", $form->{year} % 100) . ".txb";
1073

  
1074
      if ($form->{period} =~ /^[4]\d$/ ){
1075
        my %periods = ( # Lx => taxbird
1076
                     '41' => '12',
1077
                     '42' => '13',
1078
                     '43' => '14',
1079
                     '44' => '15',
1080
                   );
1081
      
1082
        foreach my $quarter ( keys %periods ) {
1083
          $form->{period} = $periods{$quarter} if ( $form->{period} eq $quarter);
1084
        }
1085
        
1086
        my %lands = ( # Lx => taxbird # TODO: besser als array...
1087
                    'Baden W?rtemberg'       => '0',
1088
                    'Bayern'                 => '1',
1089
                    'Berlin'                 => '2',
1090
                    'Brandenburg'            => '3',
1091
                    'Bremen'                 => '4',
1092
                    'Hamburg'                => '5',
1093
                    'Hessen'                 => '6',
1094
                    'Mecklenburg Vorpommern' => '7',
1095
                    'Niedersachsen'          => '8',
1096
                    'Nordrhein Westfalen'    => '9',
1097
                    'Rheinland Pfalz'        => '10',
1098
                    'Saarland'               => '11',
1099
                    'Sachsen'                => '12',
1100
                    'Sachsen Anhalt'         => '13',
1101
                    'Schleswig Holstein'     => '14',
1102
                    'Th?ringen'              => '15',
1103
              );
1104

  
1105

  
1106
        foreach my $land ( keys %lands ){
1107
          $form->{elsterland} = $lands{$land} if ($form->{elsterland} eq $land );
1108
        }
1109
      } elsif ($form->{period} =~ /^\d+$/ ) {
1110
        $form->{period} =~ s/^0//g;
1111
        my $period = $form->{period};
1112
        $period * 1;
1113
        $period--;
1114
        $form->{period} = $period;
1115
       } else {
1116
         $form->header;
1117
         USTVA::error( $locale->text('Wrong Period' ));
1118
         exit(0);
1119
                
1120
       }
1121
      
1122
    }
1123
    # Other Elster formats follow here...
1124
    
1125
  } elsif ( $form->{format} eq '' ){ # No format error.
1126
    $form->header;
1127
    USTVA::error( $locale->text('Application Error. No Format given!' ));
1128
    exit(0);
1129
 
1130
  } else { # All other Formats are wrong
1131
    $form->header;
1132
    USTVA::error( $locale->text('Application Error. Wrong Format: ') . $form->{format} );
1133
    exit(0);
1134
  }
1135
    
1136
  
1137
  $form->{templates} = $myconfig{templates};
1138
  $form->{templates} = "doc" if ( $form->{type} eq 'help' );
1063 1139

  
1064
    $form->{IN} .= '.tex'
1065
      if (   $form->{format} eq 'pdf'
1066
          or $form->{format} eq 'postscript');
1140
  $lxdebug->leave_sub();
1067 1141

  
1068
    $form->{IN} .= '.html' if ($form->{format} eq 'html');
1142
  $form->parse_template($myconfig, $userspath);
1069 1143

  
1070
    #$form->header;
1071
    #print qq|$myconfig<br>$path|;
1072
    $form->parse_template($myconfig, $userspath);
1073
  }
1074
  $lxdebug->leave_sub();
1075 1144
}
1076 1145

  
1077 1146
sub edit {
......
1770 1839
  $lxdebug->leave_sub();
1771 1840
}
1772 1841

  
1773
sub create_winston {
1774
  $lxdebug->enter_sub();
1775
  &get_config($userspath, 'finanzamt.ini');
1776

  
1777
  # There is no generic Linux GNU/GPL solution out for using ELSTER.
1778
  # In lack of availability linux users may use windows pendants. I choose
1779
  # WINSTON, because it's free of coast, it has an API and its tested under
1780
  # Linux using WINE.
1781
  # The author of WINSTON developed some c-code to realize ELSTER under
1782
  # WINDOWS and Linux (http://www.felfri.de/fa_xml/). Next year (2005) I start to
1783
  # develop a server side solution for LX-Office ELSTER under Linux and
1784
  # WINDOWS based on this c-code.
1785
  #
1786
  # You need to download WINSTON from http://www.felfri.de/winston/
1787
  # There (http://www.felfri.de/winston/download.htm) you'll find instructions
1788
  # about WINSTON under Linux WINE
1789
  # More infos about Winstons API: http://www.felfri.de/winston/schnittstellen.htm
1790
  my $azr  = '';
1791
  my $file = '';    # Filename for Winstonfile
1792
  $file .= 'U';     # 1. char 'U' = USTVA
1793

  
1794
SWITCH:
1795
  {    # 2. and 3. char 01-12= Month 41-44= Quarter (azr:Abrechnungszeitraum)
1796
    $form->{duetyp} eq "01" && do {
1797
      $azr = "01";
1798
      last SWITCH;
1799
    };
1800
    $form->{duetyp} eq "02" && do {
1801
      $azr = "02";
1802
      last SWITCH;
1803
    };
1804
    $form->{duetyp} eq "03" && do {
1805
      $azr = "03";
1806
      last SWITCH;
1807
    };
1808
    $form->{duetyp} eq "04" && do {
1809
      $azr = "04";
1810
      last SWITCH;
1811
    };
1812
    $form->{duetyp} eq "05" && do {
1813
      $azr = "05";
1814
      last SWITCH;
1815
    };
1816
    $form->{duetyp} eq "06" && do {
1817
      $azr = "06";
1818
      last SWITCH;
1819
    };
1820
    $form->{duetyp} eq "07" && do {
1821
      $azr = "07";
1822
      last SWITCH;
1823
    };
1824
    $form->{duetyp} eq "08" && do {
1825
      $azr = "08";
1826
      last SWITCH;
1827
    };
1828
    $form->{duetyp} eq "09" && do {
1829
      $azr = "09";
1830
      last SWITCH;
1831
    };
1832
    $form->{duetyp} eq "10" && do {
1833
      $azr = "10";
1834
      last SWITCH;
1835
    };
1836
    $form->{duetyp} eq "11" && do {
1837
      $azr = "11";
1838
      last SWITCH;
1839
    };
1840
    $form->{duetyp} eq "12" && do {
1841
      $azr = "12";
1842
      last SWITCH;
1843
    };
1844
    $form->{duetyp} eq "A" && do {
1845
      $azr = "41";
1846
      last SWITCH;
1847
    };
1848
    $form->{duetyp} eq "B" && do {
1849
      $azr = "42";
1850
      last SWITCH;
1851
    };
1852
    $form->{duetyp} eq "C" && do {
1853
      $azr = "43";
1854
      last SWITCH;
1855
    };
1856
    $form->{duetyp} eq "D" && do {
1857
      $azr = "44";
1858
      last SWITCH;
1859
    };
1860
    do {
1861
      $form->error(
1862
        "Ung?ltiger Anmeldezeitraum.\n
1863
                                        Sie k?nnen f?r ELSTER nur einen monatlichen oder 
1864
                                        quartalsweisen Anmeldezeitraum ausw?hlen."
1865
      );
1866
    };
1867
  }
1868

  
1869
  $file .= $azr;
1870

  
1871
  #4. and 5. char = year modulo 100
1872
  $file .= sprintf("%02d", $form->{year} % 100);
1873

  
1874
  #6. to 18. char = Elstersteuernummer
1875
  #Beispiel: Steuernummer in Bayern
1876
  #111/222/33334 ergibt f?r UStVA Jan 2004: U01049111022233334
1877

  
1878
  $file .= $form->{elsterFFFF};
1879
  $file .= $form->{elstersteuernummer};
1880

  
1881
  #file suffix
1882

  
1883
  $file .= '.xml';
1884
  $form->{elsterfile} = $file;
1885

  
1886
  #Calculations
1887

  
1888
  my $k51 =
1889
    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"51"}))
1890
    ;    # Ums?tze zu 16% USt
1891
  my $k86 =
1892
    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"86"}))
1893
    ;    # Ums?tze zu 7% USt
1894
  my $k97 =
1895
    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"97"}))
1896
    ;    # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
1897
  my $k93 =
1898
    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"93"}))
1899
    ;    # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
1900
  my $k94 =
1901
    sprintf("%d", $form->parse_amount(\%myconfig, $form->{"94"}))
1902
    ;    # neuer Fahrzeuge von Lieferern
1903
  my $k66 =
1904
    $form->parse_amount(\%myconfig, $form->{"66"}) *
1905
    100;    # Vorsteuer 7% plus 16%
1906
  my $k83 =
1907
    $form->parse_amount(\%myconfig, $form->{"83"}) * 100 ; # Endbetrag
1908
  my $k96 = $form->parse_amount(\%myconfig, $form->{"96"}) * 100;    #
1909
                                                                     #
1910
        # Now build the xml content
1911
        #
1912

  
1913
  $form->{elster} = qq|<?xml version="1.0" encoding="ISO-8859-1" ?>
1914
<!-- Diese Datei ist mit Lx-Office $form->{version} generiert -->
1915
<WinstonAusgang>
1916
 <Formular Typ="UST"></Formular>
1917
 <Ordnungsnummer>$form->{elsterFFFF}$form->{elstersteuernummer}</Ordnungsnummer>
1918
 <AnmeldeJahr>$form->{year}</AnmeldeJahr>
1919
 <AnmeldeZeitraum>$azr</AnmeldeZeitraum>
1920
  |;
1921

  
1922
  $form->{elster} .= qq|<Kennzahl Nr="51">$k51</Kennzahl>\n| if ($k51 ne '0');
1923
  $form->{elster} .= qq|<Kennzahl Nr="86">$k86</Kennzahl>\n| if ($k86 ne '0');
1924
  $form->{elster} .= qq|<Kennzahl Nr="97">$k97</Kennzahl>\n| if ($k97 ne '0');
1925
  $form->{elster} .= qq|<Kennzahl Nr="93">$k93</Kennzahl>\n| if ($k93 ne '0');
1926
  $form->{elster} .= qq|<Kennzahl Nr="94">$k94</Kennzahl>\n| if ($k94 ne '0');
1927
  $form->{elster} .= qq|<Kennzahl Nr="96">$k96</Kennzahl>\n| if ($k96 ne '0');
1928
  $form->{elster} .= qq|<Kennzahl Nr="66">$k66</Kennzahl>\n| if ($k66 ne '0');
1929
  $form->{elster} .= qq|<Kennzahl Nr="83">$k83</Kennzahl>\n| if ($k83 ne '0');
1930
  $form->{elster} .= qq|\n</WinstonAusgang>\n\n|;
1931

  
1932
  #$form->header;
1933
  #print qq|$form->{elsterfile}|;
1934
  #print qq|$form->{elster}|;
1935
  $SIG{INT} = 'IGNORE';
1936

  
1937
  &save_winston;
1938
  $lxdebug->leave_sub();
1939
}
1940

  
1941
sub save_winston {
1942
  $lxdebug->enter_sub();
1943
  my $elster     = $form->{elster};
1944
  my $elsterfile = $form->{elsterfile};
1945
  open(OUT, ">-") or $form->error("STDOUT : $!");
1946
  print OUT qq|Content-Type: application/file;
1947
Content-Disposition: attachment; filename="$elsterfile"\n\n|;
1948
  print OUT $elster;
1949
  close(OUT);
1950
  $lxdebug->leave_sub();
1951
}
1952 1842

  
1953 1843
sub continue {
1954 1844
  $lxdebug->enter_sub();
......
1973 1863
  return $finanzamt;
1974 1864
}
1975 1865

  
1976
sub test {
1977
  $lxdebug->enter_sub();
1978

  
1979
  # biegt nur den Testeintrag in Programm->Test auf eine Routine um
1980

  
1981
  $form->header;
1982
  &elster_send;
1983
  $lxdebug->leave_sub();
1984
}
1985

  
1986
sub elster_send {
1987
  $lxdebug->enter_sub();
1988

  
1989
  #read config
1990
  my $elster_conf = &elster_conf();
1991
  &elster_xml();
1992
  use Cwd;
1993
  $form->{cwd}     = cwd();
1994
  $form->{tmpdir}  = $form->{cwd} . '/' . $elster_conf->{'path'};
1995
  $form->{tmpfile} = $elster_conf->{'err'};
1996
  my $caller = $elster_conf->{'call'}[0];
1997

  
1998
  chdir("$form->{tmpdir}") or $form->error($form->cleanup . "chdir : $!");
1999
  my $send =
2000
    "faxmlsend $caller -config etc/faxmlsend.cnf -xml faxmlsend.xml -tt faxmlsend.tt -debug";
2001

  
2002
  system("$send > $form->{tmpfile}");
2003
  $form->{tmpdir} .= "$elster_conf->{'path'}/";
2004
  $form->{tmpfile} = "faxmlsend.err";
2005
  $form->error($form->cleanup
2006
        . "faxmlsend : OFD meldet: Error 404 \n Internetseite nicht vorhanden")
2007
    if ($? eq '1024');
2008
  $form->error($form->cleanup
2009
    . "faxmlsend : No such File: faxmlsend.xml \n Fehlernummer: $? \n Problem beim ?ffnen der faxmlsend.xml"
2010
    )
2011
    if ($?);
2012

  
2013
  # foreach my $line (&elster_feedback("$elster_conf->{'path'}")){
2014
  #   print qq|$line\n|;
2015
  # }
2016
  print qq|Log:<br>|;
2017

  
2018
  #for (my $i=0; $i<= )
2019
  &elster_readlog();
2020
  print qq|\n ende\n|;
2021
  $lxdebug->leave_sub();
2022
}
2023

  
2024
sub elster_readlog {
2025
  $lxdebug->enter_sub();
2026
  my $elster_conf = &elster_conf();
2027
  open(LOG, "$elster_conf->{'logfile'}")
2028
    or $form->error("$elster_conf->{'logfile'}: $!");
2029
  print qq|<listing>|;
2030
  my $log = '';
2031
  my $xml = '';
2032
  my $tmp = '';
2033
  while (<LOG>) {
2034
    my $i = 0;
2035

  
2036
    #$_ =~ s/</&lt\;/;
2037
    #$_ =~ s/>/&gt\;/;
2038
    $_ =~ s/\s+//mg;
2039

  
2040
    #$_ =~ s/\015\012//mg;
2041
    $_ =~ s/</\n</mg;
2042

  
2043
    #$_ =~ s/\n\n+//mg;
2044
    if ($_ =~ /^\d\d\d\d\d\d/g) {
2045
      $log .= qq|$_<br>|;
2046

  
2047
      #} elsif ($_ =~ /(<([^\/]*?)>)/ ) {
2048
    } elsif ($_ =~ /(<([^\/].*?)>(.*))/g) {
2049

  
2050
      #$xml .= qq|$2 = $3\n\n|;
2051
      #$_ =~ s/\015\012//mg;
2052
      $_ =~ s/\s+//;
2053
      $xml .= qq|$_\n|;
2054

  
2055
    } else {
2056
      $tmp .= qq|$_<br>|;
2057
    }
2058
    $i++;
2059
  }
2060

  
2061
  #second parse
2062
  #my $var='';
2063
  #while (<$xml>){
2064
  #  $var .= qq|$2 = $3\n\n|;
2065
  #}
2066
  #print qq|$log|;
2067
  print qq|$xml|;
2068
  print qq|</listing>|;
2069

  
2070
  # $_=$log;
2071
  #  s{<(\w+)\b([^<>]*)>
2072
  #    ((?:.(?!</?\1\b))*.)
2073
  #      (<\1>) }
2074
  #   { print "markup=",$1," args=",$2," enclosed=",$3," final=",$4 ; "" }gsex;
2075
  close LOG;
2076
  $lxdebug->leave_sub();
2077
}
2078

  
2079
sub elster_feedback {
2080
  $lxdebug->enter_sub();
2081
  my ($file) = @_;
2082
  my @content = ();
2083
  print qq|feedback:<br>|;
2084
  if (-f "$file") {
2085
    open(FH, "$file");
2086
    @content = <FH>;
2087
    close(FH);
2088
  }
2089
  $lxdebug->leave_sub();
2090
  return (@content);
2091
}
2092

  
2093
sub elster_conf {
2094
  $lxdebug->enter_sub();
2095
  my $elster_conf = { 'path'     => 'elster',
2096
                      'prg'      => 'faxmlsend',
2097
                      'err'      => 'faxmlsend.err',
2098
                      'ttfile'   => 'faxmlsend.tt',
2099
                      'xmlfile'  => 'faxmlsend.xml',
2100
                      'cline'    => '-tt $ttfile -xml $xmlfile',
2101
                      'call'     => ['send', 'protokoll', 'anmeldesteuern'],
2102
                      'logfile'  => 'log/faxmlsend.log',
2103
                      'conffile' => 'faxmlsend.cnf',
2104
                      'debug'    => '-debug' };
2105
  $lxdebug->leave_sub();
2106
  return $elster_conf;
2107

  
2108
}
2109

  
2110
sub elster_xml {
2111
  $lxdebug->enter_sub();
2112
  my $elster_conf = &elster_conf();
2113

  
2114
  #  $k51 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"51"})); # Ums?tze zu 16% USt
2115
  #  $k86 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"86"})); # Ums?tze zu 7% USt
2116
  #  $k97 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"97"})); # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
2117
  #  $k93 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"93"})); # 16% Steuerpflichtige innergemeinsachftliche Erwerbe
2118
  #  $k94 = sprintf("%d", $form->parse_amount(\%myconfig, $form->{"94"})); # neuer Fahrzeuge von Lieferern
2119
  #  $k66 = $form->parse_amount(\%myconfig, $form->{"66"}) * 100;# Vorsteuer 7% plus 16%
2120
  #  $k83 = $form->parse_amount(\%myconfig, $form->{"67"}) * 100;# Ums?tze zu 7% USt
2121
  #  $k96 = $form->parse_amount(\%myconfig, $form->{"96"}) * 100;#
2122

  
2123
  my $TransferHeader = qq|<?xml version="1.0" encoding="ISO-8859-1"?>
2124
<?xml-stylesheet type="text/xsl" href="..\\Stylesheet\\ustva.xsl"?>
2125
<Elster xmlns="http://www.elster.de/2002/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.elster.de/2002/XMLSchema
2126
..\\Schemata\\elster_UStA_200501_extern.xsd">
2127
   <TransferHeader version="7">
2128
      <Verfahren>ElsterAnmeldung</Verfahren>
2129
      <DatenArt>UStVA</DatenArt>
2130
      <Vorgang>send-NoSig</Vorgang>
2131
      <Testmerker>700000004</Testmerker>
2132
      <HerstellerID>74931</HerstellerID>
2133
      <DatenLieferant>Helmut</DatenLieferant>
2134
      <Datei>
2135
        <Verschluesselung>PKCS#7v1.5</Verschluesselung>
2136
        <Kompression>GZIP</Kompression>
2137
        <DatenGroesse>123456789012345678901234567890123456789012</DatenGroesse>
2138
        <TransportSchluessel/>
2139
      </Datei>
2140
      <RC>
2141
        <Rueckgabe>
2142
          <Code>0</Code>
2143
          <Text/>
2144
        </Rueckgabe>
2145
        <Stack>
2146
          <Code>0</Code>
2147
          <Text/>
2148
        </Stack>
2149
      </RC>
2150
      <VersionClient/>
2151
      <Zusatz>
2152
        <Info>test</Info>
2153
      </Zusatz>
2154
   </TransferHeader>|;
2155

  
2156
  my $DatenTeil = qq|
2157
   <DatenTeil>
2158
      <Nutzdatenblock>
2159
         <NutzdatenHeader version="9">
2160
            <NutzdatenTicket>234234234</NutzdatenTicket>
2161
            <Empfaenger id="F">9198</Empfaenger>
2162
            <Hersteller>
2163
               <ProduktName>ElsterAnmeldung</ProduktName>
2164
               <ProduktVersion>V 1.4</ProduktVersion>
2165
            </Hersteller>
2166
            <DatenLieferant>String, der Lieferanteninfo enthaelt</DatenLieferant>
2167
            <Zusatz>
2168
              <Info>....</Info>
2169
            </Zusatz>
2170
         </NutzdatenHeader>
2171
         <Nutzdaten>
2172
            <!--die Version gibt Auskunft ueber das Jahr und die derzeit gueltige Versionsnummer-->
2173
            <Anmeldungssteuern art="UStVA" version="200501">
2174
               <DatenLieferant>
2175
                  <Name>OFD Muenchen</Name>
2176
                  <Strasse>Meiserstr. 6</Strasse>
2177
                  <PLZ>80335</PLZ>
2178
                  <Ort>M?nchen</Ort>
2179
               </DatenLieferant>
2180
               <Erstellungsdatum>20041127</Erstellungsdatum>
2181
               <Steuerfall>
2182
                  <Umsatzsteuervoranmeldung>
2183
                     <Jahr>2005</Jahr>
2184
                     <Zeitraum>01</Zeitraum>
2185
                     <Steuernummer>9198011310134</Steuernummer>
2186
                     <Kz09>74931*NameSteuerber.*Berufsbez.*089*59958327*Mandantenname</Kz09>
2187
                  </Umsatzsteuervoranmeldung>
2188
               </Steuerfall>
2189
            </Anmeldungssteuern>
2190
         </Nutzdaten>
2191
      </Nutzdatenblock>
2192
   </DatenTeil>
2193
</Elster>\n|;
2194

  
2195
  #$DatenTeil .= qq|                              <Kz51>$k51</Kz51>\n| if ($k51 ne '0');
2196
  #$DatenTeil .= qq|                              <Kz86>$k86</Kz86>\n| if ($k86 ne '0');
2197
  #$DatenTeil .= qq|                              <Kz97>$k97</Kz97>\n| if ($k97 ne '0');
2198
  #$DatenTeil .= qq|                              <Kz93>$k93</Kz93>\n| if ($k93 ne '0');
2199
  #$DatenTeil .= qq|                              <Kz94>$k94</Kz94>\n| if ($k94 ne '0');
2200
  #$DatenTeil .= qq|                              <Kz96>$k96</Kz96>\n| if ($k96 ne '0');
2201
  #$DatenTeil .= qq|                              <Kz66>$k66</Kz66>\n| if ($k66 ne '0');
2202
  #$DatenTeil .= qq|                              <Kz83>$k83</Kz83>\n| if ($k83 ne '0');
2203

  
2204
  my $filename = "$elster_conf->{'path'}/$elster_conf->{'xmlfile'}";
2205
  open(XML, ">$elster_conf->{'path'}/$elster_conf->{'xmlfile'}")
2206
    or $form->error("$filename : $!");
2207
  print XML qq|$TransferHeader $DatenTeil|;
2208
  close XML;
2209
  $lxdebug->leave_sub();
2210
}
2211 1866

  

Auch abrufbar als: Unified diff