X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fir.pl;h=3736fbe2cb09f792dc248143d96bd241819ac019;hb=7e073dcdadf65ee98b683b7dd6461fb6fb69a039;hp=caa8a0e6d511c2dbd70931afccb2d7adbbb583b9;hpb=195883fdfd3b10f329036767f027baa6e7c402b9;p=kivitendo-erp.git
diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl
index caa8a0e6d..3736fbe2c 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
@@ -293,6 +354,13 @@ print STDERR "ir.pl-form_header\n";
qq|{duedate}> | |;
}
+ $form->{"javascript"} .= qq||;
+
+ $jsscript .=
+ $form->write_trigger(\%myconfig, 2,
+ "orddate", "BL", "trigger_orddate",
+ "quodate", "BL", "trigger_quodate");
+
$form->header;
print qq|
@@ -313,7 +381,8 @@ print STDERR "ir.pl-form_header\n";
{locked}>
{shipped}>
-
+{storno}>
+{storno_id}>
@@ -417,7 +496,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) {
@@ -607,6 +686,7 @@ print STDERR "ir.pl-form_footer\n";
|;
+ my @triggers = ();
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -619,8 +699,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"});
@@ -644,7 +726,8 @@ print STDERR "ir.pl-form_footer\n";
$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"} =
@@ -655,6 +738,7 @@ print STDERR "ir.pl-form_footer\n";
print qq|
|;
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
print qq|
@@ -676,44 +760,33 @@ print STDERR "ir.pl-form_footer\n";
if ($form->{id}) {
print qq|
+ . $locale->text('Post Payment') . 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}>
@@ -776,7 +849,7 @@ sub update {
$form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
&check_form;
- } else {
+ } else {
IR->retrieve_item(\%myconfig, \%$form);
@@ -823,7 +896,7 @@ sub update {
$form->format_amount(\%myconfig, $form->{"sellprice_$i"},
$decimalplaces);
$form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"});
+ $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
}
&display_form;
@@ -852,6 +925,65 @@ 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};
+ $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 +1008,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 +1030,8 @@ sub post {
$form->{id} = 0 if $form->{postasnew};
+
+ relink_accounts();
$form->redirect( $locale->text('Invoice')
. " $form->{invnumber} "
. $locale->text('posted!'))