Revision 54a4321b
Von Moritz Bunkus vor fast 18 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
42 | 42 |
use HTML::Template; |
43 | 43 |
use SL::Template; |
44 | 44 |
use CGI::Ajax; |
45 |
use SL::DBUtils; |
|
45 | 46 |
use SL::Menu; |
46 | 47 |
use CGI; |
47 | 48 |
|
... | ... | |
1122 | 1123 |
|
1123 | 1124 |
my $dbh = $self->dbconnect($myconfig); |
1124 | 1125 |
|
1126 |
my $query = |
|
1127 |
qq|SELECT p.terms_netto, p.terms_skonto, p.percent_skonto, | . |
|
1128 |
qq|p.description_long | . |
|
1129 |
qq|FROM payment_terms p | . |
|
1130 |
qq|WHERE p.id = ?|; |
|
1125 | 1131 |
|
1126 |
my $query = qq|SELECT p.terms_netto, p.terms_skonto, p.percent_skonto, p.description_long FROM payment_terms p |
|
1127 |
WHERE p.id = $self->{payment_id}|; |
|
1128 |
my $sth = $dbh->prepare($query); |
|
1129 |
$sth->execute || $self->dberror($query); |
|
1130 |
|
|
1131 |
($self->{terms_netto}, $self->{terms_skonto}, $self->{percent_skonto}, $self->{payment_terms}) = $sth->fetchrow_array; |
|
1132 |
($self->{terms_netto}, $self->{terms_skonto}, $self->{percent_skonto}, |
|
1133 |
$self->{payment_terms}) = |
|
1134 |
selectrow_query($self, $dbh, $query, $self->{payment_id}); |
|
1132 | 1135 |
|
1133 | 1136 |
if ($transdate eq "") { |
1134 | 1137 |
if ($self->{invdate}) { |
... | ... | |
1138 | 1141 |
} |
1139 | 1142 |
} |
1140 | 1143 |
|
1141 |
$sth->finish; |
|
1142 |
my $query = qq|SELECT date '$transdate' + $self->{terms_netto} AS netto_date,date '$transdate' + $self->{terms_skonto} AS skonto_date FROM payment_terms |
|
1143 |
LIMIT 1|; |
|
1144 |
my $sth = $dbh->prepare($query); |
|
1145 |
$sth->execute || $self->dberror($query); |
|
1146 |
($self->{netto_date}, $self->{skonto_date}) = $sth->fetchrow_array; |
|
1147 |
$sth->finish; |
|
1144 |
$query = |
|
1145 |
qq|SELECT date '$transdate' + $self->{terms_netto} AS netto_date, | . |
|
1146 |
qq|date '$transdate' + $self->{terms_skonto} AS skonto_date | . |
|
1147 |
qq|FROM payment_terms LIMIT 1|; |
|
1148 |
($self->{netto_date}, $self->{skonto_date}) = |
|
1149 |
selectrow_query($self, $dbh, $query); |
|
1148 | 1150 |
|
1149 | 1151 |
my $total = ($self->{invtotal}) ? $self->{invtotal} : $self->{ordtotal}; |
1150 | 1152 |
|
1151 |
$self->{skonto_amount} = $self->format_amount($myconfig, ($self->parse_amount($myconfig, $total) * $self->{percent_skonto}), 2); |
|
1153 |
$self->{skonto_amount} = |
|
1154 |
$self->format_amount($myconfig, |
|
1155 |
$self->parse_amount($myconfig, $total) * |
|
1156 |
$self->{percent_skonto}, 2); |
|
1157 |
|
|
1158 |
if ($self->{"language_id"}) { |
|
1159 |
$query = |
|
1160 |
qq|SELECT t.description_long, | . |
|
1161 |
qq|l.output_numberformat, l.output_dateformat, l.output_longdates | . |
|
1162 |
qq|FROM translation_payment_terms t | . |
|
1163 |
qq|LEFT JOIN language l ON t.language_id = l.id | . |
|
1164 |
qq|WHERE (t.language_id = ?) AND (t.payment_terms_id = ?)|; |
|
1165 |
my ($description_long, $output_numberformat, $output_dateformat, |
|
1166 |
$output_longdates) = |
|
1167 |
selectrow_query($self, $dbh, $query, |
|
1168 |
$self->{"language_id"}, $self->{"payment_id"}); |
|
1169 |
|
|
1170 |
$self->{payment_terms} = $description_long if ($description_long); |
|
1171 |
|
|
1172 |
if ($output_dateformat) { |
|
1173 |
foreach my $key (qw(netto_date skonto_date)) { |
|
1174 |
$self->{$key} = |
|
1175 |
$main::locale->reformat_date($myconfig, $self->{$key}, |
|
1176 |
$output_dateformat, |
|
1177 |
$output_longdates); |
|
1178 |
} |
|
1179 |
} |
|
1180 |
|
|
1181 |
if ($output_numberformat && |
|
1182 |
($output_numberformat ne $myconfig->{"numberformat"})) { |
|
1183 |
my $saved_numberformat = $myconfig->{"numberformat"}; |
|
1184 |
$myconfig->{"numberformat"} = $output_numberformat; |
|
1185 |
$self->{skonto_amount} = |
|
1186 |
$self->format_amount($myconfig, |
|
1187 |
$self->parse_amount($myconfig, $total) * |
|
1188 |
$self->{percent_skonto}, 2); |
|
1189 |
$myconfig->{"numberformat"} = $saved_numberformat; |
|
1190 |
} |
|
1191 |
} |
|
1152 | 1192 |
|
1153 | 1193 |
$self->{payment_terms} =~ s/<%netto_date%>/$self->{netto_date}/g; |
1154 | 1194 |
$self->{payment_terms} =~ s/<%skonto_date%>/$self->{skonto_date}/g; |
Auch abrufbar als: Unified diff
Die Zahlungsbedingungen werden jetzt anhand der ausgewählten Sprache formatiert.