Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1e251313

Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt

  • ID 1e25131315e72036aa6df1d626011a761218d233
  • Vorgänger 0615efff
  • Nachfolger 6ebad56e

Preisfatkoren implementiert.

Unterschiede anzeigen:

SL/AM.pm
2228 2228
  $main::lxdebug->leave_sub();
2229 2229
}
2230 2230

  
2231
sub save_price_factor {
2232
  $main::lxdebug->enter_sub();
2233

  
2234
  my ($self, $myconfig, $form) = @_;
2235

  
2236
  # connect to database
2237
  my $dbh = $form->get_standard_dbh($myconfig);
2238

  
2239
  my $query;
2240
  my @values = ($form->{description}, conv_i($form->{factor}));
2241

  
2242
  if ($form->{id}) {
2243
    $query = qq|UPDATE price_factors SET description = ?, factor = ? WHERE id = ?|;
2244
    push @values, conv_i($form->{id});
2245

  
2246
  } else {
2247
    $query = qq|INSERT INTO price_factors (description, factor, sortkey) VALUES (?, ?, (SELECT COALESCE(MAX(sortkey), 0) + 1 FROM price_factors))|;
2248
  }
2249

  
2250
  do_query($form, $dbh, $query, @values);
2251

  
2252
  $dbh->commit();
2253

  
2254
  $main::lxdebug->leave_sub();
2255
}
2256

  
2257
sub get_all_price_factors {
2258
  $main::lxdebug->enter_sub();
2259

  
2260
  my ($self, $myconfig, $form) = @_;
2261

  
2262
  # connect to database
2263
  my $dbh = $form->get_standard_dbh($myconfig);
2264

  
2265
  $form->{PRICE_FACTORS} = selectall_hashref_query($form, $dbh, qq|SELECT * FROM price_factors ORDER BY sortkey|);
2266

  
2267
  $main::lxdebug->leave_sub();
2268
}
2269

  
2270
sub get_price_factor {
2271
  $main::lxdebug->enter_sub();
2272

  
2273
  my ($self, $myconfig, $form) = @_;
2274

  
2275
  # connect to database
2276
  my $dbh = $form->get_standard_dbh($myconfig);
2277

  
2278
  my $query = qq|SELECT description, factor,
2279
                   ((SELECT COUNT(*) FROM parts      WHERE price_factor_id = ?) +
2280
                    (SELECT COUNT(*) FROM invoice    WHERE price_factor_id = ?) +
2281
                    (SELECT COUNT(*) FROM orderitems WHERE price_factor_id = ?)) = 0 AS orphaned
2282
                 FROM price_factors WHERE id = ?|;
2283

  
2284
  ($form->{description}, $form->{factor}, $form->{orphaned}) = selectrow_query($form, $dbh, $query, (conv_i($form->{id})) x 4);
2285

  
2286
  $main::lxdebug->leave_sub();
2287
}
2288

  
2289
sub delete_price_factor {
2290
  $main::lxdebug->enter_sub();
2291

  
2292
  my ($self, $myconfig, $form) = @_;
2293

  
2294
  # connect to database
2295
  my $dbh = $form->get_standard_dbh($myconfig);
2296

  
2297
  do_query($form, $dbh, qq|DELETE FROM price_factors WHERE id = ?|, conv_i($form->{id}));
2298
  $dbh->commit();
2299

  
2300
  $main::lxdebug->leave_sub();
2301
}
2231 2302

  
2232 2303

  
2233 2304
1;
SL/Form.pm
1876 1876
  $main::lxdebug->leave_sub();
1877 1877
}
1878 1878

  
1879
sub _get_price_factors {
1880
  $main::lxdebug->enter_sub();
1881

  
1882
  my ($self, $dbh, $key) = @_;
1883

  
1884
  $key ||= "all_price_factors";
1885

  
1886
  my $query = qq|SELECT * FROM price_factors ORDER BY sortkey|;
1887

  
1888
  $self->{$key} = selectall_hashref_query($self, $dbh, $query);
1889

  
1890
  $main::lxdebug->leave_sub();
1891
}
1892

  
1879 1893
sub get_lists {
1880 1894
  $main::lxdebug->enter_sub();
1881 1895

  
......
1958 1972
    $self->_get_departments($dbh, $params{"departments"});
1959 1973
  }
1960 1974

  
1975
  if ($params{price_factors}) {
1976
    $self->_get_price_factors($dbh, $params{price_factors});
1977
  }
1978

  
1961 1979
  $main::lxdebug->leave_sub();
1962 1980
}
1963 1981

  
SL/IC.pm
422 422
         ean = ?,
423 423
         not_discountable = ?,
424 424
         microfiche = ?,
425
         partsgroup_id = ?
425
         partsgroup_id = ?,
426
         price_factor_id = ?
426 427
       WHERE id = ?|;
427 428
  @values = ($form->{partnumber},
428 429
             $form->{description},
......
451 452
             $form->{not_discountable} ? 't' : 'f',
452 453
             $form->{microfiche},
453 454
             conv_i($partsgroup_id),
455
             conv_i($form->{price_factor_id}),
454 456
             conv_i($form->{id})
455 457
  );
456 458
  do_query($form, $dbh, $query, @values);
......
850 852
#  my @inactive_flags       = qw(l_subtotal short l_linetotal);
851 853

  
852 854
  my %joins = (
853
    partsgroup => 'LEFT JOIN partsgroup pg ON p.partsgroup_id = pg.id',
854
    makemodel  => 'LEFT JOIN makemodel mm ON mm.parts_id = p.id',
855
    partsgroup => 'LEFT JOIN partsgroup pg      ON (pg.id       = p.partsgroup_id)',
856
    makemodel  => 'LEFT JOIN makemodel mm       ON (mm.parts_id = p.id)',
857
    pfac       => 'LEFT JOIN price_factors pfac ON (pfac.id     = p.price_factor_id)',
855 858
    invoice_oi =>
856 859
      q|LEFT JOIN (
857 860
         SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty,          assemblyitem, 'invoice'    AS ioi FROM invoice UNION
......
869 872
           SELECT id, name, 'vendor'   AS cv FROM vendor
870 873
         ) AS cv ON cv.id = apoe.customer_id OR cv.id = apoe.vendor_id|,
871 874
  );
872
  my @join_order = qw(partsgroup makemodel invoice_oi apoe cv);
873
  my %joins_needed = (0) x scalar keys %joins;
875
  my @join_order = qw(partsgroup makemodel invoice_oi apoe cv pfac);
876
  my %joins_needed;
874 877

  
875 878
  #===== switches and simple filters ========#
876 879

  
877
  my @select_tokens = qw(id);
880
  my @select_tokens = qw(id factor);
878 881
  my @where_tokens  = qw(1=1);
879 882
  my @group_tokens  = ();
880 883

  
......
945 948
  push @where_tokens, join ' OR ', map { "($_)" } @bsooqr_tokens              if $bsooqr;
946 949

  
947 950
  $joins_needed{partsgroup}  = 1;
951
  $joins_needed{pfac}        = 1;
948 952
  $joins_needed{makemodel}   = 1 if grep { $form->{$_} || $form->{"l_$_"} } @makemodel_filters;
949 953
  $joins_needed{cv}          = 1 if $bsooqr;
950 954
  $joins_needed{apoe}        = 1 if $joins_needed{cv}   || grep { $form->{$_} || $form->{"l_$_"} } @apoe_filters;
......
967 971
  if ($form->{l_soldtotal}) {
968 972
    push @where_tokens, 'ioi.qty >= 0';
969 973
    push @group_tokens, @select_tokens;
970
    push @select_tokens, 'SUM(ioi.qty) AS soldtotal';
974
    push @select_tokens, 'SUM(ioi.qty)';
971 975
  }
972 976

  
973 977
  #============= build query ================#
......
979 983
     ordnumber    => 'apoe.', make         => 'mm.',
980 984
     quonumber    => 'apoe.', model        => 'mm.',
981 985
     invnumber    => 'apoe.', partsgroup   => 'pg.',
