Revision 3ffb8503
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
bin/mozilla/vk.pl | ||
---|---|---|
210 | 210 |
|
211 | 211 |
# so now the check-box "Description" is only used as switch for part description in invoice-mode |
212 | 212 |
# always fill the column "Description" if we are in Zwischensummenmode |
213 |
if (not defined $form->{"l_parts"}) { |
|
214 |
$form->{"l_description"} = "Y"; |
|
215 |
}; |
|
213 |
$form->{"l_description"} = "Y" if not defined $form->{"l_parts"};; |
|
216 | 214 |
map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; |
217 | 215 |
|
218 | 216 |
my @options; |
219 | 217 |
|
220 |
if ($form->{description}) { |
|
221 |
push @options, $locale->text('Description') . " : $form->{description}"; |
|
222 |
} |
|
223 |
if ($form->{customer}) { |
|
224 |
push @options, $locale->text('Customer') . " : $form->{customername}"; |
|
225 |
} |
|
226 |
if ($form->{customernumber}) { |
|
227 |
push @options, $locale->text('Customer Number') . " : $form->{customernumber}"; |
|
228 |
} |
|
229 |
# TODO: es wird nur id übergeben |
|
230 |
if ($form->{department}) { |
|
231 |
my ($department) = split /--/, $form->{department}; |
|
232 |
push @options, $locale->text('Department') . " : $department"; |
|
233 |
} |
|
234 |
if ($form->{invnumber}) { |
|
235 |
push @options, $locale->text('Invoice Number') . " : $form->{invnumber}"; |
|
236 |
} |
|
237 |
if ($form->{invdate}) { |
|
238 |
push @options, $locale->text('Invoice Date') . " : $form->{invdate}"; |
|
239 |
} |
|
240 |
if ($form->{partnumber}) { |
|
241 |
push @options, $locale->text('Part Number') . " : $form->{partnumber}"; |
|
242 |
} |
|
243 |
if ($form->{partsgroup_id}) { |
|
244 |
my $partsgroup = SL::DB::PartsGroup->new(id => $form->{partsgroup_id})->load; |
|
245 |
push @options, $locale->text('Group') . " : $partsgroup->{partsgroup}"; |
|
246 |
} |
|
247 |
if ($form->{country}) { |
|
248 |
push @options, $locale->text('Country') . " : $form->{country}"; |
|
249 |
} |
|
250 |
if ($form->{employee_id}) { |
|
251 |
my $employee = SL::DB::Employee->new(id => $form->{employee_id})->load; |
|
252 |
push @options, $locale->text('Employee') . ' : ' . $employee->name; |
|
253 |
} |
|
254 |
if ($form->{salesman_id}) { |
|
255 |
my $salesman = SL::DB::Employee->new(id => $form->{salesman_id})->load; |
|
256 |
push @options, $locale->text('Salesman') . ' : ' . $salesman->name; |
|
257 |
} |
|
258 |
if ($form->{business_id}) { |
|
259 |
my $business = SL::DB::Business->new(id => $form->{business_id})->load; |
|
260 |
push @options, $locale->text('Customer type') . ' : ' . $business->description; |
|
261 |
} |
|
262 |
if ($form->{ordnumber}) { |
|
263 |
push @options, $locale->text('Order Number') . " : $form->{ordnumber}"; |
|
264 |
} |
|
265 |
if ($form->{notes}) { |
|
266 |
push @options, $locale->text('Notes') . " : $form->{notes}"; |
|
267 |
} |
|
268 |
if ($form->{transaction_description}) { |
|
269 |
push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"; |
|
270 |
} |
|
271 |
if ($form->{transdatefrom}) { |
|
272 |
push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1); |
|
273 |
} |
|
274 |
if ($form->{transdateto}) { |
|
275 |
push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1); |
|
276 |
} |
|
218 |
push @options, $locale->text('Description') . " : $form->{description}" if $form->{description}; |
|
219 |
push @options, $locale->text('Customer') . " : $form->{customername}" if $form->{customer}; |
|
220 |
push @options, $locale->text('Customer Number') . " : $form->{customernumber}" if $form->{customernumber}; |
|
221 |
# TODO: es wird nur id übergeben |
|
222 |
push @options, $locale->text('Department') . " : " . (split /--/, $form->{department})[0] if $form->{department}; |
|
223 |
push @options, $locale->text('Invoice Number') . " : $form->{invnumber}" if $form->{invnumber}; |
|
224 |
push @options, $locale->text('Invoice Date') . " : $form->{invdate}" if $form->{invdate}; |
|
225 |
push @options, $locale->text('Part Number') . " : $form->{partnumber}" if $form->{partnumber}; |
|
226 |
push @options, $locale->text('Group') . " : " . SL::DB::PartsGroup->new(id => $form->{partsgroup_id})->load->partsgroup if $form->{partsgroup_id}; |
|
227 |
push @options, $locale->text('Country') . " : $form->{country}" if $form->{country}; |
|
228 |
push @options, $locale->text('Employee') . ' : ' . SL::DB::Employee->new(id => $form->{employee_id})->load->name if $form->{employee_id}; |
|
229 |
push @options, $locale->text('Salesman') . ' : ' . SL::DB::Employee->new(id => $form->{salesman_id})->load->name if $form->{salesman_id}; |
|
230 |
push @options, $locale->text('Customer type') . ' : ' . SL::DB::Business->new(id => $form->{business_id})->load->description if $form->{business_id}; |
|
231 |
push @options, $locale->text('Order Number') . " : $form->{ordnumber}" if $form->{ordnumber}; |
|
232 |
push @options, $locale->text('Notes') . " : $form->{notes}" if $form->{notes}; |
|
233 |
push @options, $locale->text('Transaction description') . " : $form->{transaction_description}" if $form->{transaction_description}; |
|
234 |
push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1) if $form->{transdatefrom}; |
|
235 |
push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1) if $form->{transdateto}; |
|
277 | 236 |
|
278 | 237 |
my $report = SL::ReportGenerator->new(\%myconfig, $form); |
279 | 238 |
|
... | ... | |
318 | 277 |
# Durchschnitt von marge_percent |
319 | 278 |
my @total_columns = qw(sellprice_total lastcost_total marge_total marge_percent ); |
320 | 279 |
|
321 |
my %totals = map { $_ => 0 } @total_columns; |
|
280 |
my %totals = map { $_ => 0 } @total_columns;
|
|
322 | 281 |
my %subtotals1 = map { $_ => 0 } @subtotal_columns; |
323 | 282 |
my %subtotals2 = map { $_ => 0 } @subtotal_columns; |
324 | 283 |
|
... | ... | |
352 | 311 |
|
353 | 312 |
# Anfangshauptüberschrift |
354 | 313 |
if ( $form->{l_headers_mainsort} eq "Y" && ( $idx == 0 or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} } )) { |
355 |
my $headerrow; |
|
356 |
|
|
357 |
# use $emptyname for mainsort header if mainsort is empty |
|
358 |
if ( $ar->{$form->{'mainsort'}} ) { |
|
359 |
$headerrow->{description}->{data} = $ar->{$form->{'mainsort'}}; |
|
360 |
} else { |
|
361 |
$headerrow->{description}->{data} = $locale->text('empty'); |
|
314 |
my $headerrow = { |
|
315 |
# use $emptyname for mainsort header if mainsort is empty |
|
316 |
data => $ar->{$form->{'mainsort'}} || $locale->text('empty'), |
|
317 |
class => "listmainsortheader", |
|
362 | 318 |
}; |
363 |
|
|
364 |
$headerrow->{description}->{class} = "listmainsortheader"; |
|
365 |
my $headerrow_set = [ $headerrow ]; |
|
366 |
$report->add_data($headerrow_set); |
|
319 |
$report->add_data([ { description => $headerrow } ]); |
|
367 | 320 |
|
368 | 321 |
# add empty row after main header |
369 | 322 |
# my $emptyheaderrow->{description}->{data} = ""; |
... | ... | |
373 | 326 |
}; |
374 | 327 |
|
375 | 328 |
# subsort überschriften |
376 |
if ( $idx == 0 |
|
377 |
or $ar->{ $form->{'subsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'subsort'} } |
|
378 |
or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} } |
|
329 |
# special case: subsort headers only makes (aesthetical) sense if we show individual parts |
|
330 |
if (( $idx == 0 |
|
331 |
or $ar->{ $form->{'subsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'subsort'} } |
|
332 |
or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} }) |
|
333 |
&& ($form->{l_headers_subsort} eq "Y") |
|
334 |
&& $form->{l_parts} |
|
379 | 335 |
) { |
380 |
my $headerrow; |
|
381 |
|
|
382 |
# if subsort name is defined, use that name in header, otherwise use $emptyname |
|
383 |
if ( $ar->{$form->{'subsort'}} ) { |
|
384 |
$headerrow->{description}->{data} = $ar->{$form->{'subsort'}}; |
|
385 |
} else { |
|
386 |
$headerrow->{description}->{data} = $locale->text('empty'); |
|
336 |
my $headerrow = { |
|
337 |
# if subsort name is defined, use that name in header, otherwise use $emptyname |
|
338 |
data => $ar->{$form->{'subsort'}} || $locale->text('empty'), |
|
339 |
class => "listsubsortheader", |
|
387 | 340 |
}; |
388 |
$headerrow->{description}->{class} = "listsubsortheader"; |
|
389 |
my $headerrow_set = [ $headerrow ]; |
|
390 |
# special case: subsort headers only makes (aesthetical) sense if we show individual parts |
|
391 |
$report->add_data($headerrow_set) if $form->{l_headers_subsort} eq "Y" and $form->{l_parts}; |
|
341 |
$report->add_data([ { description => $headerrow } ]); |
|
392 | 342 |
}; |
393 | 343 |
|
394 | 344 |
map { $subtotals1{$_} += $ar->{$_}; |
... | ... | |
401 | 351 |
# calculate averages for subtotals1 and subtotals2 |
402 | 352 |
# credited positions reduce both total and qty and thus don't influence average prices |
403 | 353 |
$subtotals1{sellprice} = $subtotals1{sellprice_total} / $subtotals1{qty}; |
404 |
$subtotals1{lastcost} = $subtotals1{lastcost_total} / $subtotals1{qty};
|
|
354 |
$subtotals1{lastcost} = $subtotals1{lastcost_total} / $subtotals1{qty};
|
|
405 | 355 |
} else { |
406 | 356 |
# qty is zero, so we have a special case where each position in subtotal |
407 | 357 |
# group has a corresponding credit note so that the total qty is zero in |
... | ... | |
409 | 359 |
# rather than leaving the last value in sellprice/lastcost |
410 | 360 |
|
411 | 361 |
$subtotals1{sellprice} = 0; |
412 |
$subtotals1{lastcost} = 0; |
|
362 |
$subtotals1{lastcost} = 0;
|
|
413 | 363 |
}; |
414 | 364 |
|
415 | 365 |
if ( $subtotals2{qty} != 0 ) { |
416 | 366 |
$subtotals2{sellprice} = $subtotals2{sellprice_total} / $subtotals2{qty}; |
417 |
$subtotals2{lastcost} = $subtotals2{lastcost_total} / $subtotals2{qty};
|
|
367 |
$subtotals2{lastcost} = $subtotals2{lastcost_total} / $subtotals2{qty};
|
|
418 | 368 |
} else { |
419 | 369 |
$subtotals2{sellprice} = 0; |
420 |
$subtotals2{lastcost} = 0; |
|
370 |
$subtotals2{lastcost} = 0;
|
|
421 | 371 |
}; |
422 | 372 |
|
423 | 373 |
# Ertrag prozentual in den Summen: (summe VK - summe Ertrag) / summe VK |
Auch abrufbar als: Unified diff
Refactoring: if (...) { ... } in post-if umwandeln; weniger Hilfsvariablen; knappere Statements