Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision add49a32

Von Niclas Zimmermann vor mehr als 12 Jahren hinzugefügt

  • ID add49a32e648b08f1ff93096c9750a1d8c6f9657
  • Vorgänger 8c8f6da3
  • Nachfolger 7b6a3af9

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).

Unterschiede anzeigen:

SL/VK.pm
51 51
  my @values;
52 52

  
53 53
  my $query =
54
    qq|SELECT ct.id as customerid, ct.name as customername,ct.customernumber,ct.country,ar.invnumber,ar.id,ar.transdate,p.partnumber,pg.partsgroup,i.parts_id,i.qty,i.price_factor,i.discount,i.description as description,i.lastcost,i.sellprice,i.fxsellprice,i.marge_total,i.marge_percent,i.unit,b.description as business,e.name as employee,e2.name as salesman, to_char(ar.transdate,'Month') as month, to_char(ar.transdate, 'YYYYMM') as nummonth | .
54
    qq|SELECT ct.id as customerid, ct.name as customername,ct.customernumber,ct.country,ar.invnumber,ar.id,ar.transdate,p.partnumber,pg.partsgroup,i.parts_id,i.qty,i.price_factor,i.discount,i.description as description,i.lastcost,i.sellprice,i.fxsellprice,i.marge_total,i.marge_percent,i.unit,b.description as business,e.name as employee,e2.name as salesman, to_char(ar.transdate,'Month') as month, to_char(ar.transdate, 'YYYYMM') as nummonth, p.unit as parts_unit | .
55 55
    qq|FROM invoice i | .  
56 56
    qq|JOIN ar on (i.trans_id = ar.id) | .
57 57
    qq|JOIN parts p on (i.parts_id = p.id) | .
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

  
templates/webpages/vk/search_invoice.html
29 29
               <option value="month">[% 'Month' | $T8 %]</option>
30 30
               </select>
31 31
             </td>
32
             <td align=left><input name="l_headers_mainsort" class=checkbox type=checkbox value="Y" checked> [% 'Heading' | $T8 %]</td>
33
             <td align=left><input name="l_subtotal_mainsort" class=checkbox type=checkbox value="Y" checked> [% 'Subtotal' | $T8 %]</td>
32
             <td align=left><input name="l_headers_mainsort" class=checkbox type=checkbox value=Y checked> [% 'Heading' | $T8 %]</td>
33
             <td align=left><input name="l_subtotal_mainsort" class=checkbox type=checkbox value=Y checked> [% 'Subtotal' | $T8 %]</td>
34 34
             </tr>
35 35
             <tr>
36 36
               <td align="right">[% 'Secondary sorting' | $T8 %]</td>
......
50 50
             </tr>
51 51
           <tr>
52 52
           <th align="right">[% 'Item mode' | $T8 %]</th>
53
           <td colspan="3" align=left><input name="l_parts" class=checkbox type=checkbox value="Y"> ([%'Show items from invoices individually' | $T8 %]) </td>
53
           <td colspan="3" align=left><input name="l_parts" class=checkbox type=checkbox value=Y> ([%'Show items from invoices individually' | $T8 %]) </td>
54 54
          </tr>
55 55
          <tr> 
56 56
           <th align="right">
57 57
             [% 'Total sum' | $T8 %]
58 58
           </th>
59
           <td colspan="1" align=left><input name="l_total" class=checkbox type=checkbox value="Y" checked></td>
59
           <td colspan="1" align=left><input name="l_total" class=checkbox type=checkbox value=Y checked></td>
60 60
            <td align="right" nowrap>[% 'Decimalplaces' | $T8 %]: </td>
61 61
            <td colspan="2"><input name="decimalplaces" size="2" value="2"></td>
62 62
          </tr>
......
237 237
           <td colspan="4">([% 'averaged values, in invoice mode only useful when filtered by a part' | $T8 %])</td>
238 238
          </tr>
239 239
          <tr>
240
           <td align=left><input name="l_qty" class=checkbox type=checkbox value="Y" checked>[% 'Quantity' | $T8 %]</td>
241
           <td align=left><input name="l_discount" class=checkbox type=checkbox value="Y">[% 'Discount' | $T8 %]</td>
240
           <td align=left><input name="l_qty" class=checkbox type=checkbox value=Y checked>[% 'Quantity' | $T8 %]</td>
241
           <td align=left><input name="l_discount" class=checkbox type=checkbox value=Y>[% 'Discount' | $T8 %]</td>
242 242
           <td></td>
243 243
           <td colspan="4">([% 'averaged values, in invoice mode only useful when filtered by a part' | $T8 %])</td>
244 244
          </tr>
......
250 250
           <td align=left><input name="l_description" class=checkbox type=checkbox value=Y checked>[% 'Description' | $T8 %]</td>
251 251
           <td align=left><input name="l_partnumber" class=checkbox type=checkbox value=Y>[% 'Part Number' | $T8 %]</td>
252 252
           <td align=left><input name="l_invnumber" class=checkbox type=checkbox value=Y>[% 'Invnumber' | $T8 %]</td>
253
           <td align=left><input name="l_transdate" class=checkbox type=checkbox value="Y">[% 'Invdate' | $T8 %]</td>
253
           <td align=left><input name="l_transdate" class=checkbox type=checkbox value=Y>[% 'Invdate' | $T8 %]</td>
254 254
          </tr>
255 255
          <tr>
256
           <td align=left><input name="l_unit" class=checkbox type=checkbox value="Y">[% 'Unit' | $T8 %]</td>
256
           <td align=left><input name="l_parts_unit" class=checkbox type=checkbox value=Y>[% 'Base unit' | $T8 %]</td>
257 257
           <td align=left><input name="l_partsgroup" class=checkbox type=checkbox value=Y>[% 'Group' | $T8 %]</td>
258 258
           <td align=left><input name="l_salesman" class=checkbox type=checkbox value=Y>[% 'Salesperson' | $T8 %]</td>
259 259
           <td align=left><input name="l_employee" class=checkbox type=checkbox value=Y>[% 'Employee' | $T8 %]</td>

Auch abrufbar als: Unified diff