Revision 52983c08
Von Sven Schöling vor etwa 17 Jahren hinzugefügt
bin/mozilla/is.pl | ||
---|---|---|
34 | 34 |
use SL::IS; |
35 | 35 |
use SL::PE; |
36 | 36 |
use Data::Dumper; |
37 |
use List::Util qw(max); |
|
37 | 38 |
|
38 | 39 |
require "bin/mozilla/io.pl"; |
39 | 40 |
require "bin/mozilla/arap.pl"; |
... | ... | |
467 | 468 |
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; |
468 | 469 |
} |
469 | 470 |
|
470 |
if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { |
|
471 |
$creditwarning = 1; |
|
472 |
} else { |
|
473 |
$creditwarning = 0; |
|
474 |
} |
|
471 |
$creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0; |
|
475 | 472 |
|
476 | 473 |
$form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); |
477 | 474 |
$form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); |
... | ... | |
561 | 558 |
#write Trigger |
562 | 559 |
$jsscript = |
563 | 560 |
Form->write_trigger(\%myconfig, "3", |
564 |
"invdate", "BL", |
|
565 |
"trigger1", "duedate", |
|
566 |
"BL", "trigger2", |
|
567 |
"deliverydate", "BL", |
|
568 |
"trigger3"); |
|
561 |
"invdate", "BL", "trigger1", |
|
562 |
"duedate", "BL", "trigger2", |
|
563 |
"deliverydate", "BL", "trigger3"); |
|
569 | 564 |
} |
570 | 565 |
|
571 |
if ($form->{resubmit} && ($form->{format} eq "html")) { |
|
572 |
$onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|; |
|
573 |
} elsif ($form->{resubmit}) { |
|
574 |
$onload = qq|document.invoice.submit()|; |
|
575 |
} else { |
|
576 |
$onload = "focus()"; |
|
577 |
} |
|
566 |
$credittext = $locale->text('Credit Limit exceeded!!!'); |
|
567 |
$onload = ($form->{resubmit} && ($form->{format} eq "html")) ? qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()| |
|
568 |
: ($form->{resubmit}) ? qq|document.invoice.submit()| |
|
569 |
: ($creditwarning) ? qq|alert('$credittext')| |
|
570 |
: "focus()"; |
|
578 | 571 |
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; |
579 | 572 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; |
580 |
$credittext = $locale->text('Credit Limit exceeded!!!'); |
|
581 |
if ($creditwarning) { |
|
582 |
$onload = qq|alert('$credittext')|; |
|
583 |
} |
|
584 | 573 |
|
585 |
$form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
|
|
586 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
|
|
574 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
|
|
575 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
|
587 | 576 |
|
588 | 577 |
$jsscript .= |
589 | 578 |
$form->write_trigger(\%myconfig, 2, |
... | ... | |
606 | 595 |
|
607 | 596 |
$form->hide_form(qw(id action type media format queued printed emailed title vc discount |
608 | 597 |
creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id |
609 |
max_dunning_level dunning_amount)); |
|
598 |
max_dunning_level dunning_amount |
|
599 |
shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax |
|
600 |
shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts), |
|
601 |
map { $_.'_rate', $_,'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} ); |
|
602 |
|
|
610 | 603 |
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message}; |
611 | 604 |
|
612 | 605 |
print qq| |
... | ... | |
749 | 742 |
<tr> |
750 | 743 |
<td> |
751 | 744 |
</td> |
752 |
</tr> |
|
753 |
| . |
|
754 |
$jsscript |
|
755 |
. qq| |
|
756 |
<!-- shipto are in hidden variables --> |
|
757 |
| ; |
|
758 |
map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } |
|
759 |
qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2)); |
|
760 |
print qq|<!-- email variables --> |; |
|
761 |
map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } |
|
762 |
qw(message email subject cc bcc taxaccounts)); |
|
763 |
print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|; |
|
745 |
</tr> |
|
746 |
$jsscript |
|
747 |
|; |
|
748 |
print qq|<input type="hidden" name="webdav" value="$webdav">|; |
|
764 | 749 |
|
765 |
foreach $item (split(/ /, $form->{taxaccounts})) { |
|
766 |
map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } |
|
767 |
("${item}_rate", "${item}_description", "${item}_taxnumber")); |
|
768 |
} |
|
769 | 750 |
$lxdebug->leave_sub(); |
770 | 751 |
} |
771 | 752 |
|
... | ... | |
1188 | 1169 |
sub update { |
1189 | 1170 |
$lxdebug->enter_sub(); |
1190 | 1171 |
|
1191 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } |
|
1192 |
qw(exchangerate creditlimit creditremaining); |
|
1193 |
if ($form->{second_run}) { |
|
1194 |
$form->{print_and_post} = 0; |
|
1195 |
} |
|
1196 |
|
|
1172 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); |
|
1197 | 1173 |
|
1198 |
if($form->{taxincluded}) { |
|
1199 |
$taxincluded = "checked"; |
|
1200 |
} |
|
1174 |
$form->{print_and_post} = 0 if $form->{second_run}; |
|
1175 |
$taxincluded = "checked" if $form->{taxincluded}; |
|
1201 | 1176 |
$form->{update} = 1; |
1202 | 1177 |
|
1203 | 1178 |
&check_name(customer); |
1204 | 1179 |
|
1205 |
if(!$form->{taxincluded}) { |
|
1206 |
$form->{taxincluded} = $taxincluded; |
|
1207 |
} |
|
1208 |
|
|
1180 |
$form->{taxincluded} ||= $taxincluded; |
|
1209 | 1181 |
|
1210 |
$form->{exchangerate} = $exchangerate |
|
1211 |
if ( |
|
1212 |
$form->{forex} = ( |
|
1213 |
$exchangerate = |
|
1214 |
$form->check_exchangerate( |
|
1215 |
\%myconfig, $form->{currency}, $form->{invdate}, 'buy' |
|
1216 |
))); |
|
1182 |
$form->{exchangerate} = $exchangerate if |
|
1183 |
$form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
|
1217 | 1184 |
|
1218 | 1185 |
for $i (1 .. $form->{paidaccounts}) { |
1219 |
if ($form->{"paid_$i"}) { |
|
1220 |
map { |
|
1221 |
$form->{"${_}_$i"} = |
|
1222 |
$form->parse_amount(\%myconfig, $form->{"${_}_$i"}) |
|
1223 |
} qw(paid exchangerate); |
|
1224 |
|
|
1225 |
$form->{"exchangerate_$i"} = $exchangerate |
|
1226 |
if ( |
|
1227 |
$form->{"forex_$i"} = ( |
|
1228 |
$exchangerate = |
|
1229 |
$form->check_exchangerate( |
|
1230 |
\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy' |
|
1231 |
))); |
|
1232 |
} |
|
1186 |
next unless $form->{"paid_$i"}; |
|
1187 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); |
|
1188 |
$form->{"exchangerate_$i"} = $exchangerate if |
|
1189 |
$form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); |
|
1233 | 1190 |
} |
1234 | 1191 |
|
1235 | 1192 |
$i = $form->{rowcount}; |
1236 |
$exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
|
|
1193 |
$exchangerate = $form->{exchangerate} || 1;
|
|
1237 | 1194 |
|
1238 | 1195 |
# if last row empty, check the form otherwise retrieve new item |
1239 | 1196 |
if ( ($form->{"partnumber_$i"} eq "") |
... | ... | |
1249 | 1206 |
|
1250 | 1207 |
$rows = scalar @{ $form->{item_list} }; |
1251 | 1208 |
|
1252 |
$form->{"discount_$i"} = |
|
1253 |
$form->format_amount(\%myconfig, $form->{discount} * 100); |
|
1209 |
$form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100); |
|
1254 | 1210 |
|
1255 | 1211 |
if ($rows) { |
1256 | 1212 |
$form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1; |
... | ... | |
1264 | 1220 |
|
1265 | 1221 |
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); |
1266 | 1222 |
|
1267 |
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } |
|
1268 |
qw(partnumber description unit); |
|
1269 |
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } |
|
1270 |
keys %{ $form->{item_list}[0] }; |
|
1271 |
if ($form->{"part_payment_id_$i"} ne "") { |
|
1272 |
$form->{payment_id} = $form->{"part_payment_id_$i"}; |
|
1273 |
} |
|
1223 |
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); |
|
1224 |
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; |
|
1225 |
|
|
1226 |
$form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne ""; |
|
1227 |
$form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"}; |
|
1274 | 1228 |
|
1275 |
if ($form->{"not_discountable_$i"}) { |
|
1276 |
$form->{"discount_$i"} = 0; |
|
1277 |
} |
|
1278 |
|
|
1279 |
$s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; |
|
1280 |
($dec) = ($s =~ /\.(\d+)/); |
|
1281 |
$dec = length $dec; |
|
1282 |
$decimalplaces = ($dec > 2) ? $dec : 2; |
|
1229 |
($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/; |
|
1230 |
$decimalplaces = max 2, length $1; |
|
1283 | 1231 |
|
1284 | 1232 |
if ($sellprice) { |
1285 | 1233 |
$form->{"sellprice_$i"} = $sellprice; |
1286 | 1234 |
} else { |
1287 |
|
|
1288 | 1235 |
# if there is an exchange rate adjust sellprice |
1289 | 1236 |
$form->{"sellprice_$i"} *= (1 - $form->{tradediscount}); |
1290 | 1237 |
$form->{"sellprice_$i"} /= $exchangerate; |
... | ... | |
1292 | 1239 |
|
1293 | 1240 |
$form->{"listprice_$i"} /= $exchangerate; |
1294 | 1241 |
|
1295 |
$amount = |
|
1296 |
$form->{"sellprice_$i"} * $form->{"qty_$i"} * |
|
1297 |
(1 - $form->{"discount_$i"} / 100); |
|
1298 |
map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts}); |
|
1299 |
map { $form->{"${_}_base"} += $amount } |
|
1300 |
(split / /, $form->{"taxaccounts_$i"}); |
|
1301 |
map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } |
|
1302 |
split / /, $form->{"taxaccounts_$i"} |
|
1303 |
if !$form->{taxincluded}; |
|
1242 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); |
|
1243 |
map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts}; |
|
1244 |
map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"}; |
|
1245 |
map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded}; |
|
1304 | 1246 |
|
1305 | 1247 |
$form->{creditremaining} -= $amount; |
1306 | 1248 |
|
1307 |
map { |
|
1308 |
$form->{"${_}_$i"} = |
|
1309 |
$form->format_amount(\%myconfig, $form->{"${_}_$i"}, |
|
1310 |
$decimalplaces) |
|
1311 |
} qw(sellprice listprice); |
|
1249 |
map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice); |
|
1312 | 1250 |
|
1313 |
$form->{"qty_$i"} = |
|
1314 |
$form->format_amount(\%myconfig, $form->{"qty_$i"}); |
|
1251 |
$form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); |
|
1315 | 1252 |
|
1316 | 1253 |
if ($lizenzen) { |
1317 | 1254 |
if ($form->{"inventory_accno_$i"} ne "") { |
1318 | 1255 |
$form->{"lizenzen_$i"} = qq|<option></option>|; |
1319 | 1256 |
foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) { |
1320 |
$form->{"lizenzen_$i"} .= |
|
1321 |
qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|; |
|
1257 |
$form->{"lizenzen_$i"} .= qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|; |
|
1322 | 1258 |
} |
1323 |
$form->{"lizenzen_$i"} .= |
|
1324 |
qq|<option value=-1>Neue Lizenz</option>|; |
|
1259 |
$form->{"lizenzen_$i"} .= qq|<option value=-1>Neue Lizenz</option>|; |
|
1325 | 1260 |
} |
1326 | 1261 |
} |
1327 | 1262 |
|
Auch abrufbar als: Unified diff
Kosmetikmerge aus Revisionen 5187, 5191, 5193, 5194, 5218, 5219, 5222, 5228, 5229