Revision 59d350af
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
120 | 120 |
my $service_units = AM->retrieve_units(\%myconfig, $form, "service"); |
121 | 121 |
my $all_units = AM->retrieve_units(\%myconfig, $form); |
122 | 122 |
|
123 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
124 |
|
|
123 | 125 |
my $colspan = scalar @column_index; |
124 | 126 |
|
125 | 127 |
$form->{invsubtotal} = 0; |
... | ... | |
179 | 181 |
$this_unit = $form->{"selected_unit_$i"} if AM->convert_unit($this_unit, $form->{"selected_unit_$i"}, $all_units); |
180 | 182 |
$this_unit ||= "kg"; |
181 | 183 |
|
182 |
$column_data{"unit"} = AM->unit_select_html($local_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef); |
|
184 |
my $price_factor_select; |
|
185 |
if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) { |
|
186 |
my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} }); |
|
187 |
my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
188 |
|
|
189 |
$price_factor_select = |
|
190 |
NTI($cgi->popup_menu('-name' => "price_factor_id_$i", |
|
191 |
'-default' => $form->{"price_factor_id_$i"}, |
|
192 |
'-values' => \@values, |
|
193 |
'-labels' => \%labels, |
|
194 |
'-style' => 'width:90px')) |
|
195 |
. ' '; |
|
196 |
} |
|
197 |
|
|
198 |
$column_data{"unit"} = $price_factor_select . AM->unit_select_html($local_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef); |
|
183 | 199 |
# / unit ending |
184 | 200 |
|
185 | 201 |
$form->{"sellprice_$i"} =~ /\.(\d+)/; |
186 | 202 |
$decimalplaces = max 2, length $1; |
187 | 203 |
|
188 |
$discount = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"} / 100, $decimalplaces); |
|
189 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces); |
|
190 |
$linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2); |
|
204 |
$price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1; |
|
205 |
$discount = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"} / 100, $decimalplaces); |
|
206 |
$linetotal = $form->round_amount(($form->{"sellprice_$i"} - $discount) / $price_factor, $decimalplaces); |
|
207 |
$linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2); |
|
191 | 208 |
|
192 | 209 |
# convert " to " |
193 | 210 |
map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit unit_old); |
... | ... | |
247 | 264 |
|
248 | 265 |
# begin marge calculations |
249 | 266 |
my $marge_color; |
250 |
my $real_sellprice = $form->{"sellprice_$i"} - $discount; |
|
267 |
my $real_sellprice = ($form->{"sellprice_$i"} - $discount) / $price_factor; |
|
268 |
my $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1; |
|
251 | 269 |
|
252 | 270 |
$form->{"lastcost_$i"} *= 1; |
253 | 271 |
$form->{"marge_percent_$i"} = 0; |
254 | 272 |
|
255 | 273 |
if ($real_sellprice && ($form->{"qty_$i"} * 1)) { |
256 |
$form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"}) * 100 / $real_sellprice; |
|
274 |
$form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
|
|
257 | 275 |
$myconfig{marge_percent_warn} ||= 15; |
258 | 276 |
$marge_color = 'color="#ff0000"' if $form->{"id_$i"} && ($form->{"marge_percent_$i"} < (1 * $myconfig{marge_percent_warn})); |
259 | 277 |
} |
260 | 278 |
|
261 | 279 |
my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; |
262 |
$form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"}) * $form->{"qty_$i"} * $marge_adjust_credit_note; |
|
280 |
$form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
|
|
263 | 281 |
$form->{"marge_total"} += $form->{"marge_absolut_$i"}; |
264 |
$form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"}; |
|
282 |
$form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
|
|
265 | 283 |
$form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"}; |
266 | 284 |
|
267 | 285 |
map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent); |
... | ... | |
279 | 297 |
map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" } |
280 | 298 |
qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes |
281 | 299 |
income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber |
282 |
longdescription basefactor marge_absolut marge_percent lastcost) |
|
300 |
longdescription basefactor marge_absolut marge_percent marge_price_factor lastcost)
|
|
283 | 301 |
); |
284 | 302 |
|
285 | 303 |
map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"})); |
Auch abrufbar als: Unified diff
Feature "Preisfaktoren" wieder implementiert, das teilweise in Revision 2889 rausgeflogen ist.