982
     'SUM(ioi.qty) AS soldtotal' => ' ',
986
     factor       => 'pfac.',
987
     'SUM(ioi.qty)' => ' ',
988
  );
989

  
990
  my %renamed_columns = (
991
    'factor'       => 'price_factor',
992
    'SUM(ioi.qty)' => 'soldtotal',
983 993
  );
984 994

  
985 995
  map { $table_prefix{$_} = 'ioi.' } qw(description serialnumber qty unit) if $joins_needed{invoice_oi};
996
  map { $renamed_columns{$_} = ' AS ' . $renamed_columns{$_} } keys %renamed_columns;
986 997

  
987
  my $select_clause = join ', ',    map { ($table_prefix{$_} || "p.") . $_ } @select_tokens;
998
  my $select_clause = join ', ',    map { ($table_prefix{$_} || "p.") . $_ . $renamed_columns{$_} } @select_tokens;
988 999
  my $join_clause   = join ' ',     @joins{ grep $joins_needed{$_}, @join_order };
989 1000
  my $where_clause  = join ' AND ', map { "($_)" } @where_tokens;
990 1001
  my $group_clause  = ' GROUP BY ' . join ', ',    map { ($table_prefix{$_} || "p.") . $_ } @group_tokens if scalar @group_tokens;
991 1002

  
992 1003
  my $query = qq|SELECT DISTINCT $select_clause FROM parts p $join_clause WHERE $where_clause $group_clause $order_clause $limit_clause|;
1004

  
993 1005
  $form->{parts} = selectall_hashref_query($form, $dbh, $query, @bind_vars);
994 1006

  
995 1007
##  my $where = qq|1 = 1|;
SL/IR.pm
82 82
  my $q_item_unit = qq|SELECT unit FROM parts WHERE id = ?|;
83 83
  my $h_item_unit = prepare_query($form, $dbh, $q_item_unit);
84 84

  
85
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
86
  my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
87
  my $price_factor;
88

  
85 89
  for my $i (1 .. $form->{rowcount}) {
86 90
    next unless $form->{"id_$i"};
87 91

  
......
119 123

  
120 124
    map { $taxrate += $form->{"${_}_rate"} } @taxaccounts;
121 125

  
126
    $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
127

  
122 128
    if ($form->{"inventory_accno_$i"}) {
123 129

  
124
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
130
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
125 131

  
126 132
      if ($form->{taxincluded}) {
127 133
        $taxamount              = $linetotal * ($taxrate / (1 + $taxrate));
......
151 157
      }
152 158

  
153 159
      # add purchase to inventory, this one is without the tax!
154
      $amount    = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate};
155
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2) * $form->{exchangerate};
160
      $amount    = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate} / $price_factor;
161
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2) * $form->{exchangerate};
156 162
      $linetotal = $form->round_amount($linetotal, 2);
157 163

  
158 164
      # this is the difference for the inventory
......
230 236

  
231 237
      $sth->finish();
232 238

  
233
    } else {
239
    } else {                    # if ($form->{"inventory_accno_id_$i"})
234 240

  
235
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
241
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
236 242

  
237 243
      if ($form->{taxincluded}) {
238 244
        $taxamount              = $linetotal * ($taxrate / (1 + $taxrate));
......
258 264
        map { $form->{amount}{ $form->{id} }{$_} -= $taxamount * $form->{"${_}_rate"} / $taxrate } @taxaccounts;
259 265
      }
260 266

  
261
      $amount    = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate};
262
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2) * $form->{exchangerate};
267
      $amount    = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate} / $price_factor;
268
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2) * $form->{exchangerate};
263 269
      $linetotal = $form->round_amount($linetotal, 2);
264 270

  
265 271
      # this is the difference for expense
......
286 292
    $query =
287 293
      qq|INSERT INTO invoice (trans_id, parts_id, description, qty, base_qty,
288 294
                              sellprice, fxsellprice, allocated, unit, deliverydate,
289
                              project_id, serialnumber)
290
         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
295
                              project_id, serialnumber, price_factor_id, price_factor, marge_price_factor)
296
         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|;
291 297
    @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}),
292 298
               $form->{"description_$i"}, $form->{"qty_$i"} * -1,
293 299
               $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $allocated,
294 300
               $form->{"unit_$i"}, conv_date($form->{deliverydate}),
295
               conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"});
301
               conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"},
302
               conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"}));
296 303
    do_query($form, $dbh, $query, @values);
297 304
  }
298 305

  
......
728 735
        c3.accno AS expense_accno,   c3.new_chart_id AS expense_new_chart,   date($transdate) - c3.valid_from AS expense_valid,
729 736

  
730 737
        i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
731
        p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup 
738
        i.price_factor_id, i.price_factor, i.marge_price_factor,
739
        p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup
732 740

  
733 741
        FROM invoice i
734 742
        JOIN parts p ON (i.parts_id = p.id)
......
947 955
         p.id, p.partnumber, p.description, p.lastcost AS sellprice, p.listprice,
948 956
         p.unit, p.assembly, p.bin, p.onhand, p.formel,
949 957
         p.notes AS partnotes, p.notes AS longdescription, p.not_discountable,
950
         p.inventory_accno_id,
958
         p.inventory_accno_id, p.price_factor_id,
959

  
960
         pfac.factor AS price_factor,
951 961

  
952 962
         c1.accno                         AS inventory_accno,
953 963
         c1.new_chart_id                  AS inventory_new_chart,
......
977 987
           FROM buchungsgruppen
978 988
           WHERE id = p.buchungsgruppen_id) = c3.id)
979 989
       LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
990
       LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id)
980 991
       WHERE $where|;
981 992
  my $sth = prepare_execute_query($form, $dbh, $query, @values);
982 993

  
SL/IS.pm
60 60

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

  
63
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
64
  my %price_factors;
65

  
66
  foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) {
67
    $price_factors{$pfac->{id}}  = $pfac;
68
    $pfac->{factor}             *= 1;
69
    $pfac->{formatted_factor}    = $form->format_amount($myconfig, $pfac->{factor});
70
  }
71

  
63 72
  # sort items by partsgroup
64 73
  for $i (1 .. $form->{rowcount}) {
65 74
    $partsgroup = "";
......
123 132
       deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil
124 133
       partnotes serialnumber reqdate sellprice listprice netprice
125 134
       discount p_discount discount_sub nodiscount_sub
126
       linetotal  nodiscount_linetotal tax_rate projectnumber);
135
       linetotal  nodiscount_linetotal tax_rate projectnumber
136
       price_factor price_factor_name);
127 137

  
128 138
  my @tax_arrays =
129 139
    qw(taxbase tax taxdescription taxrate taxnumber);
......
157 167
        $position++;
158 168
      }
159 169

  
160
      push @{ $form->{runningnumber} },   $position;
161
      push @{ $form->{number} },          $form->{"partnumber_$i"};
162
      push @{ $form->{serialnumber} },    $form->{"serialnumber_$i"};
163
      push @{ $form->{bin} },             $form->{"bin_$i"};
164
      push @{ $form->{"partnotes"} },     $form->{"partnotes_$i"};
165
      push @{ $form->{description} },     $form->{"description_$i"};
166
      push @{ $form->{longdescription} }, $form->{"longdescription_$i"};
167
      push @{ $form->{qty} },             $form->format_amount($myconfig, $form->{"qty_$i"});
168
      push @{ $form->{unit} },            $form->{"unit_$i"};
169
      push @{ $form->{deliverydate_oe} }, $form->{"deliverydate_$i"};
170
      push @{ $form->{sellprice} },       $form->{"sellprice_$i"};
171
      push @{ $form->{ordnumber_oe} },    $form->{"ordnumber_$i"};
172
      push @{ $form->{transdate_oe} },    $form->{"transdate_$i"};
173
      push @{ $form->{invnumber} },       $form->{"invnumber"};
174
      push @{ $form->{invdate} },         $form->{"invdate"};
170
      my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 };
