$duedate = $form->{duedate};
$taxincluded = $form->{taxincluded};
-
+ my $id = $form->{id};
IS->get_customer(\%myconfig, \%$form);
+ $form->{taxincluded} = $taxincluded;
+ $form->{id} = $id;
$form->{duedate} = $duedate if $duedate;
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
map {
$tax .=
- qq|<option value=\"$_->{taxkey}--$_->{rate}\">$_->{taxdescription} |
+ qq|<option value=\"$_->{id}--$_->{rate}\">$_->{taxdescription} |
. ($_->{rate} * 100) . qq| %|
} @{ $form->{TAX} };
$form->{taxchart} = $tax;
"<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
} else {
$form->{"select$key"} .=
- "<option value=\"$ref->{accno}--$ref->{taxkey}\">$ref->{accno}--$ref->{description}</option>\n";
+ "<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n";
}
}
if ($akey eq 'amount') {
$form->{"taxchart_$k"} = $form->{taxchart};
$form->{"taxchart_$k"} =~
- /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{taxkey}--[^\"]*)/;
+ /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{id}--[^\"]*)/;
$form->{"taxchart_$k"} = $1;
}
}
<!--
function setTaxkey(accno, row) {
var taxkey = accno.options[accno.selectedIndex].value;
- var reg = /--([0-9])*/;
+ var reg = /--([0-9]*)/;
var found = reg.exec(taxkey);
var index = found[1];
index = parseInt(index);
$tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
$tax =
qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
+ $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
print qq|
<tr>
<td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
<td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
<td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
- <td><input type="checkbox" name="korrektur_$i" value="1"></td>
+ <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
$tax
<td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
<input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
# format amounts
- $form->{"paid_$i"} =
- $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+ if ($form->{"paid_$i"}) {
+ $form->{"paid_$i"} =
+ $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+ }
$form->{"exchangerate_$i"} =
$form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- if ($form->{id} && $form->{radier}) {
-
- print qq|<input class=submit type=submit name=action value="|
- . $locale->text('Update') . qq|">
-|;
-
- if (!$form->{revtrans}) {
- if (!$form->{locked}) {
+ if ($form->{id}) {
+ if ($form->{radier}) {
+ print qq|<input class=submit type=submit name=action value="|
+ . $locale->text('Update') . qq|">
+ |;
+
+ print qq|
+ <input class=submit type=submit name=action value="|
+ . $locale->text('Post') . qq|">
+ <input class=submit type=submit name=action value="|
+ . $locale->text('Delete') . qq|">
+ |;
+ }
+ if ($transdate > $closedto) {
print qq|
- <input class=submit type=submit name=action value="|
- . $locale->text('Post') . qq|">
- <input class=submit type=submit name=action value="|
- . $locale->text('Delete') . qq|">
-|;
+ <input class=submit type=submit name=action value="|
+ . $locale->text('Use As Template') . qq|">
+ |;
}
- }
-
- if ($transdate > $closedto) {
- print qq|
-<input class=submit type=submit name=action value="|
- . $locale->text('Post as new') . qq|">
-|;
- }
-
+
} else {
if ($transdate > $closedto) {
print qq|<input class=submit type=submit name=action value="|
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
+ if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
map {
$form->{"${_}_$i"} =
$form->parse_amount(\%myconfig, $form->{"${_}_$i"})
delete($form->{AR});
for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
+ if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
$datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
$form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
$lxdebug->leave_sub();
}
+sub use_as_template {
+ $lxdebug->enter_sub();
+
+ map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
+ $form->{paidaccounts} = 1;
+ $form->{rowcount}--;
+ $form->{invdate} = $form->current_date(\%myconfig);
+ &update;
+
+ $lxdebug->leave_sub();
+}
+
sub delete {
$lxdebug->enter_sub();