[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Bug 3305912: Left menu "Projects -> Add timecard" doesn't work



Talking with Chris, we found the cause. This should be the fix: as
Chris indicates, projects without a customer / vendor attached are
completely legit, so the routine needs to take that into account.


Index: LedgerSMB/JC.pm
===================================================================
--- LedgerSMB/JC.pm     (revision 3188)
+++ LedgerSMB/JC.pm     (working copy)
@@ -301,15 +301,21 @@
     my $sth = $dbh->prepare($query);
     $sth->execute || $form->dberror($query);

-    my $pmh = PriceMatrix::price_matrix_query( $dbh, $form );
-    IS::exchangerate_defaults( $dbh, $form );
+    if (defined $form->{vendor_id} or defined $form->{customer_id} ) {
+        my $pmh = PriceMatrix::price_matrix_query( $dbh, $form );
+        IS::exchangerate_defaults( $dbh, $form );

-    while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        $ref->{description} = $ref->{translation}
-          if $ref->{translation};
-        PriceMatrix::price_matrix( $pmh, $ref, $form->{transdate}, 4, $form,
-            $myconfig );
-        push @{ $form->{all_parts} }, $ref;
+        while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            $ref->{description} = $ref->{translation}
+              if $ref->{translation};
+            PriceMatrix::price_matrix( $pmh, $ref,
$form->{transdate}, 4, $form,
+                $myconfig );
+            push @{ $form->{all_parts} }, $ref;
+        }
+    } else {
+        while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
+            push @{ $form->{all_parts} }, $ref;
+        }
     }
     $sth->finish;