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}";
172 if (@{ $form->{all_customer} }) {
173 $form->{customer} = "$form->{customer}--$form->{customer_id}";
177 if ($form->{all_departments}) {
178 $form->{selectdepartment} = "<option>\n";
179 $form->{department} = "$form->{department}--$form->{department_id}";
182 $form->{selectdepartment} .=
183 "<option>$_->{description}--$_->{id}</option>\n"
184 } (@{ $form->{all_departments} });
187 $form->{employee} = "$form->{employee}--$form->{employee_id}";
190 $form->{forex} = $form->{exchangerate};
191 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
193 foreach $key (keys %{ $form->{AR_links} }) {
194 foreach $ref (@{ $form->{AR_links}{$key} }) {
195 $form->{"select$key"} .=
196 "<option>$ref->{accno}--$ref->{description}</option>\n";
199 if ($key eq "AR_paid") {
200 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
201 $form->{"AR_paid_$i"} =
202 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
205 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
206 $form->{"datepaid_$i"} =
207 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
208 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
209 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
210 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
211 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
213 $form->{paidaccounts} = $i;
217 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
222 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
224 $form->{AR} = $form->{AR_1} unless $form->{id};
227 ($form->datetonum($form->{invdate}, \%myconfig) <=
228 $form->datetonum($form->{closedto}, \%myconfig));
230 $lxdebug->leave_sub();
233 sub prepare_invoice {
234 $lxdebug->enter_sub();
236 if ($form->{type} eq "credit_note") {
237 $form->{type} = "credit_note";
238 $form->{formname} = "credit_note";
240 $form->{type} = "invoice";
241 $form->{formname} = "invoice";
246 map { $form->{$_} =~ s/\"/"/g }
247 qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
249 # # get pricegroups for parts
250 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
254 foreach $ref (@{ $form->{invoice_details} }) {
257 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
258 $form->{"discount_$i"} =
259 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
260 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
262 $decimalplaces = ($dec > 2) ? $dec : 2;
264 $form->{"sellprice_$i"} =
265 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
268 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
269 $dec_qty = length $dec_qty;
272 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
274 map { $form->{"${_}_$i"} =~ s/\"/"/g }
275 qw(partnumber description unit partnotes);
276 $form->{rowcount} = $i;
280 $lxdebug->leave_sub();
284 $lxdebug->enter_sub();
288 if ($form->{type} eq "credit_note") {
289 $form->{title} = $locale->text('Edit Credit Note');
291 if ($form->{storno}) {
292 $form->{title} = $locale->text('Edit Storno Credit Note');
295 $form->{title} = $locale->text('Edit Sales Invoice');
297 if ($form->{storno}) {
298 $form->{title} = $locale->text('Edit Storno Invoice');
304 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
306 $payment = qq|<option value=""></option>|;
307 foreach $item (@{ $form->{payment_terms} }) {
308 if ($form->{payment_id} eq $item->{id}) {
309 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
311 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
315 my $set_duedate_url =
316 "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
318 my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
319 push(@ { $form->{AJAX} }, $pjx);
321 my @old_project_ids = ($form->{"globalproject_id"});
322 map({ push(@old_project_ids, $form->{"project_id_$_"})
323 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
325 $form->get_lists("contacts" => "ALL_CONTACTS",
326 "shipto" => "ALL_SHIPTO",
327 "projects" => { "key" => "ALL_PROJECTS",
329 "old_id" => \@old_project_ids },
330 "employees" => "ALL_SALESMEN",
331 "taxzones" => "ALL_TAXZONES",
332 "currencies" => "ALL_CURRENCIES",
333 "customers" => "ALL_CUSTOMERS");
336 my @values = (undef);
337 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
338 push(@values, $item->{"cp_id"});
339 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
340 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
343 if (scalar @values > 1) {
346 <th align="right">| . $locale->text('Contact Person') . qq|</th>
348 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
349 '-labels' => \%labels, '-default' => $form->{"cp_id"}))
357 foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
358 push(@values, $item->{"id"});
359 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
364 <th align="right">| . $locale->text('Employee') . qq|</th>
366 NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
367 '-values' => \@values, '-labels' => \%labels)) . qq|
374 foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
375 push(@values, $item->{name}.qq|--|.$item->{"id"});
376 $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
379 $form->{selectcustomer} = ($myconfig{vclimit} > scalar(@values));
382 <th align="right">| . $locale->text('Customer') . qq|</th>
384 (($myconfig{vclimit} <= scalar(@values))
385 ? qq|<input type="text" value="| . H($form->{customer}) . qq|" name="customer">|
386 : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
387 '-onChange' => 'document.getElementById(\'update_button\').click();',
388 '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
389 <input type="button" value="?" onclick="show_vc_details('customer')">
394 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
395 push(@values, $item->{"shipto_id"});
396 $labels{$item->{"shipto_id"}} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city);
400 if (scalar @values > 1) {
403 <th align="right">| . $locale->text('Shipping Address') . qq|</th>
405 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
406 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
412 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
413 push(@values, $item);
414 $labels{$item} = $item;
417 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
419 if (scalar @values) {
422 <th align="right">| . $locale->text('Currency') . qq|</th>
424 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
425 '-values' => \@values, '-labels' => \%labels)) . qq|
432 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
433 push(@values, $item->{"id"});
434 $labels{$item->{"id"}} = $item->{"projectnumber"};
436 my $globalprojectnumber =
437 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
438 '-labels' => \%labels,
439 '-default' => $form->{"globalproject_id"}));
443 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
444 push(@values, $item->{id});
445 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
450 <th align="right">| . $locale->text('Salesman') . qq|</th>
452 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id},
453 '-values' => \@values, '-labels' => \%labels))
459 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
460 push(@values, $item->{"id"});
461 $labels{$item->{"id"}} = $item->{"description"};
464 if (!$form->{"id"}) {
467 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
469 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
470 '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
477 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
479 <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
480 | . H($labels{$form->{"taxzone_id"}}) . qq|
485 # set option selected
486 foreach $item (qw(AR customer currency department employee)) {
487 $form->{"select$item"} =~ s/ selected//;
488 $form->{"select$item"} =~
489 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
492 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
498 $form->{exchangerate} =
499 $form->format_amount(\%myconfig, $form->{exchangerate});
501 $form->{creditlimit} =
502 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
503 $form->{creditremaining} =
504 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
507 if ($form->{currency} ne $form->{defaultcurrency}) {
508 if ($form->{forex}) {
510 qq|<th align="right">|
511 . $locale->text('Exchangerate')
512 . qq|</th><td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
515 qq|<th align="right">|
516 . $locale->text('Exchangerate')
517 . qq|</th><td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
521 <input type="hidden" name="forex" value="$form->{forex}">
526 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
527 <td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
528 <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
531 | if $form->{selectdepartment};
533 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
535 if ($form->{business}) {
538 <th align="right">| . $locale->text('Customer type') . qq|</th>
539 <td>$form->{business}; | . $locale->text('Trade Discount') . qq| |
540 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
546 if ($form->{max_dunning_level}) {
549 <th align="right">| . $locale->text('Max. Dunning Level') . qq|:</th>
551 <b>$form->{max_dunning_level}</b>;
552 | . $locale->text('Dunning Amount') . qq|: <b>|
553 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
560 $form->{fokus} = "invoice.customer";
562 # use JavaScript Calendar or not
563 $form->{jsscript} = 1;
565 if ($form->{type} eq "credit_note") {
567 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
568 <input type="button" name="invdate" id="trigger1" value="|
569 . $locale->text('button') . qq|"></td>|;
573 Form->write_trigger(\%myconfig, "1",
578 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
579 <input type="button" name="invdate" id="trigger1" value="|
580 . $locale->text('button') . qq|"></td>
583 <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\">
584 <input type="button" name="duedate" id="trigger2" value="|
585 . $locale->text('button') . qq|"></td></td>
588 <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\">
589 <input type="button" name="deliverydate" id="trigger3" value="|
590 . $locale->text('button') . qq|"></td></td>
595 Form->write_trigger(\%myconfig, "3",
597 "trigger1", "duedate",
599 "deliverydate", "BL",
603 if ($form->{resubmit} && ($form->{format} eq "html")) {
605 qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
606 } elsif ($form->{resubmit}) {
607 $onload = qq|document.invoice.submit()|;
611 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
612 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
613 $credittext = $locale->text('Credit Limit exceeded!!!');
614 if ($creditwarning) {
615 $onload = qq|alert('$credittext')|;
618 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
619 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
622 $form->write_trigger(\%myconfig, 2,
623 "orddate", "BL", "trigger_orddate",
624 "quodate", "BL", "trigger_quodate");
625 # show history button js
626 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
627 #/show history button js
631 <body onLoad="$onload">
632 <script type="text/javascript" src="js/common.js"></script>
633 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
634 <script type="text/javascript" src="js/vendor_selection.js"></script>
635 <script type="text/javascript" src="js/calculate_qty.js"></script>
637 <form method="post" name="invoice" action="$form->{script}">
640 $form->hide_form(qw(id action type media format queued printed emailed title vc discount
641 creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
642 max_dunning_level dunning_amount));
643 print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
647 <input type="hidden" name="lizenzen" value="$lizenzen">
649 <div class="listtop" width="100%">$form->{title}</div>
657 <input type="hidden" name="customer_klass" value="$form->{customer_klass}">
658 <input type="hidden" name="customer_id" value="$form->{customer_id}">
659 <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
660 <input type="hidden" name="selectcustomer" value="$form->{selectcustomer}">
665 <td align="right">| . $locale->text('Credit Limit') . qq|</td>
666 <td>$form->{creditlimit}; | . $locale->text('Remaining') . qq| <span class="plus$n">$form->{creditremaining}</span></td>
671 <th align="right" nowrap>| . $locale->text('Record in') . qq|</th>
672 <td colspan="3"><select name="AR" style="width:250px;">$form->{selectAR}</select></td>
673 <input type="hidden" name="selectAR" value="$form->{selectAR}">
679 <input type="hidden" name="fxgain_accno" value="$form->{fxgain_accno}">
680 <input type="hidden" name="fxloss_accno" value="$form->{fxloss_accno}">
684 <th align="right" nowrap>| . $locale->text('Shipping Point') . qq|</th>
686 $cgi->textfield("-name" => "shippingpoint", "-size" => 35, "-value" => $form->{shippingpoint}) .
689 <th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
690 <td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
693 <th align="right">| . $locale->text('Transaction description') . qq|</th>
694 <td colspan="3">| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|</td>
701 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
703 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
704 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
708 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
710 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
711 # <input size=45 id=delivery_vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
718 <td align="right" valign="top">
723 if ($form->{type} eq "credit_note") {
725 <th align="right" nowrap>| . $locale->text('Credit Note Number') . qq|</th>
726 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
729 <th align="right">| . $locale->text('Credit Note Date') . qq|</th>
734 <th align="right" nowrap>| . $locale->text('Invoice Number') . qq|</th>
735 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
738 <th align="right">| . $locale->text('Invoice Date') . qq|</th>
742 <th align="right">| . $locale->text('Due Date') . qq|</th>
746 <th align="right">| . $locale->text('Delivery Date') . qq|</th>
751 <th align="right" nowrap>| . $locale->text('Order Number') . qq|</th>
752 <td><input name="ordnumber" size="11" value="$form->{ordnumber}"></td>
755 <th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
756 <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\">
757 <input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
760 <th align="right" nowrap>| . $locale->text('Quotation Number') . qq|</th>
761 <td><input name="quonumber" size="11" value="$form->{quonumber}"></td>
764 <th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
765 <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\">
766 <input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
769 <th align="right" nowrap>| . $locale->text('Customer Order Number') . qq|</th>
770 <td><input name="cusordnumber" size="11" value="$form->{cusordnumber}"></td>
773 <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
774 <td>$globalprojectnumber</td>
789 <!-- shipto are in hidden variables -->
791 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
792 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
793 print qq|<!-- email variables --> |;
794 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
795 qw(message email subject cc bcc taxaccounts));
796 print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|;
798 foreach $item (split(/ /, $form->{taxaccounts})) {
799 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
800 ("${item}_rate", "${item}_description", "${item}_taxnumber"));
802 $lxdebug->leave_sub();
806 $lxdebug->enter_sub();
808 $form->{invtotal} = $form->{invsubtotal};
810 if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
813 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
816 $rows = ($rows > $introws) ? $rows : $introws;
818 qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
820 qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
822 $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
825 if ($form->{taxaccounts}) {
827 <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
828 . $locale->text('Tax Included') . qq|</b><br><br>|;
831 if (!$form->{taxincluded}) {
833 foreach $item (split / /, $form->{taxaccounts}) {
834 if ($form->{"${item}_base"}) {
835 $form->{"${item}_total"} =
837 $form->{"${item}_base"} * $form->{"${item}_rate"},
839 $form->{invtotal} += $form->{"${item}_total"};
840 $form->{"${item}_total"} =
841 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
845 <th align="right">$form->{"${item}_description"} |
846 . $form->{"${item}_rate"} * 100 .qq|%</th>
847 <td align="right">$form->{"${item}_total"}</td>
853 $form->{invsubtotal} =
854 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
858 <th align="right">| . $locale->text('Subtotal') . qq|</th>
859 <td align="right">$form->{invsubtotal}</td>
865 if ($form->{taxincluded}) {
866 foreach $item (split / /, $form->{taxaccounts}) {
867 if ($form->{"${item}_base"}) {
868 $form->{"${item}_total"} =
870 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
871 (1 + $form->{"${item}_rate"})
874 $form->{"${item}_netto"} =
876 ($form->{"${item}_base"} - $form->{"${item}_total"}),
878 $form->{"${item}_total"} =
879 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
880 $form->{"${item}_netto"} =
881 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
885 <th align="right">Enthaltene $form->{"${item}_description"} |
886 . $form->{"${item}_rate"} * 100 .qq|%</th>
887 <td align="right">$form->{"${item}_total"}</td>
890 <th align="right">Nettobetrag</th>
891 <td align="right">$form->{"${item}_netto"}</td>
899 $form->{oldinvtotal} = $form->{invtotal};
901 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
911 <th align="left">| . $locale->text('Notes') . qq|</th>
912 <th align="left">| . $locale->text('Internal Notes') . qq|</th>
913 <th align="right">| . $locale->text('Payment Terms') . qq|</th>
918 <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value],['duedate'])">$payment
923 <td align="right" width="100%">
929 <th align="right">| . $locale->text('Total') . qq|</th>
930 <td align="right">$form->{invtotal}</td>
942 <td><hr size="3" noshade></td>
945 <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
948 <td align="left" width="30%"><b>Dateiname</b></td>
949 <td align="left" width="70%"><b>Webdavlink</b></td>
951 foreach $file (keys %{ $form->{WEBDAV} }) {
954 <td align="left">$file</td>
955 <td align="left"><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
966 if ($form->{type} eq "credit_note") {
971 <tr class="listheading">
972 <th colspan="6" class="listheading">|
973 . $locale->text('Payments') . qq|</th>
981 <tr class="listheading">
982 <th colspan="6" class="listheading">|
983 . $locale->text('Incoming Payments') . qq|</th>
988 if ($form->{currency} eq $form->{defaultcurrency}) {
989 @column_index = qw(datepaid source memo paid AR_paid);
991 @column_index = qw(datepaid source memo paid exchangerate AR_paid);
994 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
995 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
996 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
997 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
998 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
999 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
1004 map { print "$column_data{$_}\n" } @column_index;
1012 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
1013 for $i (1 .. $form->{paidaccounts}) {
1018 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
1019 $form->{"selectAR_paid_$i"} =~
1020 s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
1023 $totalpaid += $form->{"paid_$i"};
1024 if ($form->{"paid_$i"}) {
1025 $form->{"paid_$i"} =
1026 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
1028 $form->{"exchangerate_$i"} =
1029 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
1031 $exchangerate = qq| |;
1032 if ($form->{currency} ne $form->{defaultcurrency}) {
1033 if ($form->{"forex_$i"}) {
1034 $exchangerate = qq|<input type="hidden" name="exchangerate_$i" value="$form->{"exchangerate_$i"}">$form->{"exchangerate_$i"}|;
1036 $exchangerate = qq|<input name="exchangerate_$i" size="10" value="$form->{"exchangerate_$i"}">|;
1040 $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
1042 $column_data{"paid_$i"} =
1043 qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
1044 $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
1045 $column_data{"AR_paid_$i"} =
1046 qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
1047 $column_data{"datepaid_$i"} =
1048 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)\">
1049 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
1050 $column_data{"source_$i"} =
1051 qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
1052 $column_data{"memo_$i"} =
1053 qq|<td align="center"><input name="memo_$i" size="11" value="$form->{"memo_$i"}"></td>|;
1055 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
1058 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
1061 my $paid_missing = $form->{oldinvtotal} - $totalpaid;
1067 <td align="center">| . $locale->text('Total') . qq|</td>
1068 <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
1073 <td align="center">| . $locale->text('Missing amount') . qq|</td>
1074 <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
1078 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
1079 print qq|<input type="hidden" name="oldtotalpaid" value="$totalpaid">
1084 <td><hr size="3" noshade></td>
1098 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1099 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1102 my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar");
1105 <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="|
1106 . $locale->text('Update') . qq|">
1107 <input class="submit" type="submit" name="action" value="|
1108 . $locale->text('Ship to') . qq|">
1109 <input class="submit" type="submit" name="action" value="|
1110 . $locale->text('Print') . qq|">
1111 <input class="submit" type="submit" name="action" value="|
1112 . $locale->text('E-mail') . qq|"> |;
1113 print qq|<input class="submit" type="submit" name="action" value="|
1114 . $locale->text('Storno') . qq|"> | if ($show_storno);
1115 print qq|<input class="submit" type="submit" name="action" value="|
1116 . $locale->text('Post Payment') . qq|">
1118 print qq|<input class="submit" type="submit" name="action" value="|
1119 . $locale->text('Use As Template') . qq|">
1121 if ($form->{id} && !($form->{type} eq "credit_note")) {
1123 <input class="submit" type="submit" name="action" value="|
1124 . $locale->text('Credit Note') . qq|">
1127 if ($form->{radier}) {
1129 <input class="submit" type="submit" name="action" value="|
1130 . $locale->text('Delete') . qq|">
1135 if ($invdate > $closedto) {
1137 <input class="submit" type="submit" name="action" value="|
1138 . $locale->text('Order') . qq|">
1143 if ($invdate > $closedto) {
1144 print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
1145 . $locale->text('Update') . qq|">
1146 <input class="submit" type="submit" name="action" value="|
1147 . $locale->text('Ship to') . qq|">
1148 <input class="submit" type="submit" name="action" value="|
1149 . $locale->text('Preview') . qq|">
1150 <input class="submit" type="submit" name="action" value="|
1151 . $locale->text('E-mail') . qq|">
1152 <input class="submit" type="submit" name="action" value="|
1153 . $locale->text('Print and Post') . qq|">
1154 <input class="submit" type="submit" name="action" value="|
1155 . $locale->text('Post') . qq|"> | .
1156 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
1157 '-class' => 'submit'));
1161 # button for saving history
1162 if($form->{id} ne "") {
1164 <input type="button" class="submit" onclick="set_history_window(|
1166 . qq|);" name="history" id="history" value="|
1167 . $locale->text('history')
1170 # /button for saving history
1173 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
1176 <input type="hidden" name="rowcount" value="$form->{rowcount}">
1178 $cgi->hidden("-name" => "callback", "-value" => $form->{callback})
1179 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
1180 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
1181 map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
1190 $lxdebug->leave_sub();
1194 $lxdebug->enter_sub();
1196 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1197 qw(exchangerate creditlimit creditremaining);
1198 if ($form->{second_run}) {
1199 $form->{print_and_post} = 0;
1203 if($form->{taxincluded}) {
1204 $taxincluded = "checked";
1206 $form->{update} = 1;
1208 &check_name(customer);
1210 if(!$form->{taxincluded}) {
1211 $form->{taxincluded} = $taxincluded;
1215 $form->{exchangerate} = $exchangerate
1219 $form->check_exchangerate(
1220 \%myconfig, $form->{currency}, $form->{invdate}, 'buy'
1223 for $i (1 .. $form->{paidaccounts}) {
1224 if ($form->{"paid_$i"}) {
1226 $form->{"${_}_$i"} =
1227 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1228 } qw(paid exchangerate);
1230 $form->{"exchangerate_$i"} = $exchangerate
1232 $form->{"forex_$i"} = (
1234 $form->check_exchangerate(
1235 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
1240 $i = $form->{rowcount};
1241 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1243 # if last row empty, check the form otherwise retrieve new item
1244 if ( ($form->{"partnumber_$i"} eq "")
1245 && ($form->{"description_$i"} eq "")
1246 && ($form->{"partsgroup_$i"} eq "")) {
1248 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1253 IS->retrieve_item(\%myconfig, \%$form);
1255 $rows = scalar @{ $form->{item_list} };
1257 $form->{"discount_$i"} =
1258 $form->format_amount(\%myconfig, $form->{discount} * 100);
1261 $form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1;
1270 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1272 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1273 qw(partnumber description unit);
1274 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1275 keys %{ $form->{item_list}[0] };
1276 if ($form->{"part_payment_id_$i"} ne "") {
1277 $form->{payment_id} = $form->{"part_payment_id_$i"};
1280 if ($form->{"not_discountable_$i"}) {
1281 $form->{"discount_$i"} = 0;
1284 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1285 ($dec) = ($s =~ /\.(\d+)/);
1287 $decimalplaces = ($dec > 2) ? $dec : 2;
1290 $form->{"sellprice_$i"} = $sellprice;
1293 # if there is an exchange rate adjust sellprice
1294 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1295 $form->{"sellprice_$i"} /= $exchangerate;
1298 $form->{"listprice_$i"} /= $exchangerate;
1301 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1302 (1 - $form->{"discount_$i"} / 100);
1303 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1304 map { $form->{"${_}_base"} += $amount }
1305 (split / /, $form->{"taxaccounts_$i"});
1306 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1307 split / /, $form->{"taxaccounts_$i"}
1308 if !$form->{taxincluded};
1310 $form->{creditremaining} -= $amount;
1313 $form->{"${_}_$i"} =
1314 $form->format_amount(\%myconfig, $form->{"${_}_$i"},
1316 } qw(sellprice listprice);
1319 $form->format_amount(\%myconfig, $form->{"qty_$i"});
1322 if ($form->{"inventory_accno_$i"} ne "") {
1323 $form->{"lizenzen_$i"} = qq|<option></option>|;
1324 foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
1325 $form->{"lizenzen_$i"} .=
1326 qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|;
1328 $form->{"lizenzen_$i"} .=
1329 qq|<option value=-1>Neue Lizenz</option>|;
1333 # get pricegroups for parts
1334 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1336 # build up html code for prices_$i
1337 &set_pricegroup($i);
1344 # ok, so this is a new part
1345 # ask if it is a part or service item
1347 if ( $form->{"partsgroup_$i"}
1348 && ($form->{"partsnumber_$i"} eq "")
1349 && ($form->{"description_$i"} eq "")) {
1350 $form->{rowcount}--;
1351 $form->{"discount_$i"} = "";
1355 $form->{"id_$i"} = 0;
1356 $form->{"unit_$i"} = $locale->text('ea');
1363 $lxdebug->leave_sub();
1367 $lxdebug->enter_sub();
1368 for $i (1 .. $form->{paidaccounts}) {
1369 if ($form->{"paid_$i"}) {
1370 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1372 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1374 $form->error($locale->text('Cannot post payment for a closed period!'))
1375 if ($datepaid <= $closedto);
1377 if ($form->{currency} ne $form->{defaultcurrency}) {
1378 $form->{"exchangerate_$i"} = $form->{exchangerate}
1379 if ($invdate == $datepaid);
1380 $form->isblank("exchangerate_$i",
1381 $locale->text('Exchangerate for payment missing!'));
1386 ($form->{AR}) = split /--/, $form->{AR};
1387 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1389 $form->redirect($locale->text('Payment posted!'))
1390 if (IS->post_payment(\%myconfig, \%$form));
1391 $form->error($locale->text('Cannot post payment!'));
1394 $lxdebug->leave_sub();
1398 $lxdebug->enter_sub();
1399 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
1400 $form->isblank("customer", $locale->text('Customer missing!'));
1402 $form->{invnumber} =~ s/^\s*//g;
1403 $form->{invnumber} =~ s/\s*$//g;
1405 # if oldcustomer ne customer redo form
1406 if (&check_name(customer)) {
1410 if ($form->{second_run}) {
1411 $form->{print_and_post} = 0;
1416 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1417 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1419 $form->error($locale->text('Cannot post invoice for a closed period!'))
1420 if ($invdate <= $closedto);
1422 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1423 if ($form->{currency} ne $form->{defaultcurrency});
1425 for $i (1 .. $form->{paidaccounts}) {
1426 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1427 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1429 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1431 $form->error($locale->text('Cannot post payment for a closed period!'))
1432 if ($datepaid <= $closedto);
1434 if ($form->{currency} ne $form->{defaultcurrency}) {
1435 $form->{"exchangerate_$i"} = $form->{exchangerate}
1436 if ($invdate == $datepaid);
1437 $form->isblank("exchangerate_$i",
1438 $locale->text('Exchangerate for payment missing!'));
1443 ($form->{AR}) = split /--/, $form->{AR};
1444 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1446 $form->{label} = $locale->text('Invoice');
1448 $form->{id} = 0 if $form->{postasnew};
1450 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
1451 if ($form->{postasnew}) {
1452 if ($form->{type} eq "credit_note") {
1453 undef($form->{cnnumber});
1455 undef($form->{invnumber});
1460 $form->error($locale->text('Cannot post invoice!'))
1461 unless IS->post_invoice(\%myconfig, \%$form);
1462 remove_draft() if $form->{remove_draft};
1464 if(!exists $form->{addition}) {
1465 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1466 $form->{addition} = $print_post ? "PRINTED AND POSTED" :
1467 $form->{storno} ? "STORNO" :
1469 $form->save_history($form->dbconnect(\%myconfig));
1472 $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
1475 $lxdebug->leave_sub();
1478 sub print_and_post {
1479 $lxdebug->enter_sub();
1481 $old_form = new Form;
1483 $form->{print_and_post} = 1;
1487 $lxdebug->leave_sub();
1491 sub use_as_template {
1492 $lxdebug->enter_sub();
1494 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);
1495 $form->{paidaccounts} = 1;
1496 $form->{rowcount}--;
1497 $form->{invdate} = $form->current_date(\%myconfig);
1500 $lxdebug->leave_sub();
1504 $lxdebug->enter_sub();
1506 if ($form->{storno}) {
1507 $form->error($locale->text('Cannot storno storno invoice!'));
1510 if (IS->has_storno(\%myconfig, $form, "ar")) {
1511 $form->error($locale->text("Invoice has already been storno'd!"));
1514 map({ my $key = $_; delete($form->{$key})
1515 unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
1522 # Payments must not be recorded for the new storno invoice.
1523 $form->{paidaccounts} = 0;
1524 map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
1526 $form->{storno_id} = $form->{id};
1527 $form->{storno} = 1;
1529 $form->{invnumber} = "Storno zu " . $form->{invnumber};
1530 $form->{rowcount}++;
1533 $lxdebug->leave_sub();
1537 $lxdebug->enter_sub();
1539 $form->{preview} = 1;
1540 $old_form = new Form;
1541 for (keys %$form) { $old_form->{$_} = $form->{$_} }
1542 $old_form->{rowcount}++;
1544 &print_form($old_form);
1545 $lxdebug->leave_sub();
1550 $lxdebug->enter_sub();
1551 if ($form->{second_run}) {
1552 $form->{print_and_post} = 0;
1559 <form method="post" action="$form->{script}">
1562 # delete action variable
1563 map { delete $form->{$_} } qw(action header);
1565 foreach $key (keys %$form) {
1566 $form->{$key} =~ s/\"/"/g;
1567 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1571 <h2 class="confirm">| . $locale->text('Confirm!') . qq|</h2>
1574 . $locale->text('Are you sure you want to delete Invoice Number')
1575 . qq| $form->{invnumber}
1579 <input name="action" class="submit" type="submit" value="|
1580 . $locale->text('Yes') . qq|">
1584 $lxdebug->leave_sub();
1588 $lxdebug->enter_sub();
1590 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1592 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1595 $form->{rowcount}--;
1596 $form->{shipto} = 1;
1599 $form->{title} = $locale->text('Add Credit Note');
1600 $form->{script} = 'is.pl';
1605 # bo creates the id, reset it
1606 map { delete $form->{$_} }
1607 qw(id invnumber subject message cc bcc printed emailed queued);
1608 $form->{ $form->{vc} } =~ s/--.*//g;
1609 $form->{type} = "credit_note";
1612 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1614 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1615 qw(creditlimit creditremaining);
1617 $currency = $form->{currency};
1620 $form->{currency} = $currency;
1621 $form->{exchangerate} = "";
1622 $form->{forex} = "";
1623 $form->{exchangerate} = $exchangerate
1627 $form->check_exchangerate(
1628 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1631 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1638 $lxdebug->leave_sub();
1642 $lxdebug->enter_sub();
1643 if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
1644 # saving the history
1645 if(!exists $form->{addition}) {
1646 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1647 $form->{addition} = "DELETED";
1648 $form->save_history($form->dbconnect(\%myconfig));
1650 # /saving the history
1651 $form->redirect($locale->text('Invoice deleted!'));
1653 $form->error($locale->text('Cannot delete invoice!'));
1655 $lxdebug->leave_sub();
1659 $lxdebug->enter_sub();
1664 my $saved_form = save_form();
1669 map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
1670 restore_form($saved_form);
1671 map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
1676 $lxdebug->leave_sub();