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 received module
32 #======================================================================
37 require "$form->{path}/io.pl";
38 require "$form->{path}/arap.pl";
45 $lxdebug->enter_sub();
47 $form->{title} = $locale->text('Add Vendor Invoice');
53 $lxdebug->leave_sub();
57 $lxdebug->enter_sub();
59 $form->{title} = $locale->text('Edit Vendor Invoice');
65 $lxdebug->leave_sub();
69 $lxdebug->enter_sub();
72 $form->{webdav} = $webdav;
75 $form->{jscalendar} = $jscalendar;
77 $form->create_links("AP", \%myconfig, "vendor");
79 #quote all_vendor Bug 133
80 foreach $ref (@{ $form->{all_vendor} }) {
81 $ref->{name} = $form->quote($ref->{name});
84 if ($form->{all_vendor}) {
85 unless ($form->{vendor_id}) {
86 $form->{vendor_id} = $form->{all_vendor}->[0]->{id};
90 $cp_id = $form->{cp_id};
91 IR->get_vendor(\%myconfig, \%$form);
92 IR->retrieve_invoice(\%myconfig, \%$form);
93 $form->{cp_id} = $cp_id;
96 @curr = split /:/, $form->{currencies};
98 $form->{defaultcurrency} = $curr[0];
100 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
102 $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
105 if ($form->{all_vendor}) {
106 $form->{vendor} = "$form->{vendor}--$form->{vendor_id}";
107 map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
108 (@{ $form->{all_vendor} });
112 if ($form->{all_departments}) {
113 $form->{selectdepartment} = "<option>\n";
114 $form->{department} = "$form->{department}--$form->{department_id}";
117 $form->{selectdepartment} .=
118 "<option>$_->{description}--$_->{id}\n"
119 } (@{ $form->{all_departments} });
123 $form->{forex} = $form->{exchangerate};
124 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
126 foreach $key (keys %{ $form->{AP_links} }) {
128 foreach $ref (@{ $form->{AP_links}{$key} }) {
129 $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
132 if ($key eq "AP_paid") {
133 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
134 $form->{"AP_paid_$i"} =
135 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
138 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
139 $form->{"datepaid_$i"} =
140 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
141 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
142 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
143 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
144 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
146 $form->{paidaccounts} = $i;
150 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
155 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
157 $form->{AP} = $form->{AP_1} unless $form->{id};
160 ($form->datetonum($form->{invdate}, \%myconfig) <=
161 $form->datetonum($form->{closedto}, \%myconfig));
163 $lxdebug->leave_sub();
166 sub prepare_invoice {
167 $lxdebug->enter_sub();
171 map { $form->{$_} =~ s/\"/"/g } qw(invnumber ordnumber quonumber);
173 foreach $ref (@{ $form->{invoice_details} }) {
175 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
177 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
179 $decimalplaces = ($dec > 2) ? $dec : 2;
181 $form->{"sellprice_$i"} =
182 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
185 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
186 $dec_qty = length $dec_qty;
189 $form->format_amount(\%myconfig, ($form->{"qty_$i"} * -1), $dec_qty);
191 $form->{rowcount} = $i;
195 $lxdebug->leave_sub();
199 $lxdebug->enter_sub();
201 # set option selected
202 foreach $item (qw(AP vendor currency department contact)) {
203 $form->{"select$item"} =~ s/ selected//;
204 $form->{"select$item"} =~
205 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
208 #quote selectvendor Bug 133
209 $form->{"selectvendor"} = $form->quote($form->{"selectvendor"});
211 $form->{exchangerate} =
212 $form->format_amount(\%myconfig, $form->{exchangerate});
214 $form->{creditlimit} =
215 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
216 $form->{creditremaining} =
217 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
220 if ($form->{all_contacts}) {
222 $form->{selectcontact} = "";
223 foreach $item (@{ $form->{all_contacts} }) {
224 if ($form->{cp_id} == $item->{cp_id}) {
225 $form->{selectcontact} .=
226 "<option selected>$item->{cp_name}--$item->{cp_id}";
228 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
234 if ($form->{currency} ne $form->{defaultcurrency}) {
235 if ($form->{forex}) {
237 <th align=right nowrap>|
238 . $locale->text('Exchangerate') . qq|</th>
239 <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>
243 <th align=right nowrap>|
244 . $locale->text('Exchangerate') . qq|</th>
245 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
250 <input type=hidden name=forex value=$form->{forex}>
254 ($form->{selectvendor})
255 ? qq|<select name=vendor>$form->{selectvendor}</select>\n<input type=hidden name="selectvendor" value="$form->{selectvendor}">|
256 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
259 ($form->{selectcontact})
260 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
261 : qq|<input name=contact value="$form->{contact}" size=35>|;
265 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
266 <td colspan=3><select name=department>$form->{selectdepartment}</select>
267 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
270 | if $form->{selectdepartment};
272 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
274 # use JavaScript Calendar or not
275 $form->{jsscript} = $form->{jscalendar};
277 if ($form->{jsscript}) {
279 # with JavaScript Calendar
281 <td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>
282 <td><input type=button name=invdate id="trigger1" value=|
283 . $locale->text('button') . qq|></td>
286 <td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
287 <td width="4"><input type=button name=duedate id="trigger2" value=|
288 . $locale->text('button') . qq|></td></td>
293 Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1",
294 "duedate", "BL", "trigger2");
297 # without JavaScript Calendar
299 qq|<td><input name=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>|;
301 qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
309 <form method=post action=$form->{script}>
311 <input type=hidden name=id value=$form->{id}>
312 <input type=hidden name=title value="$form->{title}">
313 <input type=hidden name=vc value="vendor">
314 <input type=hidden name=type value=$form->{type}>
315 <input type=hidden name=level value=$form->{level}>
317 <input type=hidden name=creditlimit value=$form->{creditlimit}>
318 <input type=hidden name=creditremaining value=$form->{creditremaining}>
320 <input type=hidden name=closedto value=$form->{closedto}>
321 <input type=hidden name=locked value=$form->{locked}>
323 <input type=hidden name=shipped value=$form->{shipped}>
328 <th class=listtop>$form->{title}</th>
338 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
339 <td colspan=3>$vendor</td>
341 <th align=richt nowrap>|
342 . $locale->text('Contact Person') . qq|</th>
343 <td colspan=3>$contact</td>
345 <input type=hidden name=vendor_id value=$form->{vendor_id}>
346 <input type=hidden name=oldvendor value="$form->{oldvendor}">
354 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
355 <td>$form->{creditlimit}</td>
357 <th nowrap>| . $locale->text('Remaining') . qq|</th>
358 <td class="plus$n">$form->{creditremaining}</td>
363 <th align=right>| . $locale->text('Record in') . qq|</th>
364 <td colspan=3><select name=AP>$form->{selectAP}</select></td>
365 <input type=hidden name=selectAP value="$form->{selectAP}">
369 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
370 <td><select name=currency>$form->{selectcurrency}</select></td>
378 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
379 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
382 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
386 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
390 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
391 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
392 <input type=hidden name=quonumber value="$form->{quonumber}">
403 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
404 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
405 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
406 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
407 <input type=hidden name=webdav value=$webdav>
409 <input type=hidden name=taxpart value="$form->{taxpart}">
410 <input type=hidden name=taxservice value="$form->{taxservice}">
412 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
415 foreach $item (split / /, $form->{taxaccounts}) {
417 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
418 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
422 $lxdebug->leave_sub();
426 $lxdebug->enter_sub();
428 $form->{invtotal} = $form->{invsubtotal};
430 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
433 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
436 $rows = ($rows > $introws) ? $rows : $introws;
438 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
440 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
442 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
445 if ($form->{taxaccounts}) {
447 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
448 . $locale->text('Tax Included') . qq|</b>
452 if (!$form->{taxincluded}) {
454 foreach $item (split / /, $form->{taxaccounts}) {
455 if ($form->{"${item}_base"}) {
456 $form->{invtotal} += $form->{"${item}_total"} =
458 $form->{"${item}_base"} * $form->{"${item}_rate"},
460 $form->{"${item}_total"} =
461 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
465 <th align=right>$form->{"${item}_description"}</th>
466 <td align=right>$form->{"${item}_total"}</td>
472 $form->{invsubtotal} =
473 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
477 <th align=right>| . $locale->text('Subtotal') . qq|</th>
478 <td align=right>$form->{invsubtotal}</td>
484 if ($form->{taxincluded}) {
485 foreach $item (split / /, $form->{taxaccounts}) {
486 if ($form->{"${item}_base"}) {
487 $form->{"${item}_total"} =
489 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
490 (1 + $form->{"${item}_rate"})
493 $form->{"${item}_base"} =
494 $form->round_amount($form->{"${item}_base"}, 2);
495 $form->{"${item}_netto"} =
497 ($form->{"${item}_base"} - $form->{"${item}_total"}),
499 $form->{"${item}_netto"} =
500 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
501 $form->{"${item}_total"} =
502 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
506 <th align=right>Enthaltene $form->{"${item}_description"}</th>
507 <td align=right>$form->{"${item}_total"}</td>
510 <th align=right>Nettobetrag</th>
511 <td align=right>$form->{"${item}_netto"}</td>
519 $form->{oldinvtotal} = $form->{invtotal};
521 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
525 <td colspan=$colspan>
526 <table cellspacing="0">
531 <th align=left>| . $locale->text('Notes') . qq|</th>
532 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
540 <td colspan=2 align=right width=100%>
547 <th align=right>| . $locale->text('Total') . qq|</th>
548 <td align=right>$form->{invtotal}</td>
560 <td><hr size=3 noshade></td>
563 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
566 <td align=left width=30%><b>Dateiname</b></td>
567 <td align=left width=70%><b>Webdavlink</b></td>
569 foreach $file (keys %{ $form->{WEBDAV} }) {
572 <td align=left>$file</td>
573 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
585 <input type=hidden name=jscalendar value=$form->{jscalendar}>
589 <td colspan=$colspan>
592 <th colspan=6 class=listheading>| . $locale->text('Payments') . qq|</th>
596 if ($form->{currency} eq $form->{defaultcurrency}) {
597 @column_index = qw(datepaid source memo paid AP_paid);
599 @column_index = qw(datepaid source memo paid exchangerate AP_paid);
602 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
603 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
604 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
605 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
606 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
607 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
612 map { print "$column_data{$_}\n" } @column_index;
617 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
618 for $i (1 .. $form->{paidaccounts}) {
624 $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
625 $form->{"selectAP_paid_$i"} =~
626 s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
630 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
631 $form->{"exchangerate_$i"} =
632 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
634 $exchangerate = qq| |;
635 if ($form->{currency} ne $form->{defaultcurrency}) {
636 if ($form->{"forex_$i"}) {
638 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
641 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
645 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
648 $column_data{"paid_$i"} =
649 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
650 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
651 $column_data{"AP_paid_$i"} =
652 qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
653 $column_data{"datepaid_$i"} =
654 qq|<td align=center><input name="datepaid_$i" size=11 title="$myconfig{dateformat}" value=$form->{"datepaid_$i"}></td>|;
655 $column_data{"source_$i"} =
656 qq|<td align=center><input name="source_$i" size=11 value=$form->{"source_$i"}></td>|;
657 $column_data{"memo_$i"} =
658 qq|<td align=center><input name="memo_$i" size=11 value=$form->{"memo_$i"}></td>|;
660 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
668 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
669 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
670 <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
675 <td><hr size=3 noshade></td>
681 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
682 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
685 print qq|<input class=submit type=submit name=action value="|
686 . $locale->text('Update') . qq|">
689 if (!$form->{revtrans}) {
690 if (!$form->{locked}) {
692 <input class=submit type=submit name=action value="|
693 . $locale->text('Post') . qq|">
694 <input class=submit type=submit name=action value="|
695 . $locale->text('Delete') . qq|">
700 if ($invdate > $closedto) {
702 <input class=submit type=submit name=action value="|
703 . $locale->text('Post as new') . qq|">
704 <input class=submit type=submit name=action value="|
705 . $locale->text('Order') . qq|">
710 if ($invdate > $closedto) {
711 print qq|<input class=submit type=submit name=action value="|
712 . $locale->text('Update') . qq|">
713 <input class=submit type=submit name=action value="|
714 . $locale->text('Post') . qq|">|;
718 if ($form->{menubar}) {
719 require "$form->{path}/menu.pl";
725 <input type=hidden name=rowcount value=$form->{rowcount}>
727 <input name=callback type=hidden value="$form->{callback}">
729 <input type=hidden name=path value=$form->{path}>
730 <input type=hidden name=login value=$form->{login}>
731 <input type=hidden name=password value=$form->{password}>
739 $lxdebug->leave_sub();
743 $lxdebug->enter_sub();
745 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
746 qw(exchangerate creditlimit creditremaining);
752 $form->{exchangerate} = $exchangerate
756 $form->check_exchangerate(
757 \%myconfig, $form->{currency}, $form->{invdate}, 'sell'
760 for $i (1 .. $form->{paidaccounts}) {
761 if ($form->{"paid_$i"}) {
764 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
765 } qw(paid exchangerate);
767 $form->{"exchangerate_$i"} = $exchangerate
769 $form->{"forex_$i"} = (
771 $form->check_exchangerate(
772 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
777 $i = $form->{rowcount};
778 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
780 if ( ($form->{"partnumber_$i"} eq "")
781 && ($form->{"description_$i"} eq "")
782 && ($form->{"partsgroup_$i"} eq "")) {
783 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
788 IR->retrieve_item(\%myconfig, \%$form);
790 my $rows = scalar @{ $form->{item_list} };
793 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
802 # override sellprice if there is one entered
803 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
805 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
806 qw(partnumber description unit);
808 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
809 keys %{ $form->{item_list}[0] };
811 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
813 ($dec) = ($s =~ /\.(\d+)/);
815 $decimalplaces = ($dec > 2) ? $dec : 2;
818 $form->{"sellprice_$i"} = $sellprice;
821 # if there is an exchange rate adjust sellprice
822 $form->{"sellprice_$i"} /= $exchangerate;
826 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
827 (1 - $form->{"discount_$i"} / 100);
828 $form->{creditremaining} -= $amount;
829 $form->{"sellprice_$i"} =
830 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
833 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
840 # ok, so this is a new part
841 # ask if it is a part or service item
843 if ( $form->{"partsgroup_$i"}
844 && ($form->{"partsnumber_$i"} eq "")
845 && ($form->{"description_$i"} eq "")) {
847 $form->{"discount_$i"} = "";
851 $form->{"id_$i"} = 0;
852 $form->{"unit_$i"} = $locale->text('ea');
859 $lxdebug->leave_sub();
863 $lxdebug->enter_sub();
865 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
866 $form->isblank("vendor", $locale->text('Vendor missing!'));
868 # if the vendor changed get new values
869 if (&check_name(vendor)) {
876 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
877 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
879 $form->error($locale->text('Cannot post invoice for a closed period!'))
880 if ($invdate <= $closedto);
882 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
883 if ($form->{currency} ne $form->{defaultcurrency});
885 for $i (1 .. $form->{paidaccounts}) {
886 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
887 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
889 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
891 $form->error($locale->text('Cannot post payment for a closed period!'))
892 if ($datepaid <= $closedto);
894 if ($form->{currency} ne $form->{defaultcurrency}) {
895 $form->{"exchangerate_$i"} = $form->{exchangerate}
896 if ($invdate == $datepaid);
897 $form->isblank("exchangerate_$i",
898 $locale->text('Exchangerate for payment missing!'));
903 ($form->{AP}) = split /--/, $form->{AP};
904 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
906 $form->{id} = 0 if $form->{postasnew};
908 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
909 if (!$form->{invnumber} || $form->{postasnew}) {
910 $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber");
913 $form->redirect( $locale->text('Invoice')
914 . " $form->{invnumber} "
915 . $locale->text('posted!'))
916 if (IR->post_invoice(\%myconfig, \%$form));
917 $form->error($locale->text('Cannot post invoice!'));
919 $lxdebug->leave_sub();
923 $lxdebug->enter_sub();
930 <form method=post action=$form->{script}>
933 # delete action variable
934 map { delete $form->{$_} } qw(action header);
936 foreach $key (keys %$form) {
937 $form->{$key} =~ s/\"/"/g;
938 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
942 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
945 . $locale->text('Are you sure you want to delete Invoice Number')
946 . qq| $form->{invnumber}</h4>
948 <input name=action class=submit type=submit value="|
949 . $locale->text('Yes') . qq|">
953 $lxdebug->leave_sub();
957 $lxdebug->enter_sub();
959 $form->redirect($locale->text('Invoice deleted!'))
960 if (IR->delete_invoice(\%myconfig, \%$form));
961 $form->error($locale->text('Cannot delete invoice!'));
963 $lxdebug->leave_sub();