[freeside-commits] freeside/FS/FS cust_pkg.pm, 1.62, 1.63 Conf.pm, 1.153, 1.154 ConfDefaults.pm, NONE, 1.1 cust_main_Mixin.pm, 1.1, 1.2

Ivan,,, ivan at wavetail.420.am
Mon Jun 19 01:05:30 PDT 2006


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv13210/FS/FS

Modified Files:
	cust_pkg.pm Conf.pm cust_main_Mixin.pm 
Added Files:
	ConfDefaults.pm 
Log Message:
add ability to select specific package defs. and package status to package report for qis

Index: cust_main_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main_Mixin.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cust_main_Mixin.pm	14 Jul 2005 10:52:46 -0000	1.1
+++ cust_main_Mixin.pm	19 Jun 2006 08:05:28 -0000	1.2
@@ -89,6 +89,50 @@
     : $self->cust_unlinked_msg;
 }
 
+=item country_full
+
+Given an object that contains fields from cust_main (say, from a JOINed
+search; see httemplate/search/ for examples), returns the equivalent of the
+FS::cust_main I<country_full> method, or "(unlinked)" if this object is not
+linked to a customer.
+
+=cut
+
+sub country_full {
+  my $self = shift;
+  $self->cust_linked
+    ? FS::cust_main::country_full($self)
+    : $self->cust_unlinked_msg;
+}
+
+=item invoicing_list_emailonly
+
+Given an object that contains fields from cust_main (say, from a JOINed
+search; see httemplate/search/ for examples), returns the equivalent of the
+FS::cust_main I<country_full> method, or "(unlinked)" if this object is not
+linked to a customer.
+
+=cut
+
+sub invoicing_list_emailonly {
+  my $self = shift;
+  warn "invoicing_list_email only called on $self, ".
+       "custnum ". $self->custnum. "\n";
+  $self->cust_linked
+    ? FS::cust_main::invoicing_list_emailonly($self)
+    : $self->cust_unlinked_msg;
+}
+
+#read-only
+sub invoicing_list {
+  my $self = shift;
+  $self->cust_linked
+    ? FS::cust_main::invoicing_list($self)
+    : ();
+}
+
+=cut
+
 =back
 
 =head1 BUGS

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

=head1 NAME

FS::ConfDefaults - Freeside configuration default and available values

=head1 SYNOPSIS

  use FS::ConfDefaults;

  @avail_cust_fields = FS::ConfDefaults->cust_fields_avail();

=head1 DESCRIPTION

Just a small class to keep config default and available values

=head1 METHODS

=over 4

=item cust_fields_avail

Returns a list, suitable for assigning to a hash, of available values and
labels for customer fields values.

=cut

# XXX should use msgcat for "Day phone" and "Night phone", but how?
sub cust_fields_avail { (

  'Customer' =>
    'Last, First or Company (Last, First)',
  'Cust# | Customer' =>
    'custnum | Last, First or Company (Last, First)',

  'Name | Company' =>
    'Last, First | Company',
  'Cust# | Name | Company' =>
    'custnum | Last, First | Company',

  '(bill) Customer | (service) Customer' =>
    'Last, First or Company (Last, First) | (same for service contact if present)',
  'Cust# | (bill) Customer | (service) Customer' =>
    'custnum | Last, First or Company (Last, First) | (same for service contact if present)',

  '(bill) Name | (bill) Company | (service) Name | (service) Company' =>
    'Last, First | Company | (same for service address if present)',
  'Cust# | (bill) Name | (bill) Company | (service) Name | (service) Company' =>
    'custnum | Last, First | Company | (same for service address if present)',

  'Cust# | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Invoicing email(s)' => 
    'custnum | Last, First | Company | (all address fields ) | Day phone | Night phone | Invoicing email(s)',

); }

=back

=head1 BUGS

Not yet.

=head1 SEE ALSO

L<FS::Conf>

=cut

1;

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- Conf.pm	8 May 2006 11:28:52 -0000	1.153
+++ Conf.pm	19 Jun 2006 08:05:28 -0000	1.154
@@ -4,6 +4,7 @@
 use IO::File;
 use File::Basename;
 use FS::ConfItem;
+use FS::ConfDefaults;
 
 $DEBUG = 0;
 
