#
#
@@ -705,14 +718,9 @@ print qq|
#
print qq|
|
-
+ |
-
- | . $locale->text('Employee') . qq| |
- |
-
- |
-
+ $employees
$salesman
|;
if ($form->{type} eq "credit_note") {
@@ -748,8 +756,8 @@ print qq|
| . $locale->text('Order Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Quotation Number') . qq| |
@@ -757,8 +765,8 @@ print qq|
| . $locale->text('Quotation Date') . qq| |
- |
- |
+
+ |
| . $locale->text('Customer Order Number') . qq| |
@@ -778,20 +786,20 @@ print qq|
|
-| .
+| .
$jsscript
. qq|
| ;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
+map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
print qq| |;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
+map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
qw(message email subject cc bcc taxaccounts));
print qq||;
foreach $item (split(/ /, $form->{taxaccounts})) {
- map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
+ map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
("${item}_rate", "${item}_description", "${item}_taxnumber"));
}
$lxdebug->leave_sub();
@@ -814,12 +822,12 @@ sub form_footer {
$intnotes =
qq||;
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
+ $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
$taxincluded = "";
if ($form->{taxaccounts}) {
$taxincluded = qq|
- {taxincluded}> |
+ {taxincluded}> |
. $locale->text('Tax Included') . qq|
|;
}
@@ -915,9 +923,23 @@ sub form_footer {
|
-
+ |
+
+
+ | . $locale->text('Ertrag') . qq| |
+ | . $form->format_amount(\%myconfig, $form->{marge_total}, 2, 0) . qq| |
+
+
+ | . $locale->text('Ertrag prozentual') . qq| |
+ | . $form->format_amount(\%myconfig, $form->{marge_percent}, 2, 0) . qq| % |
+
+
+
+
+ |
+
$taxincluded
-
+
$subtotal
$tax
@@ -943,11 +965,11 @@ sub form_footer {
Dateiname |
Webdavlink |
|;
- foreach $file (keys %{ $form->{WEBDAV} }) {
+ foreach $file (@{ $form->{WEBDAV} }) {
$webdav_list .= qq|
- $file |
- $form->{WEBDAV}{$file} |
+ $file->{name} |
+ $file->{type} |
|;
}
@@ -1001,7 +1023,8 @@ if ($form->{type} eq "credit_note") {
";
- my @triggers = ();
+ my @triggers = ();
+ my $totalpaid = 0;
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -1022,6 +1045,9 @@ if ($form->{type} eq "credit_note") {
$form->{"exchangerate_$i"} =
$form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ if ($form->{"exchangerate_$i"} == 0) {
+ $form->{"exchangerate_$i"} = "";
+ }
$exchangerate = qq| |;
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{"forex_$i"}) {
@@ -1034,12 +1060,12 @@ if ($form->{type} eq "credit_note") {
$exchangerate .= qq||;
$column_data{"paid_$i"} =
- qq| | |;
+ qq| | |;
$column_data{"exchangerate_$i"} = qq|$exchangerate | |;
$column_data{"AR_paid_$i"} =
qq| | |;
$column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}>
+ qq| |
| |;
$column_data{"source_$i"} =
qq| | |;
@@ -1052,7 +1078,24 @@ if ($form->{type} eq "credit_note") {
push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
- map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
+ 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| |
+
+|;
+
+ map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
print qq|
@@ -1064,7 +1107,7 @@ if ($form->{type} eq "credit_note") {
|;
- &print_options;
+ print_options();
print qq|
|
@@ -1142,20 +1185,25 @@ if ($form->{type} eq "credit_note") {
. Q($form->{id})
. qq|);" name="history" id="history" value="|
. $locale->text('history')
- . qq|">|;
+ . qq|"> |;
}
# /button for saving history
-
-
+
+ # mark_as_paid button
+ if($form->{id} ne "") {
+ print qq||;
+ }
+ # /mark_as_paid button
print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
qq|
| .
-$cgi->hidden("-name" => "callback", "-value" => $form->{callback})
+$cgi->hidden("-name" => "callback", "-value" => $form->{callback})
. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
-map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(path login password));
+map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
print qq|
@@ -1167,6 +1215,12 @@ print qq|
$lxdebug->leave_sub();
}
+sub mark_as_paid {
+ $lxdebug->enter_sub();
+ &mark_as_paid_common(\%myconfig,"ar");
+ $lxdebug->leave_sub();
+}
+
sub update {
$lxdebug->enter_sub();
@@ -1176,10 +1230,19 @@ sub update {
$form->{print_and_post} = 0;
}
+
+ if($form->{taxincluded}) {
+ $taxincluded = "checked";
+ }
$form->{update} = 1;
&check_name(customer);
+ if(!$form->{taxincluded}) {
+ $form->{taxincluded} = $taxincluded;
+ }
+
+
$form->{exchangerate} = $exchangerate
if (
$form->{forex} = (
@@ -1333,6 +1396,8 @@ sub update {
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);
@@ -1354,7 +1419,7 @@ sub post_payment {
($form->{AR}) = split /--/, $form->{AR};
($form->{AR_paid}) = split /--/, $form->{AR_paid};
relink_accounts();
- $form->redirect($locale->text(' Payment posted!'))
+ $form->redirect($locale->text('Payment posted!'))
if (IS->post_payment(\%myconfig, \%$form));
$form->error($locale->text('Cannot post payment!'));
@@ -1364,9 +1429,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("customer", $locale->text('Customer missing!'));
+ $form->{invnumber} =~ s/^\s*//g;
+ $form->{invnumber} =~ s/\s*$//g;
+
# if oldcustomer ne customer redo form
if (&check_name(customer)) {
&update;
@@ -1405,8 +1475,9 @@ sub post {
}
}
- ($form->{AR}) = split /--/, $form->{AR};
- ($form->{AR_paid}) = split /--/, $form->{AR_paid};
+ ($form->{AR}) = split /--/, $form->{AR};
+ ($form->{AR_paid}) = split /--/, $form->{AR_paid};
+ $form->{storno} ||= 0;
$form->{label} = $locale->text('Invoice');
@@ -1427,12 +1498,13 @@ sub post {
remove_draft() if $form->{remove_draft};
if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = $print_post ? "PRINTED AND POSTED" :
$form->{storno} ? "STORNO" :
"POSTED";
$form->save_history($form->dbconnect(\%myconfig));
}
-
+
$form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
unless $print_post;
@@ -1476,21 +1548,25 @@ sub storno {
}
map({ my $key = $_; delete($form->{$key})
- unless (grep({ $key eq $_ } qw(path login password id type))); }
+ unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
keys(%{ $form }));
- &invoice_links;
- &prepare_invoice;
+ 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 };
+
$form->{storno_id} = $form->{id};
$form->{storno} = 1;
$form->{id} = "";
$form->{invnumber} = "Storno zu " . $form->{invnumber};
+ $form->{rowcount}++;
- &post();
+ post();
$lxdebug->leave_sub();
-
}
sub preview {
@@ -1499,7 +1575,6 @@ sub preview {
$form->{preview} = 1;
$old_form = new Form;
for (keys %$form) { $old_form->{$_} = $form->{$_} }
- $old_form->{rowcount}++;
&print_form($old_form);
$lxdebug->leave_sub();
@@ -1560,7 +1635,7 @@ sub credit_note {
$form->{script} = 'is.pl';
$script = "is";
$buysell = 'buy';
-
+
# bo creates the id, reset it
map { delete $form->{$_} }
@@ -1603,11 +1678,12 @@ sub yes {
if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
# 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!'));
+ # /saving the history
+ $form->redirect($locale->text('Invoice deleted!'));
}
$form->error($locale->text('Cannot delete invoice!'));
@@ -1617,11 +1693,20 @@ sub yes {
sub e_mail {
$lxdebug->enter_sub();
- $print_post = 1;
+ if (!$form->{id}) {
+ $print_post = 1;
+
+ my $saved_form = save_form();
- &post;
+ post();
+
+ my %saved_vars;
+ map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
+ restore_form($saved_form);
+ map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
+ }
- &edit_e_mail;
+ edit_e_mail();
$lxdebug->leave_sub();
}
|