Revision 9c63c160
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/OE.pm | ||
---|---|---|
977 | 977 |
linetotal nodiscount_linetotal tax_rate projectnumber |
978 | 978 |
price_factor price_factor_name partsgroup); |
979 | 979 |
|
980 |
my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber); |
|
981 |
|
|
982 |
$form->{TEMPLATE_ARRAYS} = { map { $_ => [] } (@arrays, @tax_arrays) }; |
|
983 |
|
|
980 | 984 |
my $sameitem = ""; |
981 | 985 |
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) { |
982 | 986 |
$i = $item->[0]; |
983 | 987 |
|
984 | 988 |
if ($item->[1] ne $sameitem) { |
985 |
push(@{ $form->{description} }, qq|$item->[1]|); |
|
989 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, qq|$item->[1]|);
|
|
986 | 990 |
$sameitem = $item->[1]; |
987 | 991 |
|
988 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
992 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
989 | 993 |
} |
990 | 994 |
|
991 | 995 |
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); |
... | ... | |
1010 | 1014 |
|
1011 | 1015 |
my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; |
1012 | 1016 |
|
1013 |
push @{ $form->{runningnumber} }, $position; |
|
1014 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
1015 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
1016 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
1017 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
1018 |
push @{ $form->{ship} }, $form->format_amount($myconfig, $form->{"ship_$i"}); |
|
1019 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
1020 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
1021 |
push @{ $form->{partnotes} }, $form->{"partnotes_$i"}; |
|
1022 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
1023 |
push @{ $form->{reqdate} }, $form->{"reqdate_$i"}; |
|
1024 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
1025 |
push @{ $form->{listprice} }, $form->{"listprice_$i"}; |
|
1026 |
push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; |
|
1027 |
push @{ $form->{price_factor_name} }, $price_factor->{description}; |
|
1028 |
push @{ $form->{partsgroup} }, $form->{"partsgroup_$i"}; |
|
1017 |
push @{ $form->{TEMPLATE_ARRAYS}->{runningnumber} }, $position;
|
|
1018 |
push @{ $form->{TEMPLATE_ARRAYS}->{number} }, $form->{"partnumber_$i"};
|
|
1019 |
push @{ $form->{TEMPLATE_ARRAYS}->{description} }, $form->{"description_$i"};
|
|
1020 |
push @{ $form->{TEMPLATE_ARRAYS}->{longdescription} }, $form->{"longdescription_$i"};
|
|
1021 |
push @{ $form->{TEMPLATE_ARRAYS}->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"});
|
|
1022 |
push @{ $form->{TEMPLATE_ARRAYS}->{ship} }, $form->format_amount($myconfig, $form->{"ship_$i"});
|
|
1023 |
push @{ $form->{TEMPLATE_ARRAYS}->{unit} }, $form->{"unit_$i"};
|
|
1024 |
push @{ $form->{TEMPLATE_ARRAYS}->{bin} }, $form->{"bin_$i"};
|
|
1025 |
push @{ $form->{TEMPLATE_ARRAYS}->{partnotes} }, $form->{"partnotes_$i"};
|
|
1026 |
push @{ $form->{TEMPLATE_ARRAYS}->{serialnumber} }, $form->{"serialnumber_$i"};
|
|
1027 |
push @{ $form->{TEMPLATE_ARRAYS}->{reqdate} }, $form->{"reqdate_$i"};
|
|
1028 |
push @{ $form->{TEMPLATE_ARRAYS}->{sellprice} }, $form->{"sellprice_$i"};
|
|
1029 |
push @{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->{"listprice_$i"};
|
|
1030 |
push @{ $form->{TEMPLATE_ARRAYS}->{price_factor} }, $price_factor->{formatted_factor};
|
|
1031 |
push @{ $form->{TEMPLATE_ARRAYS}->{price_factor_name} }, $price_factor->{description};
|
|
1032 |
push @{ $form->{TEMPLATE_ARRAYS}->{partsgroup} }, $form->{"partsgroup_$i"};
|
|
1029 | 1033 |
|
1030 | 1034 |
my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); |
1031 | 1035 |
my ($dec) = ($sellprice =~ /\.(\d+)/); |
... | ... | |
1039 | 1043 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2); |
1040 | 1044 |
$form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); |
1041 | 1045 |
|
1042 |
push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : ''; |
|
1046 |
push @{ $form->{TEMPLATE_ARRAYS}->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
|
|
1043 | 1047 |
|
1044 | 1048 |
$linetotal = ($linetotal != 0) ? $linetotal : ''; |
1045 | 1049 |
|
1046 |
push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : ''; |
|
1047 |
push @{ $form->{p_discount} }, $form->{"discount_$i"}; |
|
1050 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : '';
|
|
1051 |
push @{ $form->{TEMPLATE_ARRAYS}->{p_discount} }, $form->{"discount_$i"};
|
|
1048 | 1052 |
|
1049 | 1053 |
$form->{ordtotal} += $linetotal; |
1050 | 1054 |
$form->{nodiscount_total} += $nodiscount_linetotal; |
... | ... | |
1056 | 1060 |
} |
1057 | 1061 |
|
1058 | 1062 |
if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) { |
1059 |
push @{ $form->{discount_sub} }, $form->format_amount($myconfig, $discount_subtotal, 2); |
|
1060 |
push @{ $form->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2); |
|
1063 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, $form->format_amount($myconfig, $discount_subtotal, 2);
|
|
1064 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
|
|
1061 | 1065 |
|
1062 | 1066 |
$discount_subtotal = 0; |
1063 | 1067 |
$nodiscount_subtotal = 0; |
1064 | 1068 |
$subtotal_header = 0; |
1065 | 1069 |
|
1066 | 1070 |
} else { |
1067 |
push @{ $form->{discount_sub} }, ""; |
|
1068 |
push @{ $form->{nodiscount_sub} }, ""; |
|
1071 |
push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, "";
|
|
1072 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, "";
|
|
1069 | 1073 |
} |
1070 | 1074 |
|
1071 | 1075 |
if (!$form->{"discount_$i"}) { |
1072 | 1076 |
$nodiscount += $linetotal; |
1073 | 1077 |
} |
1074 | 1078 |
|
1075 |
push @{ $form->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2); |
|
1076 |
push @{ $form->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2); |
|
1079 |
push @{ $form->{TEMPLATE_ARRAYS}->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
|
|
1080 |
push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
|
|
1077 | 1081 |
|
1078 |
push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}}); |
|
1082 |
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
|
|
1079 | 1083 |
|
1080 | 1084 |
my ($taxamount, $taxbase); |
1081 | 1085 |
my $taxrate = 0; |
... | ... | |
1100 | 1104 |
} |
1101 | 1105 |
|
1102 | 1106 |
$tax_rate = $taxrate * 100; |
1103 |
push(@{ $form->{tax_rate} }, qq|$tax_rate|); |
|
1107 |
push(@{ $form->{TEMPLATE_ARRAYS}->{tax_rate} }, qq|$tax_rate|);
|
|
1104 | 1108 |
|
1105 | 1109 |
if ($form->{"assembly_$i"}) { |
1106 | 1110 |
$sameitem = ""; |
... | ... | |
1126 | 1130 |
|
1127 | 1131 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
1128 | 1132 |
if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) { |
1129 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
1133 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
1130 | 1134 |
$sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--"; |
1131 |
push(@{ $form->{description} }, $sameitem); |
|
1135 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $sameitem);
|
|
1132 | 1136 |
} |
1133 | 1137 |
|
1134 |
push(@{ $form->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|); |
|
1135 |
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); |
|
1138 |
push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|);
|
|
1139 |
map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
|
1136 | 1140 |
} |
1137 | 1141 |
$sth->finish; |
1138 | 1142 |
} |
... | ... | |
1142 | 1146 |
|
1143 | 1147 |
my $tax = 0; |
1144 | 1148 |
foreach $item (sort keys %taxaccounts) { |
1145 |
push(@{ $form->{taxbase} }, |
|
1146 |
$form->format_amount($myconfig, $taxbase{$item}, 2)); |
|
1147 |
|
|
1148 | 1149 |
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2); |
1149 | 1150 |
|
1150 |
push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
|
1151 |
push(@{ $form->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
|
|
1152 |
push(@{ $form->{taxrate} },
|
|
1153 |
$form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
|
1154 |
push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
|
|
1151 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxbase} }, $form->format_amount($myconfig, $taxbase{$item}, 2));
|
|
1152 |
push(@{ $form->{TEMPLATE_ARRAYS}->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
|
1153 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxrate} }, $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
|
1154 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
|
|
1155 |
push(@{ $form->{TEMPLATE_ARRAYS}->{taxnumber} }, $form->{"${item}_taxnumber"});
|
|
1155 | 1156 |
} |
1156 | 1157 |
|
1157 | 1158 |
$form->{nodiscount_subtotal} = $form->format_amount($myconfig, $form->{nodiscount_total}, 2); |
Auch abrufbar als: Unified diff
Die Funktionen in Template.pm zum Ersetzen von Schleifenvariablen so erweitert, dass die Schleifenarrays auch in $form->{TEMPLATE_ARRAYS} gesucht werden. Weiterhin die Druckmechanismen in IS.pm, OE.pm und DN.pm so angepasst, dass sie diese Unterebene benutzen, um die Positionswerte zu speichern. Dadurch wird verhindert, dass Elemente direkt in $form sowohl als Skalar als auch als Array benutzt werden (z.B. $form->{reqdate} = ... und push @{ $form->{reqdate} }, ...).