From 38b117b7882b7a9674d5bee151ddd0f9671d1aa9 Mon Sep 17 00:00:00 2001
From: Ian Goodacre <ian@laptop2.(none)>
Date: Sun, 28 Mar 2010 23:09:01 +1300
Subject: [PATCH] Fix query on partscustomer

Adding a service to a sales invoice failed with:

DBD::Pg::st execute failed: ERROR:  column p.customer_id does not exist
LINE 2:        SELECT p.parts_id, p.customer_id AS entity_id,
                                  ^ at LedgerSMB/PriceMatrix.pm line 131.

This is since the recent revision of partscustomer which changed column
customer_id to credit_id.
---
 LedgerSMB/PriceMatrix.pm |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/LedgerSMB/PriceMatrix.pm b/LedgerSMB/PriceMatrix.pm
index a127bf5..2bb8f67 100644
--- a/LedgerSMB/PriceMatrix.pm
+++ b/LedgerSMB/PriceMatrix.pm
@@ -52,7 +52,7 @@ sub price_matrix_query {
     if ( $form->{customer_id} ) {
         my $defaultcurrency = $form->{dbh}->quote( $form->{defaultcurrency} );
         $query = qq|
-    			SELECT p.parts_id, p.customer_id AS entity_id, 
+    			SELECT p.parts_id, p.credit_id AS entity_id, 
 				NULL AS pricegroup_id, 
 				p.pricebreak, p.sellprice, p.validfrom,
 				p.validto, p.curr, NULL AS pricegroup, 
@@ -63,11 +63,11 @@ sub price_matrix_query {
 					$transdate
 				AND coalesce(p.validto, $transdate) >= 
 					$transdate
-				AND p.customer_id = $entity_id
+				AND p.credit_id = $entity_id
 
 			UNION
 
-    			SELECT p.parts_id, p.customer_id AS entity_id, 
+    			SELECT p.parts_id, p.credit_id AS entity_id, 
 				p.pricegroup_id, 
 				p.pricebreak, p.sellprice, p.validfrom,
 				p.validto, p.curr, g.pricegroup, 2 AS priority
@@ -83,7 +83,7 @@ sub price_matrix_query {
 
 			UNION
 
-    			SELECT p.parts_id, p.customer_id AS entity_id, 
+    			SELECT p.parts_id, p.credit_id AS entity_id, 
 				p.pricegroup_id, 
 				p.pricebreak, p.sellprice, p.validfrom,
 				p.validto, p.curr, g.pricegroup, 3 AS priority
-- 
1.6.3.3