171

  
172
      push @{ $form->{runningnumber} },     $position;
173
      push @{ $form->{number} },            $form->{"partnumber_$i"};
174
      push @{ $form->{serialnumber} },      $form->{"serialnumber_$i"};
175
      push @{ $form->{bin} },               $form->{"bin_$i"};
176
      push @{ $form->{"partnotes"} },       $form->{"partnotes_$i"};
177
      push @{ $form->{description} },       $form->{"description_$i"};
178
      push @{ $form->{longdescription} },   $form->{"longdescription_$i"};
179
      push @{ $form->{qty} },               $form->format_amount($myconfig, $form->{"qty_$i"});
180
      push @{ $form->{unit} },              $form->{"unit_$i"};
181
      push @{ $form->{deliverydate_oe} },   $form->{"deliverydate_$i"};
182
      push @{ $form->{sellprice} },         $form->{"sellprice_$i"};
183
      push @{ $form->{ordnumber_oe} },      $form->{"ordnumber_$i"};
184
      push @{ $form->{transdate_oe} },      $form->{"transdate_$i"};
185
      push @{ $form->{invnumber} },         $form->{"invnumber"};
186
      push @{ $form->{invdate} },           $form->{"invdate"};
187
      push @{ $form->{price_factor} },      $price_factor->{formatted_factor};
188
      push @{ $form->{price_factor_name} }, $price_factor->{description};
175 189

  
176 190
      if ($form->{lizenzen}) {
177 191
        if ($form->{"licensenumber_$i"}) {
......
193 207
      my ($dec)         = ($sellprice =~ /\.(\d+)/);
194 208
      my $decimalplaces = max 2, length($dec);
195 209

  
196
      my $discount             = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100, $decimalplaces);
197
      my $linetotal            = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100, 2);
198
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice, 2);
210
      my $discount             = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100 / $price_factor->{factor}, $decimalplaces);
211
      my $linetotal            = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100 / $price_factor->{factor}, 2);
212
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2);
199 213
      $form->{"netprice_$i"}   = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2);
200 214

  
201 215
      push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
......
517 531

  
518 532
  my %baseunits;
519 533

  
534
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
535
  my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
536
  my $price_factor;
537

  
520 538
  foreach my $i (1 .. $form->{rowcount}) {
521 539
    if ($form->{type} eq "credit_note") {
522 540
      $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}) * -1;
......
577 595
      $form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"});
578 596

  
579 597
      # round linetotal to 2 decimal places
580
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
598
      $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
599
      $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
581 600

  
582 601
      if ($form->{taxincluded}) {
583 602
        $taxamount = $linetotal * ($taxrate / (1 + $taxrate));
......
597 616
      }
598 617

  
599 618
      # add amount to income, $form->{amount}{trans_id}{accno}
600
      $amount =
601
        $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate};
619
      $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate} / $price_factor;
602 620

  
603
      $linetotal =
604
        $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2) *
605
        $form->{exchangerate};
621
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2) * $form->{exchangerate};
606 622
      $linetotal = $form->round_amount($linetotal, 2);
607 623

  
608 624
      # this is the difference from the inventory
......
662 678
                                sellprice, fxsellprice, discount, allocated, assemblyitem,
663 679
                                unit, deliverydate, project_id, serialnumber, pricegroup_id,
664 680
                                ordnumber, transdate, cusordnumber, base_qty, subtotal,
665
                                marge_percent, marge_total, lastcost)
666
           VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
681
                                marge_percent, marge_total, lastcost,
682
                                price_factor_id, price_factor, marge_price_factor)
683
           VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
684
                   (SELECT factor FROM price_factors WHERE id = ?), ?)|;
667 685

  
668 686
      @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}),
669 687
                 $form->{"description_$i"}, $form->{"longdescription_$i"}, $form->{"qty_$i"},
......
674 692
                 $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
675 693
                 $form->{"cusordnumber_$i"}, $baseqty, $form->{"subtotal_$i"} ? 't' : 'f',
676 694
                 $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"},
677
                 $form->{"lastcost_$i"});
695
                 $form->{"lastcost_$i"},
696
                 conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}),
697
                 conv_i($form->{"marge_price_factor_$i"}));
678 698
      do_query($form, $dbh, $query, @values);
679 699

  
680 700
      if ($form->{lizenzen} && $form->{"licensenumber_$i"}) {
......
1387 1407

  
1388 1408
           i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate,
1389 1409
           i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost,
1410
           i.price_factor_id, i.price_factor, i.marge_price_factor,
1390 1411
           p.partnumber, p.assembly, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel,
1391 1412
           pr.projectnumber, pg.partsgroup, prg.pricegroup
1392 1413

  
......
1687 1708
         p.unit, p.assembly, p.bin, p.onhand,
1688 1709
         p.notes AS partnotes, p.notes AS longdescription,
1689 1710
         p.not_discountable, p.formel, p.payment_id AS part_payment_id,
1711
         p.price_factor_id,
1712

  
1713
         pfac.factor AS price_factor,
1690 1714

  
1691 1715
         pg.partsgroup
1692 1716

  
......
1704 1728
           FROM buchungsgruppen
1705 1729
           WHERE id = p.buchungsgruppen_id) = c3.id)
1706 1730
       LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
1731
       LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id)
1707 1732
       WHERE $where|;
1708 1733
  my $sth = prepare_execute_query($form, $dbh, $query, @values);
1709 1734

  
SL/OE.pm
230 230
  my %taxaccounts;
231 231
  my $netamount = 0;
232 232

  
233
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
234
  my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
235
  my $price_factor;
236

  
233 237
  for my $i (1 .. $form->{rowcount}) {
234 238

  
235 239
    map({ $form->{"${_}_$i"} =
......
275 279
      $form->{"inventory_accno_$i"} *= 1;
276 280
      $form->{"expense_accno_$i"}   *= 1;
277 281

  
278
      $linetotal =
279
        $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
282
      $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
283
      $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
280 284

  
281 285
      @taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
282 286
      $taxrate     = 0;
......
324 328
        }
325 329
      }
326 330

  
327
      $netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"};
331
      $netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor;
328 332

  
329 333
      $reqdate =
330 334
        ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
......
342 346
      $query .= qq|trans_id, parts_id, description, longdescription, qty, base_qty, | .
343 347
                qq|sellprice, discount, unit, reqdate, project_id, serialnumber, ship, | .
344 348
                qq|pricegroup_id, ordnumber, transdate, cusordnumber, subtotal, | .
345
                qq|marge_percent, marge_total, lastcost) | .
349
                qq|marge_percent, marge_total, lastcost, price_factor_id, price_factor, marge_price_factor) | .
346 350
                qq|VALUES (|;
347 351
      if($form->{"orderitems_id_$i"}) {
348 352
        $query .= qq|?,|;
349 353
        push(@values, $form->{"orderitems_id_$i"});
350 354
      }
351
      $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
355
      $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
356
                   (SELECT factor FROM price_factors WHERE id = ?), ?)|;
352 357
		  push(@values,
353 358
           conv_i($form->{id}), conv_i($form->{"id_$i"}),
354 359
           $form->{"description_$i"}, $form->{"longdescription_$i"},
......
359 364
           $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
360 365
           $form->{"cusordnumber_$i"}, $form->{"subtotal_$i"} ? 't' : 'f',
361 366
           $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"},
362
           $form->{"lastcost_$i"});
367
           $form->{"lastcost_$i"},
368
           conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}),
369
           conv_i($form->{"marge_price_factor_$i"}));
363 370
      do_query($form, $dbh, $query, @values);
364 371

  
365 372
      $form->{"sellprice_$i"} = $fxsellprice;
......
724 731
           o.sellprice, o.parts_id AS id, o.unit, o.discount, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id,
725 732
           o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost,
726 733
           o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription,
734
           o.price_factor_id, o.price_factor, o.marge_price_factor,
727 735
           pr.projectnumber, p.formel,
728 736
           pg.partsgroup, o.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=o.pricegroup_id) as pricegroup
