X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fir.pl;h=6744764c66ffc9d30f69a058b98224816df4e189;hb=84da0ba2f48ac09652557a5aca1a912b06fb0b0b;hp=ee0e813a403a08624f937078a26721ea854e1d5a;hpb=e44cbe168d7cdaedc952a23102d8c834bd3a2993;p=kivitendo-erp.git
diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl
index ee0e813a4..6744764c6 100644
--- a/bin/mozilla/ir.pl
+++ b/bin/mozilla/ir.pl
@@ -36,6 +36,7 @@ use SL::PE;
require "$form->{path}/io.pl";
require "$form->{path}/arap.pl";
+require "$form->{path}/common.pl";
1;
@@ -43,7 +44,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 +68,7 @@ sub edit {
sub invoice_links {
$lxdebug->enter_sub();
-print STDERR "ir.pl-invoice_links\n";
+
# create links
$form->{webdav} = $webdav;
@@ -76,19 +77,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 +122,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|
: qq||;
- $contact =
- ($form->{selectcontact})
- ? qq|\n|
- : qq||;
-
$department = qq|
| . $locale->text('Department') . qq| |
@@ -274,14 +344,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
@@ -297,6 +365,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|
@@ -317,7 +392,8 @@ print STDERR "ir.pl-form_header\n";
{locked}>
{shipped}>
-
+{storno}>
+{storno_id}>
+
+ | . $locale->text('Order Date') . qq| |
+ |
+ |
+
+
+ | . $locale->text('Quotation Date') . qq| |
+ |
+ |
+
+
+ | . $locale->text('Project Number') . qq| |
+ $globalprojectnumber |
+
+
@@ -421,7 +511,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) {
@@ -611,6 +701,7 @@ print STDERR "ir.pl-form_footer\n";
|;
+ my @triggers = ();
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
@@ -623,8 +714,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"});
@@ -648,7 +741,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"} =
@@ -659,6 +753,7 @@ print STDERR "ir.pl-form_footer\n";
print qq|
|;
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
print qq|
@@ -680,44 +775,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}>
@@ -744,8 +828,6 @@ sub update {
&check_name(vendor);
- &check_project;
-
$form->{exchangerate} = $exchangerate
if (
$form->{forex} = (
@@ -780,7 +862,7 @@ sub update {
$form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
&check_form;
- } else {
+ } else {
IR->retrieve_item(\%myconfig, \%$form);
@@ -856,6 +938,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();
@@ -880,7 +1021,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!'));
@@ -902,6 +1043,8 @@ sub post {
$form->{id} = 0 if $form->{postasnew};
+
+ relink_accounts();
$form->redirect( $locale->text('Invoice')
. " $form->{invnumber} "
. $locale->text('posted!'))