X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=44c42ff9f397e2125c01cf024a6b1e34196bedf5;hb=6dc16826718038718653bb07b130299fe2366e45;hp=caa8a0e6d511c2dbd70931afccb2d7adbbb583b9;hpb=195883fdfd3b10f329036767f027baa6e7c402b9;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index caa8a0e6d..44c42ff9f 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -43,7 +43,7 @@ require "$form->{path}/arap.pl"; sub add { $lxdebug->enter_sub(); -print STDERR "ir.pl-add\n"; + $form->{title} = $locale->text('Add Vendor Invoice'); &invoice_links; @@ -67,7 +67,7 @@ sub edit { sub invoice_links { $lxdebug->enter_sub(); -print STDERR "ir.pl-invoice_links\n"; + # create links $form->{webdav} = $webdav; @@ -76,19 +76,43 @@ print STDERR "ir.pl-invoice_links\n"; $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]; @@ -97,7 +121,7 @@ print STDERR "ir.pl-invoice_links\n"; $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| @@ -270,14 +333,12 @@ print STDERR "ir.pl-form_header\n"; $button1 = qq| {invdate}> text('button') - . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| {duedate}> text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -313,7 +374,8 @@ print STDERR "ir.pl-form_header\n"; {locked}> {shipped}> - +{storno}> +{storno_id}> @@ -331,8 +393,7 @@ print STDERR "ir.pl-form_header\n"; + . $locale->text('Contact Person') . qq|{vendor_id}> @@ -357,6 +418,7 @@ print STDERR "ir.pl-form_header\n"; + $taxzone $department @@ -417,7 +479,7 @@ $jsscript sub form_footer { $lxdebug->enter_sub(); -print STDERR "ir.pl-form_footer\n"; + $form->{invtotal} = $form->{invsubtotal}; if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) { @@ -619,8 +681,10 @@ print STDERR "ir.pl-form_footer\n"; 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"}); @@ -676,29 +740,17 @@ print STDERR "ir.pl-form_footer\n"; if ($form->{id}) { print qq| -|; - - if (!$form->{revtrans}) { - if (!$form->{locked}) { - print qq| - - + . $locale->text('Post Payment') . qq|"> |; - } - } - - if ($invdate > $closedto) { - print qq| - - + print qq| +| unless ($form->{storno}); + if ($form->{radier}) { + print qq| + |; - } - + } } else { if ($invdate > $closedto) { print qq|{"qty_$i"} = - $form->format_amount(\%myconfig, $form->{"qty_$i"}); + $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); } &display_form; @@ -852,6 +904,54 @@ 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}; + $form->{rowcount}--; + + &post(); + $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}; + $form->redirect($locale->text(' Payment posted!')) + if (IR->post_payment(\%myconfig, \%$form)); + $form->error($locale->text('Cannot post payment!')); + + + $lxdebug->leave_sub(); +} + sub post { $lxdebug->enter_sub(); @@ -876,7 +976,7 @@ sub post { 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!')); @@ -898,6 +998,8 @@ sub post { $form->{id} = 0 if $form->{postasnew}; + + relink_accounts(); $form->redirect( $locale->text('Invoice') . " $form->{invnumber} " . $locale->text('posted!'))
$vendor | - . $locale->text('Contact Person') - . qq| $contact
| . $locale->text('Currency') . qq|