[BACK]Return to rt_invoices.pl CVS log [TXT][DIR] Up to [local] / RT / Invoicing

Diff for /RT/Invoicing/rt_invoices.pl between version 1.7 and 1.8

version 1.7, 2011/03/21 23:29:22 version 1.8, 2011/03/22 00:22:27
Line 148 
Line 148 
     }      }
     my $invoice = $cust->{invoice};      my $invoice = $cust->{invoice};
   
     #foreach my $r ($ticket->requestors) {  
     #    $users->id( $r );  
     #    $users->retrieve;  
     #    print Dump $users;  
     #}  
   
     my $project = make_project( $ticket, $cust );      my $project = make_project( $ticket, $cust );
     next unless @{ $project->{fees} } || @{ $project->{expenses} };      next unless @{ $project->{fees} } || @{ $project->{expenses} };
   
Line 301 
Line 295 
         return $cust;          return $cust;
     }      }
   
     return fake_customer($ticket);      return fake_customer( $customers, $ticket );
 }  }
   
 sub fake_customer {  sub fake_customer {
     my ($ticket) = @_;      my ( $customers, $ticket ) = @_;
   
     # XXX eventually, will generate a customer we can bill!      # make the custid the first requestor
     return;      my ($custid) = $ticket->requestors;
       return unless $custid;
   
       my $cust = $config->get('default') || {};
       $cust->{to} = get_requestor($custid);
   
       my %invoice = ( end => DateTime->now );
   
       my $lastinvoice = $state->last_invoice($custid);
       if ( $lastinvoice->{date} ) {
           my $last_invoice_date = ymd_to_DateTime( $lastinvoice->{date} );
           $invoice{start} = $last_invoice_date->clone->add( days => 1 );
       }
   
       if ( !( $invoice{start} && $invoice{start} < $invoice{end} ) ) {
           $cust->{invoice} = \%invoice;
       }
   
       $customers->{$custid} = $cust;
       return $cust;
   }
   
   sub get_requestor {
       my ($id) = @_;
   
       state %requestors;
       return $requestors{$id} if $requestors{$id};
   
       my %map = (
           address_one   => 'addr1',
           address_two   => 'addr2',
           email_address => 'email',
       );
   
       $users->id($id);
       $users->retrieve;
   
       my %requestor;
       foreach my $m ( keys %{ $users->_attributes } ) {
           next unless $users->can($m);
   
           my $v = $users->$m;
           next unless $v;
   
           $m = $map{$m} if exists $map{$m};
   
           $requestor{$m} = $v;
       }
   
       $requestors{$id} = \%requestor;
       return \%requestor;
 }  }
   
 sub make_project {  sub make_project {

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>