-
+ |
+ $vendors
+
+
+
+ $contact
+
+ | . $locale->text('Credit Limit') . qq| |
+ $form->{creditlimit}; | . $locale->text('Remaining') . qq| $form->{creditremaining} |
+
- | . $locale->text('Vendor') . qq| |
- $vendor |
-
- |
- . $locale->text('Contact Person') . qq| |
- $contact |
-
- {vendor_id}>
-
-
-
-
- |
-
-
-
- | . $locale->text('Credit Limit') . qq| |
- $form->{creditlimit} |
- |
- | . $locale->text('Remaining') . qq| |
- $form->{creditremaining} |
-
-
- |
-
- | . $locale->text('Record in') . qq| |
- |
-
+ | . $locale->text('Record in') . qq| |
+ |
+
$taxzone
$department
- | . $locale->text('Currency') . qq| |
- |
+ $currencies
$exchangerate
|
-
+ $employees
+
| . $locale->text('Invoice Number') . qq| |
|
@@ -466,13 +497,13 @@ sub form_header {
| . $locale->text('Order Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Quotation Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Project Number') . qq| |
@@ -487,8 +518,6 @@ sub form_header {
$jsscript
-
-{defaultcurrency}>
{fxgain_accno}>
{fxloss_accno}>
@@ -549,7 +578,8 @@ sub form_footer {
$tax .= qq|
- $form->{"${item}_description"} |
+ $form->{"${item}_description"} |
+ . $form->{"${item}_rate"} * 100 .qq|% |
$form->{"${item}_total"} |
|;
@@ -590,7 +620,8 @@ sub form_footer {
$tax .= qq|
- Enthaltene $form->{"${item}_description"} |
+ Enthaltene $form->{"${item}_description"} |
+ . $form->{"${item}_rate"} * 100 .qq|% |
$form->{"${item}_total"} |
@@ -630,7 +661,7 @@ sub form_footer {
$subtotal
$tax
- 0
+
| . $locale->text('Total') . qq| |
$form->{invtotal} |
@@ -669,9 +700,6 @@ sub form_footer {
print $webdav_list;
}
print qq|
-{jscalendar}>
-|;
- print qq|
@@ -701,7 +729,9 @@ sub form_footer {
|;
- my @triggers = ();
+ my @triggers = ();
+ my $totalpaid = 0;
+
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -713,6 +743,8 @@ sub form_footer {
$form->{"selectAP_paid_$i"} =~
s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
+ $totalpaid += $form->{"paid_$i"};
+
# format amounts
if ($form->{"paid_$i"}) {
$form->{"paid_$i"} =
@@ -736,12 +768,12 @@ sub form_footer {
|;
$column_data{"paid_$i"} =
- qq|{"paid_$i"}> | |;
+ qq| | |;
$column_data{"exchangerate_$i"} = qq|$exchangerate | |;
$column_data{"AP_paid_$i"} =
qq| | |;
$column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}>
+ qq| |
| |;
$column_data{"source_$i"} =
qq|{"source_$i"}> | |;
@@ -756,7 +788,22 @@ sub form_footer {
push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
+ my $paid_missing = $form->{oldinvtotal} - $totalpaid;
+
print qq|
+
+ |
+ |
+ | . $locale->text('Total') . qq| |
+ | . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq| |
+
+
+ |
+ |
+ | . $locale->text('Missing amount') . qq| |
+ | . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq| |
+
+
{oldinvtotal}>
{paidaccounts}>
@@ -773,13 +820,19 @@ sub form_footer {
$invdate = $form->datetonum($form->{invdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
+ print qq|
+|;
+
if ($form->{id}) {
+ my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap");
+
print qq|
|;
print qq|
-| unless ($form->{storno});
+| if ($show_storno);
if ($form->{radier}) {
print qq|
text('Update') . qq|">|;
-
if (!$form->{id} && ($invdate > $closedto)) {
print qq| |;
+ . $locale->text('Post') . qq|"> | .
+ NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
+ '-class' => 'submit'));
}
- print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
- qq|
+ print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers);
+ $form->hide_form(qw(rowcount callback draft_id draft_description login password));
-{rowcount}>
-
-
-
-{path}>
-{login}>
-{password}>
+ # button for saving history
+ if($form->{id} ne "") {
+ print qq|
+ |;
+ }
+ # /button for saving history
-
+print qq|
@@ -854,7 +909,7 @@ sub update {
}
$i = $form->{rowcount};
- $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
+ $exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1;
if ( ($form->{"partnumber_$i"} eq "")
&& ($form->{"description_$i"} eq "")
@@ -945,12 +1000,34 @@ sub storno {
$form->error($locale->text('Cannot storno storno invoice!'));
}
+ if (IS->has_storno(\%myconfig, $form, "ap")) {
+ $form->error($locale->text("Invoice has already been storno'd!"));
+ }
+
+ my $employee_id = $form->{employee_id};
+ invoice_links();
+ prepare_invoice();
+ relink_accounts();
+
+ # Payments must not be recorded for the new storno invoice.
+ $form->{paidaccounts} = 0;
+ map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
+
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "CANCELED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+
$form->{storno_id} = $form->{id};
$form->{storno} = 1;
$form->{id} = "";
$form->{invnumber} = "Storno zu " . $form->{invnumber};
-
- &post();
+ $form->{rowcount}++;
+ $form->{employee_id} = $employee_id;
+ post();
$lxdebug->leave_sub();
}
@@ -989,10 +1066,20 @@ sub post_payment {
($form->{AP}) = split /--/, $form->{AP};
($form->{AP_paid}) = split /--/, $form->{AP_paid};
- $form->redirect($locale->text(' Payment posted!'))
- if (IR->post_payment(\%myconfig, \%$form));
- $form->error($locale->text('Cannot post payment!'));
+ if (IR->post_payment(\%myconfig, \%$form)){
+ if (!exists $form->{addition} && $form->{id} ne "") {
+ # saving the history
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "PAYMENT POSTED";
+ $form->{what_done} = $form->{currency} . qq| | . $form->{paid} . qq| | . $locale->text("POSTED");
+ $form->save_history($form->dbconnect(\%myconfig));
+ # /saving the history
+ }
+
+ $form->redirect($locale->text('Payment posted!'));
+ }
+ $form->error($locale->text('Cannot post payment!'));
$lxdebug->leave_sub();
}
@@ -1003,6 +1090,9 @@ sub post {
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
$form->isblank("vendor", $locale->text('Vendor missing!'));
+ $form->{invnumber} =~ s/^\s*//g;
+ $form->{invnumber} =~ s/\s*$//g;
+
# if the vendor changed get new values
if (&check_name(vendor)) {
&update;
@@ -1045,10 +1135,20 @@ sub post {
relink_accounts();
- $form->redirect( $locale->text('Invoice')
+ if (IR->post_invoice(\%myconfig, \%$form)){
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "POSTED";
+ #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber};
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+ remove_draft() if $form->{remove_draft};
+ $form->redirect( $locale->text('Invoice')
. " $form->{invnumber} "
- . $locale->text('posted!'))
- if (IR->post_invoice(\%myconfig, \%$form));
+ . $locale->text('posted!'));
+ }
$form->error($locale->text('Cannot post invoice!'));
$lxdebug->leave_sub();
@@ -1058,7 +1158,6 @@ sub delete {
$lxdebug->enter_sub();
$form->header;
-
print qq|
@@ -1090,9 +1189,16 @@ sub delete {
sub yes {
$lxdebug->enter_sub();
-
- $form->redirect($locale->text('Invoice deleted!'))
- if (IR->delete_invoice(\%myconfig, \%$form));
+ if (IR->delete_invoice(\%myconfig, \%$form)) {
+ # saving the history
+ if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "DELETED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+ $form->redirect($locale->text('Invoice deleted!'));
+ }
$form->error($locale->text('Cannot delete invoice!'));
$lxdebug->leave_sub();
| |