X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=de2625f96a5409e02501e515d9b8925867b6c06b;hb=4e27e828de91b6f1252f3353f06edea72f13a0c1;hp=f6df8494ba2ad69230f6c984ab28a53a41e5b97a;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index f6df8494b..de2625f96 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -31,18 +31,16 @@ # #====================================================================== - use SL::IR; use SL::PE; - require "$form->{path}/io.pl"; require "$form->{path}/arap.pl"; +require "$form->{path}/common.pl"; 1; -# end of main - +# end of main sub add { $lxdebug->enter_sub(); @@ -52,48 +50,74 @@ sub add { &invoice_links; &prepare_invoice; &display_form; - + $lxdebug->leave_sub(); } - sub edit { $lxdebug->enter_sub(); - + + # show history button + $form->{javascript} = qq||; + #/show hhistory button + $form->{title} = $locale->text('Edit Vendor Invoice'); &invoice_links; &prepare_invoice; &display_form; - + $lxdebug->leave_sub(); } - sub invoice_links { $lxdebug->enter_sub(); # create links $form->{webdav} = $webdav; - + # set jscalendar $form->{jscalendar} = $jscalendar; - + $form->create_links("AP", \%myconfig, "vendor"); + #quote all_vendor Bug 133 + foreach $ref (@{ $form->{all_vendor} }) { + $ref->{name} = $form->quote($ref->{name}); + } + if ($form->{all_vendor}) { unless ($form->{vendor_id}) { $form->{vendor_id} = $form->{all_vendor}->[0]->{id}; } } - + if ($form->{payment_id}) { + $payment_id = $form->{payment_id}; + } + if ($form->{language_id}) { + $language_id = $form->{language_id}; + } + if ($form->{taxzone_id}) { + $taxzone_id = $form->{taxzone_id}; + } + $cp_id = $form->{cp_id}; IR->get_vendor(\%myconfig, \%$form); IR->retrieve_invoice(\%myconfig, \%$form); $form->{cp_id} = $cp_id; - + + if ($payment_id) { + $form->{payment_id} = $payment_id; + } + if ($language_id) { + $form->{language_id} = $language_id; + } + if ($taxzone_id) { + $form->{taxzone_id} = $taxzone_id; + } + # currencies - @curr = split /:/, $form->{currencies}; + @curr = split(/:/, $form->{currencies}); chomp $curr[0]; $form->{defaultcurrency} = $curr[0]; @@ -102,23 +126,27 @@ sub invoice_links { $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}"; # vendors - if ($form->{all_vendor}) { + if (@{ $form->{all_vendor} }) { $form->{vendor} = "$form->{vendor}--$form->{vendor_id}"; - map { $form->{selectvendor} .= ""; + } else { + $form->{selecttaxzone} .= + ""; + } + + } + } else { + $form->{selecttaxzone} =~ s/ selected//g; + if ($form->{taxzone_id} ne "") { + $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/; + } + } + + $taxzone = qq| + + | . $locale->text('Steuersatz') . qq| + + + |; + + + + $vendor = + ($form->{selectvendor}) + ? qq|\n| + : qq||; + $department = qq| - |.$locale->text('Department').qq| + | . $locale->text('Department') . qq| @@ -247,27 +342,40 @@ sub form_header { # use JavaScript Calendar or not $form->{jsscript} = $form->{jscalendar}; $jsscript = ""; - if ($form->{jsscript}) - { + if ($form->{jsscript}) { + # with JavaScript Calendar $button1 = qq| {invdate}> - text('button').qq|> + text('button') . qq|> |; - $button2 = qq| + $button2 = qq| {duedate}> - text('button').qq|> + text('button') . qq|> |; - #write Trigger - $jsscript = Form->write_trigger(\%myconfig,"2","invdate","BL","trigger1","duedate","BL","trigger2"); - } - else - { - # without JavaScript Calendar - $button1 = qq|{invdate}>|; - $button2 = qq|{duedate}>|; - } - + + #write Trigger + $jsscript = + Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1", + "duedate", "BL", "trigger2"); + } else { + + # without JavaScript Calendar + $button1 = + qq|{invdate}>|; + $button2 = + qq|{duedate}>|; + } + + $form->{"javascript"} .= qq||; + + $jsscript .= + $form->write_trigger(\%myconfig, 2, + "orddate", "BL", "trigger_orddate", + "quodate", "BL", "trigger_quodate"); + $form->header; print qq| @@ -279,6 +387,7 @@ sub form_header { {type}> +{level}> {creditlimit}> {creditremaining}> @@ -287,7 +396,8 @@ sub form_header { {locked}> {shipped}> - +{storno}> +{storno_id}> @@ -301,12 +411,13 @@ sub form_header {
- + - - + + - + {vendor_id}> @@ -316,22 +427,23 @@ sub form_header { - + + $taxzone $department - + $exchangerate @@ -340,23 +452,37 @@ sub form_header { + + + + + + + + + + + + + +
|.$locale->text('Vendor').qq|| . $locale->text('Vendor') . qq| $vendor|.$locale->text('Contact Person').qq|| + . $locale->text('Contact Person') . qq| $contact - + - +
|.$locale->text('Credit Limit').qq|| . $locale->text('Credit Limit') . qq| $form->{creditlimit} |.$locale->text('Remaining').qq|| . $locale->text('Remaining') . qq| $form->{creditremaining}
|.$locale->text('Record in').qq|| . $locale->text('Record in') . qq|
|.$locale->text('Currency').qq|| . $locale->text('Currency') . qq|
- + - + $button1 - + $button2 - + -
|.$locale->text('Invoice Number').qq|| . $locale->text('Invoice Number') . qq|
|.$locale->text('Invoice Date').qq|| . $locale->text('Invoice Date') . qq|
|.$locale->text('Due Date').qq|| . $locale->text('Due Date') . qq|
|.$locale->text('Order Number').qq|| . $locale->text('Order Number') . qq|
+
| . $locale->text('Order Date') . qq|
| . $locale->text('Quotation Date') . qq|
| . $locale->text('Project Number') . qq|$globalprojectnumber
@@ -364,7 +490,7 @@ sub form_header { $jsscript - + {defaultcurrency}> {fxgain_accno}> @@ -387,13 +513,11 @@ $jsscript $lxdebug->leave_sub(); } - - sub form_footer { $lxdebug->enter_sub(); $form->{invtotal} = $form->{invsubtotal}; - + if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) { $rows = 2; } @@ -401,59 +525,78 @@ sub form_footer { $introws = 2; } $rows = ($rows > $introws) ? $rows : $introws; - $notes = qq||; - $intnotes = qq||; - + $notes = + qq||; + $intnotes = + qq||; + $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; $taxincluded = ""; if ($form->{taxaccounts}) { $taxincluded = qq| - {taxincluded}> |.$locale->text('Tax Included').qq| + {taxincluded}> | + . $locale->text('Tax Included') . qq| |; } - + if (!$form->{taxincluded}) { - + foreach $item (split / /, $form->{taxaccounts}) { if ($form->{"${item}_base"}) { - $form->{invtotal} += $form->{"${item}_total"} = $form->round_amount($form->{"${item}_base"} * $form->{"${item}_rate"}, 2); - $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); - - $tax .= qq| + $form->{invtotal} += $form->{"${item}_total"} = + $form->round_amount( + $form->{"${item}_base"} * $form->{"${item}_rate"}, + 2); + $form->{"${item}_total"} = + $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); + + $tax .= qq| - $form->{"${item}_description"} + $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"} |; } } - + $form->{invsubtotal} = + $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0); - $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0); - $subtotal = qq| - |.$locale->text('Subtotal').qq| + | . $locale->text('Subtotal') . qq| $form->{invsubtotal} |; } - + if ($form->{taxincluded}) { - foreach $item (split / /, $form->{taxaccounts}) { - if ($form->{"${item}_base"}) { - $form->{"${item}_total"} = $form->round_amount(($form->{"${item}_base"} * $form->{"${item}_rate"} / (1 + $form->{"${item}_rate"})) , 2); - $form->{"${item}_base"} = $form->round_amount($form->{"${item}_base"}, 2); - $form->{"${item}_netto"} = $form->round_amount(($form->{"${item}_base"}-$form->{"${item}_total"}), 2); - $form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2); - $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); - - $tax .= qq| + foreach $item (split / /, $form->{taxaccounts}) { + if ($form->{"${item}_base"}) { + $form->{"${item}_total"} = + $form->round_amount( + ($form->{"${item}_base"} * $form->{"${item}_rate"} / + (1 + $form->{"${item}_rate"}) + ), + 2); + $form->{"${item}_base"} = + $form->round_amount($form->{"${item}_base"}, 2); + $form->{"${item}_netto"} = + $form->round_amount( + ($form->{"${item}_base"} - $form->{"${item}_total"}), + 2); + $form->{"${item}_netto"} = + $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2); + $form->{"${item}_total"} = + $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); + + $tax .= qq| - Enthaltene $form->{"${item}_description"} + Enthaltene $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"} @@ -463,12 +606,12 @@ sub form_footer { |; } } - - + } - $form->{oldinvtotal} = $form->{invtotal}; - $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0); + $form->{oldinvtotal} = $form->{invtotal}; + $form->{invtotal} = + $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0); print qq| @@ -478,8 +621,8 @@ sub form_footer { - - + + @@ -494,7 +637,7 @@ sub form_footer { $subtotal $tax 0 - +
|.$locale->text('Notes').qq||.$locale->text('Internal Notes').qq|| . $locale->text('Notes') . qq|| . $locale->text('Internal Notes') . qq|
$notes
|.$locale->text('Total').qq|| . $locale->text('Total') . qq| $form->{invtotal}
@@ -505,106 +648,121 @@ sub form_footer { |; if ($webdav) { - $webdav_list = qq| + $webdav_list = qq|
- + Dokumente im Webdav-Repository |; - foreach $file (keys %{ $form->{WEBDAV}}) { - $webdav_list .= qq| - + foreach $file (keys %{ $form->{WEBDAV} }) { + $webdav_list .= qq| + |; - } - $webdav_list .= qq| + } + $webdav_list .= qq|
Dateiname Webdavlink
$file $form->{WEBDAV}{$file}
|; -print $webdav_list; -} -print qq| + print $webdav_list; + } + print qq| {jscalendar}> |; -print qq| + print qq| - + |; - if ($form->{currency} eq $form->{defaultcurrency}) { - @column_index = qw(datepaid source memo paid AP_paid); - } else { - @column_index = qw(datepaid source memo paid exchangerate AP_paid); - } + if ($form->{currency} eq $form->{defaultcurrency}) { + @column_index = qw(datepaid source memo paid AP_paid); + } else { + @column_index = qw(datepaid source memo paid exchangerate AP_paid); + } - $column_data{datepaid} = ""; - $column_data{paid} = ""; - $column_data{exchangerate} = ""; - $column_data{AP_paid} = ""; - $column_data{source} = ""; - $column_data{memo} = ""; + $column_data{datepaid} = ""; + $column_data{paid} = ""; + $column_data{exchangerate} = ""; + $column_data{AP_paid} = ""; + $column_data{source} = ""; + $column_data{memo} = ""; - print qq| + print qq| |; - map { print "$column_data{$_}\n" } @column_index; - print qq| + map { print "$column_data{$_}\n" } @column_index; + print qq| |; - $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); - for $i (1 .. $form->{paidaccounts}) { + my @triggers = (); + $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); + for $i (1 .. $form->{paidaccounts}) { - print qq| + print qq| |; - $form->{"selectAP_paid_$i"} = $form->{selectAP_paid}; - $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/; - - # format amounts - $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); - $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); + $form->{"selectAP_paid_$i"} = $form->{selectAP_paid}; + $form->{"selectAP_paid_$i"} =~ + s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/; - $exchangerate = qq| |; - if ($form->{currency} ne $form->{defaultcurrency}) { - if ($form->{"forex_$i"}) { - $exchangerate = qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; - } else { - $exchangerate = qq|{"exchangerate_$i"}>|; - } + # format amounts + if ($form->{"paid_$i"}) { + $form->{"paid_$i"} = + $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); + } + $form->{"exchangerate_$i"} = + $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); + + $exchangerate = qq| |; + if ($form->{currency} ne $form->{defaultcurrency}) { + if ($form->{"forex_$i"}) { + $exchangerate = + qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; + } else { + $exchangerate = + qq|{"exchangerate_$i"}>|; } - $exchangerate .= qq| + } + $exchangerate .= qq| {"forex_$i"}> |; - $column_data{"paid_$i"} = qq||; - $column_data{"exchangerate_$i"} = qq||; - $column_data{"AP_paid_$i"} = qq||; - $column_data{"datepaid_$i"} = qq||; - $column_data{"source_$i"} = qq||; - $column_data{"memo_$i"} = qq||; + $column_data{"paid_$i"} = + qq||; + $column_data{"exchangerate_$i"} = qq||; + $column_data{"AP_paid_$i"} = + qq||; + $column_data{"datepaid_$i"} = + qq||; + $column_data{"source_$i"} = + qq||; + $column_data{"memo_$i"} = + qq||; + + map { print qq|$column_data{"${_}_$i"}\n| } @column_index; - map { print qq|$column_data{"${_}_$i"}\n| } @column_index; - - print qq| + print qq| |; - } - - print qq| + push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); + } + + print qq| {oldinvtotal}> {paidaccounts}> @@ -618,42 +776,38 @@ print qq|
|; - $invdate = $form->datetonum($form->{invdate}, \%myconfig); + $invdate = $form->datetonum($form->{invdate}, \%myconfig); $closedto = $form->datetonum($form->{closedto}, \%myconfig); - + if ($form->{id}) { - print qq| + print qq| |; - - if (!$form->{revtrans}) { - if (!$form->{locked}) { - print qq| - - + print qq| +| unless ($form->{storno}); + if ($form->{radier}) { + print qq| + |; - } - } - - if ($invdate > $closedto) { - print qq| - - + } + print qq| |; - } - } else { - if ($invdate > $closedto) { - print qq| - |; - } } - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + print qq||; + + if (!$form->{id} && ($invdate > $closedto)) { + print qq| |; } - -print qq| + + print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) . + qq| {rowcount}> @@ -662,8 +816,19 @@ print qq| {path}> {login}> {password}> +|; + # button for saving history + if($form->{id} ne "") { + print qq| + {id} + . qq|); name=history id=history value=| + . $locale->text('history') + . qq|>|; + } + # /button for saving history - +print qq| @@ -672,92 +837,117 @@ print qq| $lxdebug->leave_sub(); } - - sub update { $lxdebug->enter_sub(); - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); - + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } + qw(exchangerate creditlimit creditremaining); + &check_name(vendor); - &check_project; + $form->{exchangerate} = $exchangerate + if ( + $form->{forex} = ( + $exchangerate = + $form->check_exchangerate( + \%myconfig, $form->{currency}, $form->{invdate}, 'sell' + ))); - $form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'))); - - for $i (1 .. $form->{paidaccounts}) { if ($form->{"paid_$i"}) { - map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); - - $form->{"exchangerate_$i"} = $exchangerate if ($form->{"forex_$i"} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'))); + map { + $form->{"${_}_$i"} = + $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) + } qw(paid exchangerate); + + $form->{"exchangerate_$i"} = $exchangerate + if ( + $form->{"forex_$i"} = ( + $exchangerate = + $form->check_exchangerate( + \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell' + ))); } } - - $i = $form->{rowcount}; + + $i = $form->{rowcount}; $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; - if (($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq "")) { + if ( ($form->{"partnumber_$i"} eq "") + && ($form->{"description_$i"} eq "") + && ($form->{"partsgroup_$i"} eq "")) { $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid}); &check_form; - + } else { - + IR->retrieve_item(\%myconfig, \%$form); my $rows = scalar @{ $form->{item_list} }; if ($rows) { - $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); - + $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); + if ($rows > 1) { - - &select_item; - exit; - + + &select_item; + exit; + } else { + # override sellprice if there is one entered - $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); + $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); - map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); - - map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; + map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } + qw(partnumber description unit); + + map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } + keys %{ $form->{item_list}[0] }; + + $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; + + ($dec) = ($s =~ /\.(\d+)/); + $dec = length $dec; + $decimalplaces = ($dec > 2) ? $dec : 2; - $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; - - ($dec) = ($s =~ /\.(\d+)/); - $dec = length $dec; - $decimalplaces = ($dec > 2) ? $dec : 2; - if ($sellprice) { - $form->{"sellprice_$i"} = $sellprice; - } else { - # if there is an exchange rate adjust sellprice - $form->{"sellprice_$i"} /= $exchangerate; - } - - $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); - $form->{creditremaining} -= $amount; - $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); + $form->{"sellprice_$i"} = $sellprice; + } else { + + # if there is an exchange rate adjust sellprice + $form->{"sellprice_$i"} /= $exchangerate; + } + + $amount = + $form->{"sellprice_$i"} * $form->{"qty_$i"} * + (1 - $form->{"discount_$i"} / 100); + $form->{creditremaining} -= $amount; + $form->{"sellprice_$i"} = + $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, + $decimalplaces); + $form->{"qty_$i"} = + $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); } &display_form; } else { + # ok, so this is a new part # ask if it is a part or service item - if ($form->{"partsgroup_$i"} && ($form->{"partsnumber_$i"} eq "") && ($form->{"description_$i"} eq "")) { - $form->{rowcount}--; - $form->{"discount_$i"} = ""; - &display_form; - } else { - - $form->{"id_$i"} = 0; - $form->{"unit_$i"} = $locale->text('ea'); + if ( $form->{"partsgroup_$i"} + && ($form->{"partsnumber_$i"} eq "") + && ($form->{"description_$i"} eq "")) { + $form->{rowcount}--; + $form->{"discount_$i"} = ""; + &display_form; + } else { + + $form->{"id_$i"} = 0; + $form->{"unit_$i"} = $locale->text('ea'); - &new_item; + &new_item; } } @@ -765,14 +955,79 @@ sub update { $lxdebug->leave_sub(); } +sub storno { + $lxdebug->enter_sub(); + + if ($form->{storno}) { + $form->error($locale->text('Cannot storno storno invoice!')); + } + + $form->{storno_id} = $form->{id}; + $form->{storno} = 1; + $form->{id} = ""; + $form->{invnumber} = "Storno zu " . $form->{invnumber}; + + &post(); + $lxdebug->leave_sub(); + +} + +sub use_as_template { + $lxdebug->enter_sub(); + + map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); + $form->{paidaccounts} = 1; + $form->{rowcount}--; + $form->{invdate} = $form->current_date(\%myconfig); + &display_form; + + $lxdebug->leave_sub(); +} + +sub post_payment { + $lxdebug->enter_sub(); + for $i (1 .. $form->{paidaccounts}) { + if ($form->{"paid_$i"}) { + $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig); + + $form->isblank("datepaid_$i", $locale->text('Payment date missing!')); + + $form->error($locale->text('Cannot post payment for a closed period!')) + if ($datepaid <= $closedto); + + if ($form->{currency} ne $form->{defaultcurrency}) { + $form->{"exchangerate_$i"} = $form->{exchangerate} + if ($invdate == $datepaid); + $form->isblank("exchangerate_$i", + $locale->text('Exchangerate for payment missing!')); + } + } + } + + ($form->{AP}) = split /--/, $form->{AP}; + ($form->{AP_paid}) = split /--/, $form->{AP_paid}; + if (IR->post_payment(\%myconfig, \%$form)){ + + if(!exists $form->{addition} && $form->{id} ne "") { + # saving the history + $form->{addition} = "PAYMENT POSTED"; + $form->save_history($form->dbconnect(\%myconfig)); + # /saving the history + $form->redirect($locale->text(' Payment posted!')); + } + } + $form->error($locale->text('Cannot post payment!')); + + $lxdebug->leave_sub(); +} sub post { $lxdebug->enter_sub(); $form->isblank("invdate", $locale->text('Invoice Date missing!')); - $form->isblank("vendor", $locale->text('Vendor missing!')); - + $form->isblank("vendor", $locale->text('Vendor missing!')); + # if the vendor changed get new values if (&check_name(vendor)) { &update; @@ -782,46 +1037,60 @@ sub post { &validate_items; $closedto = $form->datetonum($form->{closedto}, \%myconfig); - $invdate = $form->datetonum($form->{invdate}, \%myconfig); + $invdate = $form->datetonum($form->{invdate}, \%myconfig); - $form->error($locale->text('Cannot post invoice for a closed period!')) if ($invdate <= $closedto); + $form->error($locale->text('Cannot post invoice for a closed period!')) + if ($invdate <= $closedto); + + $form->isblank("exchangerate", $locale->text('Exchangerate missing!')) + if ($form->{currency} ne $form->{defaultcurrency}); - $form->isblank("exchangerate", $locale->text('Exchangerate missing!')) if ($form->{currency} ne $form->{defaultcurrency}); - for $i (1 .. $form->{paidaccounts}) { - if ($form->{"paid_$i"}) { + if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig); $form->isblank("datepaid_$i", $locale->text('Payment date missing!')); - - $form->error($locale->text('Cannot post payment for a closed period!')) if ($datepaid <= $closedto); - + + $form->error($locale->text('Cannot post payment for a closed period!')) + if ($datepaid <= $closedto); + if ($form->{currency} ne $form->{defaultcurrency}) { - $form->{"exchangerate_$i"} = $form->{exchangerate} if ($invdate == $datepaid); - $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!')); + $form->{"exchangerate_$i"} = $form->{exchangerate} + if ($invdate == $datepaid); + $form->isblank("exchangerate_$i", + $locale->text('Exchangerate for payment missing!')); } } } - - - ($form->{AP}) = split /--/, $form->{AP}; + + ($form->{AP}) = split /--/, $form->{AP}; ($form->{AP_paid}) = split /--/, $form->{AP_paid}; - + $form->{id} = 0 if $form->{postasnew}; - $form->redirect($locale->text('Invoice')." $form->{invnumber} ".$locale->text('posted!')) if (IR->post_invoice(\%myconfig, \%$form)); + + relink_accounts(); + if (IR->post_invoice(\%myconfig, \%$form)){ + # saving the history + if(!exists $form->{addition} && $form->{id} ne "") { + $form->{addition} = "POSTED"; + #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber}; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + $form->redirect( $locale->text('Invoice') + . " $form->{invnumber} " + . $locale->text('posted!')); + } $form->error($locale->text('Cannot post invoice!')); - + $lxdebug->leave_sub(); } - - sub delete { $lxdebug->enter_sub(); $form->header; - print qq| @@ -837,27 +1106,32 @@ sub delete { } print qq| -

|.$locale->text('Confirm!').qq|

+

| . $locale->text('Confirm!') . qq|

-

|.$locale->text('Are you sure you want to delete Invoice Number').qq| $form->{invnumber}

+

| + . $locale->text('Are you sure you want to delete Invoice Number') + . qq| $form->{invnumber}

- + |; - $lxdebug->leave_sub(); } - - sub yes { $lxdebug->enter_sub(); - - $form->redirect($locale->text('Invoice deleted!')) if (IR->delete_invoice(\%myconfig, \%$form)); + if (IR->delete_invoice(\%myconfig, \%$form)) { + # saving the history + if(!exists $form->{addition}) { + $form->{addition} = "DELETED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + $form->redirect($locale->text('Invoice deleted!')); + } $form->error($locale->text('Cannot delete invoice!')); $lxdebug->leave_sub(); } - -

|.$locale->text('Payments').qq|| . $locale->text('Payments') . qq|
".$locale->text('Date')."".$locale->text('Amount')."".$locale->text('Exch')."".$locale->text('Account')."".$locale->text('Source')."".$locale->text('Memo')."" . $locale->text('Date') . "" . $locale->text('Amount') . "" . $locale->text('Exch') . "" . $locale->text('Account') . "" . $locale->text('Source') . "" . $locale->text('Memo') . "
{"paid_$i"}>$exchangerate{"datepaid_$i"}>{"source_$i"}>{"memo_$i"}>{"paid_$i"}>$exchangerate{"datepaid_$i"}> + {"source_$i"}>{"memo_$i"}>