729 737
         FROM orderitems o
......
873 881

  
874 882
  push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"});
875 883

  
884
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
885
  my %price_factors;
886

  
887
  foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) {
888
    $price_factors{$pfac->{id}}  = $pfac;
889
    $pfac->{factor}             *= 1;
890
    $pfac->{formatted_factor}    = $form->format_amount($myconfig, $pfac->{factor});
891
  }
892

  
876 893
  # sort items by partsgroup
877 894
  for $i (1 .. $form->{rowcount}) {
878 895
    $partsgroup = "";
......
900 917
    qw(runningnumber number description longdescription qty ship unit bin
901 918
       partnotes serialnumber reqdate sellprice listprice netprice
902 919
       discount p_discount discount_sub nodiscount_sub
903
       linetotal  nodiscount_linetotal tax_rate projectnumber);
920
       linetotal  nodiscount_linetotal tax_rate projectnumber
921
       price_factor price_factor_name);
904 922

  
905 923
  my $sameitem = "";
906 924
  foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
......
933 951
        $position++;
934 952
      }
935 953

  
936
      push @{ $form->{runningnumber} },   $position;
937
      push @{ $form->{number} },          $form->{"partnumber_$i"};
938
      push @{ $form->{description} },     $form->{"description_$i"};
939
      push @{ $form->{longdescription} }, $form->{"longdescription_$i"};
940
      push @{ $form->{qty} },             $form->format_amount($myconfig, $form->{"qty_$i"});
941
      push @{ $form->{ship} },            $form->format_amount($myconfig, $form->{"ship_$i"});
942
      push @{ $form->{unit} },            $form->{"unit_$i"};
943
      push @{ $form->{bin} },             $form->{"bin_$i"};
944
      push @{ $form->{partnotes} },       $form->{"partnotes_$i"};
945
      push @{ $form->{serialnumber} },    $form->{"serialnumber_$i"};
946
      push @{ $form->{reqdate} },         $form->{"reqdate_$i"};
947
      push @{ $form->{sellprice} },       $form->{"sellprice_$i"};
948
      push @{ $form->{listprice} },       $form->{"listprice_$i"};
954
      my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 };
955

  
956
      push @{ $form->{runningnumber} },     $position;
957
      push @{ $form->{number} },            $form->{"partnumber_$i"};
958
      push @{ $form->{description} },       $form->{"description_$i"};
959
      push @{ $form->{longdescription} },   $form->{"longdescription_$i"};
960
      push @{ $form->{qty} },               $form->format_amount($myconfig, $form->{"qty_$i"});
961
      push @{ $form->{ship} },              $form->format_amount($myconfig, $form->{"ship_$i"});
962
      push @{ $form->{unit} },              $form->{"unit_$i"};
963
      push @{ $form->{bin} },               $form->{"bin_$i"};
964
      push @{ $form->{partnotes} },         $form->{"partnotes_$i"};
965
      push @{ $form->{serialnumber} },      $form->{"serialnumber_$i"};
966
      push @{ $form->{reqdate} },           $form->{"reqdate_$i"};
967
      push @{ $form->{sellprice} },         $form->{"sellprice_$i"};
968
      push @{ $form->{listprice} },         $form->{"listprice_$i"};
969
      push @{ $form->{price_factor} },      $price_factor->{formatted_factor};
970
      push @{ $form->{price_factor_name} }, $price_factor->{description};
949 971

  
950 972
      my $sellprice     = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
951 973
      my ($dec)         = ($sellprice =~ /\.(\d+)/);
952 974
      my $decimalplaces = max 2, length($dec);
953 975

  
954
      my $discount             = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100, $decimalplaces);
955
      my $linetotal            = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100, 2);
956
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice, 2);
976
      my $discount             = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100 / $price_factor->{factor}, $decimalplaces);
977
      my $linetotal            = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100 / $price_factor->{factor}, 2);
978
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2);
957 979
      $form->{"netprice_$i"}   = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2);
958 980

  
959 981
      push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
bin/mozilla/am.pl
3244 3244

  
3245 3245
  $lxdebug->leave_sub();
3246 3246
}
3247

  
3248
sub add_price_factor {
3249
  $lxdebug->enter_sub();
3250

  
3251
  $form->{title}      = $locale->text('Add Price Factor');
3252
  $form->{callback} ||= build_std_url('action=add_price_factor');
3253
  $form->{fokus}      = 'description';
3254

  
3255
  $form->header();
3256
  print $form->parse_html_template2('am/edit_price_factor');
3257

  
3258
  $lxdebug->leave_sub();
3259
}
3260

  
3261
sub edit_price_factor {
3262
  $lxdebug->enter_sub();
3263

  
3264
  $form->{title}      = $locale->text('Edit Price Factor');
3265
  $form->{callback} ||= build_std_url('action=add_price_factor');
3266
  $form->{fokus}      = 'description';
3267

  
3268
  AM->get_price_factor(\%myconfig, $form);
3269

  
3270
  $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
3271

  
3272
  $form->header();
3273
  print $form->parse_html_template2('am/edit_price_factor');
3274

  
3275
  $lxdebug->leave_sub();
3276
}
3277

  
3278
sub list_price_factors {
3279
  $lxdebug->enter_sub();
3280

  
3281
  AM->get_all_price_factors(\%myconfig, \%$form);
3282

  
3283
  my $previous;
3284
  foreach my $current (@{ $form->{PRICE_FACTORS} }) {
3285
    if ($previous) {
3286
      $previous->{next_id}    = $current->{id};
3287
      $current->{previous_id} = $previous->{id};
3288
    }
3289

  
3290
    $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
3291

  
3292
    $previous = $current;
3293
  }
3294

  
3295
  $form->{callback} = build_std_url('action=list_price_factors');
3296
  $form->{title}    = $locale->text('Price Factors');
3297
  $form->{url_base} = build_std_url('callback');
3298

  
3299
  $form->header();
3300
  print $form->parse_html_template2('am/list_price_factors');
3301

  
3302
  $lxdebug->leave_sub();
3303
}
3304

  
3305
sub save_price_factor {
3306
  $lxdebug->enter_sub();
3307

  
3308
  $form->isblank("description", $locale->text('Description missing!'));
3309
  $form->isblank("factor", $locale->text('Factor missing!'));
3310

  
3311
  $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
3312

  
3313
  AM->save_price_factor(\%myconfig, $form);
3314

  
3315
  $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
3316

  
3317
  $form->redirect($locale->text('Price factor saved!'));
3318

  
3319
  $lxdebug->leave_sub();
3320
}
3321

  
3322
sub delete_price_factor {
3323
  $lxdebug->enter_sub();
3324

  
3325
  AM->delete_price_factor(\%myconfig, \%$form);
3326

  
3327
  $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
3328

  
3329
  $form->redirect($locale->text('Price factor deleted!'));
3330

  
3331
  $lxdebug->leave_sub();
3332
}
3333

  
3334
sub swap_price_factors {
3335
  $lxdebug->enter_sub();
3336

  
3337
  AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
3338
  list_price_factors();
3339

  
3340
  $lxdebug->leave_sub();
3341
}
3342

  
bin/mozilla/ic.pl
1736 1736
    # fresh row, for inserting later
1737 1737
    my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
1738 1738

  
1739
    $ref->{exchangerate}  = 1 unless $ref->{exchangerate};
1740
    $ref->{sellprice}    *= $ref->{exchangerate};
1741
    $ref->{listprice}    *= $ref->{exchangerate};
1742
    $ref->{lastcost}     *= $ref->{exchangerate};
1739
    $ref->{exchangerate} ||= 1;
1740
    $ref->{price_factor} ||= 1;
1741
    $ref->{sellprice}     *= $ref->{exchangerate} / $ref->{price_factor};
1742
    $ref->{listprice}     *= $ref->{exchangerate} / $ref->{price_factor};
1743
    $ref->{lastcost}      *= $ref->{exchangerate} / $ref->{price_factor};
1743 1744

  
1744 1745
    # use this for assemblies
