1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
30 # Inventory invoicing module
32 #======================================================================
38 require "bin/mozilla/io.pl";
39 require "bin/mozilla/arap.pl";
40 require "bin/mozilla/drafts.pl";
47 $lxdebug->enter_sub();
49 return $lxdebug->leave_sub() if (load_draft_maybe());
51 if ($form->{type} eq "credit_note") {
52 $form->{title} = $locale->text('Add Credit Note');
54 if ($form->{storno}) {
55 $form->{title} = $locale->text('Add Storno Credit Note');
58 $form->{title} = $locale->text('Add Sales Invoice');
64 "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&password=$form->{password}"
65 unless $form->{callback};
67 $form{jsscript} = "date";
69 if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
71 $form->error("Access Denied");
77 $lxdebug->leave_sub();
81 $lxdebug->enter_sub();
84 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
85 #/show hhistory button
87 if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
89 $form->error("Access Denied");
92 if ($form->{print_and_post}) {
93 $form->{action} = "print";
94 $form->{resubmit} = 1;
95 $language_id = $form->{language_id};
96 $printer_id = $form->{printer_id};
100 if ($form->{print_and_post}) {
101 $form->{language_id} = $language_id;
102 $form->{printer_id} = $printer_id;
107 $lxdebug->leave_sub();
111 $lxdebug->enter_sub();
113 $form->{vc} = 'customer';
116 $form->{webdav} = $webdav;
117 $form->{lizenzen} = $lizenzen;
119 $form->create_links("AR", \%myconfig, "customer");
121 if ($form->{all_customer}) {
122 unless ($form->{customer_id}) {
123 $form->{customer_id} = $form->{all_customer}->[0]->{id};
124 $form->{salesman_id} = $form->{all_customer}->[0]->{salesman_id};
128 if ($form->{payment_id}) {
129 $payment_id = $form->{payment_id};
131 if ($form->{language_id}) {
132 $language_id = $form->{language_id};
134 if ($form->{taxzone_id}) {
135 $taxzone_id = $form->{taxzone_id};
140 if ($form->{shipto_id}) {
141 $shipto_id = $form->{shipto_id};
144 $cp_id = $form->{cp_id};
145 IS->get_customer(\%myconfig, \%$form);
147 #quote all_customer Bug 133
148 foreach $ref (@{ $form->{all_customer} }) {
149 $ref->{name} = $form->quote($ref->{name});
154 IS->retrieve_invoice(\%myconfig, \%$form);
155 $form->{cp_id} = $cp_id;
158 $form->{payment_id} = $payment_id;
161 $form->{language_id} = $language_id;
164 $form->{taxzone_id} = $taxzone_id;
167 $form->{shipto_id} = $shipto_id;
170 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
173 if ($form->{all_departments}) {
174 $form->{selectdepartment} = "<option>\n";
175 $form->{department} = "$form->{department}--$form->{department_id}";
178 $form->{selectdepartment} .=
179 "<option>$_->{description}--$_->{id}</option>\n"
180 } (@{ $form->{all_departments} });
183 $form->{employee} = "$form->{employee}--$form->{employee_id}";
186 $form->{forex} = $form->{exchangerate};
187 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
189 foreach $key (keys %{ $form->{AR_links} }) {
190 foreach $ref (@{ $form->{AR_links}{$key} }) {
191 $form->{"select$key"} .=
192 "<option>$ref->{accno}--$ref->{description}</option>\n";
195 if ($key eq "AR_paid") {
196 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
197 $form->{"AR_paid_$i"} =
198 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
201 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
202 $form->{"datepaid_$i"} =
203 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
204 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
205 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
206 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
207 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
209 $form->{paidaccounts} = $i;
213 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
218 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
220 $form->{AR} = $form->{AR_1} unless $form->{id};
223 ($form->datetonum($form->{invdate}, \%myconfig) <=
224 $form->datetonum($form->{closedto}, \%myconfig));
226 $lxdebug->leave_sub();
229 sub prepare_invoice {
230 $lxdebug->enter_sub();
232 if ($form->{type} eq "credit_note") {
233 $form->{type} = "credit_note";
234 $form->{formname} = "credit_note";
236 $form->{type} = "invoice";
237 $form->{formname} = "invoice";
242 map { $form->{$_} =~ s/\"/"/g }
243 qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
245 # # get pricegroups for parts
246 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
250 foreach $ref (@{ $form->{invoice_details} }) {
253 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
254 $form->{"discount_$i"} =
255 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
256 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
258 $decimalplaces = ($dec > 2) ? $dec : 2;
260 $form->{"sellprice_$i"} =
261 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
264 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
265 $dec_qty = length $dec_qty;
268 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
270 map { $form->{"${_}_$i"} =~ s/\"/"/g }
271 qw(partnumber description unit partnotes);
272 $form->{rowcount} = $i;
276 $lxdebug->leave_sub();
280 $lxdebug->enter_sub();
284 if ($form->{type} eq "credit_note") {
285 $form->{title} = $locale->text('Edit Credit Note');
287 if ($form->{storno}) {
288 $form->{title} = $locale->text('Edit Storno Credit Note');
291 $form->{title} = $locale->text('Edit Sales Invoice');
293 if ($form->{storno}) {
294 $form->{title} = $locale->text('Edit Storno Invoice');
300 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
302 $payment = qq|<option value=""></option>|;
303 foreach $item (@{ $form->{payment_terms} }) {
304 if ($form->{payment_id} eq $item->{id}) {
305 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
307 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
311 my $set_duedate_url =
312 "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
314 my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
315 push(@ { $form->{AJAX} }, $pjx);
317 my @old_project_ids = ($form->{"globalproject_id"});
318 map({ push(@old_project_ids, $form->{"project_id_$_"})
319 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
321 $form->get_lists("contacts" => "ALL_CONTACTS",
322 "shipto" => "ALL_SHIPTO",
323 "projects" => { "key" => "ALL_PROJECTS",
325 "old_id" => \@old_project_ids },
326 "employees" => "ALL_SALESMEN",
327 "taxzones" => "ALL_TAXZONES",
328 "currencies" => "ALL_CURRENCIES",
329 "customers" => "ALL_CUSTOMERS");
332 my @values = (undef);
333 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
334 push(@values, $item->{"cp_id"});
335 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
336 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
339 if (scalar @values > 1) {
342 <th align="right">| . $locale->text('Contact Person') . qq|</th>
344 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
345 '-labels' => \%labels, '-default' => $form->{"cp_id"}))
353 foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
354 push(@values, $item->{"id"});
355 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
360 <th align="right">| . $locale->text('Employee') . qq|</th>
362 NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
363 '-values' => \@values, '-labels' => \%labels)) . qq|
370 foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
371 push(@values, $item->{name}.qq|--|.$item->{"id"});
372 $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
375 $form->{selectcustomer} = ($myconfig{vclimit} > scalar(@values));
378 <th align="right">| . $locale->text('Customer') . qq|</th>
380 (($myconfig{vclimit} <= scalar(@values))
381 ? qq|<input type="text" value="| . H($form->{customer}) . qq|" name="customer">|
382 : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
383 '-onChange' => 'document.getElementById(\'update_button\').click();',
384 '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
385 <input type="button" value="?" onclick="show_vc_details('customer')">
390 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
391 push(@values, $item->{"shipto_id"});
392 $labels{$item->{"shipto_id"}} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city);
396 if (scalar @values > 1) {
399 <th align="right">| . $locale->text('Shipping Address') . qq|</th>
401 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
402 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
408 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
409 push(@values, $item);
410 $labels{$item} = $item;
413 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
415 if (scalar @values) {
418 <th align="right">| . $locale->text('Currency') . qq|</th>
420 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
421 '-values' => \@values, '-labels' => \%labels)) . qq|
428 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
429 push(@values, $item->{"id"});
430 $labels{$item->{"id"}} = $item->{"projectnumber"};
432 my $globalprojectnumber =
433 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
434 '-labels' => \%labels,
435 '-default' => $form->{"globalproject_id"}));
439 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
440 push(@values, $item->{id});
441 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
446 <th align="right">| . $locale->text('Salesman') . qq|</th>
448 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id},
449 '-values' => \@values, '-labels' => \%labels))
455 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
456 push(@values, $item->{"id"});
457 $labels{$item->{"id"}} = $item->{"description"};
460 if (!$form->{"id"}) {
463 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
465 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
466 '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
473 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
475 <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
476 | . H($labels{$form->{"taxzone_id"}}) . qq|
481 # set option selected
482 foreach $item (qw(AR customer currency department employee)) {
483 $form->{"select$item"} =~ s/ selected//;
484 $form->{"select$item"} =~
485 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
488 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
494 $form->{exchangerate} =
495 $form->format_amount(\%myconfig, $form->{exchangerate});
497 $form->{creditlimit} =
498 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
499 $form->{creditremaining} =
500 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
503 if ($form->{currency} ne $form->{defaultcurrency}) {
504 if ($form->{forex}) {
506 qq|<th align="right">|
507 . $locale->text('Exchangerate')
508 . qq|</th><td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
511 qq|<th align="right">|
512 . $locale->text('Exchangerate')
513 . qq|</th><td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
517 <input type="hidden" name="forex" value="$form->{forex}">
522 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
523 <td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
524 <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
527 | if $form->{selectdepartment};
529 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
531 if ($form->{business}) {
534 <th align="right">| . $locale->text('Customer type') . qq|</th>
535 <td>$form->{business}; | . $locale->text('Trade Discount') . qq| |
536 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
542 if ($form->{max_dunning_level}) {
545 <th align="right">| . $locale->text('Max. Dunning Level') . qq|:</th>
547 <b>$form->{max_dunning_level}</b>;
548 | . $locale->text('Dunning Amount') . qq|: <b>|
549 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
556 $form->{fokus} = "invoice.customer";
558 # use JavaScript Calendar or not
559 $form->{jsscript} = 1;
561 if ($form->{type} eq "credit_note") {
563 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
564 <input type="button" name="invdate" id="trigger1" value="|
565 . $locale->text('button') . qq|"></td>|;
569 Form->write_trigger(\%myconfig, "1",
574 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
575 <input type="button" name="invdate" id="trigger1" value="|
576 . $locale->text('button') . qq|"></td>
579 <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\">
580 <input type="button" name="duedate" id="trigger2" value="|
581 . $locale->text('button') . qq|"></td></td>
584 <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\">
585 <input type="button" name="deliverydate" id="trigger3" value="|
586 . $locale->text('button') . qq|"></td></td>
591 Form->write_trigger(\%myconfig, "3",
593 "trigger1", "duedate",
595 "deliverydate", "BL",
599 if ($form->{resubmit} && ($form->{format} eq "html")) {
601 qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
602 } elsif ($form->{resubmit}) {
603 $onload = qq|document.invoice.submit()|;
607 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
608 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
609 $credittext = $locale->text('Credit Limit exceeded!!!');
610 if ($creditwarning) {
611 $onload = qq|alert('$credittext')|;
614 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
615 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
618 $form->write_trigger(\%myconfig, 2,
619 "orddate", "BL", "trigger_orddate",
620 "quodate", "BL", "trigger_quodate");
621 # show history button js
622 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
623 #/show history button js
627 <body onLoad="$onload">
628 <script type="text/javascript" src="js/common.js"></script>
629 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
630 <script type="text/javascript" src="js/vendor_selection.js"></script>
631 <script type="text/javascript" src="js/calculate_qty.js"></script>
633 <form method="post" name="invoice" action="$form->{script}">
636 $form->hide_form(qw(id action type media format queued printed emailed title vc discount
637 creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
638 max_dunning_level dunning_amount));
639 print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
643 <input type="hidden" name="lizenzen" value="$lizenzen">
645 <div class="listtop" width="100%">$form->{title}</div>
653 <input type="hidden" name="customer_klass" value="$form->{customer_klass}">
654 <input type="hidden" name="customer_id" value="$form->{customer_id}">
655 <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
656 <input type="hidden" name="selectcustomer" value="$form->{selectcustomer}">
661 <td align="right">| . $locale->text('Credit Limit') . qq|</td>
662 <td>$form->{creditlimit}; | . $locale->text('Remaining') . qq| <span class="plus$n">$form->{creditremaining}</span></td>
667 <th align="right" nowrap>| . $locale->text('Record in') . qq|</th>
668 <td colspan="3"><select name="AR" style="width:250px;">$form->{selectAR}</select></td>
669 <input type="hidden" name="selectAR" value="$form->{selectAR}">
675 <input type="hidden" name="fxgain_accno" value="$form->{fxgain_accno}">
676 <input type="hidden" name="fxloss_accno" value="$form->{fxloss_accno}">
680 <th align="right" nowrap>| . $locale->text('Shipping Point') . qq|</th>
682 $cgi->textfield("-name" => "shippingpoint", "-size" => 35, "-value" => $form->{shippingpoint}) .
685 <th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
686 <td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
689 <th align="right">| . $locale->text('Transaction description') . qq|</th>
690 <td colspan="3">| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|</td>
697 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
699 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
700 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
704 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
706 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
707 # <input size=45 id=delivery_vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
714 <td align="right" valign="top">
719 if ($form->{type} eq "credit_note") {
721 <th align="right" nowrap>| . $locale->text('Credit Note Number') . qq|</th>
722 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
725 <th align="right">| . $locale->text('Credit Note Date') . qq|</th>
730 <th align="right" nowrap>| . $locale->text('Invoice Number') . qq|</th>
731 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
734 <th align="right">| . $locale->text('Invoice Date') . qq|</th>
738 <th align="right">| . $locale->text('Due Date') . qq|</th>
742 <th align="right">| . $locale->text('Delivery Date') . qq|</th>
747 <th align="right" nowrap>| . $locale->text('Order Number') . qq|</th>
748 <td><input name="ordnumber" size="11" value="$form->{ordnumber}"></td>
751 <th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
752 <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\">
753 <input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
756 <th align="right" nowrap>| . $locale->text('Quotation Number') . qq|</th>
757 <td><input name="quonumber" size="11" value="$form->{quonumber}"></td>
760 <th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
761 <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\">
762 <input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
765 <th align="right" nowrap>| . $locale->text('Customer Order Number') . qq|</th>
766 <td><input name="cusordnumber" size="11" value="$form->{cusordnumber}"></td>
769 <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
770 <td>$globalprojectnumber</td>
785 <!-- shipto are in hidden variables -->
787 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
788 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
789 print qq|<!-- email variables --> |;
790 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
791 qw(message email subject cc bcc taxaccounts));
792 print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|;
794 foreach $item (split(/ /, $form->{taxaccounts})) {
795 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
796 ("${item}_rate", "${item}_description", "${item}_taxnumber"));
798 $lxdebug->leave_sub();
802 $lxdebug->enter_sub();
804 $form->{invtotal} = $form->{invsubtotal};
806 if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
809 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
812 $rows = ($rows > $introws) ? $rows : $introws;
814 qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
816 qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
818 $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
821 if ($form->{taxaccounts}) {
823 <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
824 . $locale->text('Tax Included') . qq|</b><br><br>|;
827 if (!$form->{taxincluded}) {
829 foreach $item (split / /, $form->{taxaccounts}) {
830 if ($form->{"${item}_base"}) {
831 $form->{"${item}_total"} =
833 $form->{"${item}_base"} * $form->{"${item}_rate"},
835 $form->{invtotal} += $form->{"${item}_total"};
836 $form->{"${item}_total"} =
837 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
841 <th align="right">$form->{"${item}_description"} |
842 . $form->{"${item}_rate"} * 100 .qq|%</th>
843 <td align="right">$form->{"${item}_total"}</td>
849 $form->{invsubtotal} =
850 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
854 <th align="right">| . $locale->text('Subtotal') . qq|</th>
855 <td align="right">$form->{invsubtotal}</td>
861 if ($form->{taxincluded}) {
862 foreach $item (split / /, $form->{taxaccounts}) {
863 if ($form->{"${item}_base"}) {
864 $form->{"${item}_total"} =
866 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
867 (1 + $form->{"${item}_rate"})
870 $form->{"${item}_netto"} =
872 ($form->{"${item}_base"} - $form->{"${item}_total"}),
874 $form->{"${item}_total"} =
875 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
876 $form->{"${item}_netto"} =
877 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
881 <th align="right">Enthaltene $form->{"${item}_description"} |
882 . $form->{"${item}_rate"} * 100 .qq|%</th>
883 <td align="right">$form->{"${item}_total"}</td>
886 <th align="right">Nettobetrag</th>
887 <td align="right">$form->{"${item}_netto"}</td>
895 $form->{oldinvtotal} = $form->{invtotal};
897 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
907 <th align="left">| . $locale->text('Notes') . qq|</th>
908 <th align="left">| . $locale->text('Internal Notes') . qq|</th>
909 <th align="right">| . $locale->text('Payment Terms') . qq|</th>
914 <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value],['duedate'])">$payment
919 <td align="right" width="100%">
925 <th align="right">| . $locale->text('Total') . qq|</th>
926 <td align="right">$form->{invtotal}</td>
938 <td><hr size="3" noshade></td>
941 <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
944 <td align="left" width="30%"><b>Dateiname</b></td>
945 <td align="left" width="70%"><b>Webdavlink</b></td>
947 foreach $file (keys %{ $form->{WEBDAV} }) {
950 <td align="left">$file</td>
951 <td align="left"><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
962 if ($form->{type} eq "credit_note") {
967 <tr class="listheading">
968 <th colspan="6" class="listheading">|
969 . $locale->text('Payments') . qq|</th>
977 <tr class="listheading">
978 <th colspan="6" class="listheading">|
979 . $locale->text('Incoming Payments') . qq|</th>
984 if ($form->{currency} eq $form->{defaultcurrency}) {
985 @column_index = qw(datepaid source memo paid AR_paid);
987 @column_index = qw(datepaid source memo paid exchangerate AR_paid);
990 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
991 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
992 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
993 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
994 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
995 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
1000 map { print "$column_data{$_}\n" } @column_index;
1008 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
1009 for $i (1 .. $form->{paidaccounts}) {
1014 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
1015 $form->{"selectAR_paid_$i"} =~
1016 s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
1019 $totalpaid += $form->{"paid_$i"};
1020 if ($form->{"paid_$i"}) {
1021 $form->{"paid_$i"} =
1022 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
1024 $form->{"exchangerate_$i"} =
1025 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
1027 $exchangerate = qq| |;
1028 if ($form->{currency} ne $form->{defaultcurrency}) {
1029 if ($form->{"forex_$i"}) {
1030 $exchangerate = qq|<input type="hidden" name="exchangerate_$i" value="$form->{"exchangerate_$i"}">$form->{"exchangerate_$i"}|;
1032 $exchangerate = qq|<input name="exchangerate_$i" size="10" value="$form->{"exchangerate_$i"}">|;
1036 $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
1038 $column_data{"paid_$i"} =
1039 qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
1040 $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
1041 $column_data{"AR_paid_$i"} =
1042 qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
1043 $column_data{"datepaid_$i"} =
1044 qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i" size="11" title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
1045 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
1046 $column_data{"source_$i"} =
1047 qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
1048 $column_data{"memo_$i"} =
1049 qq|<td align="center"><input name="memo_$i" size="11" value="$form->{"memo_$i"}"></td>|;
1051 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
1054 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
1057 my $paid_missing = $form->{oldinvtotal} - $totalpaid;
1063 <td align="center">| . $locale->text('Total') . qq|</td>
1064 <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
1069 <td align="center">| . $locale->text('Missing amount') . qq|</td>
1070 <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
1074 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
1075 print qq|<input type="hidden" name="oldtotalpaid" value="$totalpaid">
1080 <td><hr size="3" noshade></td>
1094 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1095 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1098 my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar");
1101 <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="|
1102 . $locale->text('Update') . qq|">
1103 <input class="submit" type="submit" name="action" value="|
1104 . $locale->text('Ship to') . qq|">
1105 <input class="submit" type="submit" name="action" value="|
1106 . $locale->text('Print') . qq|">
1107 <input class="submit" type="submit" name="action" value="|
1108 . $locale->text('E-mail') . qq|"> |;
1109 print qq|<input class="submit" type="submit" name="action" value="|
1110 . $locale->text('Storno') . qq|"> | if ($show_storno);
1111 print qq|<input class="submit" type="submit" name="action" value="|
1112 . $locale->text('Post Payment') . qq|">
1114 print qq|<input class="submit" type="submit" name="action" value="|
1115 . $locale->text('Use As Template') . qq|">
1117 if ($form->{id} && !($form->{type} eq "credit_note")) {
1119 <input class="submit" type="submit" name="action" value="|
1120 . $locale->text('Credit Note') . qq|">
1123 if ($form->{radier}) {
1125 <input class="submit" type="submit" name="action" value="|
1126 . $locale->text('Delete') . qq|">
1131 if ($invdate > $closedto) {
1133 <input class="submit" type="submit" name="action" value="|
1134 . $locale->text('Order') . qq|">
1139 if ($invdate > $closedto) {
1140 print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
1141 . $locale->text('Update') . qq|">
1142 <input class="submit" type="submit" name="action" value="|
1143 . $locale->text('Ship to') . qq|">
1144 <input class="submit" type="submit" name="action" value="|
1145 . $locale->text('Preview') . qq|">
1146 <input class="submit" type="submit" name="action" value="|
1147 . $locale->text('E-mail') . qq|">
1148 <input class="submit" type="submit" name="action" value="|
1149 . $locale->text('Print and Post') . qq|">
1150 <input class="submit" type="submit" name="action" value="|
1151 . $locale->text('Post') . qq|"> | .
1152 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
1153 '-class' => 'submit'));
1157 # button for saving history
1158 if($form->{id} ne "") {
1160 <input type="button" class="submit" onclick="set_history_window(|
1162 . qq|);" name="history" id="history" value="|
1163 . $locale->text('history')
1166 # /button for saving history
1169 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
1172 <input type="hidden" name="rowcount" value="$form->{rowcount}">
1174 $cgi->hidden("-name" => "callback", "-value" => $form->{callback})
1175 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
1176 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
1177 map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
1186 $lxdebug->leave_sub();
1190 $lxdebug->enter_sub();
1192 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1193 qw(exchangerate creditlimit creditremaining);
1194 if ($form->{second_run}) {
1195 $form->{print_and_post} = 0;
1199 if($form->{taxincluded}) {
1200 $taxincluded = "checked";
1202 $form->{update} = 1;
1204 &check_name(customer);
1206 if(!$form->{taxincluded}) {
1207 $form->{taxincluded} = $taxincluded;
1211 $form->{exchangerate} = $exchangerate
1215 $form->check_exchangerate(
1216 \%myconfig, $form->{currency}, $form->{invdate}, 'buy'
1219 for $i (1 .. $form->{paidaccounts}) {
1220 if ($form->{"paid_$i"}) {
1222 $form->{"${_}_$i"} =
1223 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1224 } qw(paid exchangerate);
1226 $form->{"exchangerate_$i"} = $exchangerate
1228 $form->{"forex_$i"} = (
1230 $form->check_exchangerate(
1231 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
1236 $i = $form->{rowcount};
1237 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1239 # if last row empty, check the form otherwise retrieve new item
1240 if ( ($form->{"partnumber_$i"} eq "")
1241 && ($form->{"description_$i"} eq "")
1242 && ($form->{"partsgroup_$i"} eq "")) {
1244 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1249 IS->retrieve_item(\%myconfig, \%$form);
1251 $rows = scalar @{ $form->{item_list} };
1253 $form->{"discount_$i"} =
1254 $form->format_amount(\%myconfig, $form->{discount} * 100);
1257 $form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1;
1266 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1268 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1269 qw(partnumber description unit);
1270 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1271 keys %{ $form->{item_list}[0] };
1272 if ($form->{"part_payment_id_$i"} ne "") {
1273 $form->{payment_id} = $form->{"part_payment_id_$i"};
1276 if ($form->{"not_discountable_$i"}) {
1277 $form->{"discount_$i"} = 0;
1280 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1281 ($dec) = ($s =~ /\.(\d+)/);
1283 $decimalplaces = ($dec > 2) ? $dec : 2;
1286 $form->{"sellprice_$i"} = $sellprice;
1289 # if there is an exchange rate adjust sellprice
1290 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1291 $form->{"sellprice_$i"} /= $exchangerate;
1294 $form->{"listprice_$i"} /= $exchangerate;
1297 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1298 (1 - $form->{"discount_$i"} / 100);
1299 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1300 map { $form->{"${_}_base"} += $amount }
1301 (split / /, $form->{"taxaccounts_$i"});
1302 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1303 split / /, $form->{"taxaccounts_$i"}
1304 if !$form->{taxincluded};
1306 $form->{creditremaining} -= $amount;
1309 $form->{"${_}_$i"} =
1310 $form->format_amount(\%myconfig, $form->{"${_}_$i"},
1312 } qw(sellprice listprice);
1315 $form->format_amount(\%myconfig, $form->{"qty_$i"});
1318 if ($form->{"inventory_accno_$i"} ne "") {
1319 $form->{"lizenzen_$i"} = qq|<option></option>|;
1320 foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
1321 $form->{"lizenzen_$i"} .=
1322 qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|;
1324 $form->{"lizenzen_$i"} .=
1325 qq|<option value=-1>Neue Lizenz</option>|;
1329 # get pricegroups for parts
1330 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1332 # build up html code for prices_$i
1333 &set_pricegroup($i);
1340 # ok, so this is a new part
1341 # ask if it is a part or service item
1343 if ( $form->{"partsgroup_$i"}
1344 && ($form->{"partsnumber_$i"} eq "")
1345 && ($form->{"description_$i"} eq "")) {
1346 $form->{rowcount}--;
1347 $form->{"discount_$i"} = "";
1351 $form->{"id_$i"} = 0;
1352 $form->{"unit_$i"} = $locale->text('ea');
1359 $lxdebug->leave_sub();
1363 $lxdebug->enter_sub();
1364 for $i (1 .. $form->{paidaccounts}) {
1365 if ($form->{"paid_$i"}) {
1366 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1368 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1370 $form->error($locale->text('Cannot post payment for a closed period!'))
1371 if ($datepaid <= $closedto);
1373 if ($form->{currency} ne $form->{defaultcurrency}) {
1374 $form->{"exchangerate_$i"} = $form->{exchangerate}
1375 if ($invdate == $datepaid);
1376 $form->isblank("exchangerate_$i",
1377 $locale->text('Exchangerate for payment missing!'));
1382 ($form->{AR}) = split /--/, $form->{AR};
1383 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1385 $form->redirect($locale->text('Payment posted!'))
1386 if (IS->post_payment(\%myconfig, \%$form));
1387 $form->error($locale->text('Cannot post payment!'));
1390 $lxdebug->leave_sub();
1394 $lxdebug->enter_sub();
1395 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
1396 $form->isblank("customer", $locale->text('Customer missing!'));
1398 $form->{invnumber} =~ s/^\s*//g;
1399 $form->{invnumber} =~ s/\s*$//g;
1401 # if oldcustomer ne customer redo form
1402 if (&check_name(customer)) {
1406 if ($form->{second_run}) {
1407 $form->{print_and_post} = 0;
1412 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1413 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1415 $form->error($locale->text('Cannot post invoice for a closed period!'))
1416 if ($invdate <= $closedto);
1418 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1419 if ($form->{currency} ne $form->{defaultcurrency});
1421 for $i (1 .. $form->{paidaccounts}) {
1422 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1423 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1425 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1427 $form->error($locale->text('Cannot post payment for a closed period!'))
1428 if ($datepaid <= $closedto);
1430 if ($form->{currency} ne $form->{defaultcurrency}) {
1431 $form->{"exchangerate_$i"} = $form->{exchangerate}
1432 if ($invdate == $datepaid);
1433 $form->isblank("exchangerate_$i",
1434 $locale->text('Exchangerate for payment missing!'));
1439 ($form->{AR}) = split /--/, $form->{AR};
1440 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1442 $form->{label} = $locale->text('Invoice');
1444 $form->{id} = 0 if $form->{postasnew};
1446 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
1447 if ($form->{postasnew}) {
1448 if ($form->{type} eq "credit_note") {
1449 undef($form->{cnnumber});
1451 undef($form->{invnumber});
1456 $form->error($locale->text('Cannot post invoice!'))
1457 unless IS->post_invoice(\%myconfig, \%$form);
1458 remove_draft() if $form->{remove_draft};
1460 if(!exists $form->{addition}) {
1461 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1462 $form->{addition} = $print_post ? "PRINTED AND POSTED" :
1463 $form->{storno} ? "STORNO" :
1465 $form->save_history($form->dbconnect(\%myconfig));
1468 $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
1471 $lxdebug->leave_sub();
1474 sub print_and_post {
1475 $lxdebug->enter_sub();
1477 $old_form = new Form;
1479 $form->{print_and_post} = 1;
1483 $lxdebug->leave_sub();
1487 sub use_as_template {
1488 $lxdebug->enter_sub();
1490 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);
1491 $form->{paidaccounts} = 1;
1492 $form->{rowcount}--;
1493 $form->{invdate} = $form->current_date(\%myconfig);
1496 $lxdebug->leave_sub();
1500 $lxdebug->enter_sub();
1502 if ($form->{storno}) {
1503 $form->error($locale->text('Cannot storno storno invoice!'));
1506 if (IS->has_storno(\%myconfig, $form, "ar")) {
1507 $form->error($locale->text("Invoice has already been storno'd!"));
1510 map({ my $key = $_; delete($form->{$key})
1511 unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
1518 # Payments must not be recorded for the new storno invoice.
1519 $form->{paidaccounts} = 0;
1520 map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
1522 $form->{storno_id} = $form->{id};
1523 $form->{storno} = 1;
1525 $form->{invnumber} = "Storno zu " . $form->{invnumber};
1526 $form->{rowcount}++;
1529 $lxdebug->leave_sub();
1533 $lxdebug->enter_sub();
1535 $form->{preview} = 1;
1536 $old_form = new Form;
1537 for (keys %$form) { $old_form->{$_} = $form->{$_} }
1538 $old_form->{rowcount}++;
1540 &print_form($old_form);
1541 $lxdebug->leave_sub();
1546 $lxdebug->enter_sub();
1547 if ($form->{second_run}) {
1548 $form->{print_and_post} = 0;
1555 <form method="post" action="$form->{script}">
1558 # delete action variable
1559 map { delete $form->{$_} } qw(action header);
1561 foreach $key (keys %$form) {
1562 $form->{$key} =~ s/\"/"/g;
1563 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1567 <h2 class="confirm">| . $locale->text('Confirm!') . qq|</h2>
1570 . $locale->text('Are you sure you want to delete Invoice Number')
1571 . qq| $form->{invnumber}
1575 <input name="action" class="submit" type="submit" value="|
1576 . $locale->text('Yes') . qq|">
1580 $lxdebug->leave_sub();
1584 $lxdebug->enter_sub();
1586 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1588 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1591 $form->{rowcount}--;
1592 $form->{shipto} = 1;
1595 $form->{title} = $locale->text('Add Credit Note');
1596 $form->{script} = 'is.pl';
1601 # bo creates the id, reset it
1602 map { delete $form->{$_} }
1603 qw(id invnumber subject message cc bcc printed emailed queued);
1604 $form->{ $form->{vc} } =~ s/--.*//g;
1605 $form->{type} = "credit_note";
1608 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1610 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1611 qw(creditlimit creditremaining);
1613 $currency = $form->{currency};
1616 $form->{currency} = $currency;
1617 $form->{exchangerate} = "";
1618 $form->{forex} = "";
1619 $form->{exchangerate} = $exchangerate
1623 $form->check_exchangerate(
1624 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1627 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1634 $lxdebug->leave_sub();
1638 $lxdebug->enter_sub();
1639 if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
1640 # saving the history
1641 if(!exists $form->{addition}) {
1642 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1643 $form->{addition} = "DELETED";
1644 $form->save_history($form->dbconnect(\%myconfig));
1646 # /saving the history
1647 $form->redirect($locale->text('Invoice deleted!'));
1649 $form->error($locale->text('Cannot delete invoice!'));
1651 $lxdebug->leave_sub();
1655 $lxdebug->enter_sub();
1660 my $saved_form = save_form();
1665 map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
1666 restore_form($saved_form);
1667 map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
1672 $lxdebug->leave_sub();