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);
193 foreach $ref (@{ $form->{invoice_details} }) {
195 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
197 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
199 $decimalplaces = ($dec > 2) ? $dec : 2;
201 $form->{"sellprice_$i"} =
202 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
205 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
206 $dec_qty = length $dec_qty;
209 $form->format_amount(\%myconfig, ($form->{"qty_$i"} * -1), $dec_qty);
211 $form->{rowcount} = $i;
215 $lxdebug->leave_sub();
219 $lxdebug->enter_sub();
221 # set option selected
222 foreach $item (qw(AP vendor currency department contact)) {
223 $form->{"select$item"} =~ s/ selected//;
224 $form->{"select$item"} =~
225 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
229 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
231 #quote selectvendor Bug 133
232 $form->{"selectvendor"} = $form->quote($form->{"selectvendor"});
234 $form->{exchangerate} =
235 $form->format_amount(\%myconfig, $form->{exchangerate});
237 $form->{creditlimit} =
238 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
239 $form->{creditremaining} =
240 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
243 if ($form->{all_contacts}) {
245 $form->{selectcontact} = "";
246 foreach $item (@{ $form->{all_contacts} }) {
247 if ($form->{cp_id} == $item->{cp_id}) {
248 $form->{selectcontact} .=
249 "<option selected>$item->{cp_name}--$item->{cp_id}";
251 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
257 if ($form->{currency} ne $form->{defaultcurrency}) {
258 if ($form->{forex}) {
260 <th align=right nowrap>|
261 . $locale->text('Exchangerate') . qq|</th>
262 <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>
266 <th align=right nowrap>|
267 . $locale->text('Exchangerate') . qq|</th>
268 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
273 <input type=hidden name=forex value=$form->{forex}>
277 if (@{ $form->{TAXZONE} }) {
278 $form->{selecttaxzone} = "";
279 foreach $item (@{ $form->{TAXZONE} }) {
280 if ($item->{id} == $form->{taxzone_id}) {
281 $form->{selecttaxzone} .=
282 "<option value=$item->{id} selected>$item->{description}</option>";
284 $form->{selecttaxzone} .=
285 "<option value=$item->{id}>$item->{description}</option>";
290 $form->{selecttaxzone} =~ s/ selected//g;
291 if ($form->{taxzone_id} ne "") {
292 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
295 if ($form->{rowcount} >1) {
296 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
297 $form->{selecttaxzone} = $&;
303 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
304 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
305 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
311 ($form->{selectvendor})
312 ? qq|<select name=vendor>$form->{selectvendor}</select>\n<input type=hidden name="selectvendor" value="$form->{selectvendor}">|
313 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
316 ($form->{selectcontact})
317 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
318 : qq|<input name=contact value="$form->{contact}" size=35>|;
322 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
323 <td colspan=3><select name=department>$form->{selectdepartment}</select>
324 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
327 | if $form->{selectdepartment};
329 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
331 # use JavaScript Calendar or not
332 $form->{jsscript} = $form->{jscalendar};
334 if ($form->{jsscript}) {
336 # with JavaScript Calendar
338 <td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>
339 <td><input type=button name=invdate id="trigger1" value=|
340 . $locale->text('button') . qq|></td>
343 <td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
344 <td width="4"><input type=button name=duedate id="trigger2" value=|
345 . $locale->text('button') . qq|></td></td>
350 Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1",
351 "duedate", "BL", "trigger2");
354 # without JavaScript Calendar
356 qq|<td><input name=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>|;
358 qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
366 <form method=post action=$form->{script}>
368 <input type=hidden name=id value=$form->{id}>
369 <input type=hidden name=title value="$form->{title}">
370 <input type=hidden name=vc value="vendor">
371 <input type=hidden name=type value=$form->{type}>
372 <input type=hidden name=level value=$form->{level}>
374 <input type=hidden name=creditlimit value=$form->{creditlimit}>
375 <input type=hidden name=creditremaining value=$form->{creditremaining}>
377 <input type=hidden name=closedto value=$form->{closedto}>
378 <input type=hidden name=locked value=$form->{locked}>
380 <input type=hidden name=shipped value=$form->{shipped}>
381 <input type=hidden name=storno value=$form->{storno}>
382 <input type=hidden name=storno_id value=$form->{storno_id}>
386 <th class=listtop>$form->{title}</th>
396 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
397 <td colspan=3>$vendor</td>
399 <th align=richt nowrap>|
400 . $locale->text('Contact Person') . qq|</th>
401 <td colspan=3>$contact</td>
403 <input type=hidden name=vendor_id value=$form->{vendor_id}>
404 <input type=hidden name=oldvendor value="$form->{oldvendor}">
412 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
413 <td>$form->{creditlimit}</td>
415 <th nowrap>| . $locale->text('Remaining') . qq|</th>
416 <td class="plus$n">$form->{creditremaining}</td>
421 <th align=right>| . $locale->text('Record in') . qq|</th>
422 <td colspan=3><select name=AP>$form->{selectAP}</select></td>
423 <input type=hidden name=selectAP value="$form->{selectAP}">
428 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
429 <td><select name=currency>$form->{selectcurrency}</select></td>
437 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
438 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
441 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
445 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
449 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
450 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
451 <input type=hidden name=quonumber value="$form->{quonumber}">
462 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
463 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
464 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
465 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
466 <input type=hidden name=webdav value=$webdav>
468 <input type=hidden name=taxpart value="$form->{taxpart}">
469 <input type=hidden name=taxservice value="$form->{taxservice}">
471 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
474 foreach $item (split / /, $form->{taxaccounts}) {
476 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
477 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
481 $lxdebug->leave_sub();
485 $lxdebug->enter_sub();
487 $form->{invtotal} = $form->{invsubtotal};
489 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
492 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
495 $rows = ($rows > $introws) ? $rows : $introws;
497 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
499 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
501 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
504 if ($form->{taxaccounts}) {
506 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
507 . $locale->text('Tax Included') . qq|</b>
511 if (!$form->{taxincluded}) {
513 foreach $item (split / /, $form->{taxaccounts}) {
514 if ($form->{"${item}_base"}) {
515 $form->{invtotal} += $form->{"${item}_total"} =
517 $form->{"${item}_base"} * $form->{"${item}_rate"},
519 $form->{"${item}_total"} =
520 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
524 <th align=right>$form->{"${item}_description"}</th>
525 <td align=right>$form->{"${item}_total"}</td>
531 $form->{invsubtotal} =
532 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
536 <th align=right>| . $locale->text('Subtotal') . qq|</th>
537 <td align=right>$form->{invsubtotal}</td>
543 if ($form->{taxincluded}) {
544 foreach $item (split / /, $form->{taxaccounts}) {
545 if ($form->{"${item}_base"}) {
546 $form->{"${item}_total"} =
548 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
549 (1 + $form->{"${item}_rate"})
552 $form->{"${item}_base"} =
553 $form->round_amount($form->{"${item}_base"}, 2);
554 $form->{"${item}_netto"} =
556 ($form->{"${item}_base"} - $form->{"${item}_total"}),
558 $form->{"${item}_netto"} =
559 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
560 $form->{"${item}_total"} =
561 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
565 <th align=right>Enthaltene $form->{"${item}_description"}</th>
566 <td align=right>$form->{"${item}_total"}</td>
569 <th align=right>Nettobetrag</th>
570 <td align=right>$form->{"${item}_netto"}</td>
578 $form->{oldinvtotal} = $form->{invtotal};
580 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
584 <td colspan=$colspan>
585 <table cellspacing="0">
590 <th align=left>| . $locale->text('Notes') . qq|</th>
591 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
599 <td colspan=2 align=right width=100%>
606 <th align=right>| . $locale->text('Total') . qq|</th>
607 <td align=right>$form->{invtotal}</td>
619 <td><hr size=3 noshade></td>
622 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
625 <td align=left width=30%><b>Dateiname</b></td>
626 <td align=left width=70%><b>Webdavlink</b></td>
628 foreach $file (keys %{ $form->{WEBDAV} }) {
631 <td align=left>$file</td>
632 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
644 <input type=hidden name=jscalendar value=$form->{jscalendar}>
648 <td colspan=$colspan>
651 <th colspan=6 class=listheading>| . $locale->text('Payments') . qq|</th>
655 if ($form->{currency} eq $form->{defaultcurrency}) {
656 @column_index = qw(datepaid source memo paid AP_paid);
658 @column_index = qw(datepaid source memo paid exchangerate AP_paid);
661 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
662 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
663 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
664 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
665 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
666 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
671 map { print "$column_data{$_}\n" } @column_index;
676 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
677 for $i (1 .. $form->{paidaccounts}) {
683 $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
684 $form->{"selectAP_paid_$i"} =~
685 s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
689 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
690 $form->{"exchangerate_$i"} =
691 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
693 $exchangerate = qq| |;
694 if ($form->{currency} ne $form->{defaultcurrency}) {
695 if ($form->{"forex_$i"}) {
697 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
700 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
704 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
707 $column_data{"paid_$i"} =
708 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
709 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
710 $column_data{"AP_paid_$i"} =
711 qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
712 $column_data{"datepaid_$i"} =
713 qq|<td align=center><input name="datepaid_$i" size=11 title="$myconfig{dateformat}" value=$form->{"datepaid_$i"}></td>|;
714 $column_data{"source_$i"} =
715 qq|<td align=center><input name="source_$i" size=11 value=$form->{"source_$i"}></td>|;
716 $column_data{"memo_$i"} =
717 qq|<td align=center><input name="memo_$i" size=11 value=$form->{"memo_$i"}></td>|;
719 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
727 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
728 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
729 <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
734 <td><hr size=3 noshade></td>
740 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
741 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
744 print qq|<input class=submit type=submit name=action value="|
745 . $locale->text('Post Payment') . qq|">
747 print qq|<input class=submit type=submit name=action value="|
748 . $locale->text('Storno') . qq|">
749 | unless ($form->{storno});
750 if ($form->{radier}) {
752 <input class=submit type=submit name=action value="|
753 . $locale->text('Delete') . qq|">
757 if ($invdate > $closedto) {
758 print qq|<input class=submit type=submit name=action value="|
759 . $locale->text('Update') . qq|">
760 <input class=submit type=submit name=action value="|
761 . $locale->text('Post') . qq|">|;
765 if ($form->{menubar}) {
766 require "$form->{path}/menu.pl";
772 <input type=hidden name=rowcount value=$form->{rowcount}>
774 <input name=callback type=hidden value="$form->{callback}">
776 <input type=hidden name=path value=$form->{path}>
777 <input type=hidden name=login value=$form->{login}>
778 <input type=hidden name=password value=$form->{password}>
786 $lxdebug->leave_sub();
790 $lxdebug->enter_sub();
792 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
793 qw(exchangerate creditlimit creditremaining);
799 $form->{exchangerate} = $exchangerate
803 $form->check_exchangerate(
804 \%myconfig, $form->{currency}, $form->{invdate}, 'sell'
807 for $i (1 .. $form->{paidaccounts}) {
808 if ($form->{"paid_$i"}) {
811 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
812 } qw(paid exchangerate);
814 $form->{"exchangerate_$i"} = $exchangerate
816 $form->{"forex_$i"} = (
818 $form->check_exchangerate(
819 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
824 $i = $form->{rowcount};
825 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
827 if ( ($form->{"partnumber_$i"} eq "")
828 && ($form->{"description_$i"} eq "")
829 && ($form->{"partsgroup_$i"} eq "")) {
830 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
835 IR->retrieve_item(\%myconfig, \%$form);
837 my $rows = scalar @{ $form->{item_list} };
840 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
849 # override sellprice if there is one entered
850 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
852 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
853 qw(partnumber description unit);
855 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
856 keys %{ $form->{item_list}[0] };
858 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
860 ($dec) = ($s =~ /\.(\d+)/);
862 $decimalplaces = ($dec > 2) ? $dec : 2;
865 $form->{"sellprice_$i"} = $sellprice;
868 # if there is an exchange rate adjust sellprice
869 $form->{"sellprice_$i"} /= $exchangerate;
873 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
874 (1 - $form->{"discount_$i"} / 100);
875 $form->{creditremaining} -= $amount;
876 $form->{"sellprice_$i"} =
877 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
880 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
887 # ok, so this is a new part
888 # ask if it is a part or service item
890 if ( $form->{"partsgroup_$i"}
891 && ($form->{"partsnumber_$i"} eq "")
892 && ($form->{"description_$i"} eq "")) {
894 $form->{"discount_$i"} = "";
898 $form->{"id_$i"} = 0;
899 $form->{"unit_$i"} = $locale->text('ea');
906 $lxdebug->leave_sub();
910 $lxdebug->enter_sub();
912 if ($form->{storno}) {
913 $form->error($locale->text('Cannot storno storno invoice!'));
916 $form->{storno_id} = $form->{id};
919 $form->{invnumber} = "Storno zu " . $form->{invnumber};
923 $lxdebug->leave_sub();
928 $lxdebug->enter_sub();
929 for $i (1 .. $form->{paidaccounts}) {
930 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
931 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
933 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
935 $form->error($locale->text('Cannot post payment for a closed period!'))
936 if ($datepaid <= $closedto);
938 if ($form->{currency} ne $form->{defaultcurrency}) {
939 $form->{"exchangerate_$i"} = $form->{exchangerate}
940 if ($invdate == $datepaid);
941 $form->isblank("exchangerate_$i",
942 $locale->text('Exchangerate for payment missing!'));
947 ($form->{AP}) = split /--/, $form->{AP};
948 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
949 $form->redirect($locale->text(' Payment posted!'))
950 if (IR->post_payment(\%myconfig, \%$form));
951 $form->error($locale->text('Cannot post payment!'));
954 $lxdebug->leave_sub();
958 $lxdebug->enter_sub();
960 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
961 $form->isblank("vendor", $locale->text('Vendor missing!'));
963 # if the vendor changed get new values
964 if (&check_name(vendor)) {
971 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
972 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
974 $form->error($locale->text('Cannot post invoice for a closed period!'))
975 if ($invdate <= $closedto);
977 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
978 if ($form->{currency} ne $form->{defaultcurrency});
980 for $i (1 .. $form->{paidaccounts}) {
981 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
982 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
984 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
986 $form->error($locale->text('Cannot post payment for a closed period!'))
987 if ($datepaid <= $closedto);
989 if ($form->{currency} ne $form->{defaultcurrency}) {
990 $form->{"exchangerate_$i"} = $form->{exchangerate}
991 if ($invdate == $datepaid);
992 $form->isblank("exchangerate_$i",
993 $locale->text('Exchangerate for payment missing!'));
998 ($form->{AP}) = split /--/, $form->{AP};
999 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
1001 $form->{id} = 0 if $form->{postasnew};
1003 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
1004 if (!$form->{invnumber} || $form->{postasnew}) {
1005 $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber");
1009 $form->redirect( $locale->text('Invoice')
1010 . " $form->{invnumber} "
1011 . $locale->text('posted!'))
1012 if (IR->post_invoice(\%myconfig, \%$form));
1013 $form->error($locale->text('Cannot post invoice!'));
1015 $lxdebug->leave_sub();
1019 $lxdebug->enter_sub();
1026 <form method=post action=$form->{script}>
1029 # delete action variable
1030 map { delete $form->{$_} } qw(action header);
1032 foreach $key (keys %$form) {
1033 $form->{$key} =~ s/\"/"/g;
1034 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1038 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1041 . $locale->text('Are you sure you want to delete Invoice Number')
1042 . qq| $form->{invnumber}</h4>
1044 <input name=action class=submit type=submit value="|
1045 . $locale->text('Yes') . qq|">
1049 $lxdebug->leave_sub();
1053 $lxdebug->enter_sub();
1055 $form->redirect($locale->text('Invoice deleted!'))
1056 if (IR->delete_invoice(\%myconfig, \%$form));
1057 $form->error($locale->text('Cannot delete invoice!'));
1059 $lxdebug->leave_sub();