X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fir.pl;h=6744764c66ffc9d30f69a058b98224816df4e189;hb=84da0ba2f48ac09652557a5aca1a912b06fb0b0b;hp=f6df8494ba2ad69230f6c984ab28a53a41e5b97a;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git
diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl
index f6df8494b..6744764c6 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,11 +50,10 @@ sub add {
&invoice_links;
&prepare_invoice;
&display_form;
-
+
$lxdebug->leave_sub();
}
-
sub edit {
$lxdebug->enter_sub();
@@ -65,35 +62,58 @@ sub edit {
&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 +122,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 +338,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 +383,7 @@ sub form_header {
{type}>
+{level}>
{creditlimit}>
{creditremaining}>
@@ -287,7 +392,8 @@ sub form_header {
{locked}>
{shipped}>
-
+{storno}>
+{storno_id}>
@@ -301,12 +407,13 @@ sub form_header {
|
@@ -364,7 +486,7 @@ sub form_header {
$jsscript
-
+
{defaultcurrency}>
{fxgain_accno}>
@@ -387,13 +509,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,26 +521,33 @@ 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}_total"} |
@@ -428,30 +555,40 @@ sub form_footer {
|;
}
}
-
+ $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"} |
$form->{"${item}_total"} |
@@ -463,12 +600,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 +615,8 @@ sub form_footer {
- |.$locale->text('Notes').qq| |
- |.$locale->text('Internal Notes').qq| |
+ | . $locale->text('Notes') . qq| |
+ | . $locale->text('Internal Notes') . qq| |
$notes |
@@ -494,7 +631,7 @@ sub form_footer {
$subtotal
$tax
0
- |.$locale->text('Total').qq| |
+ | . $locale->text('Total') . qq| |
$form->{invtotal} |
@@ -505,106 +642,121 @@ sub form_footer {
|
|;
if ($webdav) {
- $webdav_list = qq|
+ $webdav_list = qq|
|
-
+
Dokumente im Webdav-Repository |
Dateiname |
Webdavlink |
|;
- foreach $file (keys %{ $form->{WEBDAV}}) {
- $webdav_list .= qq|
-
+ foreach $file (keys %{ $form->{WEBDAV} }) {
+ $webdav_list .= qq|
+
$file |
$form->{WEBDAV}{$file} |
|;
- }
- $webdav_list .= qq|
+ }
+ $webdav_list .= qq|
|;
-print $webdav_list;
-}
-print qq|
+ print $webdav_list;
+ }
+ print qq|
{jscalendar}>
|;
-print qq|
+ print qq|
- |.$locale->text('Payments').qq| |
+ | . $locale->text('Payments') . 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} = "".$locale->text('Date')." | ";
- $column_data{paid} = "".$locale->text('Amount')." | ";
- $column_data{exchangerate} = "".$locale->text('Exch')." | ";
- $column_data{AP_paid} = "".$locale->text('Account')." | ";
- $column_data{source} = "".$locale->text('Source')." | ";
- $column_data{memo} = "".$locale->text('Memo')." | ";
+ $column_data{datepaid} = "" . $locale->text('Date') . " | ";
+ $column_data{paid} = "" . $locale->text('Amount') . " | ";
+ $column_data{exchangerate} = "" . $locale->text('Exch') . " | ";
+ $column_data{AP_paid} = "" . $locale->text('Account') . " | ";
+ $column_data{source} = "" . $locale->text('Source') . " | ";
+ $column_data{memo} = "" . $locale->text('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|{"paid_$i"}> | |;
- $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
- $column_data{"AP_paid_$i"} = qq| | |;
- $column_data{"datepaid_$i"} = qq|{"datepaid_$i"}> | |;
- $column_data{"source_$i"} = qq|{"source_$i"}> | |;
- $column_data{"memo_$i"} = qq|{"memo_$i"}> | |;
-
- map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
+ $column_data{"paid_$i"} =
+ qq|{"paid_$i"}> | |;
+ $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
+ $column_data{"AP_paid_$i"} =
+ qq| | |;
+ $column_data{"datepaid_$i"} =
+ qq|{"datepaid_$i"}>
+ | |;
+ $column_data{"source_$i"} =
+ qq|{"source_$i"}> | |;
+ $column_data{"memo_$i"} =
+ qq|{"memo_$i"}> | |;
+
+ 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 +770,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}>
@@ -672,92 +820,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 +938,71 @@ 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();
$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,41 +1012,48 @@ 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();
+ $form->redirect( $locale->text('Invoice')
+ . " $form->{invnumber} "
+ . $locale->text('posted!'))
+ if (IR->post_invoice(\%myconfig, \%$form));
$form->error($locale->text('Cannot post invoice!'));
-
+
$lxdebug->leave_sub();
}
-
-
sub delete {
$lxdebug->enter_sub();
@@ -837,27 +1074,26 @@ 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));
+ $form->redirect($locale->text('Invoice deleted!'))
+ if (IR->delete_invoice(\%myconfig, \%$form));
$form->error($locale->text('Cannot delete invoice!'));
$lxdebug->leave_sub();
}
-
-
|