[freeside-commits] freeside/FS/FS cust_main.pm, 1.438, 1.439 Schema.pm, 1.150, 1.151 cdr_termination.pm, NONE, 1.1

Ivan,,, ivan at wavetail.420.am
Wed Jul 1 03:28:51 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv10174/FS/FS

Modified Files:
	cust_main.pm Schema.pm 
Added Files:
	cdr_termination.pm 
Log Message:
start of settlement CDR processing, RT#5495

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- Schema.pm	30 Jun 2009 19:38:57 -0000	1.150
+++ Schema.pm	1 Jul 2009 10:28:49 -0000	1.151
@@ -694,6 +694,7 @@
         'comments', 'text', 'NULL', '', '', '', 
         'spool_cdr','char', 'NULL', 1, '', '', 
         'squelch_cdr','char', 'NULL', 1, '', '', 
+        'cdr_termination_percentage', 'decimal', 'NULL', '', '', '',
         'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
         'archived', 'char', 'NULL', 1, '', '',
       ],
@@ -2144,6 +2145,32 @@
       'index' => [ [ 'calldate' ], [ 'src' ], [ 'dst' ], [ 'charged_party' ], [ 'accountcode' ], [ 'freesidestatus' ], [ 'freesiderewritestatus' ], [ 'cdrbatch' ], ],
     },
 
+    'cdr_termination' => {
+      'columns' => [
+        'cdrtermnum', 'bigserial', '',   '', '', '',
+        'acctid',        'bigint', '',   '', '', '', 
+        'termpart',         'int', '',   '', '', '',#future expansion, see below
+        'rated_price',  @money_typen,        '', '',
+        'status',     'varchar', 'NULL', 32, '', '',
+      ],
+      'primary_key' => 'cdrtermnum',
+      'unique'      => [ [ 'acctid', 'termpart' ] ],
+      'index'       => [ [ 'acctid' ], [ 'status' ], ],
+    },
+
+    #to handle multiple termination/settlement passes...
+   # 'part_termination' => {
+   #   'columns' => [
+   #     'termpart',       'int', '',      '', '', '',
+   #     'termname',   'varchar', '', $char_d, '', '',
+   #     'cdr_column', 'varchar', '', $char_d, '', '', #maybe set it here instead of in the price plan?
+   #   ],
+   #   'primary_key' => 'termpart',
+   #   'unique' => [],
+   #   'index'  => [],
+   # },
+
+    #the remaining cdr_ tables are not really used
     'cdr_calltype' => {
       'columns' => [
         'calltypenum',   'serial',  '', '', '', '', 

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.438
retrieving revision 1.439
diff -u -d -r1.438 -r1.439
--- cust_main.pm	30 Jun 2009 12:28:36 -0000	1.438
+++ cust_main.pm	1 Jul 2009 10:28:49 -0000	1.439
@@ -1553,6 +1553,7 @@
     || $self->ut_textn('stateid_state')
     || $self->ut_textn('invoice_terms')
     || $self->ut_alphan('geocode')
+    || $self->ut_floatn('cdr_termination_percentage')
   ;
 
   #barf.  need message catalogs.  i18n.  etc.
@@ -6739,11 +6740,38 @@
 
 }
 
-=item charge AMOUNT [ PKG [ COMMENT [ TAXCLASS ] ] ]
+=item charge HASHREF || AMOUNT [ PKG [ COMMENT [ TAXCLASS ] ] ]
 
 Creates a one-time charge for this customer.  If there is an error, returns
 the error, otherwise returns false.
 
+New-style, with a hashref of options:
+
+  my $error = $cust_main->charge(
+                                  {
+                                    'amount'     => 54.32,
+                                    'quantity'   => 1,
+                                    'start_date' => str2time('7/4/2009'),
+                                    'pkg'        => 'Description',
+                                    'comment'    => 'Comment',
+                                    'additional' => [], #extra invoice detail
+                                    'classnum'   => 1,  #pkg_class
+
+                                    'setuptax'   => '', # or 'Y' for tax exempt
+
+                                    #internal taxation
+                                    'taxclass'   => 'Tax class',
+
+                                    #vendor taxation
+                                    'taxproduct' => 2,  #part_pkg_taxproduct
+                                    'override'   => {}, #XXX describe
+                                  }
+                                );
+
+Old-style:
+
+  my $error = $cust_main->charge( 54.32, 'Description', 'Comment', 'Tax class' );
+
 =cut
 
 sub charge {

--- NEW FILE: cdr_termination.pm ---
package FS::cdr_termination;

use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );

=head1 NAME

FS::cdr_termination - Object methods for cdr_termination records

=head1 SYNOPSIS

  use FS::cdr_termination;

  $record = new FS::cdr_termination \%hash;
  $record = new FS::cdr_termination { 'column' => 'value' };

  $error = $record->insert;

  $error = $new_record->replace($old_record);

  $error = $record->delete;

  $error = $record->check;

=head1 DESCRIPTION

An FS::cdr_termination object represents an CDR termination status.
FS::cdr_termination inherits from FS::Record.  The following fields are
currently supported:

=over 4

=item cdrtermnum

primary key

=item acctid

acctid

=item termpart

termpart

=item rated_price

rated_price

=item status

status


=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 { 'cdr_termination'; }

=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('cdrtermnum')
    || $self->ut_foreign_key('acctid', 'cdr', 'acctid')
    #|| $self->ut_foreign_key('termpart', 'part_termination', 'termpart')
    || $self->ut_number('termpart')
    || $self->ut_float('rated_price')
    || $self->ut_enum('status', '', 'done' ) # , 'skipped' )
  ;
  return $error if $error;

  $self->SUPER::check;
}

=item set_status_and_rated_price STATUS [ RATED_PRICE ]

Sets the status to the provided string.  If there is an error, returns the
error, otherwise returns false.

=cut

sub set_status_and_rated_price {
  my($self, $status, $rated_price) = @_;
  $self->status($status);
  $self->rated_price($rated_price);
  $self->replace();
}

=back

=head1 BUGS

=head1 SEE ALSO

L<FS::cdr>, L<FS::Record>, schema.html from the base documentation.

=cut

1;




More information about the freeside-commits mailing list