Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9c63c160

Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt

  • ID 9c63c1600059dca1ca295e264413e911da3d15bf
  • Vorgänger 560d94b2
  • Nachfolger 52dd34aa

Die Funktionen in Template.pm zum Ersetzen von Schleifenvariablen so erweitert, dass die Schleifenarrays auch in $form->{TEMPLATE_ARRAYS} gesucht werden. Weiterhin die Druckmechanismen in IS.pm, OE.pm und DN.pm so angepasst, dass sie diese Unterebene benutzen, um die Positionswerte zu speichern. Dadurch wird verhindert, dass Elemente direkt in $form sowohl als Skalar als auch als Array benutzt werden (z.B. $form->{reqdate} = ... und push @{ $form->{reqdate} }, ...).

Unterschiede anzeigen:

SL/IS.pm
145 145
       linetotal  nodiscount_linetotal tax_rate projectnumber
146 146
       price_factor price_factor_name partsgroup);
147 147

  
148
  my @tax_arrays =
149
    qw(taxbase tax taxdescription taxrate taxnumber);
148
  my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber);
149

  
150
  my @payment_arrays = qw(payment paymentaccount paymentdate paymentsource paymentmemo);
151

  
152
  $form->{TEMPLATE_ARRAYS} = { map { $_ => [] } (@arrays, @tax_arrays, @payment_arrays) };
150 153

  
151 154
  foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
152 155
    $i = $item->[0];
153 156

  
154 157
    if ($item->[1] ne $sameitem) {
155
      push(@{ $form->{description} }, qq|$item->[1]|);
158
      push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, qq|$item->[1]|);
156 159
      $sameitem = $item->[1];
157 160

  
158
      map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
161
      map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
159 162
    }
160 163

  
161 164
    $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
......
179 182

  
180 183
      my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 };
181 184

  
182
      push @{ $form->{runningnumber} },     $position;
183
      push @{ $form->{number} },            $form->{"partnumber_$i"};
184
      push @{ $form->{serialnumber} },      $form->{"serialnumber_$i"};
185
      push @{ $form->{bin} },               $form->{"bin_$i"};
186
      push @{ $form->{"partnotes"} },       $form->{"partnotes_$i"};
187
      push @{ $form->{description} },       $form->{"description_$i"};
188
      push @{ $form->{longdescription} },   $form->{"longdescription_$i"};
189
      push @{ $form->{qty} },               $form->format_amount($myconfig, $form->{"qty_$i"});
190
      push @{ $form->{unit} },              $form->{"unit_$i"};
191
      push @{ $form->{deliverydate_oe} },   $form->{"deliverydate_$i"};
192
      push @{ $form->{sellprice} },         $form->{"sellprice_$i"};
193
      push @{ $form->{ordnumber_oe} },      $form->{"ordnumber_$i"};
194
      push @{ $form->{transdate_oe} },      $form->{"transdate_$i"};
195
      push @{ $form->{invnumber} },         $form->{"invnumber"};
196
      push @{ $form->{invdate} },           $form->{"invdate"};
197
      push @{ $form->{price_factor} },      $price_factor->{formatted_factor};
198
      push @{ $form->{price_factor_name} }, $price_factor->{description};
199
      push @{ $form->{partsgroup} },        $form->{"partsgroup_$i"};
185
      push @{ $form->{TEMPLATE_ARRAYS}->{runningnumber} },     $position;
186
      push @{ $form->{TEMPLATE_ARRAYS}->{number} },            $form->{"partnumber_$i"};
187
      push @{ $form->{TEMPLATE_ARRAYS}->{serialnumber} },      $form->{"serialnumber_$i"};
188
      push @{ $form->{TEMPLATE_ARRAYS}->{bin} },               $form->{"bin_$i"};
189
      push @{ $form->{TEMPLATE_ARRAYS}->{partnotes} },         $form->{"partnotes_$i"};
190
      push @{ $form->{TEMPLATE_ARRAYS}->{description} },       $form->{"description_$i"};
191
      push @{ $form->{TEMPLATE_ARRAYS}->{longdescription} },   $form->{"longdescription_$i"};
