[freeside-commits] freeside/FS/FS/part_event/Action addpost.pm, NONE, 1.1 apply.pm, NONE, 1.1 bill.pm, NONE, 1.1 cancel.pm, NONE, 1.1 collect.pm, NONE, 1.1 cust_bill_batch.pm, NONE, 1.1 cust_bill_comp.pm, NONE, 1.1 cust_bill_fee_percent.pm, NONE, 1.1 cust_bill_realtime_card.pm, NONE, 1.1 cust_bill_realtime_check.pm, NONE, 1.1 cust_bill_realtime_lec.pm, NONE, 1.1 cust_bill_send.pm, NONE, 1.1 cust_bill_send_agent.pm, NONE, 1.1 cust_bill_send_alternate.pm, NONE, 1.1 cust_bill_send_csv_ftp.pm, NONE, 1.1 cust_bill_send_if_newest.pm, NONE, 1.1 cust_bill_spool_csv.pm, NONE, 1.1 cust_bill_suspend_if_balance.pm, NONE, 1.1 fee.pm, NONE, 1.1 suspend.pm, NONE, 1.1 suspend_if_pkgpart.pm, NONE, 1.1 suspend_unless_pkgpart.pm, NONE, 1.1

Ivan,,, ivan at wavetail.420.am
Wed Aug 1 15:24:41 PDT 2007


Update of /home/cvs/cvsroot/freeside/FS/FS/part_event/Action
In directory wavetail:/tmp/cvs-serv23435/FS/FS/part_event/Action

Added Files:
	addpost.pm apply.pm bill.pm cancel.pm collect.pm 
	cust_bill_batch.pm cust_bill_comp.pm cust_bill_fee_percent.pm 
	cust_bill_realtime_card.pm cust_bill_realtime_check.pm 
	cust_bill_realtime_lec.pm cust_bill_send.pm 
	cust_bill_send_agent.pm cust_bill_send_alternate.pm 
	cust_bill_send_csv_ftp.pm cust_bill_send_if_newest.pm 
	cust_bill_spool_csv.pm cust_bill_suspend_if_balance.pm fee.pm 
	suspend.pm suspend_if_pkgpart.pm suspend_unless_pkgpart.pm 
Log Message:
event refactor, landing on HEAD!

--- NEW FILE: cust_bill_realtime_card.pm ---
package FS::part_event::Action::cust_bill_realtime_card;

use strict;
use base qw( FS::part_event::Action );

sub description {
  #'Run card with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
  'Run card with a Business::OnlinePayment realtime gateway';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub default_weight {
  30;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->realtime_card;
}

1;

--- NEW FILE: cust_bill_send_csv_ftp.pm ---
package FS::part_event::Action::cust_bill_send_csv_ftp;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Upload CSV invoice data to an FTP server';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  (
    'ftpformat'   => { label   => 'Format',
                       type    =>'select',
                       options => ['default', 'billco'],
                       option_labels => { 'default' => 'Default',
                                          'billco'  => 'Billco',
                                        },
                     },
    'ftpserver'   => 'FTP server',
    'ftpusername' => 'FTP username',
    'ftppassword' => 'FTP password',
    'ftpdir'      => 'FTP directory',
  );
}

sub default_weight {
  50;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->send_csv(
    'protocol'   => 'ftp',
    'server'     => $self->option('ftpserver'),
    'username'   => $self->option('ftpusername'),
    'password'   => $self->option('ftppassword'),
    'dir'        => $self->option('ftpdir'),
    'format'     => $self->option('ftpformat'),
  );

  '';
}

1;

--- NEW FILE: cust_bill_send_agent.pm ---
package FS::part_event::Action::cust_bill_send_agent;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Send invoice (email/print/fax) with alternate template, for specific agents';
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  (
    'agentnum'           => { label    => 'Only for agent(s)',
                              type     => 'select-agent',
                              multiple => 1
                            },
    'agent_templatename' => { label    => 'Template',
                              type     => 'select-invoice_template',
                            },
    'agent_invoice_from' => 'Invoice email From: address',
  );
}

sub default_weight {
  50;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->send(
    $self->option('agent_templatename'),
    [ split(/\s*,\s*/, $self->option('agentnum') ) ],
    $self->option('agent_invoice_from'),
  );
}

1;

--- NEW FILE: suspend_if_pkgpart.pm ---
package FS::part_event::Action::suspend_if_pkgpart;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Suspend packages';
}

sub option_fields {
  ( 
    'if_pkgpart' => { 'label'    => 'Suspend packages:',
                      'type'     => 'select-part_pkg',
                      'multiple' => 1,
                    },
    'reasonnum' => { 'label'        => 'Reason',
                     'type'         => 'select-reason',
                     'reason_class' => 'S',
                   },
  );
};