1745 1746
    my $onhand = $ref->{onhand};
......
1986 1987
  my ($notdiscountableok, $notdiscountable);
1987 1988
  my ($formula, $formula_label, $imagelinks, $obsolete, $shopok, $shop);
1988 1989

  
1990
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
1989 1991

  
1990 1992
  map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) }
1991 1993
      qw(sellprice listprice lastcost gv));
......
2326 2328
    $unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"});
2327 2329
  }
2328 2330

  
2331
  my $price_factor;
2332
  if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
2333
    my @values = ('', map { $_->{id}                      } @{ $form->{ALL_PRICE_FACTORS} });
2334
    my %labels =      map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
2335

  
2336
    $price_factor =
2337
        qq|<tr><th align="right">|
2338
      . $locale->text('Price Factor')
2339
      . qq|</th><td>|
2340
      . NTI($cgi->popup_menu('-name'    => 'price_factor_id',
2341
                             '-default' => $form->{price_factor_id},
2342
                             '-values'  => \@values,
2343
                             '-labels'  => \%labels))
2344
      . qq|</td></tr>|;
2345
  }
2346

  
2329 2347
  $form->{fokus} = "ic.partnumber";
2330 2348
  $form->header;
2331 2349

  
......
2439 2457
		<td><input name=sellprice size=11 value=$form->{sellprice}></td>
2440 2458
	      </tr>
2441 2459
	      $lastcost
2460
	      $price_factor
2442 2461
	      <tr>
2443 2462
		<th align="right" nowrap="true">| . $locale->text('Unit') . qq|</th>
2444 2463
		<td>$unit_select</td>
......
2892 2911

  
2893 2912
    # now take it apart and restore original values
2894 2913
    foreach my $item (split /&/, $previousform) {
2895
      my ($key, $value) = split /=/, $item, 2;
2914
      my ($key, $value) = split m/=/, $item, 2;
2896 2915
      $value =~ s/%26/&/g;
2897 2916
      $form->{$key} = $value;
2898 2917
    }
......
2912 2931
      $form->{weight}    -= $form->{"weight_$i"} * $form->{"qty_$i"};
2913 2932

  
2914 2933
      # change/add values for assembly item
2915
      map { $form->{"${_}_$i"} = $newform{$_} }
2916
        qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno);
2934
      map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno price_factor_id);
2917 2935

  
2918 2936
      $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
2919 2937
      $form->{weight}    += $form->{"weight_$i"} * $form->{"qty_$i"};
......
2924 2942
      $i = $form->{rowcount};
2925 2943
      $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2926 2944

  
2927
      map { $form->{"${_}_$i"} = $newform{$_} }
2928
        qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice);
2945
      map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice lastcost price_factor_id);
2946

  
2929 2947
      $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
2948

  
2930 2949
      if ($form->{exchangerate} != 0) {
2931 2950
        $form->{"sellprice_$i"} /= $form->{exchangerate};
2932 2951
      }
2952

  
2933 2953
      $lxdebug->message($LXDebug::DEBUG1, qq|sellprice_$i in previousform 2 = | . $form->{"sellprice_$i"} . qq|\n|);
2934
      map { $form->{"taxaccounts_$i"} .= "$_ " } split / /,
2935
        $newform{taxaccount};
2954

  
2955
      map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, $newform{taxaccount};
2936 2956
      chop $form->{"taxaccounts_$i"};
2937 2957
      foreach my $item (qw(description rate taxnumber)) {
2938 2958
        my $index = $form->{"taxaccounts_$i"} . "_$item";
......
2940 2960
      }
2941 2961

  
2942 2962
      # credit remaining calculation
2943
      $amount =
2944
        $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
2945
        $form->{"qty_$i"};
2946
      map { $form->{"${_}_base"} += $amount }
2947
        (split / /, $form->{"taxaccounts_$i"});
2948
      map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
2949
        split / /, $form->{"taxaccounts_$i"}
2950
        if !$form->{taxincluded};
2963
      $amount = $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * $form->{"qty_$i"};
2964

  
2965
      map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"});
2966
      map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded};
2951 2967

  
2952 2968
      $form->{creditremaining} -= $amount;
2953 2969

  
2954 2970
      # redo number formatting, because invoice parse them!
2955
      $i = $form->{rowcount};
2956
      map {
2957
        $form->{"${_}_$i"} =
2958
          $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2959
      } qw(weight listprice sellprice rop);
2971
      map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice rop);
2960 2972
    }
2961 2973

  
2962 2974
    $form->{"id_$i"} = $parts_id;
2975

  
2976
    # Get the actual price factor (not just the ID) for the marge calculation.
2977
    $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
2978
    foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) {
2979
      next if ($pfac->{id} != $newform{price_factor_id});
2980
      $form->{"marge_price_factor_$i"} = $pfac->{factor};
2981
      last;
2982
    }
2983
    delete $form->{ALL_PRICE_FACTORS};
2984

  
2963 2985
    delete $form->{action};
2964 2986

  
2965 2987
    # restore original callback
bin/mozilla/io.pl
121 121
  my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
122 122
  my $all_units = AM->retrieve_units(\%myconfig, $form);
123 123

  
124
  my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
125

  
124 126
  push @column_index, qw(unit);
125 127

  
126 128
  #for pricegroups column
......
303 305
    ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
304 306
    $decimalplaces = max length($dec), 2;
305 307

  
306
    $discount  = (100 - $form->{"discount_$i"} * 1) / 100;
307
    $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount, $decimalplaces);
308
    $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1;
309
    $discount     = (100 - $form->{"discount_$i"} * 1) / 100;
310

  
311
    $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces);
308 312

  
309
    my $real_sellprice = $form->{"sellprice_$i"} * $discount;
313
    my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor;
310 314

  
311 315
    # marge calculations
312 316
    my ($marge_font_start, $marge_font_end);
313 317

  
314 318
    $form->{"lastcost_$i"} *= 1;
315 319

  
320
    $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1;
321

  
316 322
    if ($real_sellprice && ($form->{"qty_$i"} * 1)) {
317
      $form->{"marge_percent_$i"}     = ($real_sellprice - $form->{"lastcost_$i"}) * 100 / $real_sellprice;
323
      $form->{"marge_percent_$i"}     = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
318 324
      $myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"}));
319 325

  
320 326
      if ($form->{"id_$i"} &&
......
328 334
    }
329 335

  
330 336
    my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
331
    $form->{"marge_absolut_$i"}  = ($real_sellprice - $form->{"lastcost_$i"}) * $form->{"qty_$i"} * $marge_adjust_credit_note;
337
    $form->{"marge_absolut_$i"}  = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
332 338
    $form->{"marge_total"}      += $form->{"marge_absolut_$i"};
333
    $form->{"lastcost_total"}   += $form->{"lastcost_$i"} * $form->{"qty_$i"};
339
    $form->{"lastcost_total"}   += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
334 340
    $form->{"sellprice_total"}  += $real_sellprice * $form->{"qty_$i"};
335 341

  
336 342
    map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent);
......
387 393
      $this_unit = "kg";
388 394
    }
389 395

  
396
    my $price_factor_select;
397
    if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
398
      my @values = ('', map { $_->{id}                      } @{ $form->{ALL_PRICE_FACTORS} });
399
      my %labels =      map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
400

  
401
      $price_factor_select =
402
        NTI($cgi->popup_menu('-name'    => "price_factor_id_$i",
403
                             '-default' => $form->{"price_factor_id_$i"},
404
                             '-values'  => \@values,
405
                             '-labels'  => \%labels,
406
                             '-style'   => 'width:90px'))
407
        . ' ';
408
    }
409

  
390 410
    $column_data{"unit"} = "<td>" .
411
      $price_factor_select .
391 412
       AM->unit_select_html($is_part || $is_assembly ? $dimension_units :
392 413
                            $is_assigned ? $service_units : $all_units,
393 414
                            "unit_$i", $this_unit,
......
474 495
         "id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i",
475 496
         "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i",
476 497
         "taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i",
477
         "longdescription_$i", "basefactor_$i", "marge_absolut_$i", "marge_percent_$i", "lastcost_$i"));
