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 if ($form->{all_vendor}) {
80 unless ($form->{vendor_id}) {
81 $form->{vendor_id} = $form->{all_vendor}->[0]->{id};
84 if ($form->{payment_id}) {
85 $payment_id = $form->{payment_id};
87 if ($form->{language_id}) {
88 $language_id = $form->{language_id};
90 if ($form->{taxzone_id}) {
91 $taxzone_id = $form->{taxzone_id};
94 $cp_id = $form->{cp_id};
95 IR->get_vendor(\%myconfig, \%$form);
96 IR->retrieve_invoice(\%myconfig, \%$form);
97 $form->{cp_id} = $cp_id;
100 $form->{payment_id} = $payment_id;
103 $form->{language_id} = $language_id;
106 $form->{taxzone_id} = $taxzone_id;
110 @curr = split /:/, $form->{currencies};
112 $form->{defaultcurrency} = $curr[0];
114 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
116 $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
119 if ($form->{all_vendor}) {
120 $form->{vendor} = "$form->{vendor}--$form->{vendor_id}";
121 map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
122 (@{ $form->{all_vendor} });
126 if ($form->{all_departments}) {
127 $form->{selectdepartment} = "<option>\n";
128 $form->{department} = "$form->{department}--$form->{department_id}";
131 $form->{selectdepartment} .=
132 "<option>$_->{description}--$_->{id}\n"
133 } (@{ $form->{all_departments} });
137 $form->{forex} = $form->{exchangerate};
138 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
140 foreach $key (keys %{ $form->{AP_links} }) {
142 foreach $ref (@{ $form->{AP_links}{$key} }) {
143 $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
146 if ($key eq "AP_paid") {
147 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
148 $form->{"AP_paid_$i"} =
149 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
152 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
153 $form->{"datepaid_$i"} =
154 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
155 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
156 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
157 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
158 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
160 $form->{paidaccounts} = $i;
164 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
169 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
171 $form->{AP} = $form->{AP_1} unless $form->{id};
174 ($form->datetonum($form->{invdate}, \%myconfig) <=
175 $form->datetonum($form->{closedto}, \%myconfig));
177 $lxdebug->leave_sub();
180 sub prepare_invoice {
181 $lxdebug->enter_sub();
185 map { $form->{$_} =~ s/\"/"/g } qw(invnumber ordnumber quonumber);
187 foreach $ref (@{ $form->{invoice_details} }) {
189 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
191 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
193 $decimalplaces = ($dec > 2) ? $dec : 2;
195 $form->{"sellprice_$i"} =
196 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
199 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
200 $dec_qty = length $dec_qty;
203 $form->format_amount(\%myconfig, ($form->{"qty_$i"} * -1), $dec_qty);
205 $form->{rowcount} = $i;
209 $lxdebug->leave_sub();
213 $lxdebug->enter_sub();
215 # set option selected
216 foreach $item (qw(AP vendor currency department contact)) {
217 $form->{"select$item"} =~ s/ selected//;
218 $form->{"select$item"} =~
219 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
222 $form->{exchangerate} =
223 $form->format_amount(\%myconfig, $form->{exchangerate});
225 $form->{creditlimit} =
226 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
227 $form->{creditremaining} =
228 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
231 if ($form->{all_contacts}) {
233 $form->{selectcontact} = "";
234 foreach $item (@{ $form->{all_contacts} }) {
235 if ($form->{cp_id} == $item->{cp_id}) {
236 $form->{selectcontact} .=
237 "<option selected>$item->{cp_name}--$item->{cp_id}";
239 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
245 if ($form->{currency} ne $form->{defaultcurrency}) {
246 if ($form->{forex}) {
248 <th align=right nowrap>|
249 . $locale->text('Exchangerate') . qq|</th>
250 <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>
254 <th align=right nowrap>|
255 . $locale->text('Exchangerate') . qq|</th>
256 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
261 <input type=hidden name=forex value=$form->{forex}>
265 if (@{ $form->{TAXZONE} }) {
266 $form->{selecttaxzone} = "";
267 foreach $item (@{ $form->{TAXZONE} }) {
268 if ($item->{id} == $form->{taxzone_id}) {
269 $form->{selecttaxzone} .=
270 "<option value=$item->{id} selected>$item->{description}</option>";
272 $form->{selecttaxzone} .=
273 "<option value=$item->{id}>$item->{description}</option>";
278 $form->{selecttaxzone} =~ s/ selected//g;
279 if ($form->{taxzone_id} ne "") {
280 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
283 if ($form->{rowcount} >1) {
284 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
285 $form->{selecttaxzone} = $&;
291 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
292 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
293 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
299 ($form->{selectvendor})
300 ? qq|<select name=vendor>$form->{selectvendor}</select>\n<input type=hidden name="selectvendor" value="$form->{selectvendor}">|
301 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
304 ($form->{selectcontact})
305 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
306 : qq|<input name=contact value="$form->{contact}" size=35>|;
310 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
311 <td colspan=3><select name=department>$form->{selectdepartment}</select>
312 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
315 | if $form->{selectdepartment};
317 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
319 # use JavaScript Calendar or not
320 $form->{jsscript} = $form->{jscalendar};
322 if ($form->{jsscript}) {
324 # with JavaScript Calendar
326 <td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>
327 <td><input type=button name=invdate id="trigger1" value=|
328 . $locale->text('button') . qq|></td>
331 <td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
332 <td width="4"><input type=button name=duedate id="trigger2" value=|
333 . $locale->text('button') . qq|></td></td>
338 Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1",
339 "duedate", "BL", "trigger2");
342 # without JavaScript Calendar
344 qq|<td><input name=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>|;
346 qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
354 <form method=post action=$form->{script}>
356 <input type=hidden name=id value=$form->{id}>
357 <input type=hidden name=title value="$form->{title}">
358 <input type=hidden name=vc value="vendor">
359 <input type=hidden name=type value=$form->{type}>
360 <input type=hidden name=level value=$form->{level}>
362 <input type=hidden name=creditlimit value=$form->{creditlimit}>
363 <input type=hidden name=creditremaining value=$form->{creditremaining}>
365 <input type=hidden name=closedto value=$form->{closedto}>
366 <input type=hidden name=locked value=$form->{locked}>
368 <input type=hidden name=shipped value=$form->{shipped}>
369 <input type=hidden name=storno value=$form->{storno}>
370 <input type=hidden name=storno_id value=$form->{storno_id}>
374 <th class=listtop>$form->{title}</th>
384 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
385 <td colspan=3>$vendor</td>
387 <th align=richt nowrap>|
388 . $locale->text('Contact Person') . qq|</th>
389 <td colspan=3>$contact</td>
391 <input type=hidden name=vendor_id value=$form->{vendor_id}>
392 <input type=hidden name=oldvendor value="$form->{oldvendor}">
400 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
401 <td>$form->{creditlimit}</td>
403 <th nowrap>| . $locale->text('Remaining') . qq|</th>
404 <td class="plus$n">$form->{creditremaining}</td>
409 <th align=right>| . $locale->text('Record in') . qq|</th>
410 <td colspan=3><select name=AP>$form->{selectAP}</select></td>
411 <input type=hidden name=selectAP value="$form->{selectAP}">
416 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
417 <td><select name=currency>$form->{selectcurrency}</select></td>
425 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
426 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
429 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
433 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
437 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
438 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
439 <input type=hidden name=quonumber value="$form->{quonumber}">
450 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
451 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
452 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
453 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
454 <input type=hidden name=webdav value=$webdav>
456 <input type=hidden name=taxpart value="$form->{taxpart}">
457 <input type=hidden name=taxservice value="$form->{taxservice}">
459 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
462 foreach $item (split / /, $form->{taxaccounts}) {
464 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
465 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
469 $lxdebug->leave_sub();
473 $lxdebug->enter_sub();
475 $form->{invtotal} = $form->{invsubtotal};
477 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
480 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
483 $rows = ($rows > $introws) ? $rows : $introws;
485 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
487 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
489 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
492 if ($form->{taxaccounts}) {
494 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
495 . $locale->text('Tax Included') . qq|</b>
499 if (!$form->{taxincluded}) {
501 foreach $item (split / /, $form->{taxaccounts}) {
502 if ($form->{"${item}_base"}) {
503 $form->{invtotal} += $form->{"${item}_total"} =
505 $form->{"${item}_base"} * $form->{"${item}_rate"},
507 $form->{"${item}_total"} =
508 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
512 <th align=right>$form->{"${item}_description"}</th>
513 <td align=right>$form->{"${item}_total"}</td>
519 $form->{invsubtotal} =
520 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
524 <th align=right>| . $locale->text('Subtotal') . qq|</th>
525 <td align=right>$form->{invsubtotal}</td>
531 if ($form->{taxincluded}) {
532 foreach $item (split / /, $form->{taxaccounts}) {
533 if ($form->{"${item}_base"}) {
534 $form->{"${item}_total"} =
536 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
537 (1 + $form->{"${item}_rate"})
540 $form->{"${item}_base"} =
541 $form->round_amount($form->{"${item}_base"}, 2);
542 $form->{"${item}_netto"} =
544 ($form->{"${item}_base"} - $form->{"${item}_total"}),
546 $form->{"${item}_netto"} =
547 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
548 $form->{"${item}_total"} =
549 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
553 <th align=right>Enthaltene $form->{"${item}_description"}</th>
554 <td align=right>$form->{"${item}_total"}</td>
557 <th align=right>Nettobetrag</th>
558 <td align=right>$form->{"${item}_netto"}</td>
566 $form->{oldinvtotal} = $form->{invtotal};
568 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
572 <td colspan=$colspan>
573 <table cellspacing="0">
578 <th align=left>| . $locale->text('Notes') . qq|</th>
579 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
587 <td colspan=2 align=right width=100%>
594 <th align=right>| . $locale->text('Total') . qq|</th>
595 <td align=right>$form->{invtotal}</td>
607 <td><hr size=3 noshade></td>
610 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
613 <td align=left width=30%><b>Dateiname</b></td>
614 <td align=left width=70%><b>Webdavlink</b></td>
616 foreach $file (keys %{ $form->{WEBDAV} }) {
619 <td align=left>$file</td>
620 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
632 <input type=hidden name=jscalendar value=$form->{jscalendar}>
636 <td colspan=$colspan>
639 <th colspan=6 class=listheading>| . $locale->text('Payments') . qq|</th>
643 if ($form->{currency} eq $form->{defaultcurrency}) {
644 @column_index = qw(datepaid source memo paid AP_paid);
646 @column_index = qw(datepaid source memo paid exchangerate AP_paid);
649 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
650 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
651 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
652 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
653 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
654 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
659 map { print "$column_data{$_}\n" } @column_index;
664 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
665 for $i (1 .. $form->{paidaccounts}) {
671 $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
672 $form->{"selectAP_paid_$i"} =~
673 s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
677 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
678 $form->{"exchangerate_$i"} =
679 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
681 $exchangerate = qq| |;
682 if ($form->{currency} ne $form->{defaultcurrency}) {
683 if ($form->{"forex_$i"}) {
685 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
688 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
692 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
695 $column_data{"paid_$i"} =
696 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
697 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
698 $column_data{"AP_paid_$i"} =
699 qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
700 $column_data{"datepaid_$i"} =
701 qq|<td align=center><input name="datepaid_$i" size=11 title="$myconfig{dateformat}" value=$form->{"datepaid_$i"}></td>|;
702 $column_data{"source_$i"} =
703 qq|<td align=center><input name="source_$i" size=11 value=$form->{"source_$i"}></td>|;
704 $column_data{"memo_$i"} =
705 qq|<td align=center><input name="memo_$i" size=11 value=$form->{"memo_$i"}></td>|;
707 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
715 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
716 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
717 <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
722 <td><hr size=3 noshade></td>
728 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
729 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
732 print qq|<input class=submit type=submit name=action value="|
733 . $locale->text('Post Payment') . qq|">
735 print qq|<input class=submit type=submit name=action value="|
736 . $locale->text('Storno') . qq|">
737 | unless ($form->{storno});
740 if ($invdate > $closedto) {
741 print qq|<input class=submit type=submit name=action value="|
742 . $locale->text('Update') . qq|">
743 <input class=submit type=submit name=action value="|
744 . $locale->text('Post') . qq|">|;
748 if ($form->{menubar}) {
749 require "$form->{path}/menu.pl";
755 <input type=hidden name=rowcount value=$form->{rowcount}>
757 <input name=callback type=hidden value="$form->{callback}">
759 <input type=hidden name=path value=$form->{path}>
760 <input type=hidden name=login value=$form->{login}>
761 <input type=hidden name=password value=$form->{password}>
769 $lxdebug->leave_sub();
773 $lxdebug->enter_sub();
775 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
776 qw(exchangerate creditlimit creditremaining);
782 $form->{exchangerate} = $exchangerate
786 $form->check_exchangerate(
787 \%myconfig, $form->{currency}, $form->{invdate}, 'sell'
790 for $i (1 .. $form->{paidaccounts}) {
791 if ($form->{"paid_$i"}) {
794 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
795 } qw(paid exchangerate);
797 $form->{"exchangerate_$i"} = $exchangerate
799 $form->{"forex_$i"} = (
801 $form->check_exchangerate(
802 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
807 $i = $form->{rowcount};
808 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
810 if ( ($form->{"partnumber_$i"} eq "")
811 && ($form->{"description_$i"} eq "")
812 && ($form->{"partsgroup_$i"} eq "")) {
813 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
818 $form->{"selected_unit_$i"} = $form->{"unit_$i"};
820 IR->retrieve_item(\%myconfig, \%$form);
822 my $rows = scalar @{ $form->{item_list} };
825 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
834 # override sellprice if there is one entered
835 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
837 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
838 qw(partnumber description unit);
840 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
841 keys %{ $form->{item_list}[0] };
843 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
845 ($dec) = ($s =~ /\.(\d+)/);
847 $decimalplaces = ($dec > 2) ? $dec : 2;
850 $form->{"sellprice_$i"} = $sellprice;
853 # if there is an exchange rate adjust sellprice
854 $form->{"sellprice_$i"} /= $exchangerate;
858 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
859 (1 - $form->{"discount_$i"} / 100);
860 $form->{creditremaining} -= $amount;
861 $form->{"sellprice_$i"} =
862 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
865 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
872 # ok, so this is a new part
873 # ask if it is a part or service item
875 if ( $form->{"partsgroup_$i"}
876 && ($form->{"partsnumber_$i"} eq "")
877 && ($form->{"description_$i"} eq "")) {
879 $form->{"discount_$i"} = "";
883 $form->{"id_$i"} = 0;
884 $form->{"unit_$i"} = $locale->text('ea');
891 $lxdebug->leave_sub();
895 $lxdebug->enter_sub();
897 if ($form->{storno}) {
898 $form->error($locale->text('Cannot storno storno invoice!'));
901 $form->{storno_id} = $form->{id};
904 $form->{invnumber} = "Storno zu " . $form->{invnumber};
908 $lxdebug->leave_sub();
913 $lxdebug->enter_sub();
914 for $i (1 .. $form->{paidaccounts}) {
915 if ($form->{"paid_$i"}) {
916 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
918 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
920 $form->error($locale->text('Cannot post payment for a closed period!'))
921 if ($datepaid <= $closedto);
923 if ($form->{currency} ne $form->{defaultcurrency}) {
924 $form->{"exchangerate_$i"} = $form->{exchangerate}
925 if ($invdate == $datepaid);
926 $form->isblank("exchangerate_$i",
927 $locale->text('Exchangerate for payment missing!'));
932 ($form->{AP}) = split /--/, $form->{AP};
933 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
934 $form->redirect($locale->text(' Payment posted!'))
935 if (IR->post_payment(\%myconfig, \%$form));
936 $form->error($locale->text('Cannot post payment!'));
939 $lxdebug->leave_sub();
943 $lxdebug->enter_sub();
945 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
946 $form->isblank("vendor", $locale->text('Vendor missing!'));
948 # if the vendor changed get new values
949 if (&check_name(vendor)) {
956 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
957 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
959 $form->error($locale->text('Cannot post invoice for a closed period!'))
960 if ($invdate <= $closedto);
962 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
963 if ($form->{currency} ne $form->{defaultcurrency});
965 for $i (1 .. $form->{paidaccounts}) {
966 if ($form->{"paid_$i"}) {
967 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
969 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
971 $form->error($locale->text('Cannot post payment for a closed period!'))
972 if ($datepaid <= $closedto);
974 if ($form->{currency} ne $form->{defaultcurrency}) {
975 $form->{"exchangerate_$i"} = $form->{exchangerate}
976 if ($invdate == $datepaid);
977 $form->isblank("exchangerate_$i",
978 $locale->text('Exchangerate for payment missing!'));
983 ($form->{AP}) = split /--/, $form->{AP};
984 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
986 $form->{id} = 0 if $form->{postasnew};
988 $form->redirect( $locale->text('Invoice')
989 . " $form->{invnumber} "
990 . $locale->text('posted!'))
991 if (IR->post_invoice(\%myconfig, \%$form));
992 $form->error($locale->text('Cannot post invoice!'));
994 $lxdebug->leave_sub();
998 $lxdebug->enter_sub();
1005 <form method=post action=$form->{script}>
1008 # delete action variable
1009 map { delete $form->{$_} } qw(action header);
1011 foreach $key (keys %$form) {
1012 $form->{$key} =~ s/\"/"/g;
1013 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1017 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1020 . $locale->text('Are you sure you want to delete Invoice Number')
1021 . qq| $form->{invnumber}</h4>
1023 <input name=action class=submit type=submit value="|
1024 . $locale->text('Yes') . qq|">
1028 $lxdebug->leave_sub();
1032 $lxdebug->enter_sub();
1034 $form->redirect($locale->text('Invoice deleted!'))
1035 if (IR->delete_invoice(\%myconfig, \%$form));
1036 $form->error($locale->text('Cannot delete invoice!'));
1038 $lxdebug->leave_sub();