From: Sven Schöling Date: Fri, 6 Nov 2009 11:57:29 +0000 (+0100) Subject: Verkaufsrechnungstemplates X-Git-Tag: release-2.6.1beta1~113 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/09fe7f33a735ecc3f4a3112ad716f674983b00cc?hp=8cd27a4864bc76580ed0d9884694c833a616e8eb Verkaufsrechnungstemplates Merge branch 'is_template' Conflicts: bin/mozilla/is.pl --- diff --git a/SL/AP.pm b/SL/AP.pm index 7b5a46150..aaf2d5e6e 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -35,8 +35,11 @@ package AP; use SL::DBUtils; +use SL::IO; use SL::MoreCommon; +use Data::Dumper; + use strict; sub post_transaction { @@ -67,7 +70,7 @@ sub post_transaction { (split(/--/, $form->{"AP_amount_$i"}))[0]; } ($form->{AP_amounts}{payables}) = split(/--/, $form->{APselected}); - ($form->{AP}{payables}) = split(/--/, $form->{APselected}); + ($form->{AP_payables}) = split(/--/, $form->{APselected}); # reverse and parse amounts for my $i (1 .. $form->{rowcount}) { @@ -155,9 +158,6 @@ sub post_transaction { # amount for total AP $form->{payables} = $form->{invtotal}; - $form->{datepaid} = $form->{transdate} unless ($form->{datepaid}); - my $datepaid = ($form->{invpaid} != 0) ? $form->{datepaid} : undef; - # update exchangerate if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) { $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, 0, @@ -195,14 +195,14 @@ sub post_transaction { $query = qq|UPDATE ap SET invnumber = ?, transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?, - amount = ?, duedate = ?, paid = ?, datepaid = ?, netamount = ?, + amount = ?, duedate = ?, paid = ?, netamount = ?, curr = ?, notes = ?, department_id = ?, storno = ?, storno_id = ? WHERE id = ?|; @values = ($form->{invnumber}, conv_date($form->{transdate}), $form->{ordnumber}, conv_i($form->{vendor_id}), $form->{taxincluded} ? 't' : 'f', $form->{invtotal}, conv_date($form->{duedate}), $form->{invpaid}, - conv_date($datepaid), $form->{netamount}, + $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}), $form->{storno}, $form->{storno_id}, $form->{id}); @@ -272,7 +272,7 @@ sub post_transaction { # get paid account - ($form->{AP}{"paid_$i"}) = split(/--/, $form->{"AP_paid_$i"}); + ($form->{"AP_paid_account_$i"}) = split(/--/, $form->{"AP_paid_$i"}); $form->{"datepaid_$i"} = $form->{transdate} unless ($form->{"datepaid_$i"}); @@ -289,9 +289,9 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = ($form->{id}, $form->{AP}{payables}, $amount, + @values = ($form->{id}, $form->{AP_payables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, - $form->{AP}{payables}); + $form->{AP_payables}); do_query($form, $dbh, $query, @values); } $form->{payables} = $amount; @@ -301,9 +301,9 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = ($form->{id}, $form->{AP}{"paid_$i"}, $form->{"paid_$i"}, + @values = ($form->{id}, $form->{"AP_paid_account_$i"}, $form->{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, - $form->{"memo_$i"}, $project_id, $form->{AP}{"paid_$i"}); + $form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"}); do_query($form, $dbh, $query, @values); # add exchange rate difference @@ -315,9 +315,9 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = ($form->{id}, $form->{AP}{"paid_$i"}, $amount, + @values = ($form->{id}, $form->{"AP_paid_account_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, - $form->{AP}{"paid_$i"}); + $form->{"AP_paid_account_$i"}); do_query($form, $dbh, $query, @values); } @@ -354,6 +354,8 @@ sub post_transaction { do_query($form, $dbh, $query, $form->{invpaid}, $form->{invpaid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); } + IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh); + my $rc = 1; if (!$provided_dbh) { $dbh->commit(); @@ -786,6 +788,8 @@ sub storno { do_query($form, $dbh, $query, (values %$row)); } + map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id); + $dbh->commit; $main::lxdebug->leave_sub(); diff --git a/SL/AR.pm b/SL/AR.pm index b48741d34..7d037838c 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -36,6 +36,7 @@ package AR; use Data::Dumper; use SL::DBUtils; +use SL::IO; use SL::MoreCommon; use strict; @@ -141,10 +142,6 @@ sub post_transaction { ($null, $form->{department_id}) = split(/--/, $form->{department}); $form->{department_id} *= 1; - # record last payment date in ar table - $form->{datepaid} ||= $form->{transdate} ; - my $datepaid = ($form->{paid} != 0) ? $form->{datepaid} : undef; - # amount for AR account $form->{receivables} = $form->round_amount($form->{amount}, 2) * -1; @@ -156,12 +153,12 @@ sub post_transaction { $query = qq|UPDATE ar set invnumber = ?, ordnumber = ?, transdate = ?, customer_id = ?, - taxincluded = ?, amount = ?, duedate = ?, paid = ?, datepaid = ?, + taxincluded = ?, amount = ?, duedate = ?, paid = ?, netamount = ?, curr = ?, notes = ?, department_id = ?, employee_id = ?, storno = ?, storno_id = ? WHERE id = ?|; my @values = ($form->{invnumber}, $form->{ordnumber}, conv_date($form->{transdate}), conv_i($form->{customer_id}), $form->{taxincluded} ? 't' : 'f', $form->{amount}, - conv_date($form->{duedate}), $form->{paid}, conv_date($datepaid), $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}), + conv_date($form->{duedate}), $form->{paid}, $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}), conv_i($form->{employee_id}), $form->{storno} ? 't' : 'f', $form->{storno_id}, conv_i($form->{id})); do_query($form, $dbh, $query, @values); @@ -266,6 +263,8 @@ sub post_transaction { } } + IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); + my $rc = 1; if (!$provided_dbh) { $rc = $dbh->commit(); @@ -673,6 +672,8 @@ sub storno { do_query($form, $dbh, $query, (values %$row)); } + map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id); + $dbh->commit; $main::lxdebug->leave_sub(); diff --git a/SL/CT.pm b/SL/CT.pm index 12df265d8..1b9d91593 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -1071,7 +1071,7 @@ sub get_bank_info { my $table = $params{vc} eq 'customer' ? 'customer' : 'vendor'; my @ids = ref $params{id} eq 'ARRAY' ? @{ $params{id} } : ($params{id}); - my $placeholders = ('?') x scalar @ids; + my $placeholders = join ", ", ('?') x scalar @ids; my $query = qq|SELECT id, name, account_number, bank, bank_code, iban, bic FROM ${table} WHERE id IN (${placeholders})|; diff --git a/SL/DN.pm b/SL/DN.pm index e1a634202..0ac071c6f 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -618,9 +618,11 @@ sub get_dunning { qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount, ct.name AS customername, ct.id AS customer_id, a.duedate, da.fee, da.interest, dn.dunning_description, da.transdate AS dunning_date, - da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id + da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id, + e2.name AS salesman FROM ar a - JOIN customer ct ON (a.customer_id = ct.id), dunning da + JOIN customer ct ON (a.customer_id = ct.id) + LEFT JOIN employee e2 ON (a.salesman_id = e2.id), dunning da LEFT JOIN dunning_config dn ON (da.dunning_config_id = dn.id) $where ORDER BY $sortorder|; diff --git a/SL/Form.pm b/SL/Form.pm index 17273ec50..579b1ef65 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -630,6 +630,8 @@ sub create_http_response { sub header { $main::lxdebug->enter_sub(); + # extra code ist currently only used by menuv3 and menuv4 to set their css. + # it is strongly deprecated, and will be changed in a future version. my ($self, $extra_code) = @_; if ($self->{header}) { @@ -2738,7 +2740,7 @@ sub all_departments { ORDER BY description|; $self->{all_departments} = selectall_hashref_query($self, $dbh, $query); - delete($self->{all_departments}) unless (@{ $self->{all_departments} }); + delete($self->{all_departments}) unless (@{ $self->{all_departments} || [] }); $main::lxdebug->leave_sub(); } diff --git a/SL/IO.pm b/SL/IO.pm index 814a452dc..b840e458c 100644 --- a/SL/IO.pm +++ b/SL/IO.pm @@ -1,5 +1,8 @@ package IO; +use List::Util qw(first); +use List::MoreUtils qw(any); + use SL::DBUtils; use strict; @@ -26,4 +29,50 @@ sub retrieve_partunits { } +sub set_datepaid { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(id table)); + + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + my $id = conv_i($params{id}); + my $table = (any { $_ eq $params{table} } qw(ar ap gl)) ? $params{table} : 'ar'; + + my ($curr_datepaid, $curr_paid) = selectfirst_array_query($form, $dbh, qq|SELECT datepaid, paid FROM $table WHERE id = ?|, $id); + + my $query = <commit() unless $params{dbh}; + + $main::lxdebug->leave_sub(); +} + + 1; diff --git a/SL/IR.pm b/SL/IR.pm index ab515b21a..7e24d4e01 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -41,6 +41,7 @@ use SL::CVar; use SL::DBUtils; use SL::DO; use SL::GenericTranslations; +use SL::IO; use SL::MoreCommon; use List::Util qw(min); @@ -141,9 +142,6 @@ sub post_invoice { # ansonsten stolpert man immer wieder viermal statt einmal heftig # und auch das undo discount formatting ist nicht besonders wartungsfreundlich - # keep entered selling price - $fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); - # keine ahnung wofür das in IS.pm gemacht wird: # my ($dec) = ($fxsellprice =~ /\.(\d+)/); # $dec = length $dec; @@ -510,9 +508,11 @@ sub post_invoice { } } + IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh); + if ($payments_only) { - $query = qq|UPDATE ap SET paid = ?, datepaid = ? WHERE id = ?|; - do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); + $query = qq|UPDATE ap SET paid = ? WHERE id = ?|; + do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); if (!$provided_dbh) { $dbh->commit(); @@ -536,7 +536,7 @@ sub post_invoice { $query = qq|UPDATE ap SET invnumber = ?, ordnumber = ?, quonumber = ?, transdate = ?, orddate = ?, quodate = ?, vendor_id = ?, amount = ?, - netamount = ?, paid = ?, duedate = ?, datepaid = ?, + netamount = ?, paid = ?, duedate = ?, invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?, intnotes = ?, curr = ?, storno_id = ?, storno = ?, cp_id = ?, employee_id = ?, department_id = ?, @@ -545,7 +545,7 @@ sub post_invoice { @values = ( $form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, conv_date($form->{invdate}), conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount, - $netamount, $form->{paid}, conv_date($form->{duedate}), $form->{paid} ? conv_date($form->{datepaid}) : undef, + $netamount, $form->{paid}, conv_date($form->{duedate}), '1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f', $form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), diff --git a/SL/IS.pm b/SL/IS.pm index e17efc6e6..7c923b0dd 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -45,6 +45,7 @@ use SL::DO; use SL::GenericTranslations; use SL::MoreCommon; use SL::IC; +use SL::IO; use Data::Dumper; use strict; @@ -948,9 +949,11 @@ sub post_invoice { $form->{marge_total} *= -1; } + IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); + if ($payments_only) { - $query = qq|UPDATE ar SET paid = ?, datepaid = ? WHERE id = ?|; - do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); + $query = qq|UPDATE ar SET paid = ? WHERE id = ?|; + do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); if (!$provided_dbh) { $dbh->commit(); @@ -988,7 +991,7 @@ sub post_invoice { $query = qq|UPDATE ar set invnumber = ?, ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, orddate = ?, quodate = ?, customer_id = ?, - amount = ?, netamount = ?, paid = ?, datepaid = ?, + amount = ?, netamount = ?, paid = ?, duedate = ?, deliverydate = ?, invoice = ?, shippingpoint = ?, shipvia = ?, terms = ?, notes = ?, intnotes = ?, curr = ?, department_id = ?, payment_id = ?, taxincluded = ?, @@ -997,11 +1000,11 @@ sub post_invoice { cp_id = ?, marge_total = ?, marge_percent = ?, globalproject_id = ?, delivery_customer_id = ?, transaction_description = ?, delivery_vendor_id = ?, - donumber = ? + donumber = ? WHERE id = ?|; @values = ( $form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"}, conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}), - $amount, $netamount, $form->{"paid"}, conv_date($form->{"datepaid"}), + $amount, $netamount, $form->{"paid"}, conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), '1', $form->{"shippingpoint"}, $form->{"shipvia"}, conv_i($form->{"terms"}), $form->{"notes"}, $form->{"intnotes"}, $form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}), $form->{"taxincluded"} ? 't' : 'f', @@ -1010,7 +1013,7 @@ sub post_invoice { conv_i($form->{"cp_id"}), 1 * $form->{marge_total} , 1 * $form->{marge_percent}, conv_i($form->{"globalproject_id"}), conv_i($form->{"delivery_customer_id"}), $form->{transaction_description}, conv_i($form->{"delivery_vendor_id"}), - $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb + $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb conv_i($form->{"id"})); do_query($form, $dbh, $query, @values); diff --git a/SL/Menu.pm b/SL/Menu.pm index 9fcf15374..9dfb85190 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -63,46 +63,35 @@ sub menuitem { my ($self, $myconfig, $form, $item) = @_; - my $module = $form->{script}; - my $action = "section_menu"; - my $target = ""; + my $module = $self->{$item}{module} || $form->{script}; + my $action = $self->{$item}{action} || "section_menu"; + my $target = $self->{$item}{target} || ""; - if ($self->{$item}{module}) { - $module = $self->{$item}{module}; - } - if ($self->{$item}{action}) { - $action = $self->{$item}{action}; - } - if ($self->{$item}{target}) { - $target = $self->{$item}{target}; - } + my $level = $form->escape($item); - my $level = $form->escape($item); + my $style = 'style="vertical-align:top"'; + my $target_token = ($target) + ? "target='$target'" : ''; - my $str = qq|{$item}{href}) + ? $form->escape($self->{$item}{href}) + : "$module?action=$action&level=$level"; - my @vars = qw(module action target href); - - if ($self->{$item}{href}) { - $str = qq|{$item}{href}|; - @vars = qw(module target href); - } + my @vars = ($self->{$item}{href}) + ? qw(module target href) + : qw(module action target href); map { delete $self->{$item}{$_} } @vars; # add other params foreach my $key (keys %{ $self->{$item} }) { - $str .= "&" . $form->escape($key, 1) . "="; + $href .= "&" . $form->escape($key, 1) . "="; my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); $value = $myconfig->{$value} . "/$conf" if ($conf); - $str .= $form->escape($value, 1); - } - - if ($target) { - $str .= qq| target=$target|; + $href .= $form->escape($value, 1); } - $str .= ">"; + my $str = ""; $main::lxdebug->leave_sub(); diff --git a/SL/MoreCommon.pm b/SL/MoreCommon.pm index 48eef0cf9..e93dd172e 100644 --- a/SL/MoreCommon.pm +++ b/SL/MoreCommon.pm @@ -165,6 +165,5 @@ sub listify { my @ary = scalar @_ > 1 ? @_ : ref $_[0] eq 'ARRAY' ? @{ $_[0] } : (@_); return wantarray ? @ary : scalar @ary; } -+ 1; diff --git a/SL/RecordLinks.pm b/SL/RecordLinks.pm index 09fd642c1..ae61edd34 100644 --- a/SL/RecordLinks.pm +++ b/SL/RecordLinks.pm @@ -203,3 +203,82 @@ sub delete { } 1; + +__END__ + +=head1 NAME + +SL::RecordLinks - Verlinkung von Lx-Office Objekten. + +=head1 SYNOPSIS + + use SL::RecordLinks; + + my @links = RecordLinks->get_links( + from_table => 'ar', + from_id => 2, + to_table => 'oe', + ); + my @links = RecordLinks->get_links_via( + from_table => 'oe', + to_id => '14', + via => [ + { id => 12 }, + { id => 13}, + ], + ); + + RecordLinks->create_links( + mode => 'ids', + from_table => 'ar', + from_id => 1, + to_table => 'oe', + to_ids => [4, 6, 9], + ) + RecordLinks->create_links(@links); + + delete + +=head1 DESCRIPTION + +=over 4 + +Transitive RecordLinks mit get_links_via. + +get_links_via erwartet den zusätzlichen parameter via. via ist ein +hashref mit den jeweils optionalen Einträgen table und id, die sich +genauso verhalten wie die from/to_table/id werte der get_links funktion. + +Alternativ kann via auch ein Array dieser Hashes sein: + + get_links_via( + from_table => 'oe', + from_id => 1, + to_table => 'ar', + via => { + table => 'delivery_orders' + }, + ) + + get_links_via( + from_table => 'oe', + to_id => '14', + via => [ + { id => 12 }, + { id => 13}, + ], + ) + +Die Einträge in einem via-Array werden exakt in dieser Reihenfolge +benutzt und sind nicht optional. Da obige Beispiel würde also die +Verknüpfung: + + oe:11 -> ar:12 -> is:13 -> do:14 + +finden, nicht aber: + + oe:11 -> ar:13 -> do:14 + +=back + +=cut diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 97f2dbad9..551b0ee10 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -163,21 +163,21 @@ sub create_links { map { $form->{selectcurrency} .= "