Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 96d10ecc

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID 96d10eccdcde8518cf9cc1ed863be32cf34ccfc2
  • Vorgänger f28ef48d
  • Nachfolger 2c61e4a2

Beim Drucken von Einkaufs- und Verkaufsbelegen die Projektnummern aus der Datenbank holen. Liste der Arrays, die in order_details/invoice_details aufgebaut werden, zentral angelegt, sodass bei "leeren" Zeilen auch wirklich alle bestückt werden können, ohne die Liste an drei Orten bearbeiten zu müssen.

Unterschiede anzeigen:

SL/IS.pm
58 58
  ($form->{terms}) = $sth->fetchrow_array;
59 59
  $sth->finish;
60 60

  
61
  my (@project_ids, %projectnumbers);
62

  
63
  push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"});
64

  
65
  # sort items by partsgroup
66
  for $i (1 .. $form->{rowcount}) {
67
    $partsgroup = "";
68
    if ($form->{"partsgroup_$i"} && $form->{groupitems}) {
69
      $partsgroup = $form->{"partsgroup_$i"};
70
    }
71
    push @partsgroup, [$i, $partsgroup];
72
    push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"});
73
  }
74

  
75
  if (@project_ids) {
76
    $query = "SELECT id, projectnumber FROM project WHERE id IN (" .
77
      join(", ", map({ "?" } @project_ids)) . ")";
78
    $sth = $dbh->prepare($query);
79
    $sth->execute(@project_ids) ||
80
      $form->dberror($query . " (" . join(", ", @project_ids) . ")");
81
    while (my $ref = $sth->fetchrow_hashref()) {
82
      $projectnumbers{$ref->{id}} = $ref->{projectnumber};
83
    }
84
    $sth->finish();
85
  }
86

  
87
  $form->{"globalprojectnumber"} =
88
    $projectnumbers{$form->{"globalproject_id"}};
89

  
61 90
  my $tax = 0;
62 91
  my $item;
63 92
  my $i;
......
91 120
  my $subtotal_header = 0;
92 121
  my $subposition = 0;
93 122

  
123
  my @arrays =
124
    qw(runningnumber number description longdescription qty ship unit bin
125
       deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil
126
       partnotes serialnumber reqdate sellprice listprice netprice
127
       discount p_discount discount_sub nodiscount_sub
128
       linetotal  nodiscount_linetotal tax_rate projectnumber);
129

  
130
  my @tax_arrays =
131
    qw(taxbase tax taxdescription taxrate taxnumber);
132

  
133
  map({ $form->{$_} = [] } (@arrays, @tax_arrays));
94 134

  
95 135
  foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
96 136
    $i = $item->[0];
......
99 139
      push(@{ $form->{description} }, qq|$item->[1]|);
100 140
      $sameitem = $item->[1];
101 141

  
102
      map { push(@{ $form->{$_} }, "") }
103
        qw(runningnumber number serialnumber bin partnotes qty unit deliverydate sellprice listprice netprice discount linetotal);
142
      map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
104 143
    }
105 144

  
106 145
    $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
......
230 269
      push(@{ $form->{nodiscount_linetotal} },
231 270
           $form->format_amount($myconfig, $nodiscount_linetotal, 2));
232 271

  
272
      push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
233 273

  
234
      
235 274
      @taxaccounts = split / /, $form->{"taxaccounts_$i"};
236 275
      $taxrate     = 0;
237 276
      $taxdiff     = 0;
......
302 341

  
303 342
        while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
304 343
          if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
305
            map { push(@{ $form->{$_} }, "") }
306
              qw(runningnumber number serialnumber unit qty bin sellprice listprice netprice discount linetotal nodiscount_linetotal);
344
            map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
307 345
            $sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
308 346
            push(@{ $form->{description} }, $sameitem);
309 347
          }
......
314 352
               $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}
315 353
                 )
316 354
                 . qq| -- $form->{"a_partnumber"}, $form->{"a_description"}|);
317
          map { push(@{ $form->{$_} }, "") }
318
            qw(number unit qty runningnumber serialnumber bin sellprice listprice netprice discount linetotal nodiscount_linetotal);
355
          map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
319 356

  
320 357
        }
321 358
        $sth->finish;
SL/OE.pm
935 935
  my %oid = ('Pg'     => 'oid',
936 936
             'Oracle' => 'rowid');
937 937

  
938
  my (@project_ids, %projectnumbers);
939

  
940
  push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"});
941

  
938 942
  # sort items by partsgroup
939 943
  for $i (1 .. $form->{rowcount}) {
940 944
    $partsgroup = "";
......
942 946
      $partsgroup = $form->{"partsgroup_$i"};
943 947
    }
944 948
    push @partsgroup, [$i, $partsgroup];
949
    push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"});
950
  }
