summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2000-01-31 05:22:23 +0000
committerivan <ivan>2000-01-31 05:22:23 +0000
commit959663cd4d4885295f44de43ac005e55d054102f (patch)
tree3778bf1f08c5c29fe63898074b13ba228a687183
parent8079b2e02397e4c35ca2991afaa156f65330a084 (diff)
prepaid "internet cards"
-rw-r--r--FS/FS/cust_main.pm72
-rw-r--r--FS/FS/prepay_credit.pm128
-rwxr-xr-xbin/fs-setup18
-rwxr-xr-xfs_signup/FS-SignupClient/cgi/signup.cgi7
-rw-r--r--htdocs/docs/schema.html10
-rw-r--r--htdocs/docs/signup.html3
-rw-r--r--htdocs/docs/upgrade5.html7
7 files changed, 229 insertions, 16 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 50535da55..59ec41b81 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -27,6 +27,7 @@ use FS::part_referral;
use FS::cust_main_county;
use FS::agent;
use FS::cust_main_invoice;
+use FS::prepay_credit;
@ISA = qw( FS::Record );
@@ -148,9 +149,9 @@ FS::Record. The following fields are currently supported:
=item fax - phone (optional)
-=item payby - `CARD' (credit cards), `BILL' (billing), or `COMP' (free)
+=item payby - `CARD' (credit cards), `BILL' (billing), `COMP' (free), or `PREPAY' (special billing type: applies a credit - see L<FS::prepay_credit> and sets billing type to BILL)
-=item payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username)
+=item payinfo - card number, P.O., comp issuer (4-8 lowercase alphanumerics; think username) or prepayment identifier (see L<FS::prepay_credit>)
=item paydate - expiration date, mm/yyyy, m/yyyy, mm/yy or m/yy
@@ -182,6 +183,52 @@ sub table { 'cust_main'; }
Adds this customer to the database. If there is an error, returns the error,
otherwise returns false.
+=cut
+
+sub insert {
+ my $self = shift;
+
+ my $flag = 0;
+ if ( $self->payby eq 'PREPAY' ) {
+ $self->payby('BILL');
+ $flag = 1;
+ }
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $error = $self->SUPER::insert;
+ return $error if $error;
+
+ if ( $flag ) {
+ my $prepay_credit =
+ qsearchs('prepay_credit', { 'identifier' => $self->payinfo } );
+ warn "WARNING: can't find pre-found prepay_credit: ". $self->payinfo
+ unless $prepay_credit;
+ my $amount = $prepay_credit->amount;
+ my $error = $prepay_credit->delete;
+ if ( $error ) {
+ warn "WARNING: can't delete prepay_credit: ". $self->payinfo;
+ } else {
+ my $cust_credit = new FS::cust_credit {
+ 'custnum' => $self->custnum,
+ 'amount' => $amount,
+ };
+ my $error = $cust_credit->insert;
+ warn "WARNING: error inserting cust_credit for prepay_credit: $error"
+ if $error;
+ }
+
+ }
+
+ '';
+
+}
+
=item delete NEW_CUSTNUM
This deletes the customer. If there is an error, returns the error, otherwise
@@ -314,7 +361,7 @@ sub check {
or return "Illegal zip: ". $self->zip;
$self->zip($1);
- $self->payby =~ /^(CARD|BILL|COMP)$/
+ $self->payby =~ /^(CARD|BILL|COMP|PREPAY)$/
or return "Illegal payby: ". $self->payby;
$self->payby($1);
@@ -340,10 +387,21 @@ sub check {
$error = $self->ut_textn('payinfo');
return "Illegal comp account issuer: ". $self->payinfo if $error;
+ } elsif ( $self->payby eq 'PREPAY' ) {
+
+ my $payinfo = $self->payinfo;
+ $payinfo =~ s/\W//g; #anything else would just confuse things
+ $self->payinfo($payinfo);
+ $error = $self->ut_alpha('payinfo');
+ return "Illegal prepayment identifier: ". $self->payinfo if $error;
+ return "Unknown prepayment identifier"
+ unless qsearchs('prepay_credit', { 'identifier' => $self->payinfo } );
+
}
if ( $self->paydate eq '' ) {
- return "Expriation date required" unless $self->payby eq 'BILL';
+ return "Expriation date required"
+ unless $self->payby eq 'BILL' || $self->payby eq 'PREPAY';
$self->paydate('');
} else {
$self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/
@@ -799,10 +857,6 @@ sub collect {
return "Unknown payment type ". $self->payby;
}
-
-
-
-
}
'';
@@ -939,7 +993,7 @@ sub check_invoicing_list {
=head1 VERSION
-$Id: cust_main.pm,v 1.2 1999-08-12 04:16:01 ivan Exp $
+$Id: cust_main.pm,v 1.3 2000-01-31 05:22:23 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/prepay_credit.pm b/FS/FS/prepay_credit.pm
new file mode 100644
index 000000000..86274aa4c
--- /dev/null
+++ b/FS/FS/prepay_credit.pm
@@ -0,0 +1,128 @@
+package FS::prepay_credit;
+
+use strict;
+use vars qw( @ISA );
+#use FS::Record qw( qsearch qsearchs );
+use FS::Record qw();
+
+@ISA = qw(FS::Record);
+
+=head1 NAME
+
+FS::prepay_credit - Object methods for prepay_credit records
+
+=head1 SYNOPSIS
+
+ use FS::prepay_credit;
+
+ $record = new FS::prepay_credit \%hash;
+ $record = new FS::prepay_credit {
+ 'identifier' => '4198123455512121'
+ 'amount' => '19.95',
+ };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::table_name object represents an pre--paid credit, such as a pre-paid
+"calling card". FS::prepay_credit inherits from FS::Record. The following
+fields are currently supported:
+
+=over 4
+
+=item field - description
+
+=item identifier - identifier entered by the user to receive the credit
+
+=item amount - amount of the credit
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new pre-paid credit. To add the example 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
+
+sub table { 'prepay_credit'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+=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
+
+=item check
+
+Checks all fields to make sure this is a valid pre-paid credit. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ my $identifier = $self->identifier;
+ $identifier =~ s/\W//g; #anything else would just confuse things
+ $self->identifier($identifier);
+
+ $self->ut_number('prepaynum')
+ || $self->ut_alpha('identifier')
+ || $self->ut_money('amount')
+ ;
+
+}
+
+=back
+
+=head1 VERSION
+
+$Id: prepay_credit.pm,v 1.1 2000-01-31 05:22:23 ivan Exp $
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=head1 HISTORY
+
+$Log: prepay_credit.pm,v $
+Revision 1.1 2000-01-31 05:22:23 ivan
+prepaid "internet cards"
+
+
+=cut
+
+1;
+
diff --git a/bin/fs-setup b/bin/fs-setup
index f1dd3a8b4..dcaccdf1c 100755
--- a/bin/fs-setup
+++ b/bin/fs-setup
@@ -1,6 +1,6 @@
#!/usr/bin/perl -Tw
#
-# $Id: fs-setup,v 1.21 2000-01-30 06:03:26 ivan Exp $
+# $Id: fs-setup,v 1.22 2000-01-31 05:22:23 ivan Exp $
#
# ivan@sisd.com 97-nov-8,9
#
@@ -32,7 +32,10 @@
# fix radius attributes ivan@sisd.com 98-sep-27
#
# $Log: fs-setup,v $
-# Revision 1.21 2000-01-30 06:03:26 ivan
+# Revision 1.22 2000-01-31 05:22:23 ivan
+# prepaid "internet cards"
+#
+# Revision 1.21 2000/01/30 06:03:26 ivan
# postgres 6.5 finally supports decimal(10,2)
#
# Revision 1.20 2000/01/28 22:53:33 ivan
@@ -663,6 +666,17 @@ sub tables_hash_hack {
# 'index' => [ [] ],
#},
+ 'prepay_credit' => {
+ 'columns' => [
+ 'prepaynum', 'int', '', '',
+ 'identifier', 'varchar', '', $char_d,
+ 'amount', @money_type,
+ ],
+ 'primary_key' => 'prepaynum',
+ 'unique' => [ ['identifier'] ],
+ 'index => [ [] ],
+ },
+
);
%tables;
diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi
index 6fccf11b1..961ad505a 100755
--- a/fs_signup/FS-SignupClient/cgi/signup.cgi
+++ b/fs_signup/FS-SignupClient/cgi/signup.cgi
@@ -1,6 +1,6 @@
#!/usr/bin/perl -Tw
#
-# $Id: signup.cgi,v 1.3 2000-01-28 22:49:49 ivan Exp $
+# $Id: signup.cgi,v 1.4 2000-01-31 05:22:23 ivan Exp $
use strict;
use vars qw( @payby $cgi $locales $packages $pops $r $error
@@ -22,7 +22,8 @@ use Text::Template;
#
#@payby = qw( CARD BILL COMP );
#@payby = qw( CARD BILL );
-@payby = qw( CARD );
+#@payby = qw( CARD );
+@payby = qw( CARD PREPAY );
$ieak_file = '/usr/local/freeside/ieak.template';
@@ -220,12 +221,14 @@ END
'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD"). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR>${r}Exp !. expselect("BILL", "12-2037"). qq!<BR>${r}Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR>${r}Exp !. expselect("COMP"),
+ 'PREPAY' => qq!Prepaid card<BR>${r}<INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
);
my %paybychecked = (
'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD", $paydate). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("BILL", $paydate). qq!<BR>${r}Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("COMP", $paydate),
+ 'PREPAY' => qq!Prepaid card<BR>${r}<INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
);
for (@payby) {
diff --git a/htdocs/docs/schema.html b/htdocs/docs/schema.html
index 92965d795..3eea6f69d 100644
--- a/htdocs/docs/schema.html
+++ b/htdocs/docs/schema.html
@@ -154,8 +154,8 @@
</ul>
<li><a name="part_referral">part_referral</a> - Referral listing
<ul>
- <li>refnum</li> - primary key
- <li>referral</li> - referral
+ <li>refnum - primary key
+ <li>referral - referral
</ul>
<li><a name="part_svc">part_svc</a> - Service definitions
<ul>
@@ -176,6 +176,12 @@
<li>svcpart - <a href="#part_svc">Service definition</a>
<li>quantity - quantity of this service that this package includes
</ul>
+ <li><a name="prepay_credit">prepay_credit</a>
+ <ul>
+ <li>prepaynum - primary key
+ <li>identifier - text or numeric string used to receive this credit
+ <li>amount - amount of credit
+ </ul>
<li><a name="svc_acct">svc_acct</a> - Accounts
<ul>
<li>svcnum - <a href="#cust_svc">primary key</a>
diff --git a/htdocs/docs/signup.html b/htdocs/docs/signup.html
index a00995994..c78d1362c 100644
--- a/htdocs/docs/signup.html
+++ b/htdocs/docs/signup.html
@@ -41,6 +41,7 @@ Optional:
<li>$password
<li>$email_name - first and last name
</ul>
-(an example file is included as <b>fs_signup/ieak.template</b>)
+ (an example file is included as <b>fs_signup/ieak.template</b>)
+ <li>If there are any entries in the <i>prepay_credit</i> table, a user can enter a string matching the <b>identifier</i> column to receive the credit specified in the <b>amount</b> column, after which that <b>identifier</b> is no longer valid. This can be used to implement pre-paid "calling card" type signups.
</ul>
</body>
diff --git a/htdocs/docs/upgrade5.html b/htdocs/docs/upgrade5.html
index 82a7602a3..fc4bf2c39 100644
--- a/htdocs/docs/upgrade5.html
+++ b/htdocs/docs/upgrade5.html
@@ -12,6 +12,13 @@
<li>Apply the following changes to your database:
<pre>
ALTER TABLE svc_acct_pop ADD loc CHAR(4);
+CREATE TABLE prepay_credit (
+ prepaynum int NOT NULL,
+ identifier varchar(80) NOT NULL,
+ amount decimal(10,2) NOT NULL,
+ PRIMARY KEY (prepaynum),
+ INDEX (identifier)
+);
</pre>
<li>Copy or symlink htdocs to the new copy.
<li>Remove the symlink or directory <i>(your_site_perl_directory)</i>/FS.