From 3d717fb381ffaec49a6457badd72b5095a60f1f6 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 13 May 2008 00:38:42 +0000 Subject: Correcting Customer/vendor name not showing up in certain cases git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2140 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/AA.pm | 14 +++++++------- LedgerSMB/Form.pm | 20 ++++++++++++++++++-- LedgerSMB/Template.pm | 12 ++++++++++-- UI/payments/payments_detail.html | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm index 997d893b..ce8679a7 100644 --- a/LedgerSMB/AA.pm +++ b/LedgerSMB/AA.pm @@ -308,17 +308,18 @@ sub post_transaction { # AR/AP Transaction. # ~A $query = qq| - INSERT INTO $table (invnumber, person_id) - VALUES (?, (select p.id from person p, entity e, users u + INSERT INTO $table (invnumber, person_id, + entity_credit_account) + VALUES (?, (select e.id from person p, entity e, users u where u.username = ? AND e.id = u.entity_id - AND p.entity_id = e.id ))|; + AND p.entity_id = e.id ), ?)|; # the second param is undef, as the DBI api expects a hashref of # attributes to pass to $dbh->prepare. This is not used here. # ~A - $dbh->do($query,undef,$uid,$form->{login}) || $form->dberror($query); + $dbh->do($query,undef,$uid,$form->{login}, $form->{"$form->{vc}_id"}) || $form->dberror($query); $query = qq| SELECT id FROM $table @@ -337,7 +338,6 @@ sub post_transaction { SET invnumber = ?, ordnumber = ?, transdate = ?, - entity_credit_account = ?, taxincluded = ?, amount = ?, duedate = ?, @@ -350,10 +350,10 @@ sub post_transaction { ponumber = ? WHERE id = ? |; - + my @queryargs = ( $form->{invnumber}, $form->{ordnumber}, - $form->{transdate}, $form->{"$form->{vc}_id"}, + $form->{transdate}, $form->{taxincluded}, $invamount, $form->{duedate}, $paid, $datepaid, $invnetamount, diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index a71d7dca..b33a239a 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -1719,8 +1719,14 @@ $module and $dbh are unused. sub all_vc { my ( $self, $myconfig, $vc, $module, $dbh, $transdate, $job ) = @_; - my $ref; + my $table; + + if ($module eq 'AR'){ + $table = 'ar'; + } elsif ($module eq 'AP'){ + $table = 'ap'; + } $dbh = $self->{dbh}; @@ -1784,8 +1790,18 @@ sub all_vc { $sth->finish; + } elsif ($self->{id}) { + $query = qq| + SELECT ec.id, e.name + FROM entity e + JOIN entity_credit_account ec ON (ec.entity_id = e.id) + WHERE ec.id = (select entity_credit_account FROM $table + WHERE id = ?) + ORDER BY name|; + $sth = $self->{dbh}->prepare($query); + $sth->execute($self->{id}); + ($self->{"${vc}_id"}, $self->{$vc}) = $sth->fetchrow_array(); } - # get self if ( !$self->{employee_id} ) { ( $self->{employee}, $self->{employee_id} ) = split /--/, diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm index 0c396ac6..35602cb4 100755 --- a/LedgerSMB/Template.pm +++ b/LedgerSMB/Template.pm @@ -374,8 +374,16 @@ sub _email_output { } sub _lpr_output { - my $self = shift; - #TODO stub + my ($self) = shift; + my $args = $self->{output_args}; + if ($self->{format} != /(pdf|ps)/){ + throw Error::Simple "Invalid Format"; + } + my $lpr = $LedgerSMB::Sysconfig::printer{$args->{printer}}; + + open(LPR, '|-', $lpr); + print LPR $self->{output}; + close(LPR); } 1; diff --git a/UI/payments/payments_detail.html b/UI/payments/payments_detail.html index 6419be4b..3b0edd8f 100644 --- a/UI/payments/payments_detail.html +++ b/UI/payments/payments_detail.html @@ -177,7 +177,7 @@ type = "checkbox" name = "id_$r.contact_id" value = r.contact_id - checked = (r.unselected) ? "" : "checked" + # checked = (r.unselected) ? "" : "checked" } ?> -- cgit v1.2.3