951

  
952
  if (@project_ids) {
953
    $query = "SELECT id, projectnumber FROM project WHERE id IN (" .
954
      join(", ", map({ "?" } @project_ids)) . ")";
955
    $sth = $dbh->prepare($query);
956
    $sth->execute(@project_ids) ||
957
      $form->dberror($query . " (" . join(", ", @project_ids) . ")");
958
    while (my $ref = $sth->fetchrow_hashref()) {
959
      $projectnumbers{$ref->{id}} = $ref->{projectnumber};
960
    }
961
    $sth->finish();
945 962
  }
946 963

  
964
  $form->{"globalprojectnumber"} =
965
    $projectnumbers{$form->{"globalproject_id"}};
966

  
967
  my @arrays =
968
    qw(runningnumber number description longdescription qty ship unit bin
969
       partnotes serialnumber reqdate sellprice listprice netprice
970
       discount p_discount discount_sub nodiscount_sub
971
       linetotal  nodiscount_linetotal tax_rate projectnumber);
972

  
973
  my @tax_arrays =
974
    qw(taxbase tax taxdescription taxrate taxnumber);
975

  
976
  map({ $form->{$_} = [] } (@arrays, @tax_arrays));
977

  
947 978
  my $sameitem = "";
948 979
  foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
949 980
    $i = $item->[0];
......
952 983
      push(@{ $form->{description} }, qq|$item->[1]|);
953 984
      $sameitem = $item->[1];
954 985

  
955
      map { push(@{ $form->{$_} }, "") }
956
        qw(runningnumber number qty ship unit bin partnotes
957
           serialnumber reqdate sellprice listprice netprice
958
           discount p_discount linetotal);
986
      map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
959 987
    }
960 988

  
961 989
    $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
......
1036 1064
      push(@{ $form->{p_discount} }, $form->{"discount_$i"});
1037 1065

  
1038 1066
      $form->{ordtotal} += $linetotal;
1039
     $discount_subtotal += $linetotal;
1067
      $discount_subtotal += $linetotal;
1040 1068
      $form->{nodiscount_total} += $nodiscount_linetotal;
1041 1069
      $nodiscount_subtotal += $nodiscount_linetotal;
1042 1070
      $form->{discount_total} += $form->parse_amount($myconfig, $discount);
......
1062 1090
      push(@{ $form->{nodiscount_linetotal} },
1063 1091
           $form->format_amount($myconfig, $nodiscount_linetotal, 2));
1064 1092

  
1093
      push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
1094

  
1065 1095
      my ($taxamount, $taxbase);
1066 1096
      my $taxrate = 0;
1067 1097

  
......
1114 1144

  
1115 1145
        while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1116 1146
          if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
1117
            map { push(@{ $form->{$_} }, "") }
1118
              qw(runningnumber ship bin serialnumber number unit bin qty 
1119
                 reqdate sellprice listprice netprice discount p_discount
1120
                 linetotal nodiscount_linetotal);
1147
            map({ push(@{ $form->{$_} }, "") }
1148
                grep({ $_ ne "description" } @arrays));
1121 1149
            $sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
1122 1150
            push(@{ $form->{description} }, $sameitem);
1123 1151
          }
......
1127 1155
                 )
1128 1156
                 . qq|, $ref->{partnumber}, $ref->{description}|);
1129 1157

  
1130
          map { push(@{ $form->{$_} }, "") }
1131
            qw(number unit qty runningnumber ship bin serialnumber reqdate 
1132
               sellprice listprice netprice discount p_discount linetotal 
1133
               nodiscount_linetotal);
1134

  
1158
          map({ push(@{ $form->{$_} }, "") }
1159
              grep({ $_ ne "description" } @arrays));
1135 1160
        }
1136 1161
        $sth->finish;
1137 1162
      }
......
1141 1166

  
1142 1167
  my $tax = 0;
1143 1168
  foreach $item (sort keys %taxaccounts) {
1144
      push(@{ $form->{taxbase} },
1145
           $form->format_amount($myconfig, $taxbase{$item}, 2));
1169
    push(@{ $form->{taxbase} },
1170
         $form->format_amount($myconfig, $taxbase{$item}, 2));
1146 1171

  
1147
      $tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
1172
    $tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
1148 1173

  
1149
      push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
1150
      push(@{ $form->{taxdescription} }, $form->{"${item}_description"});
1151
      push(@{ $form->{taxrate} },
1152
           $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
1153
      push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
1174
    push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
1175
    push(@{ $form->{taxdescription} }, $form->{"${item}_description"});
1176
    push(@{ $form->{taxrate} },
1177
         $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
1178
    push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
1154 1179
  }
1155 1180
  $form->{subtotal} = $form->format_amount($myconfig, $form->{total}, 2);
1156 1181
  $yesdiscount = $form->{nodiscount_total} - $nodiscount;

Auch abrufbar als: Unified diff