Revision 52983c08
Von Sven Schöling vor mehr als 17 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
678 | 678 |
|
679 | 679 |
# get default accounts and last invoice number |
680 | 680 |
|
681 |
$query= |
|
682 |
qq|SELECT |
|
683 |
(SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, |
|
684 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
|
685 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
|
686 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
|
687 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
688 |
d.curr AS currencies |
|
689 |
$q_invdate |
|
690 |
FROM defaults d|; |
|
681 |
$query = qq|SELECT |
|
682 |
(SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, |
|
683 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
|
684 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
|
685 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
|
686 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
687 |
d.curr AS currencies |
|
688 |
$q_invdate |
|
689 |
FROM defaults d|; |
|
691 | 690 |
$ref = selectfirst_hashref_query($form, $dbh, $query); |
692 | 691 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
693 | 692 |
|
... | ... | |
699 | 698 |
} |
700 | 699 |
|
701 | 700 |
# retrieve invoice |
702 |
$query = |
|
703 |
qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, |
|
704 |
orddate, quodate, globalproject_id, |
|
705 |
ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, |
|
706 |
intnotes, curr AS currency |
|
707 |
FROM ap |
|
708 |
WHERE id = ?|; |
|
701 |
$query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, |
|
702 |
orddate, quodate, globalproject_id, |
|
703 |
ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, |
|
704 |
intnotes, curr AS currency |
|
705 |
FROM ap |
|
706 |
WHERE id = ?|; |
|
709 | 707 |
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); |
710 | 708 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
711 | 709 |
|
712 |
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell"); |
|
710 |
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell");
|
|
713 | 711 |
|
714 | 712 |
# get shipto |
715 | 713 |
$query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AP')|; |
... | ... | |
725 | 723 |
# retrieve individual items |
726 | 724 |
$query = |
727 | 725 |
qq|SELECT |
728 |
c1.accno AS inventory_accno, |
|
729 |
c1.new_chart_id AS inventory_new_chart, |
|
730 |
date($transdate) - c1.valid_from AS inventory_valid, |
|
731 |
|
|
732 |
c2.accno AS income_accno, |
|
733 |
c2.new_chart_id AS income_new_chart, |
|
734 |
date($transdate) - c2.valid_from AS income_valid, |
|
726 |
c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from AS inventory_valid, |
|
727 |
c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from AS income_valid, |
|
728 |
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid, |
|
735 | 729 |
|
736 |
c3.accno AS expense_accno, |
|
737 |
c3.new_chart_id AS expense_new_chart, |
|
738 |
date($transdate) - c3.valid_from AS expense_valid, |
|
739 |
|
|
740 |
i.description, i.qty, i.fxsellprice AS sellprice, |
|
741 |
i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, |
|
742 |
|
|
743 |
p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, |
|
744 |
pr.projectnumber, |
|
745 |
pg.partsgroup |
|
730 |
i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, |
|
731 |
p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup |
|
746 | 732 |
|
747 | 733 |
FROM invoice i |
748 | 734 |
JOIN parts p ON (i.parts_id = p.id) |
749 |
LEFT JOIN chart c1 ON |
|
750 |
((SELECT inventory_accno_id |
|
751 |
FROM buchungsgruppen |
|
752 |
WHERE id = p.buchungsgruppen_id) = c1.id) |
|
753 |
LEFT JOIN chart c2 ON |
|
754 |
((SELECT income_accno_id_${taxzone_id} |
|
755 |
FROM buchungsgruppen |
|
756 |
WHERE id = p.buchungsgruppen_id) = c2.id) |
|
757 |
LEFT JOIN chart c3 ON |
|
758 |
((SELECT expense_accno_id_${taxzone_id} |
|
759 |
FROM buchungsgruppen |
|
760 |
WHERE id = p.buchungsgruppen_id) = c3.id) |
|
735 |
LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) |
|
736 |
LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id) |
|
737 |
LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id) |
|
761 | 738 |
LEFT JOIN project pr ON (i.project_id = pr.id) |
762 | 739 |
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) |
763 | 740 |
|
... | ... | |
767 | 744 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); |
768 | 745 |
|
769 | 746 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
770 |
if (!$ref->{"part_inventory_accno_id"}) { |
|
771 |
map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)); |
|
772 |
} |
|
747 |
map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"}; |
|
773 | 748 |
delete($ref->{"part_inventory_accno_id"}); |
774 | 749 |
|
775 | 750 |
foreach my $type (qw(inventory income expense)) { |
776 | 751 |
while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) { |
777 |
my $query = |
|
778 |
qq|SELECT accno, new_chart_id, date($transdate) - valid_from |
|
779 |
FROM chart |
|
780 |
WHERE id = ?|; |
|
781 |
($ref->{"${type}_accno"}, |
|
782 |
$ref->{"${type}_new_chart"}, |
|
783 |
$ref->{"${type}_valid"}) |
|
784 |
= selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); |
|
752 |
my $query = qq|SELECT accno, new_chart_id, date($transdate) - valid_from FROM chart WHERE id = ?|; |
|
753 |
@$ref{ map $type.$_, qw(_accno _new_chart _valid) } = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); |
|
785 | 754 |
} |
786 | 755 |
} |
787 | 756 |
|
788 | 757 |
# get tax rates and description |
789 | 758 |
my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; |
790 | 759 |
$query = |
791 |
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber |
|
792 |
FROM tax t |
|
760 |
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber FROM tax t |
|
793 | 761 |
LEFT JOIN chart c ON (c.id = t.chart_id) |
794 | 762 |
WHERE t.id in |
795 |
(SELECT tk.tax_id |
|
796 |
FROM taxkeys tk |
|
797 |
WHERE tk.chart_id = |
|
798 |
(SELECT id |
|
799 |
FROM chart |
|
800 |
WHERE accno = ?) |
|
763 |
(SELECT tk.tax_id FROM taxkeys tk |
|
764 |
WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) |
|
801 | 765 |
AND (startdate <= $transdate) |
802 | 766 |
ORDER BY startdate DESC |
803 | 767 |
LIMIT 1) |
SL/IS.pm | ||
---|---|---|
1376 | 1376 |
map { $form->{$_} = $ref->{$_} } keys %{ $ref }; |
1377 | 1377 |
|
1378 | 1378 |
|
1379 |
$form->{exchangerate} = |
|
1380 |
$form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy"); |
|
1379 |
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy"); |
|
1381 | 1380 |
|
1382 | 1381 |
# get shipto |
1383 | 1382 |
$query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AR')|; |
... | ... | |
1387 | 1386 |
|
1388 | 1387 |
foreach my $vc (qw(customer vendor)) { |
1389 | 1388 |
next if !$form->{"delivery_${vc}_id"}; |
1390 |
($form->{"delivery_${vc}_string"}) |
|
1391 |
= selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id); |
|
1389 |
($form->{"delivery_${vc}_string"}) = selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id); |
|
1392 | 1390 |
} |
1393 | 1391 |
|
1394 | 1392 |
# get printed, emailed |
1395 |
$query = |
|
1396 |
qq|SELECT printed, emailed, spoolfile, formname |
|
1397 |
FROM status |
|
1398 |
WHERE trans_id = ?|; |
|
1393 |
$query = qq|SELECT printed, emailed, spoolfile, formname FROM status WHERE trans_id = ?|; |
|
1399 | 1394 |
$sth = prepare_execute_query($form, $dbh, $query, $id); |
1400 | 1395 |
|
1401 | 1396 |
while ($ref = $sth->fetchrow_hashref(NAME_lc)) { |
1402 | 1397 |
$form->{printed} .= "$ref->{formname} " if $ref->{printed}; |
1403 | 1398 |
$form->{emailed} .= "$ref->{formname} " if $ref->{emailed}; |
1404 |
$form->{queued} .= "$ref->{formname} $ref->{spoolfile} " |
|
1405 |
if $ref->{spoolfile}; |
|
1399 |
$form->{queued} .= "$ref->{formname} $ref->{spoolfile} " if $ref->{spoolfile}; |
|
1406 | 1400 |
} |
1407 | 1401 |
$sth->finish; |
1408 | 1402 |
map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued); |
1409 | 1403 |
|
1410 |
my $transdate = |
|
1411 |
$form->{deliverydate} ? $dbh->quote($form->{deliverydate}) :
|
|
1412 |
$form->{invdate} ? $dbh->quote($form->{invdate}) :
|
|
1413 |
"current_date"; |
|
1404 |
my $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
|
|
1405 |
: $form->{invdate} ? $dbh->quote($form->{invdate})
|
|
1406 |
: "current_date";
|
|
1407 |
|
|
1414 | 1408 |
|
1415 | 1409 |
my $taxzone_id = $form->{taxzone_id} *= 1; |
1416 | 1410 |
$taxzone_id = 0 if (0 > $taxzone_id) || (3 < $taxzone_id); |
... | ... | |
1418 | 1412 |
# retrieve individual items |
1419 | 1413 |
$query = |
1420 | 1414 |
qq|SELECT |
1421 |
c1.accno AS inventory_accno, |
|
1422 |
c1.new_chart_id AS inventory_new_chart, |
|
1423 |
date($transdate) - c1.valid_from AS inventory_valid, |
|
1424 |
|
|
1425 |
c2.accno AS income_accno, |
|
1426 |
c2.new_chart_id AS income_new_chart, |
|
1427 |
date($transdate) - c2.valid_from as income_valid, |
|
1428 |
|
|
1429 |
c3.accno AS expense_accno, |
|
1430 |
c3.new_chart_id AS expense_new_chart, |
|
1431 |
date($transdate) - c3.valid_from AS expense_valid, |
|
1415 |
c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from AS inventory_valid, |
|
1416 |
c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid, |
|
1417 |
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid, |
|
1432 | 1418 |
|
1433 |
i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, |
|
1434 |
i.discount, i.parts_id AS id, i.unit, i.deliverydate, |
|
1435 |
i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, |
|
1436 |
i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost, |
|
1437 |
|
|
1438 |
p.partnumber, p.assembly, p.bin, p.notes AS partnotes, |
|
1439 |
p.inventory_accno_id AS part_inventory_accno_id, p.formel, |
|
1440 |
|
|
1441 |
pr.projectnumber, |
|
1442 |
pg.partsgroup, |
|
1443 |
prg.pricegroup |
|
1419 |
i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate, |
|
1420 |
i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost, |
|
1421 |
p.partnumber, p.assembly, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel, |
|
1422 |
pr.projectnumber, pg.partsgroup, prg.pricegroup |
|
1444 | 1423 |
|
1445 | 1424 |
FROM invoice i |
1446 | 1425 |
LEFT JOIN parts p ON (i.parts_id = p.id) |
... | ... | |
1448 | 1427 |
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) |
1449 | 1428 |
LEFT JOIN pricegroup prg ON (i.pricegroup_id = prg.id) |
1450 | 1429 |
|
1451 |
LEFT JOIN chart c1 ON |
|
1452 |
((SELECT inventory_accno_id |
|
1453 |
FROM buchungsgruppen |
|
1454 |
WHERE id = p.buchungsgruppen_id) = c1.id) |
|
1455 |
LEFT JOIN chart c2 ON |
|
1456 |
((SELECT income_accno_id_${taxzone_id} |
|
1457 |
FROM buchungsgruppen |
|
1458 |
WHERE id=p.buchungsgruppen_id) = c2.id) |
|
1459 |
LEFT JOIN chart c3 ON |
|
1460 |
((SELECT expense_accno_id_${taxzone_id} |
|
1461 |
FROM buchungsgruppen |
|
1462 |
WHERE id = p.buchungsgruppen_id) = c3.id) |
|
1463 |
|
|
1464 |
WHERE (i.trans_id = ?) |
|
1465 |
AND NOT (i.assemblyitem = '1') |
|
1466 |
ORDER BY i.id|; |
|
1430 |
LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) |
|
1431 |
LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id) |
|
1432 |
LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id) |
|
1433 |
|
|
1434 |
WHERE (i.trans_id = ?) AND NOT (i.assemblyitem = '1') ORDER BY i.id|; |
|
1467 | 1435 |
|
1468 | 1436 |
$sth = prepare_execute_query($form, $dbh, $query, $id); |
1469 | 1437 |
|
1470 | 1438 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
1471 |
if (!$ref->{"part_inventory_accno_id"}) { |
|
1472 |
map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)); |
|
1473 |
} |
|
1439 |
map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"}; |
|
1474 | 1440 |
delete($ref->{"part_inventory_accno_id"}); |
1475 | 1441 |
|
1476 | 1442 |
foreach my $type (qw(inventory income expense)) { |
1477 | 1443 |
while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) { |
1478 |
my $query = |
|
1479 |
qq|SELECT accno, new_chart_id, date($transdate) - valid_from |
|
1480 |
FROM chart |
|
1481 |
WHERE id = ?|; |
|
1482 |
($ref->{"${type}_accno"}, |
|
1483 |
$ref->{"${type}_new_chart"}, |
|
1484 |
$ref->{"${type}_valid"}) |
|
1485 |
= selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); |
|
1444 |
my $query = qq|SELECT accno, new_chart_id, date($transdate) - valid_from FROM chart WHERE id = ?|; |
|
1445 |
@$ref{ map $type.$_, qw(_accno _new_chart _valid) } = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); |
|
1486 | 1446 |
} |
1487 | 1447 |
} |
1488 | 1448 |
|
1489 | 1449 |
# get tax rates and description |
1490 |
my $accno_id = |
|
1491 |
($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; |
|
1450 |
my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; |
|
1492 | 1451 |
$query = |
1493 |
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber |
|
1494 |
FROM tax t |
|
1452 |
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber FROM tax t |
|
1495 | 1453 |
LEFT JOIN chart c ON (c.id = t.chart_id) |
1496 | 1454 |
WHERE t.id IN |
1497 |
(SELECT tk.tax_id |
|
1498 |
FROM taxkeys tk |
|
1499 |
WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) |
|
1455 |
(SELECT tk.tax_id FROM taxkeys tk |
|
1456 |
WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) |
|
1500 | 1457 |
AND startdate <= date($transdate) |
1501 |
ORDER BY startdate DESC |
|
1502 |
LIMIT 1) |
|
1458 |
ORDER BY startdate DESC LIMIT 1) |
|
1503 | 1459 |
ORDER BY c.accno|; |
1504 | 1460 |
my $stw = prepare_execute_query($form, $dbh, $query, $accno_id); |
1505 | 1461 |
$ref->{taxaccounts} = ""; |
1506 | 1462 |
my $i=0; |
1507 | 1463 |
while ($ptr = $stw->fetchrow_hashref(NAME_lc)) { |
1508 | 1464 |
|
1509 |
# if ($customertax{$ref->{accno}}) { |
|
1510 | 1465 |
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { |
1511 | 1466 |
$i++; |
1512 | 1467 |
$ptr->{accno} = $i; |
... | ... | |
1523 | 1478 |
} |
1524 | 1479 |
|
1525 | 1480 |
if ($form->{lizenzen}) { |
1526 |
$query = |
|
1527 |
qq|SELECT l.licensenumber, l.id AS licenseid |
|
1528 |
FROM license l, licenseinvoice li |
|
1529 |
WHERE l.id = li.license_id AND li.trans_id = ?|; |
|
1530 |
my ($licensenumber, $licenseid) |
|
1531 |
= selectrow_query($form, $dbh, $query, conv_i($ref->{invoice_pos})); |
|
1481 |
$query = qq|SELECT l.licensenumber, l.id AS licenseid FROM license l, licenseinvoice li WHERE l.id = li.license_id AND li.trans_id = ?|; |
|
1482 |
my ($licensenumber, $licenseid) = selectrow_query($form, $dbh, $query, conv_i($ref->{invoice_pos})); |
|
1532 | 1483 |
$ref->{lizenzen} = "<option value=\"$licenseid\">$licensenumber</option>"; |
1533 | 1484 |
} |
1534 | 1485 |
|
bin/mozilla/ir.pl | ||
---|---|---|
34 | 34 |
use SL::IR; |
35 | 35 |
use SL::IS; |
36 | 36 |
use SL::PE; |
37 |
use List::Util qw(max); |
|
37 | 38 |
|
38 | 39 |
require "bin/mozilla/io.pl"; |
39 | 40 |
require "bin/mozilla/arap.pl"; |
... | ... | |
216 | 217 |
# set option selected |
217 | 218 |
foreach $item (qw(AP vendor currency department)) { |
218 | 219 |
$form->{"select$item"} =~ s/ selected//; |
219 |
$form->{"select$item"} =~ |
|
220 |
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; |
|
220 |
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; |
|
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; |
... | ... | |
232 | 232 |
if ($form->{currency} ne $form->{defaultcurrency}) { |
233 | 233 |
if ($form->{forex}) { |
234 | 234 |
$exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th> |
235 |
<td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>\n|;
|
|
235 |
<td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>\n|; |
|
236 | 236 |
} else { |
237 | 237 |
$exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th> |
238 |
<td><input name=exchangerate size=10 value=$form->{exchangerate}></td>\n|;
|
|
238 |
<td><input name=exchangerate size=10 value=$form->{exchangerate}></td>\n|; |
|
239 | 239 |
} |
240 | 240 |
} |
241 | 241 |
$exchangerate .= qq| <input type=hidden name=forex value=$form->{forex}>\n|; |
... | ... | |
245 | 245 |
|
246 | 246 |
$form->get_lists("contacts" => "ALL_CONTACTS", |
247 | 247 |
"projects" => { "key" => "ALL_PROJECTS", |
248 |
"all" => 0, |
|
249 |
"old_id" => \@old_project_ids }, |
|
248 |
"all" => 0,
|
|
249 |
"old_id" => \@old_project_ids },
|
|
250 | 250 |
"taxzones" => "ALL_TAXZONES", |
251 | 251 |
"employees" => "ALL_SALESMEN", |
252 | 252 |
"currencies" => "ALL_CURRENCIES", |
... | ... | |
330 | 330 |
(($myconfig{vclimit} <= scalar(@values)) |
331 | 331 |
? qq|<input type="text" value="| . H($form->{vendor}) . qq|" name="vendor">| |
332 | 332 |
: (NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{oldvendor}, |
333 |
'-onChange' => 'document.getElementById(\'update_button\').click();', |
|
334 |
'-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq| |
|
333 |
'-onChange' => 'document.getElementById(\'update_button\').click();',
|
|
334 |
'-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
|
|
335 | 335 |
<input type="button" value="?" onclick="show_vc_details('vendor')"> |
336 | 336 |
</td>|; |
337 | 337 |
|
... | ... | |
367 | 367 |
<td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select> |
368 | 368 |
<input type="hidden" name="selectdepartment" value="$form->{selectdepartment}"> |
369 | 369 |
</td> |
370 |
</tr> |
|
371 |
| if $form->{selectdepartment}; |
|
370 |
</tr>\n| if $form->{selectdepartment}; |
|
372 | 371 |
|
373 | 372 |
$n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; |
374 | 373 |
|
... | ... | |
378 | 377 |
|
379 | 378 |
$button1 = qq| |
380 | 379 |
<td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"> |
381 |
<input type=button name=invdate id="trigger1" value=| . $locale->text('button') . qq|></td>\n|; |
|
380 |
<input type=button name=invdate id="trigger1" value=| . $locale->text('button') . qq|></td>\n|;
|
|
382 | 381 |
$button2 = qq| |
383 | 382 |
<td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"> |
384 |
<input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|></td></td>\n|; |
|
383 |
<input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|></td></td>\n|;
|
|
385 | 384 |
|
386 | 385 |
#write Trigger |
387 | 386 |
$jsscript = |
388 |
Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1", |
|
387 |
Form->write_trigger(\%myconfig, "2", |
|
388 |
"invdate", "BL", "trigger1", |
|
389 | 389 |
"duedate", "BL", "trigger2"); |
390 | 390 |
|
391 |
$form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
|
|
392 |
$form->{"javascript"} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
|
|
393 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
|
|
391 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
|
|
392 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
|
|
393 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
|
394 | 394 |
|
395 | 395 |
$jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate"); |
396 | 396 |
|
397 | 397 |
$form->header; |
398 |
$onload = qq|focus()|; |
|
398 |
$onload = qq|focus()|;
|
|
399 | 399 |
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; |
400 | 400 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; |
401 | 401 |
print qq| |
... | ... | |
404 | 404 |
<form method=post action=$form->{script}> |
405 | 405 |
|; |
406 | 406 |
|
407 |
$form->hide_form(qw(id title vc type level creditlimit creditremaining |
|
408 |
closedto locked shippted storno storno_id |
|
409 |
max_dunning_level dunning_amount)); |
|
407 |
$form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id |
|
408 |
max_dunning_level dunning_amount vendor_id oldvendor selectvendor taxaccounts |
|
409 |
fxgain_accno fxloss_accno taxpart taxservice), |
|
410 |
map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} ); |
|
410 | 411 |
|
411 | 412 |
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message}; |
412 | 413 |
|
... | ... | |
419 | 420 |
<td valign="top"> |
420 | 421 |
<table> |
421 | 422 |
$vendors |
422 |
<input type="hidden" name="vendor_id" value="$form->{vendor_id}"> |
|
423 |
<input type="hidden" name="oldvendor" value="$form->{oldvendor}"> |
|
424 |
<input type="hidden" name="selectvendor" value= "$form->{selectvendor}"> |
|
425 | 423 |
$contact |
426 | 424 |
<tr> |
427 | 425 |
<td align="right">| . $locale->text('Credit Limit') . qq|</td> |
... | ... | |
483 | 481 |
|
484 | 482 |
$jsscript |
485 | 483 |
|
486 |
<input type=hidden name=fxgain_accno value=$form->{fxgain_accno}> |
|
487 |
<input type=hidden name=fxloss_accno value=$form->{fxloss_accno}> |
|
488 | 484 |
<input type=hidden name=webdav value=$webdav> |
489 |
|
|
490 |
<input type=hidden name=taxpart value="$form->{taxpart}"> |
|
491 |
<input type=hidden name=taxservice value="$form->{taxservice}"> |
|
492 |
|
|
493 |
<input type=hidden name=taxaccounts value="$form->{taxaccounts}"> |
|
494 | 485 |
|; |
495 | 486 |
|
496 | 487 |
foreach $item (split / /, $form->{taxaccounts}) { |
... | ... | |
854 | 845 |
sub update { |
855 | 846 |
$lxdebug->enter_sub(); |
856 | 847 |
|
857 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } |
|
858 |
qw(exchangerate creditlimit creditremaining); |
|
848 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); |
|
859 | 849 |
|
860 | 850 |
&check_name(vendor); |
861 | 851 |
|
862 |
$form->{exchangerate} = $exchangerate |
|
863 |
if ( |
|
864 |
$form->{forex} = ( |
|
865 |
$exchangerate = |
|
866 |
$form->check_exchangerate( |
|
867 |
\%myconfig, $form->{currency}, $form->{invdate}, 'sell' |
|
868 |
))); |
|
852 |
$form->{exchangerate} = $exchangerate if |
|
853 |
$form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
869 | 854 |
|
870 | 855 |
for $i (1 .. $form->{paidaccounts}) { |
871 |
if ($form->{"paid_$i"}) { |
|
872 |
map { |
|
873 |
$form->{"${_}_$i"} = |
|
874 |
$form->parse_amount(\%myconfig, $form->{"${_}_$i"}) |
|
875 |
} qw(paid exchangerate); |
|
876 |
|
|
877 |
$form->{"exchangerate_$i"} = $exchangerate |
|
878 |
if ( |
|
879 |
$form->{"forex_$i"} = ( |
|
880 |
$exchangerate = |
|
881 |
$form->check_exchangerate( |
|
882 |
\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell' |
|
883 |
))); |
|
884 |
} |
|
856 |
next unless $form->{"paid_$i"}; |
|
857 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); |
|
858 |
$form->{"exchangerate_$i"} = $exchangerate if |
|
859 |
$form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); |
|
885 | 860 |
} |
886 | 861 |
|
887 | 862 |
$i = $form->{rowcount}; |
888 |
$exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1;
|
|
863 |
$exchangerate = ($form->{exchangerate} * 1) || 1;
|
|
889 | 864 |
|
890 | 865 |
if ( ($form->{"partnumber_$i"} eq "") |
891 | 866 |
&& ($form->{"description_$i"} eq "") |
... | ... | |
912 | 887 |
# override sellprice if there is one entered |
913 | 888 |
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); |
914 | 889 |
|
915 |
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } |
|
916 |
qw(partnumber description unit);
|
|
890 |
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
|
|
891 |
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
|
|
917 | 892 |
|
918 |
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } |
|
919 |
keys %{ $form->{item_list}[0] }; |
|
920 |
|
|
921 |
$s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; |
|
922 |
|
|
923 |
($dec) = ($s =~ /\.(\d+)/); |
|
924 |
$dec = length $dec; |
|
925 |
$decimalplaces = ($dec > 2) ? $dec : 2; |
|
893 |
($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/; |
|
894 |
$decimalplaces = max 2, length $1; |
|
926 | 895 |
|
927 | 896 |
if ($sellprice) { |
928 | 897 |
$form->{"sellprice_$i"} = $sellprice; |
929 | 898 |
} else { |
930 |
|
|
931 | 899 |
# if there is an exchange rate adjust sellprice |
932 | 900 |
$form->{"sellprice_$i"} /= $exchangerate; |
933 | 901 |
} |
934 | 902 |
|
935 |
$amount = |
|
936 |
$form->{"sellprice_$i"} * $form->{"qty_$i"} * |
|
937 |
(1 - $form->{"discount_$i"} / 100); |
|
903 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); |
|
938 | 904 |
$form->{creditremaining} -= $amount; |
939 |
$form->{"sellprice_$i"} = |
|
940 |
$form->format_amount(\%myconfig, $form->{"sellprice_$i"}, |
|
941 |
$decimalplaces); |
|
942 |
$form->{"qty_$i"} = |
|
943 |
$form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); |
|
905 |
$form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); |
|
906 |
$form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); |
|
944 | 907 |
} |
945 | 908 |
|
946 | 909 |
&display_form; |
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 |
|
bin/mozilla/oe.pl | ||
---|---|---|
38 | 38 |
use SL::IS; |
39 | 39 |
use SL::PE; |
40 | 40 |
use SL::ReportGenerator; |
41 |
use List::Util qw(max); |
|
41 | 42 |
|
42 | 43 |
require "bin/mozilla/io.pl"; |
43 | 44 |
require "bin/mozilla/arap.pl"; |
... | ... | |
324 | 325 |
sub form_header { |
325 | 326 |
$lxdebug->enter_sub(); |
326 | 327 |
|
327 |
my $checkedclosed = $form->{"closed"} ? "checked" : "";
|
|
328 |
my $checkedclosed = $form->{"closed"} ? "checked" : "";
|
|
328 | 329 |
my $checkeddelivered = $form->{"delivered"} ? "checked" : ""; |
329 | 330 |
|
330 |
if ($form->{old_employee_id}) { |
|
331 |
$form->{employee_id} = $form->{old_employee_id}; |
|
332 |
} |
|
333 |
if ($form->{old_salesman_id}) { |
|
334 |
$form->{salesman_id} = $form->{old_salesman_id}; |
|
335 |
} |
|
331 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; |
|
332 |
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; |
|
336 | 333 |
|
337 | 334 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
338 | 335 |
|
339 |
|
|
340 |
if ($form->{old_employee_id}) { |
|
341 |
$form->{employee_id} = $form->{old_employee_id}; |
|
342 |
} |
|
343 |
if ($form->{old_salesman_id}) { |
|
344 |
$form->{salesman_id} = $form->{old_salesman_id}; |
|
345 |
} |
|
336 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; |
|
337 |
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; |
|
346 | 338 |
|
347 | 339 |
map { $form->{$_} =~ s/\"/"/g } |
348 | 340 |
qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname |
... | ... | |
365 | 357 |
|; |
366 | 358 |
|
367 | 359 |
#write Trigger |
368 |
$jsscript = |
|
369 |
Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", |
|
370 |
"reqdate", "BL", "trigger2"); |
|
360 |
$jsscript = Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", "reqdate", "BL", "trigger2"); |
|
371 | 361 |
|
372 | 362 |
my @tmp; |
373 | 363 |
|
374 | 364 |
if (($form->{"type"} eq "sales_order") || |
375 | 365 |
($form->{"type"} eq "purchase_order")) { |
376 |
push(@tmp, qq| |
|
377 |
<input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered> |
|
378 |
<label for="delivered">| . $locale->text('Delivered') . qq|</label>|); |
|
366 |
push(@tmp, qq|<input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered> |
|
367 |
<label for="delivered">| . $locale->text('Delivered') . qq|</label>|); |
|
379 | 368 |
} |
380 | 369 |
|
381 | 370 |
if ($form->{id}) { |
382 |
push(@tmp, qq| |
|
383 |
<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed> |
|
384 |
<label for="closed">| . $locale->text('Closed') . qq|</label>|); |
|
371 |
push(@tmp, qq|<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed> |
|
372 |
<label for="closed">| . $locale->text('Closed') . qq|</label>|); |
|
385 | 373 |
} |
386 | 374 |
|
387 | 375 |
if (@tmp) { |
388 |
$openclosed .= qq| |
|
389 |
<tr> |
|
390 |
<td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq| |
|
391 |
</td> |
|
392 |
</tr> |
|
393 |
|; |
|
376 |
$openclosed .= qq|<tr> |
|
377 |
<td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq| |
|
378 |
</td> |
|
379 |
</tr>\n|; |
|
394 | 380 |
} |
395 | 381 |
|
396 | 382 |
# set option selected |
397 | 383 |
foreach $item ($form->{vc}, currency, department, ($form->{vc} eq "customer" ? customer : vendor)) { |
398 | 384 |
$form->{"select$item"} =~ s/ selected//; |
399 |
$form->{"select$item"} =~ |
|
400 |
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; |
|
385 |
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; |
|
401 | 386 |
} |
402 | 387 |
|
403 | 388 |
#quote select[customer|vendor] Bug 133 |
... | ... | |
429 | 414 |
my @values = (undef); |
430 | 415 |
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) { |
431 | 416 |
push(@values, $item->{"cp_id"}); |
432 |
$labels{$item->{"cp_id"}} = $item->{"cp_name"} . |
|
433 |
($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); |
|
417 |
$labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); |
|
434 | 418 |
} |
435 | 419 |
|
436 | 420 |
my $contact; |
... | ... | |
506 | 490 |
push(@values, $item->{"id"}); |
507 | 491 |
$labels{$item->{"id"}} = $item->{"projectnumber"}; |
508 | 492 |
} |
509 |
my $globalprojectnumber = |
|
510 |
NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, |
|
511 |
'-labels' => \%labels, |
|
512 |
'-default' => $form->{"globalproject_id"})); |
|
493 |
my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, |
|
494 |
'-labels' => \%labels, |
|
495 |
'-default' => $form->{"globalproject_id"})); |
|
513 | 496 |
|
514 | 497 |
my $salesmen = ""; |
515 | 498 |
%labels = (); |
... | ... | |
582 | 565 |
</tr>|; |
583 | 566 |
} |
584 | 567 |
|
585 |
$form->{exchangerate} = |
|
586 |
$form->format_amount(\%myconfig, $form->{exchangerate}); |
|
587 |
|
|
588 |
if (!$form->{exchangerate}) { |
|
589 |
$form->{exchangerate} = ""; |
|
590 |
} |
|
568 |
$form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); |
|
569 |
$form->{exchangerate} = "" unless $form->{exchangerate}; |
|
591 | 570 |
|
592 |
if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { |
|
593 |
$creditwarning = 1; |
|
594 |
} else { |
|
595 |
$creditwarning = 0; |
|
596 |
} |
|
571 |
$creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0; |
|
597 | 572 |
|
598 |
$form->{creditlimit} = |
|
599 |
$form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); |
|
600 |
$form->{creditremaining} = |
|
601 |
$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); |
|
573 |
$form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); |
|
574 |
$form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); |
|
602 | 575 |
|
603 |
$exchangerate = qq| |
|
604 |
<input type=hidden name=forex value=$form->{forex}> |
|
605 |
|; |
|
576 |
$exchangerate = qq|\n<input type=hidden name=forex value=$form->{forex}>\n|; |
|
606 | 577 |
|
607 | 578 |
if ($form->{currency} ne $form->{defaultcurrency}) { |
608 | 579 |
if ($form->{forex}) { |
609 | 580 |
$exchangerate .= |
610 |
qq|<th align=right>| |
|
611 |
. $locale->text('Exchangerate') |
|
581 |
qq|<th align=right>| . $locale->text('Exchangerate') |
|
612 | 582 |
. qq|</th><td>$form->{exchangerate}</td> |
613 | 583 |
<input type=hidden name=exchangerate value=$form->{exchangerate}> |
614 | 584 |
|; |
615 | 585 |
} else { |
616 | 586 |
$exchangerate .= |
617 |
qq|<th align=right>| |
|
618 |
. $locale->text('Exchangerate') |
|
587 |
qq|<th align=right>| . $locale->text('Exchangerate') |
|
619 | 588 |
. qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|; |
620 | 589 |
} |
621 | 590 |
} |
... | ... | |
683 | 652 |
</tr> |
684 | 653 |
|; |
685 | 654 |
} else { |
686 |
$reqlabel = |
|
687 |
($form->{type} eq 'sales_quotation') |
|
688 |
? $locale->text('Valid until') |
|
689 |
: $locale->text('Required by'); |
|
655 |
$reqlabel = ($form->{type} eq 'sales_quotation') ? $locale->text('Valid until') : $locale->text('Required by'); |
|
690 | 656 |
if ($form->{type} eq 'sales_quotation') { |
691 | 657 |
$ordnumber = qq| |
692 | 658 |
<tr> |
... | ... | |
707 | 673 |
|
708 | 674 |
} |
709 | 675 |
|
710 |
$ordnumber .= qq| |
|
711 |
<tr> |
|
712 |
<th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th> |
|
713 |
$button1 |
|
714 |
</tr> |
|
715 |
<tr> |
|
716 |
<th align=right nowrap=true>$reqlabel</th> |
|
717 |
$button2 |
|
718 |
</tr> |
|
719 |
|; |
|
720 |
$creditremaining = qq| <tr> |
|
721 |
<td colspan=4></td> |
|
722 |
$shipto |
|
723 |
</tr>|; |
|
676 |
$ordnumber .= qq| <tr> <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th> $button1 </tr> |
|
677 |
<tr> <th align=right nowrap=true>$reqlabel</th> $button2 </tr>\n|; |
|
678 |
$creditremaining = qq| <tr> <td colspan=4></td> $shipto </tr>|; |
|
724 | 679 |
} |
725 | 680 |
|
726 | 681 |
$department = qq| |
... | ... | |
732 | 687 |
</tr> | if $form->{selectdepartment}; |
733 | 688 |
|
734 | 689 |
if ($form->{type} eq 'sales_order') { |
735 |
if ($form->{selectemployee}) { |
|
736 |
$employee .= qq| |
|
737 |
<input type="hidden" name="customer_klass" value="$form->{customer_klass}">|; |
|
738 |
} |
|
739 |
} else { |
|
740 |
$employee .= qq| |
|
741 |
<input type="hidden" name="customer_klass" value="$form->{customer_klass}">|; |
|
742 |
} |
|
743 |
if ($form->{resubmit} && ($form->{format} eq "html")) { |
|
744 |
$onload = |
|
745 |
qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|; |
|
746 |
} elsif ($form->{resubmit}) { |
|
747 |
$onload = qq|document.oe.submit()|; |
|
690 |
$employee .= qq|\n<input type="hidden" name="customer_klass" value="$form->{customer_klass}">| if $form->{selectemployee}; |
|
748 | 691 |
} else { |
749 |
$onload = "focus()";
|
|
692 |
$employee .= qq|\n<input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
|
|
750 | 693 |
} |
751 | 694 |
|
752 | 695 |
$credittext = $locale->text('Credit Limit exceeded!!!'); |
753 |
if ($creditwarning) { |
|
754 |
$onload = qq|alert('$credittext')|; |
|
755 |
} |
|
756 |
|
|
696 |
|
|
697 |
$onload = ($form->{resubmit} && ($form->{format} eq "html")) ? "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()" |
|
698 |
: ($form->{resubmit}) ? "document.oe.submit()" |
|
699 |
: ($creditwarning) ? "alert('$credittext')" |
|
700 |
: "focus()"; |
|
701 |
|
|
757 | 702 |
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; |
758 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; |
|
703 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
|
|
759 | 704 |
|
760 |
$form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|; |
|
761 |
# show history button js |
|
705 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|; |
|
762 | 706 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|; |
763 |
#/show history button js |
|
764 | 707 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
765 | 708 |
|
766 | 709 |
$form->header; |
... | ... | |
778 | 721 |
|
779 | 722 |
$form->hide_form(qw(id action type vc formname media format proforma queued printed emailed |
780 | 723 |
title discount creditlimit creditremaining tradediscount business |
781 |
max_dunning_level dunning_amount)); |
|
782 |
|
|
724 |
max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode |
|
725 |
shiptocity shiptocountry shiptocontact shiptophone shiptofax |
|
726 |
shiptodepartment_1 shiptodepartment_2 shiptoemail |
|
727 |
message email subject cc bcc taxpart taxservice taxaccounts), |
|
728 |
map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} ); |
|
783 | 729 |
print qq| |
784 | 730 |
|
785 | 731 |
<table width=100%> |
... | ... | |
858 | 804 |
|
859 | 805 |
$jsscript |
860 | 806 |
|
861 |
<!-- shipto are in hidden variables --> |
|
862 |
|
|
863 |
<input type=hidden name=shiptoname value="$form->{shiptoname}"> |
|
864 |
<input type=hidden name=shiptostreet value="$form->{shiptostreet}"> |
|
865 |
<input type=hidden name=shiptozipcode value="$form->{shiptozipcode}"> |
|
866 |
<input type=hidden name=shiptocity value="$form->{shiptocity}"> |
|
867 |
<input type=hidden name=shiptocountry value="$form->{shiptocountry}"> |
|
868 |
<input type=hidden name=shiptocontact value="$form->{shiptocontact}"> |
|
869 |
<input type=hidden name=shiptophone value="$form->{shiptophone}"> |
|
870 |
<input type=hidden name=shiptofax value="$form->{shiptofax}"> |
|
871 |
<input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}"> |
|
872 |
<input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}"> |
|
873 |
<input type=hidden name=shiptoemail value="$form->{shiptoemail}"> |
|
874 |
|
|
875 |
<!-- email variables --> |
|
876 |
<input type=hidden name=message value="$form->{message}"> |
|
877 |
<input type=hidden name=email value="$form->{email}"> |
|
878 |
<input type=hidden name=subject value="$form->{subject}"> |
|
879 |
<input type=hidden name=cc value="$form->{cc}"> |
|
880 |
<input type=hidden name=bcc value="$form->{bcc}"> |
|
881 |
|
|
882 |
<input type=hidden name=taxpart value="$form->{taxpart}"> |
|
883 |
<input type=hidden name=taxservice value="$form->{taxservice}"> |
|
884 |
|
|
885 |
<input type=hidden name=taxaccounts value="$form->{taxaccounts}"> |
|
886 | 807 |
|; |
887 | 808 |
|
888 |
foreach $item (split / /, $form->{taxaccounts}) { |
|
889 |
print qq| |
|
890 |
<input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}> |
|
891 |
<input type=hidden name="${item}_description" value="$form->{"${item}_description"}"> |
|
892 |
|; |
|
893 |
} |
|
894 | 809 |
$lxdebug->leave_sub(); |
895 | 810 |
} |
896 | 811 |
|
... | ... | |
1190 | 1105 |
|
1191 | 1106 |
set_headings($form->{"id"} ? "edit" : "add"); |
1192 | 1107 |
|
1193 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } |
|
1194 |
qw(exchangerate creditlimit creditremaining); |
|
1108 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); |
|
1195 | 1109 |
$form->{update} = 1; |
1196 | 1110 |
|
1197 |
if($form->{payment_id}) { |
|
1198 |
$payment_id = $form->{payment_id}; |
|
1199 |
} |
|
1111 |
$payment_id = $form->{payment_id} if $form->{payment_id}; |
|
1200 | 1112 |
|
1201 | 1113 |
&check_name($form->{vc}); |
1202 | 1114 |
|
1203 |
if($form->{payment_id} eq "") { |
|
1204 |
$form->{payment_id} = $payment_id; |
|
1205 |
} |
|
1115 |
$form->{payment_id} = $payment_id if $form->{payment_id} eq ""; |
|
1206 | 1116 |
|
1207 | 1117 |
$buysell = 'buy'; |
1208 | 1118 |
$buysell = 'sell' if ($form->{vc} eq 'vendor'); |
1209 |
$form->{exchangerate} = $exchangerate |
|
1210 |
if ( |
|
1211 |
$form->{forex} = ( |
|
1212 |
$exchangerate = |
|
1213 |
$form->check_exchangerate( |
|
1214 |
\%myconfig, $form->{currency}, $form->{transdate}, $buysell |
|
1215 |
))); |
|
1119 |
$form->{exchangerate} = $exchangerate if |
|
1120 |
$form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell); |
|
1216 | 1121 |
|
1217 | 1122 |
# for pricegroups |
1218 | 1123 |
$i = $form->{rowcount}; |
1219 | 1124 |
|
1220 |
$exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
|
|
1125 |
$exchangerate = $form->{exchangerate} || 1;
|
|
1221 | 1126 |
|
1222 | 1127 |
if ( ($form->{"partnumber_$i"} eq "") |
1223 | 1128 |
&& ($form->{"description_$i"} eq "") |
... | ... | |
1232 | 1137 |
|| $form->{type} eq 'request_quotation') { |
1233 | 1138 |
IR->retrieve_item(\%myconfig, \%$form); |
1234 | 1139 |
} |
1235 |
if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') { |
|
1140 |
if ( $form->{type} eq 'sales_order' |
|
1141 |
|| $form->{type} eq 'sales_quotation') { |
|
1236 | 1142 |
IS->retrieve_item(\%myconfig, \%$form); |
1237 | 1143 |
} |
1238 | 1144 |
|
1239 | 1145 |
my $rows = scalar @{ $form->{item_list} }; |
1240 | 1146 |
|
1241 |
$form->{"discount_$i"} = |
|
1242 |
$form->format_amount(\%myconfig, $form->{discount} * 100); |
|
1147 |
$form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100); |
|
1243 | 1148 |
|
1244 | 1149 |
if ($rows) { |
1245 | 1150 |
$form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); |
... | ... | |
1251 | 1156 |
|
1252 | 1157 |
} else { |
1253 | 1158 |
|
1254 |
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); |
|
1255 |
if ($form->{"not_discountable_$i"}) { |
|
1256 |
$form->{"discount_$i"} = 0; |
|
1257 |
} |
|
1258 |
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } |
|
1259 |
qw(partnumber description unit); |
|
1260 |
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } |
|
1261 |
keys %{ $form->{item_list}[0] }; |
|
1262 |
if ($form->{"part_payment_id_$i"} ne "") { |
|
1263 |
$form->{payment_id} = $form->{"part_payment_id_$i"}; |
|
1264 |
} |
|
1265 |
|
|
1266 |
$s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; |
|
1159 |
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); |
|
1160 |
$form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"}; |
|
1161 |
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); |
|
1162 |
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; |
|
1163 |
$form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne ""; |
|
1267 | 1164 |
|
1268 |
($dec) = ($s =~ /\.(\d+)/); |
|
1269 |
$dec = length $dec; |
|
1270 |
$decimalplaces = ($dec > 2) ? $dec : 2; |
|
1165 |
($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/; |
|
1166 |
$decimalplaces = max 2, length $1; |
|
1271 | 1167 |
|
1272 | 1168 |
if ($sellprice) { |
1273 | 1169 |
$form->{"sellprice_$i"} = $sellprice; |
1274 | 1170 |
} else { |
1275 |
|
|
1276 | 1171 |
$form->{"sellprice_$i"} *= (1 - $form->{tradediscount}); |
1277 |
|
|
1278 |
# if there is an exchange rate adjust sellprice |
|
1279 |
$form->{"sellprice_$i"} /= $exchangerate; |
|
1172 |
$form->{"sellprice_$i"} /= $exchangerate; # if there is an exchange rate adjust sellprice |
|
1280 | 1173 |
} |
1281 | 1174 |
|
1282 |
$amount = |
|
1283 |
$form->{"sellprice_$i"} * $form->{"qty_$i"} * |
|
1284 |
(1 - $form->{"discount_$i"} / 100); |
|
1285 |
map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts}); |
|
1286 |
map { $form->{"${_}_base"} += $amount } |
|
1287 |
(split / /, $form->{"taxaccounts_$i"}); |
|
1288 |
map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } |
|
1289 |
split / /, $form->{taxaccounts} |
|
1290 |
if !$form->{taxincluded}; |
|
1175 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); |
|
1176 |
map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts}; |
|
1177 |
map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"}; |
|
1178 |
map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{taxaccounts} if !$form->{taxincluded}; |
|
1291 | 1179 |
|
1292 | 1180 |
$form->{creditremaining} -= $amount; |
1293 | 1181 |
|
1294 |
$form->{"sellprice_$i"} = |
|
1295 |
$form->format_amount(\%myconfig, $form->{"sellprice_$i"}, |
|
1296 |
$decimalplaces); |
|
1297 |
$form->{"qty_$i"} = |
|
1298 |
$form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); |
|
1182 |
$form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); |
|
1183 |
$form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); |
|
1299 | 1184 |
|
1300 | 1185 |
# get pricegroups for parts |
1301 | 1186 |
IS->get_pricegroups_for_parts(\%myconfig, \%$form); |
lx-erp.conf | ||
---|---|---|
96 | 96 |
# |
97 | 97 |
# Beipiel: |
98 | 98 |
# $LXDebug::global_level = LXDebug::TRACE | LXDebug::QUERY; |
99 |
$LXDebug::global_level = LXDebug::NONE;
|
|
99 |
$LXDebug::global_level = LXDebug::DEVEL;
|
|
100 | 100 |
|
101 | 101 |
# ?berwachung der Inhalte von $form aktiviert oder nicht? Wenn ja, |
102 | 102 |
# dann k?nnen einzelne Variablen mit |
Auch abrufbar als: Unified diff
Kosmetikmerge aus Revisionen 5187, 5191, 5193, 5194, 5218, 5219, 5222, 5228, 5229