# get default accounts and last invoice number
- $query=
- qq|SELECT
- (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno,
- (SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
- (SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
- (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
- d.curr AS currencies
- $q_invdate
- FROM defaults d|;
+ $query = qq|SELECT
+ (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno,
+ (SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
+ (SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
+ (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
+ d.curr AS currencies
+ $q_invdate
+ FROM defaults d|;
$ref = selectfirst_hashref_query($form, $dbh, $query);
map { $form->{$_} = $ref->{$_} } keys %$ref;
}
# retrieve invoice
- $query =
- qq|SELECT cp_id, invnumber, transdate AS invdate, duedate,
- orddate, quodate, globalproject_id,
- ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate,
- intnotes, curr AS currency
- FROM ap
- WHERE id = ?|;
+ $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate,
+ orddate, quodate, globalproject_id,
+ ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate,
+ intnotes, curr AS currency
+ FROM ap
+ WHERE id = ?|;
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id}));
map { $form->{$_} = $ref->{$_} } keys %$ref;
- $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell");
+ $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell");
# get shipto
$query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AP')|;
# retrieve individual items
$query =
qq|SELECT
- c1.accno AS inventory_accno,
- c1.new_chart_id AS inventory_new_chart,
- date($transdate) - c1.valid_from AS inventory_valid,
-
- c2.accno AS income_accno,
- c2.new_chart_id AS income_new_chart,
- date($transdate) - c2.valid_from AS income_valid,
+ c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from AS inventory_valid,
+ c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from AS income_valid,
+ c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid,
- c3.accno AS expense_accno,
- c3.new_chart_id AS expense_new_chart,
- date($transdate) - c3.valid_from AS expense_valid,
-
- i.description, i.qty, i.fxsellprice AS sellprice,
- i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
-
- p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin,
- pr.projectnumber,
- pg.partsgroup
+ i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
+ p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup
FROM invoice i
JOIN parts p ON (i.parts_id = p.id)
- LEFT JOIN chart c1 ON
- ((SELECT inventory_accno_id
- FROM buchungsgruppen
- WHERE id = p.buchungsgruppen_id) = c1.id)
- LEFT JOIN chart c2 ON
- ((SELECT income_accno_id_${taxzone_id}
- FROM buchungsgruppen
- WHERE id = p.buchungsgruppen_id) = c2.id)
- LEFT JOIN chart c3 ON
- ((SELECT expense_accno_id_${taxzone_id}
- FROM buchungsgruppen
- WHERE id = p.buchungsgruppen_id) = c3.id)
+ LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id)
+ LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id)
+ LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id)
LEFT JOIN project pr ON (i.project_id = pr.id)
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
- if (!$ref->{"part_inventory_accno_id"}) {
- map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid));
- }
+ map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"};
delete($ref->{"part_inventory_accno_id"});
foreach my $type (qw(inventory income expense)) {
while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) {
- my $query =
- qq|SELECT accno, new_chart_id, date($transdate) - valid_from
- FROM chart
- WHERE id = ?|;
- ($ref->{"${type}_accno"},
- $ref->{"${type}_new_chart"},
- $ref->{"${type}_valid"})
- = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"});
+ my $query = qq|SELECT accno, new_chart_id, date($transdate) - valid_from FROM chart WHERE id = ?|;
+ @$ref{ map $type.$_, qw(_accno _new_chart _valid) } = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"});
}
}
# get tax rates and description
my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
$query =
- qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
- FROM tax t
+ qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber FROM tax t
LEFT JOIN chart c ON (c.id = t.chart_id)
WHERE t.id in
- (SELECT tk.tax_id
- FROM taxkeys tk
- WHERE tk.chart_id =
- (SELECT id
- FROM chart
- WHERE accno = ?)
+ (SELECT tk.tax_id FROM taxkeys tk
+ WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?)
AND (startdate <= $transdate)
ORDER BY startdate DESC
LIMIT 1)
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
- $form->{exchangerate} =
- $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy");
+ $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy");
# get shipto
$query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AR')|;
foreach my $vc (qw(customer vendor)) {
next if !$form->{"delivery_${vc}_id"};
- ($form->{"delivery_${vc}_string"})
- = selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id);
+ ($form->{"delivery_${vc}_string"}) = selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id);
}
# get printed, emailed
- $query =
- qq|SELECT printed, emailed, spoolfile, formname
- FROM status
- WHERE trans_id = ?|;
+ $query = qq|SELECT printed, emailed, spoolfile, formname FROM status WHERE trans_id = ?|;
$sth = prepare_execute_query($form, $dbh, $query, $id);
while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
$form->{printed} .= "$ref->{formname} " if $ref->{printed};
$form->{emailed} .= "$ref->{formname} " if $ref->{emailed};
- $form->{queued} .= "$ref->{formname} $ref->{spoolfile} "
- if $ref->{spoolfile};
+ $form->{queued} .= "$ref->{formname} $ref->{spoolfile} " if $ref->{spoolfile};
}
$sth->finish;
map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
- my $transdate =
- $form->{deliverydate} ? $dbh->quote($form->{deliverydate}) :
- $form->{invdate} ? $dbh->quote($form->{invdate}) :
- "current_date";
+ my $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
+ : $form->{invdate} ? $dbh->quote($form->{invdate})
+ : "current_date";
+
my $taxzone_id = $form->{taxzone_id} *= 1;
$taxzone_id = 0 if (0 > $taxzone_id) || (3 < $taxzone_id);
# retrieve individual items
$query =
qq|SELECT
- c1.accno AS inventory_accno,
- c1.new_chart_id AS inventory_new_chart,
- date($transdate) - c1.valid_from AS inventory_valid,
-
- c2.accno AS income_accno,
- c2.new_chart_id AS income_new_chart,
- date($transdate) - c2.valid_from as income_valid,
-
- c3.accno AS expense_accno,
- c3.new_chart_id AS expense_new_chart,
- date($transdate) - c3.valid_from AS expense_valid,
+ c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from AS inventory_valid,
+ c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid,
+ c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid,
- i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice,
- i.discount, i.parts_id AS id, i.unit, i.deliverydate,
- i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id,
- i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost,
-
- p.partnumber, p.assembly, p.bin, p.notes AS partnotes,
- p.inventory_accno_id AS part_inventory_accno_id, p.formel,
-
- pr.projectnumber,
- pg.partsgroup,
- prg.pricegroup
+ i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate,
+ i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost,
+ p.partnumber, p.assembly, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel,
+ pr.projectnumber, pg.partsgroup, prg.pricegroup
FROM invoice i
LEFT JOIN parts p ON (i.parts_id = p.id)
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id)
LEFT JOIN pricegroup prg ON (i.pricegroup_id = prg.id)
- LEFT JOIN chart c1 ON
- ((SELECT inventory_accno_id
- FROM buchungsgruppen
- WHERE id = p.buchungsgruppen_id) = c1.id)
- LEFT JOIN chart c2 ON
- ((SELECT income_accno_id_${taxzone_id}
- FROM buchungsgruppen
- WHERE id=p.buchungsgruppen_id) = c2.id)
- LEFT JOIN chart c3 ON
- ((SELECT expense_accno_id_${taxzone_id}
- FROM buchungsgruppen
- WHERE id = p.buchungsgruppen_id) = c3.id)
-
- WHERE (i.trans_id = ?)
- AND NOT (i.assemblyitem = '1')
- ORDER BY i.id|;
+ LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id)
+ LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id)
+ LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id)
+
+ WHERE (i.trans_id = ?) AND NOT (i.assemblyitem = '1') ORDER BY i.id|;
$sth = prepare_execute_query($form, $dbh, $query, $id);
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
- if (!$ref->{"part_inventory_accno_id"}) {
- map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid));
- }
+ map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"};
delete($ref->{"part_inventory_accno_id"});
foreach my $type (qw(inventory income expense)) {
while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) {
- my $query =
- qq|SELECT accno, new_chart_id, date($transdate) - valid_from
- FROM chart
- WHERE id = ?|;
- ($ref->{"${type}_accno"},
- $ref->{"${type}_new_chart"},
- $ref->{"${type}_valid"})
- = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"});
+ my $query = qq|SELECT accno, new_chart_id, date($transdate) - valid_from FROM chart WHERE id = ?|;
+ @$ref{ map $type.$_, qw(_accno _new_chart _valid) } = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"});
}
}
# get tax rates and description
- my $accno_id =
- ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
+ my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
$query =
- qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
- FROM tax t
+ qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber FROM tax t
LEFT JOIN chart c ON (c.id = t.chart_id)
WHERE t.id IN
- (SELECT tk.tax_id
- FROM taxkeys tk
- WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?)
+ (SELECT tk.tax_id FROM taxkeys tk
+ WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?)
AND startdate <= date($transdate)
- ORDER BY startdate DESC
- LIMIT 1)
+ ORDER BY startdate DESC LIMIT 1)
ORDER BY c.accno|;
my $stw = prepare_execute_query($form, $dbh, $query, $accno_id);
$ref->{taxaccounts} = "";
my $i=0;
while ($ptr = $stw->fetchrow_hashref(NAME_lc)) {
- # if ($customertax{$ref->{accno}}) {
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) {
$i++;
$ptr->{accno} = $i;
}
if ($form->{lizenzen}) {
- $query =
- qq|SELECT l.licensenumber, l.id AS licenseid
- FROM license l, licenseinvoice li
- WHERE l.id = li.license_id AND li.trans_id = ?|;
- my ($licensenumber, $licenseid)
- = selectrow_query($form, $dbh, $query, conv_i($ref->{invoice_pos}));
+ $query = qq|SELECT l.licensenumber, l.id AS licenseid FROM license l, licenseinvoice li WHERE l.id = li.license_id AND li.trans_id = ?|;
+ my ($licensenumber, $licenseid) = selectrow_query($form, $dbh, $query, conv_i($ref->{invoice_pos}));
$ref->{lizenzen} = "<option value=\"$licenseid\">$licensenumber</option>";
}
use SL::IR;
use SL::IS;
use SL::PE;
+use List::Util qw(max);
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
# set option selected
foreach $item (qw(AP vendor currency department)) {
$form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~
- s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{forex}) {
$exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
- <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>\n|;
+ <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>\n|;
} else {
$exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
- <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>\n|;
+ <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>\n|;
}
}
$exchangerate .= qq| <input type=hidden name=forex value=$form->{forex}>\n|;
$form->get_lists("contacts" => "ALL_CONTACTS",
"projects" => { "key" => "ALL_PROJECTS",
- "all" => 0,
- "old_id" => \@old_project_ids },
+ "all" => 0,
+ "old_id" => \@old_project_ids },
"taxzones" => "ALL_TAXZONES",
"employees" => "ALL_SALESMEN",
"currencies" => "ALL_CURRENCIES",
(($myconfig{vclimit} <= scalar(@values))
? qq|<input type="text" value="| . H($form->{vendor}) . qq|" name="vendor">|
: (NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{oldvendor},
- '-onChange' => 'document.getElementById(\'update_button\').click();',
- '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
+ '-onChange' => 'document.getElementById(\'update_button\').click();',
+ '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
<input type="button" value="?" onclick="show_vc_details('vendor')">
</td>|;
<td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
<input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
</td>
- </tr>
-| if $form->{selectdepartment};
+ </tr>\n| if $form->{selectdepartment};
$n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
$button1 = qq|
<td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
- <input type=button name=invdate id="trigger1" value=| . $locale->text('button') . qq|></td>\n|;
+ <input type=button name=invdate id="trigger1" value=| . $locale->text('button') . qq|></td>\n|;
$button2 = qq|
<td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\">
- <input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|></td></td>\n|;
+ <input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|></td></td>\n|;
#write Trigger
$jsscript =
- Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1",
+ Form->write_trigger(\%myconfig, "2",
+ "invdate", "BL", "trigger1",
"duedate", "BL", "trigger2");
- $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
- $form->{"javascript"} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
- $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
$jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate");
$form->header;
- $onload = qq|focus()|;
+ $onload = qq|focus()|;
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
print qq|
<form method=post action=$form->{script}>
|;
- $form->hide_form(qw(id title vc type level creditlimit creditremaining
- closedto locked shippted storno storno_id
- max_dunning_level dunning_amount));
+ $form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id
+ max_dunning_level dunning_amount vendor_id oldvendor selectvendor taxaccounts
+ fxgain_accno fxloss_accno taxpart taxservice),
+ map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} );
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
<td valign="top">
<table>
$vendors
- <input type="hidden" name="vendor_id" value="$form->{vendor_id}">
- <input type="hidden" name="oldvendor" value="$form->{oldvendor}">
- <input type="hidden" name="selectvendor" value= "$form->{selectvendor}">
$contact
<tr>
<td align="right">| . $locale->text('Credit Limit') . qq|</td>
$jsscript
-<input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
-<input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
<input type=hidden name=webdav value=$webdav>
-
-<input type=hidden name=taxpart value="$form->{taxpart}">
-<input type=hidden name=taxservice value="$form->{taxservice}">
-
-<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
|;
foreach $item (split / /, $form->{taxaccounts}) {
sub update {
$lxdebug->enter_sub();
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
- qw(exchangerate creditlimit creditremaining);
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining);
&check_name(vendor);
- $form->{exchangerate} = $exchangerate
- if (
- $form->{forex} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{invdate}, 'sell'
- )));
+ $form->{exchangerate} = $exchangerate if
+ $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell');
for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
- map {
- $form->{"${_}_$i"} =
- $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
- } qw(paid exchangerate);
-
- $form->{"exchangerate_$i"} = $exchangerate
- if (
- $form->{"forex_$i"} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
- )));
- }
+ next unless $form->{"paid_$i"};
+ map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
+ $form->{"exchangerate_$i"} = $exchangerate if
+ $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell');
}
$i = $form->{rowcount};
- $exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1;
+ $exchangerate = ($form->{exchangerate} * 1) || 1;
if ( ($form->{"partnumber_$i"} eq "")
&& ($form->{"description_$i"} eq "")
# override sellprice if there is one entered
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
- qw(partnumber description unit);
+ map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
+ map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
- map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
- keys %{ $form->{item_list}[0] };
-
- $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
-
- ($dec) = ($s =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
+ $decimalplaces = max 2, length $1;
if ($sellprice) {
$form->{"sellprice_$i"} = $sellprice;
} else {
-
# if there is an exchange rate adjust sellprice
$form->{"sellprice_$i"} /= $exchangerate;
}
- $amount =
- $form->{"sellprice_$i"} * $form->{"qty_$i"} *
- (1 - $form->{"discount_$i"} / 100);
+ $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
$form->{creditremaining} -= $amount;
- $form->{"sellprice_$i"} =
- $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
- $decimalplaces);
- $form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
+ $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
+ $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
}
&display_form;
use SL::IS;
use SL::PE;
use Data::Dumper;
+use List::Util qw(max);
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
- if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
- $creditwarning = 1;
- } else {
- $creditwarning = 0;
- }
+ $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
$form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
$form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
#write Trigger
$jsscript =
Form->write_trigger(\%myconfig, "3",
- "invdate", "BL",
- "trigger1", "duedate",
- "BL", "trigger2",
- "deliverydate", "BL",
- "trigger3");
+ "invdate", "BL", "trigger1",
+ "duedate", "BL", "trigger2",
+ "deliverydate", "BL", "trigger3");
}
- if ($form->{resubmit} && ($form->{format} eq "html")) {
- $onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
- } elsif ($form->{resubmit}) {
- $onload = qq|document.invoice.submit()|;
- } else {
- $onload = "focus()";
- }
+ $credittext = $locale->text('Credit Limit exceeded!!!');
+ $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|
+ : ($form->{resubmit}) ? qq|document.invoice.submit()|
+ : ($creditwarning) ? qq|alert('$credittext')|
+ : "focus()";
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
- $credittext = $locale->text('Credit Limit exceeded!!!');
- if ($creditwarning) {
- $onload = qq|alert('$credittext')|;
- }
- $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
- $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
$jsscript .=
$form->write_trigger(\%myconfig, 2,
$form->hide_form(qw(id action type media format queued printed emailed title vc discount
creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
- max_dunning_level dunning_amount));
+ max_dunning_level dunning_amount
+ shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax
+ shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts),
+ map { $_.'_rate', $_,'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} );
+
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
print qq|
<tr>
<td>
</td>
- </tr>
-| .
-$jsscript
-. qq|
-<!-- shipto are in hidden variables -->
-| ;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
-print qq|<!-- email variables --> |;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- qw(message email subject cc bcc taxaccounts));
-print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|;
+ </tr>
+ $jsscript
+|;
+ print qq|<input type="hidden" name="webdav" value="$webdav">|;
- foreach $item (split(/ /, $form->{taxaccounts})) {
- map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- ("${item}_rate", "${item}_description", "${item}_taxnumber"));
- }
$lxdebug->leave_sub();
}
sub update {
$lxdebug->enter_sub();
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
- qw(exchangerate creditlimit creditremaining);
- if ($form->{second_run}) {
- $form->{print_and_post} = 0;
- }
-
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining);
- if($form->{taxincluded}) {
- $taxincluded = "checked";
- }
+ $form->{print_and_post} = 0 if $form->{second_run};
+ $taxincluded = "checked" if $form->{taxincluded};
$form->{update} = 1;
&check_name(customer);
- if(!$form->{taxincluded}) {
- $form->{taxincluded} = $taxincluded;
- }
-
+ $form->{taxincluded} ||= $taxincluded;
- $form->{exchangerate} = $exchangerate
- if (
- $form->{forex} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{invdate}, 'buy'
- )));
+ $form->{exchangerate} = $exchangerate if
+ $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy');
for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
- map {
- $form->{"${_}_$i"} =
- $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
- } qw(paid exchangerate);
-
- $form->{"exchangerate_$i"} = $exchangerate
- if (
- $form->{"forex_$i"} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
- )));
- }
+ next unless $form->{"paid_$i"};
+ map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
+ $form->{"exchangerate_$i"} = $exchangerate if
+ $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy');
}
$i = $form->{rowcount};
- $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
+ $exchangerate = $form->{exchangerate} || 1;
# if last row empty, check the form otherwise retrieve new item
if ( ($form->{"partnumber_$i"} eq "")
$rows = scalar @{ $form->{item_list} };
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{discount} * 100);
+ $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100);
if ($rows) {
$form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1;
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
- qw(partnumber description unit);
- map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
- keys %{ $form->{item_list}[0] };
- if ($form->{"part_payment_id_$i"} ne "") {
- $form->{payment_id} = $form->{"part_payment_id_$i"};
- }
+ map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
+ map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
+
+ $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
+ $form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"};
- if ($form->{"not_discountable_$i"}) {
- $form->{"discount_$i"} = 0;
- }
-
- $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
- ($dec) = ($s =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
+ $decimalplaces = max 2, length $1;
if ($sellprice) {
$form->{"sellprice_$i"} = $sellprice;
} else {
-
# if there is an exchange rate adjust sellprice
$form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
$form->{"sellprice_$i"} /= $exchangerate;
$form->{"listprice_$i"} /= $exchangerate;
- $amount =
- $form->{"sellprice_$i"} * $form->{"qty_$i"} *
- (1 - $form->{"discount_$i"} / 100);
- map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
- map { $form->{"${_}_base"} += $amount }
- (split / /, $form->{"taxaccounts_$i"});
- map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
- split / /, $form->{"taxaccounts_$i"}
- if !$form->{taxincluded};
+ $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
+ map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
+ map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"};
+ map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded};
$form->{creditremaining} -= $amount;
- map {
- $form->{"${_}_$i"} =
- $form->format_amount(\%myconfig, $form->{"${_}_$i"},
- $decimalplaces)
- } qw(sellprice listprice);
+ map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice);
- $form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"});
+ $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
if ($lizenzen) {
if ($form->{"inventory_accno_$i"} ne "") {
$form->{"lizenzen_$i"} = qq|<option></option>|;
foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
- $form->{"lizenzen_$i"} .=
- qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|;
+ $form->{"lizenzen_$i"} .= qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|;
}
- $form->{"lizenzen_$i"} .=
- qq|<option value=-1>Neue Lizenz</option>|;
+ $form->{"lizenzen_$i"} .= qq|<option value=-1>Neue Lizenz</option>|;
}
}
use SL::IS;
use SL::PE;
use SL::ReportGenerator;
+use List::Util qw(max);
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
sub form_header {
$lxdebug->enter_sub();
- my $checkedclosed = $form->{"closed"} ? "checked" : "";
+ my $checkedclosed = $form->{"closed"} ? "checked" : "";
my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
- if ($form->{old_employee_id}) {
- $form->{employee_id} = $form->{old_employee_id};
- }
- if ($form->{old_salesman_id}) {
- $form->{salesman_id} = $form->{old_salesman_id};
- }
+ $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
+ $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
-
- if ($form->{old_employee_id}) {
- $form->{employee_id} = $form->{old_employee_id};
- }
- if ($form->{old_salesman_id}) {
- $form->{salesman_id} = $form->{old_salesman_id};
- }
+ $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
+ $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
map { $form->{$_} =~ s/\"/"/g }
qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
|;
#write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
- "reqdate", "BL", "trigger2");
+ $jsscript = Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", "reqdate", "BL", "trigger2");
my @tmp;
if (($form->{"type"} eq "sales_order") ||
($form->{"type"} eq "purchase_order")) {
- push(@tmp, qq|
- <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
- <label for="delivered">| . $locale->text('Delivered') . qq|</label>|);
+ push(@tmp, qq|<input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
+ <label for="delivered">| . $locale->text('Delivered') . qq|</label>|);
}
if ($form->{id}) {
- push(@tmp, qq|
- <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
- <label for="closed">| . $locale->text('Closed') . qq|</label>|);
+ push(@tmp, qq|<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
+ <label for="closed">| . $locale->text('Closed') . qq|</label>|);
}
if (@tmp) {
- $openclosed .= qq|
- <tr>
- <td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq|
- </td>
- </tr>
-|;
+ $openclosed .= qq|<tr>
+ <td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq|
+ </td>
+ </tr>\n|;
}
# set option selected
foreach $item ($form->{vc}, currency, department, ($form->{vc} eq "customer" ? customer : vendor)) {
$form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~
- s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
#quote select[customer|vendor] Bug 133
my @values = (undef);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
push(@values, $item->{"cp_id"});
- $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
- ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
+ $labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
}
my $contact;
push(@values, $item->{"id"});
$labels{$item->{"id"}} = $item->{"projectnumber"};
}
- my $globalprojectnumber =
- NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
- '-labels' => \%labels,
- '-default' => $form->{"globalproject_id"}));
+ my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+ '-labels' => \%labels,
+ '-default' => $form->{"globalproject_id"}));
my $salesmen = "";
%labels = ();
</tr>|;
}
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
-
- if (!$form->{exchangerate}) {
- $form->{exchangerate} = "";
- }
+ $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
+ $form->{exchangerate} = "" unless $form->{exchangerate};
- if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
- $creditwarning = 1;
- } else {
- $creditwarning = 0;
- }
+ $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} =
- $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
+ $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
+ $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
- $exchangerate = qq|
-<input type=hidden name=forex value=$form->{forex}>
-|;
+ $exchangerate = qq|\n<input type=hidden name=forex value=$form->{forex}>\n|;
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{forex}) {
$exchangerate .=
- qq|<th align=right>|
- . $locale->text('Exchangerate')
+ qq|<th align=right>| . $locale->text('Exchangerate')
. qq|</th><td>$form->{exchangerate}</td>
<input type=hidden name=exchangerate value=$form->{exchangerate}>
|;
} else {
$exchangerate .=
- qq|<th align=right>|
- . $locale->text('Exchangerate')
+ qq|<th align=right>| . $locale->text('Exchangerate')
. qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
}
}
</tr>
|;
} else {
- $reqlabel =
- ($form->{type} eq 'sales_quotation')
- ? $locale->text('Valid until')
- : $locale->text('Required by');
+ $reqlabel = ($form->{type} eq 'sales_quotation') ? $locale->text('Valid until') : $locale->text('Required by');
if ($form->{type} eq 'sales_quotation') {
$ordnumber = qq|
<tr>
}
- $ordnumber .= qq|
- <tr>
- <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
- $button1
- </tr>
- <tr>
- <th align=right nowrap=true>$reqlabel</th>
- $button2
- </tr>
-|;
- $creditremaining = qq| <tr>
- <td colspan=4></td>
- $shipto
- </tr>|;
+ $ordnumber .= qq| <tr> <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th> $button1 </tr>
+ <tr> <th align=right nowrap=true>$reqlabel</th> $button2 </tr>\n|;
+ $creditremaining = qq| <tr> <td colspan=4></td> $shipto </tr>|;
}
$department = qq|
</tr> | if $form->{selectdepartment};
if ($form->{type} eq 'sales_order') {
- if ($form->{selectemployee}) {
- $employee .= qq|
- <input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
- }
- } else {
- $employee .= qq|
- <input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
- }
- if ($form->{resubmit} && ($form->{format} eq "html")) {
- $onload =
- qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
- } elsif ($form->{resubmit}) {
- $onload = qq|document.oe.submit()|;
+ $employee .= qq|\n<input type="hidden" name="customer_klass" value="$form->{customer_klass}">| if $form->{selectemployee};
} else {
- $onload = "focus()";
+ $employee .= qq|\n<input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
}
$credittext = $locale->text('Credit Limit exceeded!!!');
- if ($creditwarning) {
- $onload = qq|alert('$credittext')|;
- }
-
+
+ $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()"
+ : ($form->{resubmit}) ? "document.oe.submit()"
+ : ($creditwarning) ? "alert('$credittext')"
+ : "focus()";
+
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
- $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
- $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
- # show history button js
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
- #/show history button js
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
$form->header;
$form->hide_form(qw(id action type vc formname media format proforma queued printed emailed
title discount creditlimit creditremaining tradediscount business
- max_dunning_level dunning_amount));
-
+ max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode
+ shiptocity shiptocountry shiptocontact shiptophone shiptofax
+ shiptodepartment_1 shiptodepartment_2 shiptoemail
+ message email subject cc bcc taxpart taxservice taxaccounts),
+ map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} );
print qq|
<table width=100%>
$jsscript
-<!-- shipto are in hidden variables -->
-
-<input type=hidden name=shiptoname value="$form->{shiptoname}">
-<input type=hidden name=shiptostreet value="$form->{shiptostreet}">
-<input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
-<input type=hidden name=shiptocity value="$form->{shiptocity}">
-<input type=hidden name=shiptocountry value="$form->{shiptocountry}">
-<input type=hidden name=shiptocontact value="$form->{shiptocontact}">
-<input type=hidden name=shiptophone value="$form->{shiptophone}">
-<input type=hidden name=shiptofax value="$form->{shiptofax}">
-<input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
-<input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
-<input type=hidden name=shiptoemail value="$form->{shiptoemail}">
-
-<!-- email variables -->
-<input type=hidden name=message value="$form->{message}">
-<input type=hidden name=email value="$form->{email}">
-<input type=hidden name=subject value="$form->{subject}">
-<input type=hidden name=cc value="$form->{cc}">
-<input type=hidden name=bcc value="$form->{bcc}">
-
-<input type=hidden name=taxpart value="$form->{taxpart}">
-<input type=hidden name=taxservice value="$form->{taxservice}">
-
-<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
|;
- foreach $item (split / /, $form->{taxaccounts}) {
- print qq|
-<input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
-<input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
-|;
- }
$lxdebug->leave_sub();
}
set_headings($form->{"id"} ? "edit" : "add");
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
- qw(exchangerate creditlimit creditremaining);
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining);
$form->{update} = 1;
- if($form->{payment_id}) {
- $payment_id = $form->{payment_id};
- }
+ $payment_id = $form->{payment_id} if $form->{payment_id};
&check_name($form->{vc});
- if($form->{payment_id} eq "") {
- $form->{payment_id} = $payment_id;
- }
+ $form->{payment_id} = $payment_id if $form->{payment_id} eq "";
$buysell = 'buy';
$buysell = 'sell' if ($form->{vc} eq 'vendor');
- $form->{exchangerate} = $exchangerate
- if (
- $form->{forex} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{transdate}, $buysell
- )));
+ $form->{exchangerate} = $exchangerate if
+ $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell);
# for pricegroups
$i = $form->{rowcount};
- $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
+ $exchangerate = $form->{exchangerate} || 1;
if ( ($form->{"partnumber_$i"} eq "")
&& ($form->{"description_$i"} eq "")
|| $form->{type} eq 'request_quotation') {
IR->retrieve_item(\%myconfig, \%$form);
}
- if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
+ if ( $form->{type} eq 'sales_order'
+ || $form->{type} eq 'sales_quotation') {
IS->retrieve_item(\%myconfig, \%$form);
}
my $rows = scalar @{ $form->{item_list} };
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{discount} * 100);
+ $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100);
if ($rows) {
$form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
} else {
- $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- if ($form->{"not_discountable_$i"}) {
- $form->{"discount_$i"} = 0;
- }
- map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
- qw(partnumber description unit);
- map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
- keys %{ $form->{item_list}[0] };
- if ($form->{"part_payment_id_$i"} ne "") {
- $form->{payment_id} = $form->{"part_payment_id_$i"};
- }
-
- $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
+ $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
+ $form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"};
+ map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
+ map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
+ $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
- ($dec) = ($s =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
+ $decimalplaces = max 2, length $1;
if ($sellprice) {
$form->{"sellprice_$i"} = $sellprice;
} else {
-
$form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
-
- # if there is an exchange rate adjust sellprice
- $form->{"sellprice_$i"} /= $exchangerate;
+ $form->{"sellprice_$i"} /= $exchangerate; # if there is an exchange rate adjust sellprice
}
- $amount =
- $form->{"sellprice_$i"} * $form->{"qty_$i"} *
- (1 - $form->{"discount_$i"} / 100);
- map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
- map { $form->{"${_}_base"} += $amount }
- (split / /, $form->{"taxaccounts_$i"});
- map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
- split / /, $form->{taxaccounts}
- if !$form->{taxincluded};
+ $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
+ map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
+ map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"};
+ map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{taxaccounts} if !$form->{taxincluded};
$form->{creditremaining} -= $amount;
- $form->{"sellprice_$i"} =
- $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
- $decimalplaces);
- $form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
+ $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
+ $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
# get pricegroups for parts
IS->get_pricegroups_for_parts(\%myconfig, \%$form);
#
# Beipiel:
# $LXDebug::global_level = LXDebug::TRACE | LXDebug::QUERY;
-$LXDebug::global_level = LXDebug::NONE;
+$LXDebug::global_level = LXDebug::DEVEL;
# Überwachung der Inhalte von $form aktiviert oder nicht? Wenn ja,
# dann können einzelne Variablen mit