-
-
$jsscript
-
+
{rowcount}>
+
+
+
+
+ |
+ . $locale->text('Account') . qq| |
+ |
+ . $locale->text('Amount') . qq| |
+ |
+ . $locale->text('Tax') . qq| |
+ |
+ . $locale->text('Korrektur') . qq| |
+ |
+ . $locale->text('Taxkey') . qq| |
+ |
+ . $locale->text('Project') . qq| |
+
|;
- $form->{"tax"} = $form->format_amount(\%myconfig, $form->{"tax"}, 2);
-
$amount = $locale->text('Amount');
$project = $locale->text('Project');
- for $i (1 .. 1) {
+ for $i (1 .. $form->{rowcount}) {
# format amounts
$form->{"amount_$i"} =
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
+ $selectAR_amount = $selectAR_amount_unquoted;
+ $selectAR_amount =~
+ s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
+ $tax = $taxchart;
+ $tax_selected = $form->{"taxchart_$i"};
+ $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
+ $tax =
+ qq| | |;
+ $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
print qq|
- $amount |
- {"amount_$i"}> |
- $project |
+ |
+ {"amount_$i"}> |
+ {"tax_$i"}> |
+ |
+ $tax
{"project_id_$i"}>
|
- |
|;
$amount = "";
$project = "";
}
- $taxlabel =
- ($form->{taxincluded})
- ? $locale->text('Tax Included')
- : $locale->text('Tax');
-
- print qq|
-
- $taxlabel |
- {"tax"}> |
- |
- |
- |
-
-|;
-
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
print qq|
-
- | . $locale->text('Total') . qq| |
+
+
+ |
+
+
+ |
+
$form->{invtotal} |
{oldinvtotal}>
@@ -582,14 +608,19 @@ $jsscript
- |
- |
-
-
+ |
+
+
+
+ |
+
+
+
+
- | . $locale->text('Notes') . qq| |
- $notes |
+ | . $locale->text('Notes') . qq| |
+ $notes |
|
@@ -599,8 +630,7 @@ $jsscript
|
- . $locale->text('Incoming Payments')
- . qq| |
+ . $locale->text('Incoming Payments') . qq|
|;
@@ -625,6 +655,7 @@ $jsscript
";
+ my @triggers = ();
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
print "
@@ -636,8 +667,10 @@ $jsscript
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"});
@@ -662,7 +695,8 @@ $jsscript
qq| | |;
$column_data{exchangerate} = qq|$exchangerate | |;
$column_data{datepaid} =
- qq|{"datepaid_$i"}> | |;
+ qq|{"datepaid_$i"}>
+ | |;
$column_data{source} =
qq| | |;
$column_data{memo} =
@@ -673,9 +707,12 @@ $jsscript
print "
";
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
- print qq|
+
+ print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
+ qq|
{paidaccounts}>
@@ -708,30 +745,26 @@ sub form_footer {
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- if ($form->{id} && $form->{radier}) {
-
- print qq|
-|;
-
- if (!$form->{revtrans}) {
- if (!$form->{locked}) {
+ if ($form->{id}) {
+ if ($form->{radier}) {
+ print qq|
+ |;
+
+ print qq|
+
+
+ |;
+ }
+ if ($transdate > $closedto) {
print qq|
-
-
-|;
+
+ |;
}
- }
-
- if ($transdate > $closedto) {
- print qq|
-
-|;
- }
-
+
} else {
if ($transdate > $closedto) {
print qq|{path}/menu.pl";
- &menubar;
- }
-
print "
@@ -767,9 +795,9 @@ sub update {
$form->{invtotal} = 0;
- $form->{selectAR_amount} = $form->{AR_amount};
- $form->{selectAR_amount} =~
- s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
+ # $form->{selectAR_amount} = $form->{AR_amount};
+ # $form->{selectAR_amount} =~
+ # s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
$form->{selectAR} = $form->{AR};
@@ -790,21 +818,37 @@ sub update {
@flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
$count = 0;
@a = ();
- for $i (1 .. 1) {
+
+ for $i (1 .. $form->{rowcount}) {
$form->{"amount_$i"} =
$form->parse_amount(\%myconfig, $form->{"amount_$i"});
+ $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
if ($form->{"amount_$i"}) {
push @a, {};
$j = $#a;
+ if (!$form->{"korrektur_$i"}) {
+ ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
+ if ($taxkey > 1) {
+ if ($form->{taxincluded}) {
+ $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
+ } else {
+ $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
+ }
+ } else {
+ $form->{"tax_$i"} = 0;
+ }
+ }
+ $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
+ $totaltax += $form->{"tax_$i"};
map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
$count++;
}
}
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
-
- map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. 1);
+ $form->{rowcount} = $count + 1;
+ map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
$form->{exchangerate} = $exchangerate
if (
@@ -821,43 +865,11 @@ sub update {
&check_project;
-TAXCALC:
-
- # recalculate taxes
-
- @taxaccounts = split / /, $form->{taxaccounts};
-
- $form->{"tax"} = $form->parse_amount(\%myconfig, $form->{"tax"});
-
- if ($form->{taxincluded} && $form->{"rate"}) {
- $taxrate = $form->{"rate"};
- $withholdingrate = 0;
-
- $amount =
- $form->round_amount(
- ($form->{invtotal} - ($form->{invtotal} / ($taxrate + 1))),
- 2);
- $form->{"tax"} = $form->round_amount($amount, 2);
- $taxdiff += ($amount - $form->{"tax"});
-
- if (abs $taxdiff >= 0.005) {
- $form->{"tax"} += $form->round_amount($taxdiff, 2);
- $taxdiff = 0;
- }
- $totaltax += $form->{"tax"};
-
- } else {
- $form->{"tax"} =
- $form->round_amount($form->{invtotal} * $form->{"rate"}, 2);
- $totaltax += $form->{"tax"};
-
- }
-
$form->{invtotal} =
($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"})
@@ -906,7 +918,7 @@ sub post {
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!'));
@@ -958,6 +970,18 @@ sub post_as_new {
$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();
@@ -1030,8 +1054,8 @@ sub search {
} (@{ $form->{all_departments} });
}
- $department = qq|
-
+ $department = qq|
+
| . $locale->text('Department') . qq| |
|
@@ -1048,14 +1072,12 @@ sub search {
$button1 = qq|
text('button')
- . qq|> |
+ . $locale->text('button') . qq|>
|;
$button2 = qq|
text('button')
- . qq|> |
+ . $locale->text('button') . qq|>
|;
#write Trigger
@@ -1274,10 +1296,11 @@ sub ar_transactions {
$option .= $locale->text('Closed');
}
- @columns =
- $form->sort_columns(
- qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee shippingpoint shipvia)
- );
+ @columns = $form->sort_columns(
+ qw(transdate id type invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee shippingpoint shipvia)
+ );
+
+ $form->{"l_type"} = "Y";
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
@@ -1306,6 +1329,8 @@ sub ar_transactions {
""
. $locale->text('Due Date')
. " | ";
+ $column_header{type} =
+ "" . $locale->text('Type') . " | ";
$column_header{invnumber} =
""
. $locale->text('Invoice')
@@ -1432,6 +1457,11 @@ sub ar_transactions {
$column_data{invnumber} =
" | {id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber} | ";
+ $column_data{type} = "" .
+ ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
+ $ar->{amount} < 0 ?
+ $locale->text("Credit note (one letter abbreviation)") :
+ $locale->text("Invoice (one letter abbreviation)")) . " | ";
$column_data{ordnumber} = "$ar->{ordnumber} | ";
$column_data{name} = "$ar->{name} | ";
$ar->{notes} =~ s/\r\n/ /g;
@@ -1506,14 +1536,8 @@ sub ar_transactions {
|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
+ . $locale->text('Sales Invoice') . qq|">
- print qq|
|