498
         "longdescription_$i", "basefactor_$i", "marge_absolut_$i", "marge_percent_$i", "lastcost_$i",
499
         "marge_price_factor_$i"));
478 500

  
479 501
########################################
480 502
    # Eintrag fuer Version 2.2.0 geaendert #
......
530 552
|;
531 553

  
532 554
    if ($form->{"id_$i"} && $is_sales) {
555
      my $marge_price_factor;
556

  
557
      $form->{"marge_price_factor_$i"} *= 1;
558

  
559
      if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) {
560
        $marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"});
561
      }
562

  
533 563
      print qq|
534
          ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b>&nbsp;$form->{"marge_absolut_$i"} &nbsp;$form->{"marge_percent_$i"} % ${marge_font_end}
564
          ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b>&nbsp;$form->{"marge_absolut_$i"}&nbsp;$form->{"marge_percent_$i"} % ${marge_font_end}
535 565
          &nbsp;<b>| . $locale->text('LP') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
536
          &nbsp;<b>| . $locale->text('EK') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2);
566
          &nbsp;<b>| . $locale->text('EK') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor;
537 567
    }
538 568

  
539 569
    print qq|
......
695 725
    my @new_fields =
696 726
      qw(bin listprice inventory_accno income_accno expense_accno unit weight
697 727
         assembly taxaccounts partsgroup formel longdescription not_discountable
698
         part_payment_id partnotes id lastcost);
728
         part_payment_id partnotes id lastcost price_factor_id price_factor);
699 729
    push(@new_fields, "lizenzen") if ($lizenzen);
700 730

  
701 731
    print join "\n", map { $cgi->hidden("-name" => "new_${_}_$i", "-value" => $ref->{$_}) } @new_fields;
......
751 781
  # if there was a price entered, override it
752 782
  $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
753 783

  
754
  map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
784
  my @new_fields =
755 785
    qw(id partnumber description sellprice listprice inventory_accno
756 786
       income_accno expense_accno bin unit weight assembly taxaccounts
757
       partsgroup formel longdescription not_discountable partnotes lastcost);
787
       partsgroup formel longdescription not_discountable partnotes lastcost
788
       price_factor_id price_factor);
789

  
790
  map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } @new_fields;
791

  
792
  $form->{"marge_price_factor_$i"} = $form->{"new_price_factor_$j"};
793

  
758 794
  if ($form->{"part_payment_id_$i"} ne "") {
759 795
    $form->{payment_id} = $form->{"part_payment_id_$i"};
760 796
  }
......
804 840

  
805 841
  # delete all the new_ variables
806 842
  for $i (1 .. $form->{lastndx}) {
807
    map { delete $form->{"new_${_}_$i"} }
808
      qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
843
    map { delete $form->{"new_${_}_$i"} } @new_fields;
809 844
  }
810 845

  
811 846
  map { delete $form->{$_} } qw(ndx lastndx nextsub);
......
871 906

  
872 907
  print $cgi->hidden("-name" => "previousform", "-value" => $previousform);
873 908
  map { print $cgi->hidden("-name" => $_, "-value" => $form->{$_}); }        qw(rowcount vc login password);
874
  map { print $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$i"}); } qw(partnumber description unit sellprice);
909
  map { print $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$i"}); } qw(partnumber description unit sellprice price_factor_id);
875 910
  print $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts});
876 911

  
877 912
print qq|
......
992 1027
  $lxdebug->enter_sub();
993 1028
  my @a     = ();
994 1029
  my $count = 0;
995
  my @flds  = (
996
    qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor marge_absolut marge_percent lastcost )
997
  );
998

  
1030
  my @flds  = (qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor marge_absolut marge_percent marge_price_factor lastcost price_factor_id));
999 1031

  
1000 1032
  # remove any makes or model rows
1001 1033
  if ($form->{item} eq 'part') {
......
1796 1828
                        } keys(%{$form})));
1797 1829

  
1798 1830
  reformat_numbers($output_numberformat, undef,
1799
                   qw(qty),
1831
                   qw(qty price_factor),
1800 1832
                   grep({ /^qty_\d+$/
1801 1833
                        } keys(%{$form})));
1802 1834

  
bin/mozilla/ir.pl
61 61

  
62 62
sub edit {
63 63
  $lxdebug->enter_sub();
64
  
64
  $form->{"Watchdog::qty_1"} = 1;
65 65
  # show history button
66 66
  $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
67 67
  #/show hhistory button
......
243 243
  my @old_project_ids = ($form->{"globalproject_id"});
244 244
  map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
245 245

  
246
  $form->get_lists("contacts"   => "ALL_CONTACTS",
247
                   "projects"   => { "key"  => "ALL_PROJECTS",
248
                                     "all"    => 0,
249
                                     "old_id" => \@old_project_ids },
250
                   "taxzones"   => "ALL_TAXZONES",
251
                   "employees"  => "ALL_SALESMEN",
252
                   "currencies" => "ALL_CURRENCIES",
253
                   "vendors"    => "ALL_VENDORS");
246
  $form->get_lists("contacts"      => "ALL_CONTACTS",
247
                   "projects"      => { "key"  => "ALL_PROJECTS",
248
                                      "all"    => 0,
249
                                      "old_id" => \@old_project_ids },
250
                   "taxzones"      => "ALL_TAXZONES",
251
                   "employees"     => "ALL_SALESMEN",
252
                   "currencies"    => "ALL_CURRENCIES",
253
                   "vendors"       => "ALL_VENDORS",
254
                   "price_factors" => "ALL_PRICE_FACTORS");
254 255

  
255 256
  my %labels;
256 257
  my @values = (undef);
......
890 891
        map { $form->{item_list}[$i]{$_} =~ s/\"/&quot;/g } qw(partnumber description unit);
891 892
        map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
892 893

  
894
        $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
895

  
893 896
        ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
894 897
        $decimalplaces = max 2, length $1;
895 898

  
bin/mozilla/is.pl
312 312
  my @old_project_ids = ($form->{"globalproject_id"});
313 313
  map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
314 314

  
315
  $form->get_lists("contacts"   => "ALL_CONTACTS",
316
                   "shipto"     => "ALL_SHIPTO",
317
                   "projects"   => { "key"    => "ALL_PROJECTS",
318
                                     "all"    => 0,
319
                                     "old_id" => \@old_project_ids },
320
                   "employees"  => "ALL_SALESMEN",
321
                   "taxzones"   => "ALL_TAXZONES",
322
                   "currencies" => "ALL_CURRENCIES",
323
                   "customers"  => "ALL_CUSTOMERS");
315
  $form->get_lists("contacts"      => "ALL_CONTACTS",
316
                   "shipto"        => "ALL_SHIPTO",
317
                   "projects"      => { "key"    => "ALL_PROJECTS",
318
                                        "all"    => 0,
319
                                        "old_id" => \@old_project_ids },
320
                   "employees"     => "ALL_SALESMEN",
321
                   "taxzones"      => "ALL_TAXZONES",
322
                   "currencies"    => "ALL_CURRENCIES",
323
                   "customers"     => "ALL_CUSTOMERS",
324
                   "price_factors" => "ALL_PRICE_FACTORS");
324 325

  
325 326
  my %labels;
326 327
  my @values = (undef);
......
1226 1227
        $form->{payment_id}    = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
1227 1228
        $form->{"discount_$i"} = 0                             if $form->{"not_discountable_$i"};
1228 1229

  
1230
        $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
1231

  
1229 1232
        ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
1230 1233
        $decimalplaces = max 2, length $1;
1231 1234

  
bin/mozilla/oe.pl
403 403
                     "all"      => 0,
404 404
                     "old_id"   => \@old_project_ids
405 405
                   },
406
                   "employees"  => "ALL_EMPLOYEES",
407
                   "salesmen"   => "ALL_SALESMEN",
408
                   "taxzones"   => "ALL_TAXZONES",
409
                   "payments"   => "ALL_PAYMENTS",
410
                   "currencies" => "ALL_CURRENCIES",
411
                   $vc          => "ALL_" . uc($vc));