192
      push @{ $form->{TEMPLATE_ARRAYS}->{qty} },               $form->format_amount($myconfig, $form->{"qty_$i"});
193
      push @{ $form->{TEMPLATE_ARRAYS}->{unit} },              $form->{"unit_$i"};
194
      push @{ $form->{TEMPLATE_ARRAYS}->{deliverydate_oe} },   $form->{"deliverydate_$i"};
195
      push @{ $form->{TEMPLATE_ARRAYS}->{sellprice} },         $form->{"sellprice_$i"};
196
      push @{ $form->{TEMPLATE_ARRAYS}->{ordnumber_oe} },      $form->{"ordnumber_$i"};
197
      push @{ $form->{TEMPLATE_ARRAYS}->{transdate_oe} },      $form->{"transdate_$i"};
198
      push @{ $form->{TEMPLATE_ARRAYS}->{invnumber} },         $form->{"invnumber"};
199
      push @{ $form->{TEMPLATE_ARRAYS}->{invdate} },           $form->{"invdate"};
200
      push @{ $form->{TEMPLATE_ARRAYS}->{price_factor} },      $price_factor->{formatted_factor};
201
      push @{ $form->{TEMPLATE_ARRAYS}->{price_factor_name} }, $price_factor->{description};
202
      push @{ $form->{TEMPLATE_ARRAYS}->{partsgroup} },        $form->{"partsgroup_$i"};
203
      push @{ $form->{TEMPLATE_ARRAYS}->{reqdate} },           $form->{"reqdate_$i"};
200 204

  
201 205
      if ($form->{lizenzen}) {
202 206
        if ($form->{"licensenumber_$i"}) {
203 207
          $query = qq|SELECT licensenumber, validuntil FROM license WHERE id = ?|;
204 208
          my ($licensenumber, $validuntil) = selectrow_query($form, $dbh, $query, conv_i($form->{"licensenumber_$i"}));
205
          push(@{ $form->{licensenumber} }, $licensenumber);
206
          push(@{ $form->{validuntil} }, $locale->date($myconfig, $validuntil, 0));
209
          push(@{ $form->{TEMPLATE_ARRAYS}->{licensenumber} }, $licensenumber);
210
          push(@{ $form->{TEMPLATE_ARRAYS}->{validuntil} }, $locale->date($myconfig, $validuntil, 0));
207 211

  
208 212
        } else {
209
          push(@{ $form->{licensenumber} }, "");
210
          push(@{ $form->{validuntil} },    "");
213
          push(@{ $form->{TEMPLATE_ARRAYS}->{licensenumber} }, "");
214
          push(@{ $form->{TEMPLATE_ARRAYS}->{validuntil} },    "");
211 215
        }
212 216
      }
213 217

  
214 218
      # listprice
215
      push(@{ $form->{listprice} }, $form->{"listprice_$i"});
219
      push(@{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->{"listprice_$i"});
216 220

  
217 221
      my $sellprice     = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
218 222
      my ($dec)         = ($sellprice =~ /\.(\d+)/);
......
226 230
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2);
227 231
      $form->{"netprice_$i"}   = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2);
228 232

  
229
      push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
233
      push @{ $form->{TEMPLATE_ARRAYS}->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
230 234

  
231 235
      $linetotal = ($linetotal != 0) ? $linetotal : '';
232 236

  
233
      push @{ $form->{discount} },   ($discount  != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : '';
234
      push @{ $form->{p_discount} }, $form->{"discount_$i"};
237
      push @{ $form->{TEMPLATE_ARRAYS}->{discount} },   ($discount  != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : '';
238
      push @{ $form->{TEMPLATE_ARRAYS}->{p_discount} }, $form->{"discount_$i"};
235 239

  
236 240
      $form->{total}            += $linetotal;
237 241
      $form->{nodiscount_total} += $nodiscount_linetotal;
......
243 247
      }
244 248

  
245 249
      if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) {
246
        push @{ $form->{discount_sub} },   $form->format_amount($myconfig, $discount_subtotal,   2);
247
        push @{ $form->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
250
        push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} },   $form->format_amount($myconfig, $discount_subtotal,   2);
251
        push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
248 252

  
249 253
        $discount_subtotal   = 0;
250 254
        $nodiscount_subtotal = 0;
251 255
        $subtotal_header     = 0;
252 256

  
253 257
      } else {
254
        push @{ $form->{discount_sub} },   "";
255
        push @{ $form->{nodiscount_sub} }, "";
258
        push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} },   "";