@@ -1619,18 +1620,9 @@
   {
     'key'         => 'cust-fields',
     'section'     => 'UI',
-    'description' => 'Which customer fields to display on reports',
+    'description' => 'Which customer fields to display on reports by default',
     'type'        => 'select',
-    'select_enum' => [
-      'Customer: Last, First</b> or</i> Company (Last, First)</b>',
-      'Cust# | Customer: custnum | Last, First or Company (Last, First)',
-      'Name | Company: Last, First | Company',
-      'Cust# | Name | Company: custnum | Last, First | Company',
-      '(bill) Customer | (service) Customer: Last, First or Company (Last, First) | (same for service address if present)',
-      'Cust# | (bill) Customer | (service) Customer:  custnum | Last, First or Company (Last, First) | (same for service address if present)',
-      '(bill) Name | (bill) Company | (service) Name | (service) Company: Last, First | Company | (same for service address if present)',
-      'Cust# | (bill) Name | (bill) Company | (service) Name | (service) Company: custnum | Last, First | Company | (same for service address if present)',
-    ],
+    'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
   },
 
   {
@@ -1709,6 +1701,21 @@
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'batch-default_format',
+    'section'     => 'billing',
+    'description' => 'Default format for batches.',
+    'type'        => 'select',
+    'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM' ]
+  },
+
+  {
+    'key'         => 'batchconfig-BoM',
+    'section'     => 'billing',
+    'description' => 'Configuration for Bank of Montreal batching, seven lines: 1. Origin ID, 2. Datacenter, 3. Typecode, 4. Short name, 5. Long name, 6. Bank, 7. Bank account',
+    'type'        => 'textarea',
+  },
+
 );
 
 1;

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- cust_pkg.pm	30 Dec 2005 02:41:22 -0000	1.62
+++ cust_pkg.pm	19 Jun 2006 08:05:28 -0000	1.63
@@ -2,6 +2,7 @@
 
 use strict;
 use vars qw(@ISA $disable_agentcheck @SVCDB_CANCEL_SEQ $DEBUG);
+use Tie::IxHash;
 use FS::UID qw( getotaker dbh );
 use FS::Misc qw( send_email );
 use FS::Record qw( qsearch qsearchs );
@@ -824,26 +825,45 @@
 sub status {
   my $self = shift;
 
+  my $freq = length($self->freq) ? $self->freq : $self->part_pkg->freq;
+
   return 'cancelled' if $self->get('cancel');
   return 'suspended' if $self->susp;
   return 'not yet billed' unless $self->setup;
-  return 'one-time charge' if $self->part_pkg->freq =~ /^(0|$)/;
+  return 'one-time charge' if $freq =~ /^(0|$)/;
   return 'active';
 }
 
-=item statuscolor
+=item statuses
 
-Returns a hex triplet color string for this package's status.
+Class method that returns the list of possible status strings for pacakges
+(see L<the status method|/status>).  For example:
+
+  @statuses = FS::cust_pkg->statuses();
 
 =cut
 
-my %statuscolor = (
+tie my %statuscolor, 'Tie::IxHash', 
   'not yet billed'  => '000000',
   'one-time charge' => '000000',
   'active'          => '00CC00',
   'suspended'       => 'FF9900',
   'cancelled'       => 'FF0000',
-);
+;
+
+sub statuses {
+  my $self = shift; #could be class...
+  grep { $_ !~ /^(not yet billed)$/ } #this is a dumb status anyway
+                                      # mayble split btw one-time vs. recur
+    keys %statuscolor;
+}
+
+=item statuscolor
+
+Returns a hex triplet color string for this package's status.
+
+=cut
+
 sub statuscolor {
   my $self = shift;
   $statuscolor{$self->status};
@@ -1163,7 +1183,7 @@
 
 =back
 
-=head1 CLASS METHOD
+=head1 CLASS METHODS
 
 =over 4
 
@@ -1178,6 +1198,17 @@
              where cust_pkg.pkgpart = part_pkg.pkgpart )
 "; }
 
+=item onetime_sql
+
+Returns an SQL expression identifying one-time packages.
+
+=cut
+
+sub onetime_sql { "
+  '0' = ( select freq from part_pkg
+            where cust_pkg.pkgpart = part_pkg.pkgpart )
+"; }
+
 =item active_sql
 
 Returns an SQL expression identifying active packages.
@@ -1190,6 +1221,19 @@
   AND ( cust_pkg.susp   IS NULL OR cust_pkg.susp   = 0 )
 "; }
 
+=item inactive_sql
+
+Returns an SQL expression identifying inactive packages (one-time packages
+that are otherwise unsuspended/uncancelled).
+
+=cut
+
+sub inactive_sql { "
+  ". $_[0]->onetime_sql(). "
+  AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
+  AND ( cust_pkg.susp   IS NULL OR cust_pkg.susp   = 0 )
+"; }
+
 =item susp_sql
 =item suspended_sql
 
@@ -1198,11 +1242,13 @@
 =cut
 
 sub suspended_sql { susp_sql(@_); }
-sub susp_sql { "
-  ". $_[0]->recurring_sql(). "
-  AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
-  AND cust_pkg.susp IS NOT NULL AND cust_pkg.susp != 0
-"; }
+sub susp_sql {
+  #$_[0]->recurring_sql(). ' AND '.
+  "
+        ( cust_pkg.cancel IS     NULL  OR cust_pkg.cancel = 0 )
+    AND   cust_pkg.susp   IS NOT NULL AND cust_pkg.susp  != 0
+  ";
+}
 
 =item cancel_sql
 =item cancelled_sql
@@ -1212,10 +1258,10 @@
 =cut
 
 sub cancelled_sql { cancel_sql(@_); }
-sub cancel_sql { "
-  ". $_[0]->recurring_sql(). "
-  AND cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0
-"; }
+sub cancel_sql { 
+  #$_[0]->recurring_sql(). ' AND '.
+  "cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0";
+}
 
 =head1 SUBROUTINES
 



More information about the freeside-commits mailing list