[freeside-commits] freeside/FS/FS Schema.pm, 1.317.2.16, 1.317.2.17 rate_tier.pm, NONE, 1.1.2.2 rate_tier_detail.pm, NONE, 1.1.2.2 cdr.pm, 1.74, 1.74.2.1 cust_bill_pkg.pm, 1.56.2.3, 1.56.2.4
Ivan,,,
ivan at wavetail.420.am
Sun Nov 13 20:28:52 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv30904/FS/FS
Modified Files:
Tag: FREESIDE_2_3_BRANCH
Schema.pm cdr.pm cust_bill_pkg.pm
Added Files:
Tag: FREESIDE_2_3_BRANCH
rate_tier.pm rate_tier_detail.pm
Log Message:
rate tiers for vnes, RT#14903
--- NEW FILE: rate_tier.pm ---
package FS::rate_tier;
use base qw( FS::o2m_Common FS::Record );
use strict;
use FS::Record qw( qsearch qsearchs );
use FS::rate_tier_detail;
=head1 NAME
FS::rate_tier - Object methods for rate_tier records
=head1 SYNOPSIS
use FS::rate_tier;
$record = new FS::rate_tier \%hash;
$record = new FS::rate_tier { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::rate_tier object represents a set of rate tiers. FS::rate_tier inherits
from FS::Record. The following fields are currently supported:
=over 4
=item tiernum
primary key
=item tiername
tiername
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new record. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'rate_tier'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
# the insert method can be inherited from FS::Record
=item delete
Delete this record from the database.
=cut
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=cut
# the replace method can be inherited from FS::Record
=item check
Checks all fields to make sure this is a valid record. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
=cut
# the check method should currently be supplied - FS::Record contains some
# data checking routines
sub check {
my $self = shift;
my $error =
$self->ut_numbern('tiernum')
|| $self->ut_text('tiername')
;
return $error if $error;
$self->SUPER::check;
}
=item rate_tier_detail QUANTITY
=cut
sub rate_tier_detail {
my $self = shift;
if ( defined($_[0]) && length($_[0]) ) {
my $quantity = shift;
qsearchs({
'table' => 'rate_tier_detail',
'hashref' => { 'tiernum' => $self->tiernum,
'min_quan' => { op=>'<=', value=>$quantity },
},
'order_by' => 'ORDER BY min_charge ASC LIMIT 1',
});
} else {
qsearch({
'table' => 'rate_tier_detail',
'hashref' => { 'tiernum' => $self->tiernum, },
'order_by' => 'ORDER BY min_quan ASC',
});
}
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
--- NEW FILE: rate_tier_detail.pm ---
package FS::rate_tier_detail;
use base qw( FS::Record );
use strict;
use FS::Record; # qw( qsearch qsearchs );
use FS::rate_tier;
=head1 NAME
FS::rate_tier_detail - Object methods for rate_tier_detail records
=head1 SYNOPSIS
use FS::rate_tier_detail;
$record = new FS::rate_tier_detail \%hash;
$record = new FS::rate_tier_detail { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::rate_tier_detail object represents rate tier pricing.
FS::rate_tier_detail inherits from FS::Record. The following fields are
currently supported:
=over 4
=item tierdetailnum
primary key
=item tiernum
tiernum
=item min_quan
min_quan
=item min_charge
min_charge
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new record. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'rate_tier_detail'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
# the insert method can be inherited from FS::Record
=item delete
Delete this record from the database.
=cut
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=cut
# the replace method can be inherited from FS::Record
=item check
Checks all fields to make sure this is a valid record. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
=cut
# the check method should currently be supplied - FS::Record contains some
# data checking routines
sub check {
my $self = shift;
my $min_quan = $self->min_quan;
$min_quan =~ s/[ ,]//g;
$self->min_quan($min_quan);
$self->min_quan(0) if $self->min_quan eq '';
my $error =
$self->ut_numbern('tierdetailnum')
|| $self->ut_foreign_key('tiernum', 'rate_tier', 'tiernum')
|| $self->ut_number('min_quan')
|| $self->ut_textn('min_charge') #XXX money? but we use 4 decimal places
;
return $error if $error;
$self->SUPER::check;
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.74
retrieving revision 1.74.2.1
diff -u -w -d -r1.74 -r1.74.2.1
--- cdr.pm 9 Jun 2011 22:09:06 -0000 1.74
+++ cdr.pm 14 Nov 2011 04:28:49 -0000 1.74.2.1
@@ -401,7 +401,9 @@
sub set_status_and_rated_price {
my($self, $status, $rated_price, $svcnum, %opt) = @_;
+
if($opt{'inbound'}) {
+
my $term = qsearchs('cdr_termination', {
acctid => $self->acctid,
termpart => 1 # inbound
@@ -419,13 +421,19 @@
status => $status,
svcnum => $svcnum,
});
+ $term->rated_seconds($opt{rated_seconds}) if exists($opt{rated_seconds});
+ $term->rated_minutes($opt{rated_minutes}) if exists($opt{rated_minutes});
return $term->insert;
- }
- else {
+
+ } else {
+
$self->freesidestatus($status);
$self->rated_price($rated_price);
+ $self->rated_seconds($opt{rated_seconds}) if exists($opt{rated_seconds});
+ $self->rated_minutes($opt{rated_minutes}) if exists($opt{rated_minutes});
$self->svcnum($svcnum) if $svcnum;
return $self->replace();
+
}
}
@@ -642,6 +650,20 @@
return %export_formats;
}
+=item downstream_csv OPTION => VALUE ...
+
+Options:
+
+format
+
+charge
+
+seconds
+
+granularity
+
+=cut
+
sub downstream_csv {
my( $self, %opt ) = @_;
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.56.2.3
retrieving revision 1.56.2.4
diff -u -w -d -r1.56.2.3 -r1.56.2.4
--- cust_bill_pkg.pm 3 Aug 2011 22:13:07 -0000 1.56.2.3
+++ cust_bill_pkg.pm 14 Nov 2011 04:28:49 -0000 1.56.2.4
@@ -820,8 +820,18 @@
if ( $self->get('details') ) {
@values =
- map { $_->[2] }
- grep { ref($_) && ( defined($classnum) ? $_->[3] eq $classnum : 1 ) }
+ map { ref($_) eq 'HASH'
+ ? $_->{'amount'}
+ : $_->[2]
+ }
+ grep { ref($_) && ( defined($classnum)
+ ? $classnum eq ( ref($_) eq 'HASH'
+ ? $_->{'classnum'}
+ : $_->[3]
+ )
+ : 1
+ )
+ }
@{ $self->get('details') };
}else{
@@ -852,7 +862,10 @@
my %seen = ();
foreach my $detail ( grep { ref($_) } @{$self->get('details')} ) {
- $seen{ $detail->[3] } = 1;
+ $seen{ ref($detail) eq 'HASH'
+ ? $detail->{'classnum'}
+ : $detail->[3]
+ } = 1;
}
keys %seen;
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.317.2.16
retrieving revision 1.317.2.17
diff -u -w -d -r1.317.2.16 -r1.317.2.17
--- Schema.pm 12 Nov 2011 00:35:43 -0000 1.317.2.16
+++ Schema.pm 14 Nov 2011 04:28:49 -0000 1.317.2.17
@@ -2688,6 +2688,30 @@
'index' => [],
},
+ #not really part of the above rate_ stuff (used with flat rate rather than
+ # rated billing), but could be eventually, and its a rate
+ 'rate_tier' => {
+ 'columns' => [
+ 'tiernum', 'serial', '', '', '', '',
+ 'tiername', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'tiernum',
+ 'unique' => [ [ 'tiername'], ],
+ 'index' => [],
+ },
+
+ 'rate_tier_detail' => {
+ 'columns' => [
+ 'tierdetailnum', 'serial', '', '', '', '',
+ 'tiernum', 'int', '', '', '', '',
+ 'min_quan', 'int', '', '', '', '',
+ 'min_charge', 'decimal', '', '10,4', '', '',
+ ],
+ 'primary_key' => 'tierdetailnum',
+ 'unique' => [],
+ 'index' => [ ['tiernum'], ],
+ },
+
'usage_class' => {
'columns' => [
'classnum', 'serial', '', '', '', '',
@@ -2875,24 +2899,17 @@
'max_callers', 'int', 'NULL', '', '', '',
###
- # fields for unitel/RSLCOM/convergent that don't map well to asterisk
- # defaults
- # though these are now used elsewhere:
+ # old fields for unitel/RSLCOM/convergent that don't map to asterisk
+ # ones we adoped moved to "own fields" section below
# charged_party, upstream_price, rated_price, carrierid, cdrtypenum
###
- #cdr_type: Usage = 1, S&E = 7, OC&C = 8
- 'cdrtypenum', 'int', 'NULL', '', '', '',
-
- 'charged_party', 'varchar', 'NULL', $char_d, '', '',
-
'upstream_currency', 'char', 'NULL', 3, '', '',
'upstream_price', 'decimal', 'NULL', '10,4', '', '',
'upstream_rateplanid', 'int', 'NULL', '', '', '', #?
# how it was rated internally...
'ratedetailnum', 'int', 'NULL', '', '', '',
- 'rated_price', 'decimal', 'NULL', '10,4', '', '',
'distance', 'decimal', 'NULL', '', '', '',
'islocal', 'int', 'NULL', '', '', '', # '', '', 0, '' instead?
@@ -2903,16 +2920,24 @@
'description', 'varchar', 'NULL', $char_d, '', '',
'quantity', 'int', 'NULL', '', '', '',
- #cdr_carrier: Telstra =1, Optus = 2, RSL COM = 3
- 'carrierid', 'int', 'NULL', '', '', '',
-
'upstream_rateid', 'int', 'NULL', '', '', '',
###
#and now for our own fields
###
- # a svcnum... right..?
+ 'cdrtypenum', 'int', 'NULL', '', '', '',
+
+ 'charged_party', 'varchar', 'NULL', $char_d, '', '',
+
+ # how it was rated internally...
+ 'rated_price', 'decimal', 'NULL', '10,4', '', '',
+ 'rated_seconds', 'int', 'NULL', '', '', '',
+ 'rated_minutes', 'double precision', 'NULL', '', '', '',
+
+ 'carrierid', 'int', 'NULL', '', '', '',
+
+ # service it was matched to
'svcnum', 'int', 'NULL', '', '', '',
#NULL, done (or something)
@@ -2963,6 +2988,8 @@
'acctid', 'bigint', '', '', '', '',
'termpart', 'int', '', '', '', '',#future use see below
'rated_price', 'decimal', 'NULL', '10,4', '', '',
+ 'rated_seconds', 'int', 'NULL', '', '', '',
+ 'rated_minutes', 'double precision', 'NULL', '', '', '',
'status', 'varchar', 'NULL', 32, '', '',
'svcnum', 'int', 'NULL', '', '', '',
],
More information about the freeside-commits
mailing list