259
        push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, "";
256 260
      }
257 261

  
258 262
      if (!$form->{"discount_$i"}) {
259 263
        $nodiscount += $linetotal;
260 264
      }
261 265

  
262
      push @{ $form->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
263
      push @{ $form->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
266
      push @{ $form->{TEMPLATE_ARRAYS}->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
267
      push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
264 268

  
265
      push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
269
      push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
266 270

  
267 271
      @taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
268 272
      $taxrate     = 0;
......
304 308
        }
305 309
      }
306 310
      my $tax_rate = $taxrate * 100;
307
      push(@{ $form->{tax_rate} }, qq|$tax_rate|);
311
      push(@{ $form->{TEMPLATE_ARRAYS}->{tax_rate} }, qq|$tax_rate|);
308 312
      if ($form->{"assembly_$i"}) {
309 313
        $sameitem = "";
310 314

  
......
327 331

  
328 332
        while (my $ref = $sth->fetchrow_hashref('NAME_lc')) {
329 333
          if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
330
            map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
334
            map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
331 335
            $sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
332
            push(@{ $form->{description} }, $sameitem);
336
            push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $sameitem);
333 337
          }
334 338

  
335 339
          map { $form->{"a_$_"} = $ref->{$_} } qw(partnumber description);
336 340

  
337
          push(@{ $form->{description} },
341
          push(@{ $form->{TEMPLATE_ARRAYS}->{description} },
338 342
               $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}
339 343
                 )
340 344
                 . qq| -- $form->{"a_partnumber"}, $form->{"a_description"}|);
341
          map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
345
          map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
342 346

  
343 347
        }
344 348
        $sth->finish;
......
347 351
  }
348 352

  
349 353
  foreach my $item (sort keys %taxaccounts) {
350
    push(@{ $form->{taxbase} },
351
          $form->format_amount($myconfig, $taxbase{$item}, 2));
352

  
353 354
    $tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
354 355

  
355
    push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
356
    push(@{ $form->{taxdescription} }, $form->{"${item}_description"}  . q{ } . 100 * $form->{"${item}_rate"} . q{%});
357
    push(@{ $form->{taxrate} },
358
          $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
359
    push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
356
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxbase} },        $form->format_amount($myconfig, $taxbase{$item}, 2));
357
    push(@{ $form->{TEMPLATE_ARRAYS}->{tax} },            $form->format_amount($myconfig, $taxamount,      2));
358
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} },        $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
359
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
360
    push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} },      $form->{"${item}_taxnumber"});
360 361
  }
361 362

  
362 363
  for my $i (1 .. $form->{paidaccounts}) {
363 364
    if ($form->{"paid_$i"}) {
364
      push(@{ $form->{payment} }, $form->{"paid_$i"});
365 365
      my ($accno, $description) = split(/--/, $form->{"AR_paid_$i"});
366
      push(@{ $form->{paymentaccount} }, $description);
367
      push(@{ $form->{paymentdate} },    $form->{"datepaid_$i"});
368
      push(@{ $form->{paymentsource} },  $form->{"source_$i"});
369
      push(@{ $form->{paymentmemo} },    $form->{"memo_$i"});
366

  
367
      push(@{ $form->{TEMPLATE_ARRAYS}->{payment} },        $form->{"paid_$i"});
368
      push(@{ $form->{TEMPLATE_ARRAYS}->{paymentaccount} }, $description);
369
      push(@{ $form->{TEMPLATE_ARRAYS}->{paymentdate} },    $form->{"datepaid_$i"});
370
      push(@{ $form->{TEMPLATE_ARRAYS}->{paymentsource} },  $form->{"source_$i"});
371
      push(@{ $form->{TEMPLATE_ARRAYS}->{paymentmemo} },    $form->{"memo_$i"});
370 372

  
371 373
      $form->{paid} += $form->parse_amount($myconfig, $form->{"paid_$i"});
372 374
    }

Auch abrufbar als: Unified diff