diff options
-rwxr-xr-x | LedgerSMB.pm | 1 | ||||
-rw-r--r-- | LedgerSMB/RP.pm | 40 | ||||
-rw-r--r-- | bin/rp.pl | 14 |
3 files changed, 36 insertions, 19 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 1ca8e574..49126940 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -151,6 +151,7 @@ sub new { $self->{VERSION} = $VERSION; $self->merge($params); + $self->{have_latex} = $LedgerSMB::Sysconfig::latex; # Adding this so that empty values are stored in the db as NULL's. If # stored procedures want to handle them differently, they must opt to do so. diff --git a/LedgerSMB/RP.pm b/LedgerSMB/RP.pm index a9790855..bd27677f 100644 --- a/LedgerSMB/RP.pm +++ b/LedgerSMB/RP.pm @@ -2189,10 +2189,12 @@ sub payments { my $ml = 1; if ( $form->{db} eq 'ar' ) { $table = 'customer'; + $account_class = 2; $ml = -1; } if ( $form->{db} eq 'ap' ) { $table = 'vendor'; + $account_class = 1; } my $query; @@ -2215,6 +2217,9 @@ sub payments { if ( $form->{fromdate} ) { $where .= " AND ac.transdate >= " . $dbh->quote( $form->{fromdate} ); } + if ($form->{meta_number} ) { + $where .= " AND c.meta_number = " . $dbh->quote($form->{meta_number}); + } if ( $form->{todate} ) { $where .= " AND ac.transdate <= " . $dbh->quote( $form->{todate} ); } @@ -2224,7 +2229,7 @@ sub payments { if ( $form->{description} ne "" ) { $var = $dbh->quote( $form->like( lc $form->{description} ) ); - $where .= " AND lower(c.name) LIKE $var"; + $where .= " AND lower(ce.name) LIKE $var"; } if ( $form->{source} ne "" ) { $var = $dbh->quote( $form->like( lc $form->{source} ) ); @@ -2263,14 +2268,19 @@ sub payments { push @{ $form->{PR} }, $ref; $sth->finish; - $query = qq| - SELECT c.name, ac.transdate, + $query = qq| + SELECT ce.name, ac.transdate, sum(ac.amount) * $ml AS paid, ac.source, - ac.memo, e.name AS employee, a.till, a.curr + ac.memo, ee.name AS employee, a.till, a.curr, + c.meta_number FROM acc_trans ac JOIN $form->{db} a ON (ac.trans_id = a.id) - JOIN $table c ON (c.id = a.${table}_id) - LEFT JOIN employee e ON (a.employee_id = e.id) + JOIN entity_credit_account c ON + (c.id = a.entity_credit_account) + JOIN entity ce ON (ce.id = c.entity_id) + LEFT JOIN entity_employee e ON + (a.person_id = e.entity_id) + LEFT JOIN entity ee ON (e.entity_id = ee.id) $dpt_join WHERE ac.chart_id = $ref->{id} $where|; @@ -2283,26 +2293,28 @@ sub payments { } $query .= qq| - GROUP BY c.name, ac.transdate, ac.source, ac.memo, - e.name, a.till, a.curr|; + GROUP BY ce.name, ac.transdate, ac.source, ac.memo, + ee.name, a.till, a.curr, c.meta_number|; - if ( $form->{till} eq "" ) { + if ( $form->{till} eq "" && !$form->{meta_number}) { - $query .= qq| + $query .= qq| UNION SELECT g.description, ac.transdate, sum(ac.amount) * $ml AS paid, ac.source, - ac.memo, e.name AS employee, '' AS till, - '' AS curr + ac.memo, ee.name AS employee, '' AS till, + '' AS curr, '' AS meta_number FROM acc_trans ac JOIN gl g ON (g.id = ac.trans_id) LEFT - JOIN employee e ON (g.employee_id = e.id) + JOIN entity_employee e ON + (g.person_id = e.entity_id) + JOIN entity ee ON (e.entity_id = ee.id) $dpt_join WHERE ac.chart_id = $ref->{id} $glwhere AND (ac.amount * $ml) > 0 GROUP BY g.description, ac.transdate, - ac.source, ac.memo, e.name|; + ac.source, ac.memo, ee.name|; } @@ -1877,6 +1877,7 @@ sub tax_subtotal { my %column_data; for (@{$column_index}) { $column_data{$_} = ' ' } + #SC: Yes, right now these are global, inherited from generate_tax_report $subtotal = $form->format_amount( \%myconfig, $subtotalnetamount + $subtotaltax, @@ -1910,6 +1911,7 @@ sub list_payments { my %hiddens; my @options; + my $vc = ($form->{db} eq 'ar') ? 'Customer' : 'Vendor'; if ( $form->{account} ) { ( $form->{paymentaccounts} ) = split /--/, $form->{account}; } @@ -1921,11 +1923,12 @@ sub list_payments { RP->payments( \%myconfig, \%$form ); - my @columns = $form->sort_columns(qw(transdate name paid source memo)); + my @columns = $form->sort_columns(qw(transdate name paid source meta_number +memo)); if ( $form->{till} ) { @columns = - $form->sort_columns(qw(transdate name paid curr source till)); + $form->sort_columns(qw(transdate name paid curr source meta_number till)); if ( $myconfig{role} ne 'user' ) { @columns = $form->sort_columns( @@ -2001,9 +2004,9 @@ sub list_payments { href => "$href&sort=source", text => $locale->text('Source'), }; - $column_header{memo} = { - href => "$href&sort=memo", - text => $locale->text('Memo'), + $column_header{meta_number} = { + href => "$href&sort=meta_number", + text => $locale->text("$vc Number"), }; $column_header{employee} = { href => "$href&sort=employee", @@ -2042,6 +2045,7 @@ sub list_payments { next if ( $form->{till} && !$payment->{till} ); my %column_data; + $column_data{meta_number} = $payment->{meta_number}; $column_data{name} = $payment->{name}; $column_data{transdate} = $payment->{transdate}; $column_data{paid} = |