sub default_weight {
  10;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my @err = $cust_main->suspend_if_pkgpart( {
    'pkgparts' => [ split(/\s*,\s*/, $self->option('if_pkgpart') ) ],
    'reason'   => $self->option('reasonnum'),
  } );

  die join(' / ', @err) if scalar(@err);

  '';
}

1;

--- NEW FILE: bill.pm ---
package FS::part_event::Action::bill;

use strict;
use base qw( FS::part_event::Action );

sub description {
  #'Generate invoices (normally only used with a <i>Late Fee</i> event)';
  'Generate invoices (normally only used with a Late Fee event)';
}

sub deprecated {
  1;
}

sub default_weight {
  60;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my $error = $cust_main->bill;
  die $error if $error;

  '';
}

1;

--- NEW FILE: suspend.pm ---
package FS::part_event::Action::suspend;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Suspend';
}

sub option_fields {
  ( 
    'reasonnum' => { 'label'        => 'Reason',
                     'type'         => 'select-reason',
                     'reason_class' => 'S',
                   },
  );
};

sub default_weight {
  10;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my @err = $cust_main->suspend( 'reason' => $self->option('reasonnum') );

  die join(' / ', @err) if scalar(@err);

  '';

}

1;

--- NEW FILE: cust_bill_batch.pm ---
package FS::part_event::Action::cust_bill_batch;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Add card or check to a pending batch';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub default_weight {
  40;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->batch_card; # ( %options ); #XXX options??
}

1;

--- NEW FILE: cust_bill_send_alternate.pm ---
package FS::part_event::Action::cust_bill_send_alternate;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Send invoice (email/print/fax) with alternate template';
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  (
    'templatename' => { label    => 'Template',
                        type     => 'select-invoice_template',
                      },
  );
}

sub default_weight {
  50;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->send( $self->option('templatename') );
}

1;

--- NEW FILE: cust_bill_realtime_lec.pm ---
package FS::part_event::Action::cust_bill_realtime_lec;

use strict;
use base qw( FS::part_event::Action );

sub description {
  #'Run phone bill ("LEC") billing with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
  'Run phone bill ("LEC") billing with a Business::OnlinePayment realtime gateway';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub default_weight {
  30;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->realtime_lec;
}

1;

--- NEW FILE: cust_bill_fee_percent.pm ---
package FS::part_event::Action::cust_bill_fee_percent;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Late fee (percentage of invoice)';
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  ( 
    'percent' => { label=>'Percent', size=>2, },
    'reason'  => 'Reason',
  );
}

sub default_weight {
  10;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  my $error = $cust_main->charge(
    sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ),
    $self->option('reason')
  );
  die $error if $error;

  '';
}

1;

--- NEW FILE: suspend_unless_pkgpart.pm ---
package FS::part_event::Action::suspend_unless_pkgpart;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Suspend packages except';
}

sub option_fields {
  ( 
    'unless_pkgpart' => { 'label'    => 'Suspend packages except:',
                          'type'     => 'select-part_pkg',
                          'multiple' => 1,
                        },
    'reasonnum' => { 'label'        => 'Reason',
                     'type'         => 'select-reason',
                     'reason_class' => 'S',
                   },
  );
};

sub default_weight {
  10;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my @err = $cust_main->suspend_unless_pkgpart( {
    'pkgparts' => [ split(/\s*,\s*/, $self->option('unless_pkgpart') ) ],
    'reason'   => $self->option('reasonnum'),
  } );

  die join(' / ', @err) if scalar(@err);

  '';
}

1;

--- NEW FILE: apply.pm ---
package FS::part_event::Action::apply;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Apply unapplied payments and credits';
}

sub deprecated {
  1;
}

sub default_weight {
  70;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  $cust_main->apply_payments_and_credits;

  '';
}

1;

--- NEW FILE: cust_bill_comp.pm ---
package FS::part_event::Action::cust_bill_comp;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Pay invoice with a complimentary "payment"';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub default_weight {
  30;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  my $error = $cust_bill->comp;
  die $error if $error;

  '';
}

1;

--- NEW FILE: cust_bill_suspend_if_balance.pm ---
package FS::part_event::Action::cust_bill_suspend_if_balance;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Suspend if balance (this invoice and previous) over';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  ( 
    'balanceover' => { label=>'Balance over', type=>'money', }, # size=>7 },
    'reasonnum' => { 'label'        => 'Reason',
                     'type'         => 'select-reason',
                     'reason_class' => 'S',
                   },
  );
};

