reconcile invoice destination contacts with multiple-customer contacts, #25536 and...
[freeside.git] / httemplate / REST / 1.0 / rate_detail
1 <% encode_rest( \@rate_detail ) %>\
2 <%init>
3
4 rest_auth($cgi);
5
6 my $extra_sql = '';
7 if ( $cgi->param('countrycode') =~ /^\+?(\d+)$/ ) {
8   my $countrycode = $1;
9   $extra_sql = "
10     WHERE EXISTS ( SELECT 1 FROM rate_region
11                      WHERE rate_detail.dest_regionnum = rate_region.regionnum
12                        AND countrycode = '$countrycode'
13   ";
14 }
15
16 my @detail_fields = fields('rate_detail');
17 my @region_fields = fields('rate_region');
18
19 my @rate_detail =
20   map {
21     my $rate_detail = $_;
22     my $rate_region = $rate_detail->dest_region;
23
24     +{
25       ( map { $_ => $rate_detail->$_ } @detail_fields ),
26       ( map { $_ => $rate_region->$_ } @region_fields ),
27      };
28
29   } qsearch({
30       'table'   => 'rate_detail',
31       'hashref' => {},
32       extra_sql => $extra_sql,
33     });
34
35 </%init>