-
+ |
+ $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| |
|
@@ -482,13 +501,13 @@ sub form_header {
| . $locale->text('Order Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Quotation Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Project Number') . qq| |
@@ -503,8 +522,6 @@ sub form_header {
$jsscript
-
-{defaultcurrency}>
{fxgain_accno}>
{fxloss_accno}>
@@ -648,7 +665,7 @@ sub form_footer {
$subtotal
$tax
- 0
+
| . $locale->text('Total') . qq| |
$form->{invtotal} |
@@ -687,9 +704,6 @@ sub form_footer {
print $webdav_list;
}
print qq|
-{jscalendar}>
-|;
- print qq|
@@ -719,7 +733,9 @@ sub form_footer {
|;
- my @triggers = ();
+ my @triggers = ();
+ my $totalpaid = 0;
+
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -731,6 +747,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"} =
@@ -754,12 +772,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"}> | |;
@@ -774,7 +792,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}>
@@ -791,6 +824,10 @@ 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");
@@ -812,9 +849,6 @@ sub form_footer {
}
- print qq||;
-
if (!$form->{id} && ($invdate > $closedto)) {
print qq| | .
@@ -822,19 +856,8 @@ sub form_footer {
'-class' => 'submit'));
}
- print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
- qq|
-
-{rowcount}>
-
-
-
-{path}>
-{login}>
-{password}>
-|
- . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
- . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
+ print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers);
+ $form->hide_form(qw(rowcount callback draft_id draft_description login password));
# button for saving history
if($form->{id} ne "") {
@@ -846,7 +869,12 @@ sub form_footer {
. qq|">|;
}
# /button for saving history
-
+ # mark_as_paid button
+ if($form->{id} ne "") {
+ print qq||;
+ }
+ # /mark_as_paid button
print qq|
@@ -856,6 +884,12 @@ print qq|
$lxdebug->leave_sub();
}
+sub mark_as_paid {
+ $lxdebug->enter_sub();
+ &mark_as_paid_common(\%myconfig,"ap");
+ $lxdebug->leave_sub();
+}
+
sub update {
$lxdebug->enter_sub();
@@ -985,16 +1019,30 @@ sub storno {
$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();
}
@@ -1013,6 +1061,8 @@ sub use_as_template {
sub post_payment {
$lxdebug->enter_sub();
+
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
for $i (1 .. $form->{paidaccounts}) {
if ($form->{"paid_$i"}) {
$datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
@@ -1034,17 +1084,19 @@ sub post_payment {
($form->{AP}) = split /--/, $form->{AP};
($form->{AP_paid}) = split /--/, $form->{AP_paid};
if (IR->post_payment(\%myconfig, \%$form)){
-
- if(!exists $form->{addition} && $form->{id} ne "") {
+ 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!'));
+ # /saving the history
}
+
+ $form->redirect($locale->text('Payment posted!'));
}
- $form->error($locale->text('Cannot post payment!'));
+ $form->error($locale->text('Cannot post payment!'));
$lxdebug->leave_sub();
}
@@ -1052,9 +1104,14 @@ sub post_payment {
sub post {
$lxdebug->enter_sub();
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+
$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;
@@ -1092,6 +1149,7 @@ sub post {
($form->{AP}) = split /--/, $form->{AP};
($form->{AP_paid}) = split /--/, $form->{AP_paid};
+ $form->{storno} = 0;
$form->{id} = 0 if $form->{postasnew};
@@ -1100,7 +1158,8 @@ sub post {
if (IR->post_invoice(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{addition} = "POSTED";
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "POSTED";
#$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber};
$form->save_history($form->dbconnect(\%myconfig));
}
@@ -1153,6 +1212,7 @@ sub yes {
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));
}
| |