sub default_weight {
  10;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  my @err = $cust_bill->cust_suspend_if_balance_over(
    $self->option('balanceover'),
    'reason' => $self->option('reasonnum'),
  );

  die join(' / ', @err) if scalar(@err);

  '';
}

1;

--- NEW FILE: collect.pm ---
package FS::part_event::Action::collect;

use strict;
use base qw( FS::part_event::Action );

sub description {
  #'Collect on invoices (normally only used with a <i>Late Fee</i> and <i>Generate Invoice</i> events)';
  'Collect on invoices (normally only used with a Late Fee and Generate Invoice events)';
}

sub deprecated {
  1;
}

sub default_weight {
  80;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my $error = $cust_main->collect;
  die $error if $error;

  '';
}

1;

--- NEW FILE: fee.pm ---
package FS::part_event::Action::fee;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Late fee (flat)';
}

sub option_fields {
  ( 
    'charge' => { label=>'Amount', type=>'money', }, # size=>7, },
    'reason' => 'Reason',
  );
};

sub default_weight {
  10;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my $error = $cust_main->charge( $self->option('charge'), $self->option('reason') );

  die $error if $error;

  '';
}

1;

--- NEW FILE: cancel.pm ---
package FS::part_event::Action::cancel;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Cancel';
}

sub option_fields {
  ( 
    'reasonnum' => { 'label'        => 'Reason',
                     'type'         => 'select-reason',
                     'reason_class' => 'C',
                   },
  );

};

sub default_weight {
  20;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  my $error = $cust_main->cancel( 'reason' => $self->option('reasonnum') );
  die $error if $error;
  
  '';
}

1;

--- NEW FILE: addpost.pm ---
package FS::part_event::Action::addpost;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Add postal invoicing';
}

sub default_weight {
  20;
}

sub do_action {
  my( $self, $cust_object ) = @_;

  my $cust_main = $self->cust_main($cust_object);

  $cust_main->invoicing_list_addpost();

  '';
}

1;

--- NEW FILE: cust_bill_spool_csv.pm ---
package FS::part_event::Action::cust_bill_spool_csv;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Spool CSV invoice data';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  (
    'spoolformat'       => { label   => 'Format',
                             type    => 'select',
                             options => ['default', 'billco'],
                             option_labels => { 'default' => 'Default',
                                                'billco'  => 'Billco',
                                              },
                           },
    'spooldest'         => { label   => 'For destination',
                             type    => 'select',
                             options => [ '', qw( POST EMAIL FAX ) ],
                             option_labels => { ''      => '(all)',
                                                'POST'  => 'Postal Mail',
                                                'EMAIL' => 'Email',
                                                'FAX'   => 'Fax',
                                              },
                           },
    'spoolbalanceover'  => { label =>
                               'If balance (this invoice and previous) over',
                             type  => 'money',
                           },
    'spoolagent_spools' => { label => 'Individual per-agent spools',
                             type  => 'checkbox',
                           },
  );
}

sub default_weight {
  50;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->spool_csv(
    'format'       => $self->option('spoolformat'),
    'dest'         => $self->option('spooldest'),
    'balanceover'  => $self->option('spoolbalanceover'),
    'agent_spools' => $self->option('spoolagent_spools'),
  );
}

1;

--- NEW FILE: cust_bill_send.pm ---
package FS::part_event::Action::cust_bill_send;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Send invoice (email/print/fax)';
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub default_weight {
  50;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->send;
}

1;

--- NEW FILE: cust_bill_realtime_check.pm ---
package FS::part_event::Action::cust_bill_realtime_check;

use strict;
use base qw( FS::part_event::Action );

sub description {
  #'Run check with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
  'Run check with a Business::OnlinePayment realtime gateway';
}

sub deprecated {
  1;
}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub default_weight {
  30;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->realtime_ach;
}

1;

--- NEW FILE: cust_bill_send_if_newest.pm ---
package FS::part_event::Action::cust_bill_send_if_newest;

use strict;
use base qw( FS::part_event::Action );

sub description {
  'Send invoice (email/print/fax) with alternate template, if it is still the newest invoice (useful for late notices - set to 31 days or later)';
}

# XXX is this handled better by something against customers??
#sub deprecated {
#  1;
#}

sub eventtable_hashref {
  { 'cust_bill' => 1 };
}

sub option_fields {
  (
    'if_newest_templatename' => { label    => 'Template',
                                  type     => 'select-invoice_template',
                                },
  );
}

sub default_weight {
  50;
}

sub do_action {
  my( $self, $cust_bill ) = @_;

  #my $cust_main = $self->cust_main($cust_bill);
  my $cust_main = $cust_bill->cust_main;

  $cust_bill->send( $self->option('templatename') );
}

1;



More information about the freeside-commits mailing list