summaryrefslogtreecommitdiff
path: root/httemplate/REST
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-11-18 13:07:47 -0800
committerMark Wells <mark@freeside.biz>2015-11-18 13:07:47 -0800
commitb2fd002f3285b70311642f8ff0025598d42bd16e (patch)
tree8005ab27d04c8aaaa7e9bfd10a9ba0f48cafd967 /httemplate/REST
parent1daa37e733b9e972e5328503374130a423d02836 (diff)
track customer invoice destination emails using contact_email, #25536
Diffstat (limited to 'httemplate/REST')
-rw-r--r--httemplate/REST/1.0/cust_main18
1 files changed, 12 insertions, 6 deletions
diff --git a/httemplate/REST/1.0/cust_main b/httemplate/REST/1.0/cust_main
index 4656bcb25..5401195fc 100644
--- a/httemplate/REST/1.0/cust_main
+++ b/httemplate/REST/1.0/cust_main
@@ -47,17 +47,23 @@ if ( $r->method eq 'GET' ) {
if ( $cgi->param('cust_main_invoice_dest') ) {
my $dest = dbh->quote(scalar($cgi->param('cust_main_invoice_dest')));
$extra_sql = "
- WHERE EXISTS ( SELECT 1 FROM cust_main_invoice
- WHERE cust_main.custnum = cust_main_invoice.custnum
- AND dest = $dest
+ WHERE EXISTS ( SELECT 1 FROM cust_contact
+ JOIN contact USING (contactnum)
+ JOIN contact_email USING (contactnum)
+ WHERE cust_main.custnum = cust_contact.custnum
+ AND contact.invoice_dest = 'Y'
+ AND contact_email.emailaddress = $dest
)
";
} elsif ( $cgi->param('cust_main_invoice_dest_substring') ) {
my $dest = dbh->quote('%'. scalar($cgi->param('cust_main_invoice_dest_substring')). '%');
$extra_sql = "
- WHERE EXISTS ( SELECT 1 FROM cust_main_invoice
- WHERE cust_main.custnum = cust_main_invoice.custnum
- AND dest ILIKE $dest
+ WHERE EXISTS ( SELECT 1 FROM cust_contact
+ JOIN contact USING (contactnum)
+ JOIN contact_email USING (contactnum)
+ WHERE cust_main.custnum = cust_contact.custnum
+ AND contact.invoice_dest = 'Y'
+ AND contact_email.emailaddress ILIKE $dest
)
";
}