X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=4f40da73f3eaf0f5b7809dbac9496b11462a3e12;hb=87c7db6a14d2276b72c85a8423e3995f20255b6a;hp=66e5da7aed21ba22d8b1190628901ac062cba094;hpb=f9f5330a26eb3f447677ab2524c823cb9f96723b;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 66e5da7ae..4f40da73f 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -32,10 +32,13 @@ #====================================================================== use SL::IR; +use SL::IS; use SL::PE; require "$form->{path}/io.pl"; require "$form->{path}/arap.pl"; +require "$form->{path}/common.pl"; +require "bin/mozilla/drafts.pl"; 1; @@ -44,6 +47,8 @@ require "$form->{path}/arap.pl"; sub add { $lxdebug->enter_sub(); + return $lxdebug->leave_sub() if (load_draft_maybe()); + $form->{title} = $locale->text('Add Vendor Invoice'); &invoice_links; @@ -55,7 +60,11 @@ sub add { sub edit { $lxdebug->enter_sub(); - + + # show history button + $form->{javascript} = qq||; + #/show hhistory button + $form->{title} = $locale->text('Edit Vendor Invoice'); &invoice_links; @@ -86,14 +95,33 @@ sub invoice_links { $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,7 +130,7 @@ 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|\n| : qq||; - $contact = - ($form->{selectcontact}) - ? qq|\n| - : qq||; - $department = qq| | . $locale->text('Department') . qq| @@ -301,6 +380,13 @@ sub form_header { qq|{duedate}>|; } + $form->{"javascript"} .= qq||; + + $jsscript .= + $form->write_trigger(\%myconfig, 2, + "orddate", "BL", "trigger_orddate", + "quodate", "BL", "trigger_quodate"); + $form->header; print qq| @@ -321,7 +407,10 @@ sub form_header { {locked}> {shipped}> +{storno}> +{storno_id}> +| . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| @@ -364,6 +453,7 @@ sub form_header { + $taxzone $department @@ -391,7 +481,21 @@ sub form_header { -
| . $locale->text('Currency') . qq|
+ + | . $locale->text('Order Date') . qq| + + + + + | . $locale->text('Quotation Date') . qq| + + + + + | . $locale->text('Project Number') . qq| + $globalprojectnumber + + @@ -462,7 +566,8 @@ sub form_footer { $tax .= qq| - $form->{"${item}_description"} + $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"} |; @@ -503,7 +608,8 @@ sub form_footer { $tax .= qq| - Enthaltene $form->{"${item}_description"} + Enthaltene $form->{"${item}_description"} | + . $form->{"${item}_rate"} * 100 .qq|% $form->{"${item}_total"} @@ -614,6 +720,7 @@ sub form_footer { |; + my @triggers = (); $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); for $i (1 .. $form->{paidaccounts}) { @@ -626,8 +733,10 @@ sub form_footer { 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); + 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"}); @@ -651,7 +760,8 @@ sub form_footer { $column_data{"AP_paid_$i"} = qq||; $column_data{"datepaid_$i"} = - qq|{"datepaid_$i"}>|; + qq|{"datepaid_$i"}> + |; $column_data{"source_$i"} = qq|{"source_$i"}>|; $column_data{"memo_$i"} = @@ -662,6 +772,7 @@ sub form_footer { print qq| |; + push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); } print qq| @@ -682,45 +793,38 @@ sub form_footer { $closedto = $form->datetonum($form->{closedto}, \%myconfig); if ($form->{id}) { + my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap"); + print qq| + . $locale->text('Post Payment') . qq|"> |; - - if (!$form->{revtrans}) { - if (!$form->{locked}) { - print qq| - - + print qq| +| if ($show_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| | . + NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), + '-class' => 'submit')); } - print qq| + print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) . + qq| {rowcount}> @@ -729,8 +833,22 @@ sub form_footer { {path}> {login}> {password}> +| + . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) + . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]); - + # button for saving history + if($form->{id} ne "") { + print qq| + |; + } + # /button for saving history + +print qq| @@ -747,8 +865,6 @@ sub update { &check_name(vendor); - &check_project; - $form->{exchangerate} = $exchangerate if ( $form->{forex} = ( @@ -775,7 +891,7 @@ sub update { } $i = $form->{rowcount}; - $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; + $exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1; if ( ($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") @@ -783,7 +899,7 @@ sub update { $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid}); &check_form; - } else { + } else { IR->retrieve_item(\%myconfig, \%$form); @@ -859,6 +975,81 @@ sub update { $lxdebug->leave_sub(); } +sub storno { + $lxdebug->enter_sub(); + + if ($form->{storno}) { + $form->error($locale->text('Cannot storno storno invoice!')); + } + + if (IS->has_storno(\%myconfig, $form, "ap")) { + $form->error($locale->text("Invoice has already been storno'd!")); + } + + invoice_links(); + prepare_invoice(); + relink_accounts(); + + $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(); @@ -905,10 +1096,21 @@ sub post { $form->{id} = 0 if $form->{postasnew}; - $form->redirect( $locale->text('Invoice') + + 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 + remove_draft() if $form->{remove_draft}; + $form->redirect( $locale->text('Invoice') . " $form->{invnumber} " - . $locale->text('posted!')) - if (IR->post_invoice(\%myconfig, \%$form)); + . $locale->text('posted!')); + } $form->error($locale->text('Cannot post invoice!')); $lxdebug->leave_sub(); @@ -918,7 +1120,6 @@ sub delete { $lxdebug->enter_sub(); $form->header; - print qq| @@ -950,9 +1151,15 @@ sub delete { 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();