[freeside-commits] freeside/FS/FS/part_pkg rt_time.pm,NONE,1.1
Jason Hall
jayce at wavetail.420.am
Mon Jan 25 20:47:05 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv24585/part_pkg
Added Files:
rt_time.pm
Log Message:
First version of RT Billing pkg. Basic concept is if a customer has this package, then any time added to ticket comments in RT will be added up and multiplied by the base rate, with each entry showing up as a lineitem on their next invoice.
This has not been used in production yet by anybody, it was just a proposal done for a customer.
Modified Files:
TicketSystem/RT_External.pm
Added Files:
part_pkg/rt_time.pm
--- NEW FILE: rt_time.pm ---
package FS::part_pkg::rt_time;
use strict;
use FS::Conf;
use FS::Record qw(qsearchs qsearch);
use FS::part_pkg::recur_Common;
use Carp qw(cluck);
our @ISA = qw(FS::part_pkg::recur_Common);
our $DEBUG = 0;
our %info = (
'name' => 'Bill from Time Worked on tickets in RT',
'shortname' => 'Project Billing (RT)',
'fields' => {
'base_rate' => { 'name' => 'Rate (per minute)',
'default' => 0,
},
}
);
sub calc_setup {
my($self, $cust_pkg ) = @_;
$self->option('setup_fee');
}
sub calc_recur {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_;
my $charges = 0;
$charges += $self->calc_usage(@_);
$charges += $self->calc_recur_Common(@_);
$charges;
}
sub calc_cancel {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_;
$self->calc_usage(@_);
}
sub calc_usage {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_;
my $last_bill = $cust_pkg->get('last_bill') || $cust_pkg->get('setup');
my @tickets = @{ FS::TicketSystem->comments_on_tickets( $cust_pkg->custnum, 100, $last_bill ) };
my $charges = 0;
my $rate = $self->option('base_rate');
foreach my $ding ( @tickets) {
$charges += sprintf('%.2f', $ding->{'timetaken'} * $rate);
push @$details, join( ", ", ("($ding->{timetaken}) Minutes", substr($ding->{'content'},0,255)));
}
cluck $rate, $charges, @$details if $DEBUG > 0;
return $charges;
}
1;
More information about the freeside-commits
mailing list