406
                   "employees"     => "ALL_EMPLOYEES",
407
                   "salesmen"      => "ALL_SALESMEN",
408
                   "taxzones"      => "ALL_TAXZONES",
409
                   "payments"      => "ALL_PAYMENTS",
410
                   "currencies"    => "ALL_CURRENCIES",
411
                   $vc             => "ALL_" . uc($vc),
412
                   "price_factors" => "ALL_PRICE_FACTORS");
412 413

  
413 414
  my %labels;
414 415
  my @values = (undef);
......
1162 1163
        map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
1163 1164
        $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
1164 1165

  
1166
        $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
1167

  
1165 1168
        ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
1166 1169
        $decimalplaces = max 2, length $1;
1167 1170

  
doc/dokumentenvorlagen-und-variablen.html
708 708
    <td><code>partsgroup</code></td>
709 709
    <td>Warengruppe</td>
710 710
   </tr>
711
   <tr>
712
    <td><code>price_factor</code></td>
713
    <td>Der Preisfaktor als Zahl, sofern einer eingestellt ist</td>
714
   </tr>
715
   <tr>
716
    <td><code>price_factor_name</code></td>
717
    <td>Der Name des Preisfaktors, sofern einer eingestellt ist</td>
718
   </tr>
711 719
   <tr>
712 720
    <td><code>projectnumber</code></td>
713 721
    <td>Projektnummer</td>
locale/de/all
109 109
  'Add License'                 => 'Lizenz erfassen',
110 110
  'Add Part'                    => 'Ware erfassen',
111 111
  'Add Payment Terms'           => 'Zahlungskonditionen hinzuf?gen',
112
  'Add Price Factor'            => 'Preisfaktor erfassen',
112 113
  'Add Pricegroup'              => 'Preisgruppe erfassen',
113 114
  'Add Printer'                 => 'Drucker hinzuf?gen',
114 115
  'Add Project'                 => 'Projekt erfassen',
......
448 449
  'Edit Part'                   => 'Ware bearbeiten',
449 450
  'Edit Payment Terms'          => 'Zahlungskonditionen bearbeiten',
450 451
  'Edit Preferences for'        => 'Benutzereinstellungen f?r',
452
  'Edit Price Factor'           => 'Preisfaktor bearbeiten',
451 453
  'Edit Pricegroup'             => 'Preisgruppe bearbeiten',
452 454
  'Edit Printer'                => 'Drucker bearbeiten',
453 455
  'Edit Project'                => 'Projekt bearbeiten',
......
505 507
  'Extended'                    => 'Gesamt',
506 508
  'Extension Of Time'           => 'Dauerfristverl?ngerung',
507 509
  'Factor'                      => 'Faktor',
510
  'Factor missing!'             => 'Der Faktor fehlt.',
508 511
  'Falsches Datumsformat!'      => 'Falsches Datumsformat!',
509 512
  'Fax'                         => 'Fax',
510 513
  'Feb'                         => 'Feb',
......
667 670
  'List Lead'                   => 'Kundenquelle anzeigen',
668 671
  'List Payment Terms'          => 'Zahlungskonditionen anzeigen',
669 672
  'List Price'                  => 'Listenpreis',
673
  'List Price Factors'          => 'Preisfaktoren anzeigen',
670 674
  'List Pricegroups'            => 'Preisgruppen anzeigen',
671 675
  'List Printer'                => 'Drucker anzeigen',
672 676
  'List Tax'                    => 'Bearbeiten',
......
878 882
  'Previous transdate text'     => 'wurde gespeichert am',
879 883
  'Previous transnumber text'   => 'Letzte Buchung mit der Buchungsnummer',
880 884
  'Price'                       => 'Preis',
885
  'Price Factor'                => 'Preisfaktor',
886
  'Price Factors'               => 'Preisfaktoren',
887
  'Price factor deleted!'       => 'Preisfaktor gel&ouml;scht.',
888
  'Price factor saved!'         => 'Preisfaktor gespeichert.',
881 889
  'Pricegroup'                  => 'Preisgruppe',
882 890
  'Pricegroup deleted!'         => 'Preisgruppe gel?scht!',
883 891
  'Pricegroup missing!'         => 'Preisgruppe fehlt!',
locale/de/am
53 53
  'Add Language'                => 'Sprache hinzuf?gen',
54 54
  'Add Lead'                    => 'Kundenquelle erfassen',
55 55
  'Add Payment Terms'           => 'Zahlungskonditionen hinzuf?gen',
56
  'Add Price Factor'            => 'Preisfaktor erfassen',
56 57
  'Add Printer'                 => 'Drucker hinzuf?gen',
57 58
  'Add and edit %s'             => '%s hinzuf&uuml;gen und bearbeiten',
58 59
  'Address'                     => 'Adresse',
......
118 119
  'Edit Lead'                   => 'Kundenquelle bearbeiten',
119 120
  'Edit Payment Terms'          => 'Zahlungskonditionen bearbeiten',
120 121
  'Edit Preferences for'        => 'Benutzereinstellungen f?r',
122
  'Edit Price Factor'           => 'Preisfaktor bearbeiten',
121 123
  'Edit Printer'                => 'Drucker bearbeiten',
122 124
  'Enforce transaction reversal for all dates' => 'Gegenbuchungen f?r jeden Zeitraum aktualisieren',
123 125
  'Enter longdescription'       => 'Langtext eingeben',
......
128 130
  'Expense Account'             => 'Aufwandskonto',
129 131
  'Expenses EU with UStId'      => 'Aufwand EU m. UStId',
130 132
  'Expenses EU without UStId'   => 'Erl&ouml;se EU o. UStId',
133
  'Factor missing!'             => 'Der Faktor fehlt.',
131 134
  'Fax'                         => 'Fax',
132 135
  'File'                        => 'Datei',
133 136
  'Foreign Exchange Gain'       => 'Wechselkursertr?ge',
......
208 211
  'Please enter values'         => 'Bitte Werte eingeben',
209 212
  'Postscript'                  => 'Postscript',
210 213
  'Preferences saved!'          => 'Einstellungen gespeichert!',
214
  'Price Factors'               => 'Preisfaktoren',
215
  'Price factor deleted!'       => 'Preisfaktor gel&ouml;scht.',
216
  'Price factor saved!'         => 'Preisfaktor gespeichert.',
211 217
  'Print options'               => 'Druckoptionen',
212 218
  'Printer'                     => 'Drucker',
213 219
  'Printer Command'             => 'Druckbefehl',
......
327 333
  'add_language'                => 'add_language',
328 334
  'add_lead'                    => 'add_lead',
329 335
  'add_payment'                 => 'add_payment',
336
  'add_price_factor'            => 'add_price_factor',
330 337
  'add_printer'                 => 'add_printer',
331 338
  'add_tax'                     => 'add_tax',
332 339
  'add_unit'                    => 'add_unit',
......
346 353
  'delete_language'             => 'delete_language',
347 354
  'delete_lead'                 => 'delete_lead',
348 355
  'delete_payment'              => 'delete_payment',
356
  'delete_price_factor'         => 'delete_price_factor',
349 357
  'delete_printer'              => 'delete_printer',
350 358
  'delete_tax'                  => 'delete_tax',
351 359
  'delivery_customer_selection' => 'delivery_customer_selection',
......
359 367
  'edit_language'               => 'edit_language',
360 368
  'edit_lead'                   => 'edit_lead',
361 369
  'edit_payment'                => 'edit_payment',
370
  'edit_price_factor'           => 'edit_price_factor',
362 371
  'edit_printer'                => 'edit_printer',
363 372
  'edit_tax'                    => 'edit_tax',
364 373
  'edit_units'                  => 'edit_units',
......
376 385
  'list_language'               => 'list_language',
377 386
  'list_lead'                   => 'list_lead',
