Revision add49a32
Von Niclas Zimmermann vor mehr als 12 Jahren hinzugefügt
bin/mozilla/vk.pl | ||
---|---|---|
34 | 34 |
use POSIX qw(strftime); |
35 | 35 |
use List::Util qw(sum first); |
36 | 36 |
|
37 |
use SL::AM; |
|
37 | 38 |
use SL::VK; |
38 | 39 |
use SL::IS; |
39 | 40 |
use SL::ReportGenerator; |
... | ... | |
149 | 150 |
$form->{title} = $locale->text('Sales Report'); |
150 | 151 |
|
151 | 152 |
@columns = |
152 |
qw(description invnumber transdate customernumber customername partnumber partsgroup country business transdate qty unit sellprice sellprice_total discount lastcost lastcost_total marge_total marge_percent employee salesman); |
|
153 |
qw(description invnumber transdate customernumber customername partnumber partsgroup country business transdate qty parts_unit sellprice sellprice_total discount lastcost lastcost_total marge_total marge_percent employee salesman);
|
|
153 | 154 |
|
154 | 155 |
my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs_ic }, @{ $cvar_configs_ct }; |
155 | 156 |
my @searchable_custom_variables = grep { $_->{searchable} } @{ $cvar_configs_ic }, @{ $cvar_configs_ct }; |
... | ... | |
184 | 185 |
'invnumber' => { 'text' => $locale->text('Invoice Number'), }, |
185 | 186 |
'transdate' => { 'text' => $locale->text('Invoice Date'), }, |
186 | 187 |
'qty' => { 'text' => $locale->text('Quantity'), }, |
187 |
'unit' => { 'text' => $locale->text('Unit'), },
|
|
188 |
'parts_unit' => { 'text' => $locale->text('Base unit'), },
|
|
188 | 189 |
'sellprice' => { 'text' => $locale->text('Sales price'), }, |
189 | 190 |
'sellprice_total' => { 'text' => $locale->text('Sales net amount'), }, |
190 | 191 |
'lastcost_total' => { 'text' => $locale->text('Purchase net amount'), }, |
... | ... | |
203 | 204 |
|
204 | 205 |
map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns; |
205 | 206 |
|
206 |
my %column_alignment = map { $_ => 'right' } qw(lastcost sellprice sellprice_total lastcost_total unit discount marge_total marge_percent qty); |
|
207 |
my %column_alignment = map { $_ => 'right' } qw(lastcost sellprice sellprice_total lastcost_total parts_unit discount marge_total marge_percent qty);
|
|
207 | 208 |
|
208 | 209 |
|
209 | 210 |
# so now the check-box "Description" is only used as switch for part description in invoice-mode |
... | ... | |
322 | 323 |
|
323 | 324 |
my $idx = 0; |
324 | 325 |
|
326 |
my $basefactor; |
|
327 |
my $all_units = AM->retrieve_all_units(); |
|
328 |
|
|
325 | 329 |
foreach my $ar (@{ $form->{AR} }) { |
330 |
$basefactor = $all_units->{$ar->{unit}}->{factor} / $all_units->{$ar->{parts_unit}}->{factor}; |
|
331 |
$basefactor = 1 unless $basefactor; |
|
326 | 332 |
|
327 | 333 |
$ar->{price_factor} = 1 unless $ar->{price_factor}; |
328 | 334 |
# calculate individual sellprice |
329 | 335 |
# discount was already accounted for in db sellprice |
330 |
$ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor}; |
|
336 |
$ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor} / $basefactor;
|
|
331 | 337 |
$ar->{lastcost} = $ar->{lastcost} / $ar->{price_factor}; |
332 |
$ar->{sellprice_total} = $ar->{qty} * ( $ar->{fxsellprice} * ( 1 - $ar->{discount} ) ) ; |
|
333 |
$ar->{lastcost_total} = $ar->{qty} * $ar->{lastcost}; |
|
338 |
$ar->{sellprice_total} = $ar->{qty} * ( $ar->{fxsellprice} * ( 1 - $ar->{discount} ) ) / $ar->{price_factor};
|
|
339 |
$ar->{lastcost_total} = $ar->{qty} * $ar->{lastcost} * $basefactor;
|
|
334 | 340 |
# marge_percent wird neu berechnet, da Wert in invoice leer ist (Bug) |
335 | 341 |
$ar->{marge_percent} = $ar->{sellprice_total} ? (($ar->{sellprice_total}-$ar->{lastcost_total}) / $ar->{sellprice_total} * 100) : 0; |
336 | 342 |
# marge_total neu berechnen |
... | ... | |
415 | 421 |
# wird laufend bei jeder Position neu berechnet |
416 | 422 |
$totals{marge_percent} = $totals{sellprice_total} ? ( ($totals{sellprice_total} - $totals{lastcost_total}) / $totals{sellprice_total} ) * 100 : 0; |
417 | 423 |
|
424 |
#passt die qty an die gewählte Einheit an |
|
425 |
#qty wurde bisher noch für andere Berechnungen benötigt und daher erst am Schluss überschrieben |
|
426 |
$ar->{qty} *= $basefactor; |
|
427 |
|
|
418 | 428 |
map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, 2) } qw(marge_total marge_percent); |
419 | 429 |
map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, $form->{"decimalplaces"} )} qw(lastcost sellprice sellprice_total lastcost_total); |
420 | 430 |
|
Auch abrufbar als: Unified diff
Verkaufsbericht Einheiten und Preisfaktoren berücksichtigen
Im Verkaufsbericht werden jetzt auch Einheiten und Preisfaktoren
berücksichtigt. Vorher kam es zu Fehlern, wenn man Rechnungen
mit von den Basisangaben abweichenden Einheiten oder Preisfaktoren
erstellt hat. Weiterhin werden in dem Bericht nur noch absolute Mengen
in Verbindung mit der Basiseinheit angezeigt (nicht mehr die Einheit
aus dem Beleg; zur Berechnung von Durchschnitten).