This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / bin / freeside-dedup-cust_bill_pkg_detail-header
1 #!/usr/bin/perl -w
2
3 use strict;
4 use vars qw( %seen $opt_d );
5 use Getopt::Std;
6 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearch);
8 use FS::cust_bill_pkg_detail;
9
10 getopts('d');
11
12 my $user = shift or die &usage;
13 adminsuidsetup $user;
14
15 my $extra_sql = "AND detail LIKE 'Date,Time%'";
16 my @cust_bill_pkg_detail = qsearch( { 'table'     => 'cust_bill_pkg_detail',
17                                       'hashref'   => {format => 'C'},
18                                       'extra_sql' => $extra_sql,
19                                   } );
20 for my $detail (@cust_bill_pkg_detail) {
21   if ( $seen{$detail->billpkgnum} ) {
22     if ($opt_d) { # dry run
23       print "DELETE cust_bill_pkg_detail WHERE detailnum=". $detail->detailnum.
24         "\n";
25     } else {
26       $detail->delete;
27     }
28   } else {
29     $seen{$detail->billpkgnum} = 1;
30   }
31 }
32
33 sub usage {
34   die "Usage:\n\n  freeside-sqlradius-dedup-group [-d] user\n";
35 }
36
37 =head1 NAME
38
39 freeside-dedup-cust_bill_pkg_detail-header - Command line tool to eliminate duplicate headers from cdr details on invoices
40
41 =head1 SYNOPSIS
42
43   freeside-dedup-cust_bill_pkg_detail-header user
44
45 =head1 DESCRIPTION
46
47   Removes all but one header when duplicate entries exist on invoice 
48   cdr details.
49
50   -d: dry run
51
52 =head1 SEE ALSO
53
54 L<FS::part_pkg::voip_cdr>
55
56 =cut
57