-
-
+
+
+ |
+ | . $locale->text('Transaction description') . qq| |
+ | . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq| |
+ |;
+#
+#
+#
+# |
+#
+print qq|
-
+ |
|
@@ -492,37 +814,21 @@ sub form_header {
|
-
+| .
$jsscript
-
+. qq|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-|;
-
- foreach $item (split / /, $form->{taxaccounts}) {
- print qq|
-
-
-
-|;
+| ;
+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->{$_})); }
+ qw(message email subject cc bcc taxaccounts));
+print qq||;
+
+ foreach $item (split(/ /, $form->{taxaccounts})) {
+ map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
+ ("${item}_rate", "${item}_description", "${item}_taxnumber"));
}
$lxdebug->leave_sub();
}
@@ -540,16 +846,16 @@ sub form_footer {
}
$rows = ($rows > $introws) ? $rows : $introws;
$notes =
- qq||;
+ qq||;
$intnotes =
- qq||;
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
+ qq||;
+
+ $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
$taxincluded = "";
if ($form->{taxaccounts}) {
$taxincluded = qq|
- {taxincluded}> |
+ {taxincluded}> |
. $locale->text('Tax Included') . qq|
|;
}
@@ -567,8 +873,9 @@ sub form_footer {
$tax .= qq|
- $form->{"${item}_description"} |
- $form->{"${item}_total"} |
+ $form->{"${item}_description"} |
+ . $form->{"${item}_rate"} * 100 .qq|% |
+ $form->{"${item}_total"} |
|;
}
@@ -579,8 +886,8 @@ sub form_footer {
$subtotal = qq|
- | . $locale->text('Subtotal') . qq| |
- $form->{invsubtotal} |
+ | . $locale->text('Subtotal') . qq| |
+ $form->{invsubtotal} |
|;
@@ -606,12 +913,13 @@ sub form_footer {
$tax .= qq|
- Enthaltene $form->{"${item}_description"} |
- $form->{"${item}_total"} |
+ Enthaltene $form->{"${item}_description"} |
+ . $form->{"${item}_rate"} * 100 .qq|% |
+ $form->{"${item}_total"} |
- Nettobetrag |
- $form->{"${item}_netto"} |
+ Nettobetrag |
+ $form->{"${item}_netto"} |
|;
}
@@ -626,28 +934,31 @@ sub form_footer {
print qq|
-
-
+
+
- | . $locale->text('Notes') . qq| |
- | . $locale->text('Internal Notes') . qq| |
+ | . $locale->text('Notes') . qq| |
+ | . $locale->text('Internal Notes') . qq| |
+ | . $locale->text('Payment Terms') . qq| |
-
+
$notes |
$intnotes |
+ |
|
-
+ |
$taxincluded
-
+
$subtotal
$tax
- | . $locale->text('Total') . qq| |
- $form->{invtotal} |
+ | . $locale->text('Total') . qq| |
+ $form->{invtotal} |
@@ -659,20 +970,20 @@ sub form_footer {
if ($webdav) {
$webdav_list = qq|
-
|
+
|
- Dokumente im Webdav-Repository |
+ Dokumente im Webdav-Repository |
-
- Dateiname |
- Webdavlink |
+
+ Dateiname |
+ Webdavlink |
|;
foreach $file (keys %{ $form->{WEBDAV} }) {
$webdav_list .= qq|
- $file |
- $form->{WEBDAV}{$file} |
+ $file |
+ $form->{WEBDAV}{$file} |
|;
}
@@ -683,15 +994,27 @@ sub form_footer {
print $webdav_list;
}
+if ($form->{type} eq "credit_note") {
print qq|
-
-
- |
+
+
+ |
+ . $locale->text('Payments') . qq| |
+
+|;
+} else {
+ print qq|
+
+
+
+
+ |
. $locale->text('Incoming Payments') . qq| |
|;
+}
if ($form->{currency} eq $form->{defaultcurrency}) {
@column_index = qw(datepaid source memo paid AR_paid);
@@ -714,6 +1037,8 @@ sub form_footer {
";
+ my @triggers = ();
+
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -726,59 +1051,56 @@ sub form_footer {
# format amounts
$totalpaid += $form->{"paid_$i"};
- $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"});
$exchangerate = qq| |;
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{"forex_$i"}) {
- $exchangerate =
- qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
+ $exchangerate = qq|$form->{"exchangerate_$i"}|;
} else {
- $exchangerate =
- qq|{"exchangerate_$i"}>|;
+ $exchangerate = qq||;
}
}
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
+ $exchangerate .= qq||;
$column_data{"paid_$i"} =
- qq|{"paid_$i"}> | |;
- $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
+ qq| | |;
+ $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
$column_data{"AR_paid_$i"} =
- qq| | |;
+ qq| | |;
$column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}> | |;
+ qq|
+ | |;
$column_data{"source_$i"} =
- qq| | |;
+ qq| | |;
$column_data{"memo_$i"} =
- qq| | |;
+ qq| | |;
map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
print "
\n";
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
- print qq|
-{paidaccounts}>
-
-{oldinvtotal}>
-
+ map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
+ print qq|
|
-
|
+
|
|;
- &print_options;
+ print_options();
print qq|
|
@@ -790,69 +1112,87 @@ sub form_footer {
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
if ($form->{id}) {
+ my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar");
+
print qq|
-
-
-
-
+ |;
+ print qq| | if ($show_storno);
+ print qq|
|;
-
- if (!$form->{revtrans}) {
- if (!$form->{locked}) {
- print qq|
-
-
+ print qq|
|;
- }
- }
+ if ($form->{id} && !($form->{type} eq "credit_note")) {
+ print qq|
+
+|;
+ }
+ if ($form->{radier}) {
+ print qq|
+
+|;
+ }
+
if ($invdate > $closedto) {
print qq|
-
-
|;
}
} else {
if ($invdate > $closedto) {
- print qq|
-
-
-
-
- |;
+ | .
+ NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
+ '-class' => 'submit'));
}
}
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
+ # button for saving history
+ if($form->{id} ne "") {
+ print qq|
+ |;
}
+ # /button for saving history
- print qq|
-
-{rowcount}>
-
-
-{path}>
-{login}>
-{password}>
+ print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
+ qq|
+
+| .
+$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(login password));
+print qq|
@@ -871,9 +1211,19 @@ sub update {
if ($form->{second_run}) {
$form->{print_and_post} = 0;
}
+
+
+ if($form->{taxincluded}) {
+ $taxincluded = "checked";
+ }
+ $form->{update} = 1;
+
&check_name(customer);
- &check_project;
+ if(!$form->{taxincluded}) {
+ $form->{taxincluded} = $taxincluded;
+ }
+
$form->{exchangerate} = $exchangerate
if (
@@ -911,7 +1261,7 @@ sub update {
$form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
&check_form;
- } else {
+ } else {
IS->retrieve_item(\%myconfig, \%$form);
@@ -930,14 +1280,19 @@ sub update {
} else {
- $sellprice = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
+ $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
qw(partnumber description unit);
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
keys %{ $form->{item_list}[0] };
+ if ($form->{"part_payment_id_$i"} ne "") {
+ $form->{payment_id} = $form->{"part_payment_id_$i"};
+ }
- $form->{"discount_$i"} = $form->{discount} * 100;
+ if ($form->{"not_discountable_$i"}) {
+ $form->{"discount_$i"} = 0;
+ }
$s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
($dec) = ($s =~ /\.(\d+)/);
@@ -1021,11 +1376,45 @@ sub update {
$lxdebug->leave_sub();
}
+sub post_payment {
+ $lxdebug->enter_sub();
+ for $i (1 .. $form->{paidaccounts}) {
+ if ($form->{"paid_$i"}) {
+ $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
+
+ $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
+
+ $form->error($locale->text('Cannot post payment for a closed period!'))
+ if ($datepaid <= $closedto);
+
+ if ($form->{currency} ne $form->{defaultcurrency}) {
+ $form->{"exchangerate_$i"} = $form->{exchangerate}
+ if ($invdate == $datepaid);
+ $form->isblank("exchangerate_$i",
+ $locale->text('Exchangerate for payment missing!'));
+ }
+ }
+ }
+
+ ($form->{AR}) = split /--/, $form->{AR};
+ ($form->{AR_paid}) = split /--/, $form->{AR_paid};
+ relink_accounts();
+ $form->redirect($locale->text(' Payment posted!'))
+ if (IS->post_payment(\%myconfig, \%$form));
+ $form->error($locale->text('Cannot post payment!'));
+
+
+ $lxdebug->leave_sub();
+}
+
sub post {
$lxdebug->enter_sub();
$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;
@@ -1047,7 +1436,7 @@ sub post {
if ($form->{currency} ne $form->{defaultcurrency});
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!'));
@@ -1072,20 +1461,30 @@ sub post {
$form->{id} = 0 if $form->{postasnew};
# get new invnumber in sequence if no invnumber is given or if posasnew was requested
- if (!$form->{invnumber} || $form->{postasnew}) {
- $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
- }
- if ($print_post) {
- if (!(IS->post_invoice(\%myconfig, \%$form))) {
- $form->error($locale->text('Cannot post invoice!'));
+ if ($form->{postasnew}) {
+ if ($form->{type} eq "credit_note") {
+ undef($form->{cnnumber});
+ } else {
+ undef($form->{invnumber});
}
- } else {
- $form->redirect(
- $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
- if (IS->post_invoice(\%myconfig, \%$form));
- $form->error($locale->text('Cannot post invoice!'));
}
+ relink_accounts();
+ $form->error($locale->text('Cannot post invoice!'))
+ unless IS->post_invoice(\%myconfig, \%$form);
+ 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;
+
$lxdebug->leave_sub();
}
@@ -1102,6 +1501,51 @@ sub print_and_post {
}
+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);
+ &display_form;
+
+ $lxdebug->leave_sub();
+}
+
+sub storno {
+ $lxdebug->enter_sub();
+
+ if ($form->{storno}) {
+ $form->error($locale->text('Cannot storno storno invoice!'));
+ }
+
+ if (IS->has_storno(\%myconfig, $form, "ar")) {
+ $form->error($locale->text("Invoice has already been storno'd!"));
+ }
+
+ map({ my $key = $_; delete($form->{$key})
+ unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
+ keys(%{ $form }));
+
+ 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();
+ $lxdebug->leave_sub();
+}
+
sub preview {
$lxdebug->enter_sub();
@@ -1125,7 +1569,7 @@ sub delete {
print qq|
-
|;
@@ -1153,12 +1597,94 @@ sub delete {
$lxdebug->leave_sub();
}
-sub yes {
+sub credit_note {
$lxdebug->enter_sub();
- $form->redirect($locale->text('Invoice deleted!'))
- if (IS->delete_invoice(\%myconfig, \%$form, $spool));
+ $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
+ $form->{duedate} =
+ $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
+
+ $form->{id} = '';
+ $form->{rowcount}--;
+ $form->{shipto} = 1;
+
+
+ $form->{title} = $locale->text('Add Credit Note');
+ $form->{script} = 'is.pl';
+ $script = "is";
+ $buysell = 'buy';
+
+
+ # bo creates the id, reset it
+ map { delete $form->{$_} }
+ qw(id invnumber subject message cc bcc printed emailed queued);
+ $form->{ $form->{vc} } =~ s/--.*//g;
+ $form->{type} = "credit_note";
+
+
+ map { $form->{"select$_"} = "" } ($form->{vc}, currency);
+
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
+ qw(creditlimit creditremaining);
+
+ $currency = $form->{currency};
+ &invoice_links;
+
+ $form->{currency} = $currency;
+ $form->{exchangerate} = "";
+ $form->{forex} = "";
+ $form->{exchangerate} = $exchangerate
+ if (
+ $form->{forex} = (
+ $exchangerate =
+ $form->check_exchangerate(
+ \%myconfig, $form->{currency}, $form->{invdate}, $buysell
+ )));
+
+ $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
+
+ &prepare_invoice;
+
+
+ &display_form;
+
+ $lxdebug->leave_sub();
+}
+
+sub yes {
+ $lxdebug->enter_sub();
+ 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!'));
+ }
$form->error($locale->text('Cannot delete invoice!'));
$lxdebug->leave_sub();
}
+
+sub e_mail {
+ $lxdebug->enter_sub();
+
+ if (!$form->{id}) {
+ $print_post = 1;
+
+ my $saved_form = save_form();
+
+ 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();
+
+ $lxdebug->leave_sub();
+}
| | | | |