378 387
  'list_payment'                => 'list_payment',
388
  'list_price_factors'          => 'list_price_factors',
379 389
  'list_printer'                => 'list_printer',
380 390
  'list_tax'                    => 'list_tax',
381 391
  'mark_as_paid_common'         => 'mark_as_paid_common',
......
393 403
  'save_lead'                   => 'save_lead',
394 404
  'save_payment'                => 'save_payment',
395 405
  'save_preferences'            => 'save_preferences',
406
  'save_price_factor'           => 'save_price_factor',
396 407
  'save_printer'                => 'save_printer',
397 408
  'save_tax'                    => 'save_tax',
398 409
  'save_unit'                   => 'save_unit',
......
408 419
  'show_vc_details'             => 'show_vc_details',
409 420
  'swap_buchungsgruppen'        => 'swap_buchungsgruppen',
410 421
  'swap_payment_terms'          => 'swap_payment_terms',
422
  'swap_price_factors'          => 'swap_price_factors',
411 423
  'swap_units'                  => 'swap_units',
412 424
  'vendor_selection'            => 'vendor_selection',
413 425
  'erfassen'                    => 'add',
locale/de/ic
185 185
  'Preis'                       => 'Preis',
186 186
  'Preisklasse'                 => 'Preisgruppe',
187 187
  'Price'                       => 'Preis',
188
  'Price Factor'                => 'Preisfaktor',
188 189
  'Pricegroup'                  => 'Preisgruppe',
189 190
  'Printer'                     => 'Drucker',
190 191
  'Proforma Invoice'            => 'Proformarechnung',
locale/de/ir
231 231
  '[email]'                     => '[email]',
232 232
  'bin_list'                    => 'Lagerliste',
233 233
  'button'                      => '?',
234
  'ea'                          => 'St.',
235 234
  'emailed to'                  => 'gemailt an',
236 235
  'history'                     => 'Historie',
237 236
  'invoice'                     => 'Rechnung',
locale/de/is
257 257
  '[email]'                     => '[email]',
258 258
  'bin_list'                    => 'Lagerliste',
259 259
  'button'                      => '?',
260
  'ea'                          => 'St.',
261 260
  'emailed to'                  => 'gemailt an',
262 261
  'history'                     => 'Historie',
263 262
  'invoice'                     => 'Rechnung',
locale/de/menu
20 20
  'Add License'                 => 'Lizenz erfassen',
21 21
  'Add Part'                    => 'Ware erfassen',
22 22
  'Add Payment Terms'           => 'Zahlungskonditionen hinzuf?gen',
23
  'Add Price Factor'            => 'Preisfaktor erfassen',
23 24
  'Add Pricegroup'              => 'Preisgruppe erfassen',
24 25
  'Add Printer'                 => 'Drucker hinzuf?gen',
25 26
  'Add Project'                 => 'Projekt erfassen',
......
69 70
  'List Languages'              => 'Sprachen anzeigen',
70 71
  'List Lead'                   => 'Kundenquelle anzeigen',
71 72
  'List Payment Terms'          => 'Zahlungskonditionen anzeigen',
73
  'List Price Factors'          => 'Preisfaktoren anzeigen',
72 74
  'List Pricegroups'            => 'Preisgruppen anzeigen',
73 75
  'List Printer'                => 'Drucker anzeigen',
74 76
  'List Tax'                    => 'Bearbeiten',
......
80 82
  'Payment Terms'               => 'Zahlungskonditionen',
81 83
  'Payments'                    => 'Zahlungsausg?nge',
82 84
  'Preferences'                 => 'Benutzereinstellungen',
85
  'Price Factors'               => 'Preisfaktoren',
83 86
  'Pricegroups'                 => 'Preisgruppen',
84 87
  'Printer'                     => 'Drucker',
85 88
  'Programm'                    => 'Programm',
locale/de/menunew
19 19
  'Add License'                 => 'Lizenz erfassen',
20 20
  'Add Part'                    => 'Ware erfassen',
21 21
  'Add Payment Terms'           => 'Zahlungskonditionen hinzuf?gen',
22
  'Add Price Factor'            => 'Preisfaktor erfassen',
22 23
  'Add Pricegroup'              => 'Preisgruppe erfassen',
23 24
  'Add Printer'                 => 'Drucker hinzuf?gen',
24 25
  'Add Project'                 => 'Projekt erfassen',
......
68 69
  'List Languages'              => 'Sprachen anzeigen',
69 70
  'List Lead'                   => 'Kundenquelle anzeigen',
70 71
  'List Payment Terms'          => 'Zahlungskonditionen anzeigen',
72
  'List Price Factors'          => 'Preisfaktoren anzeigen',
71 73
  'List Pricegroups'            => 'Preisgruppen anzeigen',
72 74
  'List Printer'                => 'Drucker anzeigen',
73 75
  'List Tax'                    => 'Bearbeiten',
......
79 81
  'Payment Terms'               => 'Zahlungskonditionen',
80 82
  'Payments'                    => 'Zahlungsausg?nge',
81 83
  'Preferences'                 => 'Benutzereinstellungen',
84
  'Price Factors'               => 'Preisfaktoren',
82 85
  'Pricegroups'                 => 'Preisgruppen',
83 86
  'Printer'                     => 'Drucker',
84 87
  'Programm'                    => 'Programm',
locale/de/oe
273 273
  '[email]'                     => '[email]',
274 274
  'bin_list'                    => 'Lagerliste',
275 275
  'button'                      => '?',
276
  'ea'                          => 'St.',
277 276
  'emailed to'                  => 'gemailt an',
278 277
  'history'                     => 'Historie',
279 278
  'invoice'                     => 'Rechnung',
menu.ini
436 436
action=edit_units
437 437
unit_type=service
438 438

  
439
[System--Price Factors]
440
module=menu.pl
441
action=acc_menu
442
target=acc_menu
443
submenu=1
444

  
445
[System--Price Factors--Add Price Factor]
446
module=am.pl
447
action=add_price_factor
448

  
449
[System--Price Factors--List Price Factors]
450
module=am.pl
451
action=list_price_factors
439 452

  
440 453
[System--Departments]
441 454
module=menu.pl
sql/Pg-upgrade2/price_factors.sql
1
-- @tag: price_factors
2
-- @description: Tabellen und Spalten f&uuml;r Preisfaktoren
3
-- @depends: release_2_4_3
4

  
5
CREATE TABLE price_factors (
6
  "id"  integer DEFAULT nextval('id'::text),
7
  "description" text,
8
  "factor" numeric(15,5),
9
  "sortkey" integer,
10

  
11
  PRIMARY KEY (id)
12
 );
13

  
14
ALTER TABLE parts ADD COLUMN price_factor_id integer;
15

  
16
ALTER TABLE invoice ADD COLUMN price_factor_id integer;
17
ALTER TABLE invoice ADD COLUMN price_factor numeric(15,5);
18
ALTER TABLE invoice ALTER COLUMN price_factor SET DEFAULT 1;
19
UPDATE invoice SET price_factor = 1;
20

  
21
ALTER TABLE invoice ADD COLUMN marge_price_factor numeric(15,5);
22
ALTER TABLE invoice ALTER COLUMN marge_price_factor SET DEFAULT 1;
23
UPDATE invoice SET marge_price_factor = 1;
24

  
25
ALTER TABLE orderitems ADD COLUMN price_factor_id integer;
26
ALTER TABLE orderitems ADD COLUMN price_factor numeric(15,5);
27
ALTER TABLE orderitems ALTER COLUMN price_factor SET DEFAULT 1;
28
UPDATE orderitems SET price_factor = 1;
29

  
30
ALTER TABLE orderitems ADD COLUMN marge_price_factor numeric(15,5);
31
ALTER TABLE orderitems ALTER COLUMN marge_price_factor SET DEFAULT 1;
32
UPDATE orderitems SET marge_price_factor = 1;
33

  
34
INSERT INTO price_factors (description, factor, sortkey) VALUES ('pro 10',      10, 1);
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff