Revision 1e251313
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
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 |
Auch abrufbar als: Unified diff
Preisfatkoren implementiert.