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};
89 if ($form->{payment_id}) {
90 $payment_id = $form->{payment_id};
92 if ($form->{language_id}) {
93 $language_id = $form->{language_id};
95 if ($form->{taxzone_id}) {
96 $taxzone_id = $form->{taxzone_id};
99 $cp_id = $form->{cp_id};
100 IR->get_vendor(\%myconfig, \%$form);
101 IR->retrieve_invoice(\%myconfig, \%$form);
102 $form->{cp_id} = $cp_id;
105 $form->{payment_id} = $payment_id;
108 $form->{language_id} = $language_id;
111 $form->{taxzone_id} = $taxzone_id;
115 @curr = split /:/, $form->{currencies};
117 $form->{defaultcurrency} = $curr[0];
119 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
121 $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
124 if ($form->{all_vendor}) {
125 $form->{vendor} = "$form->{vendor}--$form->{vendor_id}";
126 map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
127 (@{ $form->{all_vendor} });
131 if ($form->{all_departments}) {
132 $form->{selectdepartment} = "<option>\n";
133 $form->{department} = "$form->{department}--$form->{department_id}";
136 $form->{selectdepartment} .=
137 "<option>$_->{description}--$_->{id}\n"
138 } (@{ $form->{all_departments} });
142 $form->{forex} = $form->{exchangerate};
143 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
145 foreach $key (keys %{ $form->{AP_links} }) {
147 foreach $ref (@{ $form->{AP_links}{$key} }) {
148 $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
151 if ($key eq "AP_paid") {
152 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
153 $form->{"AP_paid_$i"} =
154 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
157 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
158 $form->{"datepaid_$i"} =
159 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
160 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
161 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
162 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
163 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
165 $form->{paidaccounts} = $i;
169 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
174 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
176 $form->{AP} = $form->{AP_1} unless $form->{id};
179 ($form->datetonum($form->{invdate}, \%myconfig) <=
180 $form->datetonum($form->{closedto}, \%myconfig));
182 $lxdebug->leave_sub();
185 sub prepare_invoice {
186 $lxdebug->enter_sub();
190 map { $form->{$_} =~ s/\"/"/g } qw(invnumber ordnumber quonumber);
192 foreach $ref (@{ $form->{invoice_details} }) {
194 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
196 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
198 $decimalplaces = ($dec > 2) ? $dec : 2;
200 $form->{"sellprice_$i"} =
201 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
204 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
205 $dec_qty = length $dec_qty;
208 $form->format_amount(\%myconfig, ($form->{"qty_$i"} * -1), $dec_qty);
210 $form->{rowcount} = $i;
214 $lxdebug->leave_sub();
218 $lxdebug->enter_sub();
220 # set option selected
221 foreach $item (qw(AP vendor currency department contact)) {
222 $form->{"select$item"} =~ s/ selected//;
223 $form->{"select$item"} =~
224 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
227 #quote selectvendor Bug 133
228 $form->{"selectvendor"} = $form->quote($form->{"selectvendor"});
230 $form->{exchangerate} =
231 $form->format_amount(\%myconfig, $form->{exchangerate});
233 $form->{creditlimit} =
234 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
235 $form->{creditremaining} =
236 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
239 if ($form->{all_contacts}) {
241 $form->{selectcontact} = "";
242 foreach $item (@{ $form->{all_contacts} }) {
243 if ($form->{cp_id} == $item->{cp_id}) {
244 $form->{selectcontact} .=
245 "<option selected>$item->{cp_name}--$item->{cp_id}";
247 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
253 if ($form->{currency} ne $form->{defaultcurrency}) {
254 if ($form->{forex}) {
256 <th align=right nowrap>|
257 . $locale->text('Exchangerate') . qq|</th>
258 <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>
262 <th align=right nowrap>|
263 . $locale->text('Exchangerate') . qq|</th>
264 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
269 <input type=hidden name=forex value=$form->{forex}>
273 if (@{ $form->{TAXZONE} }) {
274 $form->{selecttaxzone} = "";
275 foreach $item (@{ $form->{TAXZONE} }) {
276 if ($item->{id} == $form->{taxzone_id}) {
277 $form->{selecttaxzone} .=
278 "<option value=$item->{id} selected>$item->{description}</option>";
280 $form->{selecttaxzone} .=
281 "<option value=$item->{id}>$item->{description}</option>";
286 $form->{selecttaxzone} =~ s/ selected//g;
287 if ($form->{taxzone_id} ne "") {
288 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
291 if ($form->{rowcount} >1) {
292 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
293 $form->{selecttaxzone} = $&;
299 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
300 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
301 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
307 ($form->{selectvendor})
308 ? qq|<select name=vendor>$form->{selectvendor}</select>\n<input type=hidden name="selectvendor" value="$form->{selectvendor}">|
309 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
312 ($form->{selectcontact})
313 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
314 : qq|<input name=contact value="$form->{contact}" size=35>|;
318 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
319 <td colspan=3><select name=department>$form->{selectdepartment}</select>
320 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
323 | if $form->{selectdepartment};
325 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
327 # use JavaScript Calendar or not
328 $form->{jsscript} = $form->{jscalendar};
330 if ($form->{jsscript}) {
332 # with JavaScript Calendar
334 <td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>
335 <td><input type=button name=invdate id="trigger1" value=|
336 . $locale->text('button') . qq|></td>
339 <td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
340 <td width="4"><input type=button name=duedate id="trigger2" value=|
341 . $locale->text('button') . qq|></td></td>
346 Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1",
347 "duedate", "BL", "trigger2");
350 # without JavaScript Calendar
352 qq|<td><input name=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>|;
354 qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
362 <form method=post action=$form->{script}>
364 <input type=hidden name=id value=$form->{id}>
365 <input type=hidden name=title value="$form->{title}">
366 <input type=hidden name=vc value="vendor">
367 <input type=hidden name=type value=$form->{type}>
368 <input type=hidden name=level value=$form->{level}>
370 <input type=hidden name=creditlimit value=$form->{creditlimit}>
371 <input type=hidden name=creditremaining value=$form->{creditremaining}>
373 <input type=hidden name=closedto value=$form->{closedto}>
374 <input type=hidden name=locked value=$form->{locked}>
376 <input type=hidden name=shipped value=$form->{shipped}>
377 <input type=hidden name=storno value=$form->{storno}>
378 <input type=hidden name=storno_id value=$form->{storno_id}>
382 <th class=listtop>$form->{title}</th>
392 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
393 <td colspan=3>$vendor</td>
395 <th align=richt nowrap>|
396 . $locale->text('Contact Person') . qq|</th>
397 <td colspan=3>$contact</td>
399 <input type=hidden name=vendor_id value=$form->{vendor_id}>
400 <input type=hidden name=oldvendor value="$form->{oldvendor}">
408 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
409 <td>$form->{creditlimit}</td>
411 <th nowrap>| . $locale->text('Remaining') . qq|</th>
412 <td class="plus$n">$form->{creditremaining}</td>
417 <th align=right>| . $locale->text('Record in') . qq|</th>
418 <td colspan=3><select name=AP>$form->{selectAP}</select></td>
419 <input type=hidden name=selectAP value="$form->{selectAP}">
424 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
425 <td><select name=currency>$form->{selectcurrency}</select></td>
433 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
434 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
437 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
441 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
445 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
446 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
447 <input type=hidden name=quonumber value="$form->{quonumber}">
458 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
459 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
460 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
461 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
462 <input type=hidden name=webdav value=$webdav>
464 <input type=hidden name=taxpart value="$form->{taxpart}">
465 <input type=hidden name=taxservice value="$form->{taxservice}">
467 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
470 foreach $item (split / /, $form->{taxaccounts}) {
472 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
473 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
477 $lxdebug->leave_sub();
481 $lxdebug->enter_sub();
483 $form->{invtotal} = $form->{invsubtotal};
485 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
488 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
491 $rows = ($rows > $introws) ? $rows : $introws;
493 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
495 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
497 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
500 if ($form->{taxaccounts}) {
502 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
503 . $locale->text('Tax Included') . qq|</b>
507 if (!$form->{taxincluded}) {
509 foreach $item (split / /, $form->{taxaccounts}) {
510 if ($form->{"${item}_base"}) {
511 $form->{invtotal} += $form->{"${item}_total"} =
513 $form->{"${item}_base"} * $form->{"${item}_rate"},
515 $form->{"${item}_total"} =
516 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
520 <th align=right>$form->{"${item}_description"}</th>
521 <td align=right>$form->{"${item}_total"}</td>
527 $form->{invsubtotal} =
528 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
532 <th align=right>| . $locale->text('Subtotal') . qq|</th>
533 <td align=right>$form->{invsubtotal}</td>
539 if ($form->{taxincluded}) {
540 foreach $item (split / /, $form->{taxaccounts}) {
541 if ($form->{"${item}_base"}) {
542 $form->{"${item}_total"} =
544 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
545 (1 + $form->{"${item}_rate"})
548 $form->{"${item}_base"} =
549 $form->round_amount($form->{"${item}_base"}, 2);
550 $form->{"${item}_netto"} =
552 ($form->{"${item}_base"} - $form->{"${item}_total"}),
554 $form->{"${item}_netto"} =
555 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
556 $form->{"${item}_total"} =
557 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
561 <th align=right>Enthaltene $form->{"${item}_description"}</th>
562 <td align=right>$form->{"${item}_total"}</td>
565 <th align=right>Nettobetrag</th>
566 <td align=right>$form->{"${item}_netto"}</td>
574 $form->{oldinvtotal} = $form->{invtotal};
576 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
580 <td colspan=$colspan>
581 <table cellspacing="0">
586 <th align=left>| . $locale->text('Notes') . qq|</th>
587 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
595 <td colspan=2 align=right width=100%>
602 <th align=right>| . $locale->text('Total') . qq|</th>
603 <td align=right>$form->{invtotal}</td>
615 <td><hr size=3 noshade></td>
618 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
621 <td align=left width=30%><b>Dateiname</b></td>
622 <td align=left width=70%><b>Webdavlink</b></td>
624 foreach $file (keys %{ $form->{WEBDAV} }) {
627 <td align=left>$file</td>
628 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
640 <input type=hidden name=jscalendar value=$form->{jscalendar}>
644 <td colspan=$colspan>
647 <th colspan=6 class=listheading>| . $locale->text('Payments') . qq|</th>
651 if ($form->{currency} eq $form->{defaultcurrency}) {
652 @column_index = qw(datepaid source memo paid AP_paid);
654 @column_index = qw(datepaid source memo paid exchangerate AP_paid);
657 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
658 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
659 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
660 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
661 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
662 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
667 map { print "$column_data{$_}\n" } @column_index;
672 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
673 for $i (1 .. $form->{paidaccounts}) {
679 $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
680 $form->{"selectAP_paid_$i"} =~
681 s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
685 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
686 $form->{"exchangerate_$i"} =
687 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
689 $exchangerate = qq| |;
690 if ($form->{currency} ne $form->{defaultcurrency}) {
691 if ($form->{"forex_$i"}) {
693 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
696 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
700 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
703 $column_data{"paid_$i"} =
704 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
705 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
706 $column_data{"AP_paid_$i"} =
707 qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
708 $column_data{"datepaid_$i"} =
709 qq|<td align=center><input name="datepaid_$i" size=11 title="$myconfig{dateformat}" value=$form->{"datepaid_$i"}></td>|;
710 $column_data{"source_$i"} =
711 qq|<td align=center><input name="source_$i" size=11 value=$form->{"source_$i"}></td>|;
712 $column_data{"memo_$i"} =
713 qq|<td align=center><input name="memo_$i" size=11 value=$form->{"memo_$i"}></td>|;
715 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
723 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
724 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
725 <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
730 <td><hr size=3 noshade></td>
736 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
737 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
740 print qq|<input class=submit type=submit name=action value="|
741 . $locale->text('Post Payment') . qq|">
743 print qq|<input class=submit type=submit name=action value="|
744 . $locale->text('Storno') . qq|">
745 | unless ($form->{storno});
748 if ($invdate > $closedto) {
749 print qq|<input class=submit type=submit name=action value="|
750 . $locale->text('Update') . qq|">
751 <input class=submit type=submit name=action value="|
752 . $locale->text('Post') . qq|">|;
756 if ($form->{menubar}) {
757 require "$form->{path}/menu.pl";
763 <input type=hidden name=rowcount value=$form->{rowcount}>
765 <input name=callback type=hidden value="$form->{callback}">
767 <input type=hidden name=path value=$form->{path}>
768 <input type=hidden name=login value=$form->{login}>
769 <input type=hidden name=password value=$form->{password}>
777 $lxdebug->leave_sub();
781 $lxdebug->enter_sub();
783 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
784 qw(exchangerate creditlimit creditremaining);
790 $form->{exchangerate} = $exchangerate
794 $form->check_exchangerate(
795 \%myconfig, $form->{currency}, $form->{invdate}, 'sell'
798 for $i (1 .. $form->{paidaccounts}) {
799 if ($form->{"paid_$i"}) {
802 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
803 } qw(paid exchangerate);
805 $form->{"exchangerate_$i"} = $exchangerate
807 $form->{"forex_$i"} = (
809 $form->check_exchangerate(
810 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
815 $i = $form->{rowcount};
816 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
818 if ( ($form->{"partnumber_$i"} eq "")
819 && ($form->{"description_$i"} eq "")
820 && ($form->{"partsgroup_$i"} eq "")) {
821 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
826 $form->{"selected_unit_$i"} = $form->{"unit_$i"};
828 IR->retrieve_item(\%myconfig, \%$form);
830 my $rows = scalar @{ $form->{item_list} };
833 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
842 # override sellprice if there is one entered
843 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
845 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
846 qw(partnumber description unit);
848 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
849 keys %{ $form->{item_list}[0] };
851 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
853 ($dec) = ($s =~ /\.(\d+)/);
855 $decimalplaces = ($dec > 2) ? $dec : 2;
858 $form->{"sellprice_$i"} = $sellprice;
861 # if there is an exchange rate adjust sellprice
862 $form->{"sellprice_$i"} /= $exchangerate;
866 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
867 (1 - $form->{"discount_$i"} / 100);
868 $form->{creditremaining} -= $amount;
869 $form->{"sellprice_$i"} =
870 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
873 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
880 # ok, so this is a new part
881 # ask if it is a part or service item
883 if ( $form->{"partsgroup_$i"}
884 && ($form->{"partsnumber_$i"} eq "")
885 && ($form->{"description_$i"} eq "")) {
887 $form->{"discount_$i"} = "";
891 $form->{"id_$i"} = 0;
892 $form->{"unit_$i"} = $locale->text('ea');
899 $lxdebug->leave_sub();
903 $lxdebug->enter_sub();
905 if ($form->{storno}) {
906 $form->error($locale->text('Cannot storno storno invoice!'));
909 $form->{storno_id} = $form->{id};
912 $form->{invnumber} = "Storno zu " . $form->{invnumber};
916 $lxdebug->leave_sub();
921 $lxdebug->enter_sub();
922 for $i (1 .. $form->{paidaccounts}) {
923 if ($form->{"paid_$i"}) {
924 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
926 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
928 $form->error($locale->text('Cannot post payment for a closed period!'))
929 if ($datepaid <= $closedto);
931 if ($form->{currency} ne $form->{defaultcurrency}) {
932 $form->{"exchangerate_$i"} = $form->{exchangerate}
933 if ($invdate == $datepaid);
934 $form->isblank("exchangerate_$i",
935 $locale->text('Exchangerate for payment missing!'));
940 ($form->{AP}) = split /--/, $form->{AP};
941 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
942 $form->redirect($locale->text(' Payment posted!'))
943 if (IR->post_payment(\%myconfig, \%$form));
944 $form->error($locale->text('Cannot post payment!'));
947 $lxdebug->leave_sub();
951 $lxdebug->enter_sub();
953 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
954 $form->isblank("vendor", $locale->text('Vendor missing!'));
956 # if the vendor changed get new values
957 if (&check_name(vendor)) {
964 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
965 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
967 $form->error($locale->text('Cannot post invoice for a closed period!'))
968 if ($invdate <= $closedto);
970 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
971 if ($form->{currency} ne $form->{defaultcurrency});
973 for $i (1 .. $form->{paidaccounts}) {
974 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
975 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
977 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
979 $form->error($locale->text('Cannot post payment for a closed period!'))
980 if ($datepaid <= $closedto);
982 if ($form->{currency} ne $form->{defaultcurrency}) {
983 $form->{"exchangerate_$i"} = $form->{exchangerate}
984 if ($invdate == $datepaid);
985 $form->isblank("exchangerate_$i",
986 $locale->text('Exchangerate for payment missing!'));
991 ($form->{AP}) = split /--/, $form->{AP};
992 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
994 $form->{id} = 0 if $form->{postasnew};
996 $form->redirect( $locale->text('Invoice')
997 . " $form->{invnumber} "
998 . $locale->text('posted!'))
999 if (IR->post_invoice(\%myconfig, \%$form));
1000 $form->error($locale->text('Cannot post invoice!'));
1002 $lxdebug->leave_sub();
1006 $lxdebug->enter_sub();
1013 <form method=post action=$form->{script}>
1016 # delete action variable
1017 map { delete $form->{$_} } qw(action header);
1019 foreach $key (keys %$form) {
1020 $form->{$key} =~ s/\"/"/g;
1021 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1025 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1028 . $locale->text('Are you sure you want to delete Invoice Number')
1029 . qq| $form->{invnumber}</h4>
1031 <input name=action class=submit type=submit value="|
1032 . $locale->text('Yes') . qq|">
1036 $lxdebug->leave_sub();
1040 $lxdebug->enter_sub();
1042 $form->redirect($locale->text('Invoice deleted!'))
1043 if (IR->delete_invoice(\%myconfig, \%$form));
1044 $form->error($locale->text('Cannot delete invoice!'));
1046 $lxdebug->leave_sub();