freeside/FS/FS part_pkg.pm,1.28,1.29 cust_pkg.pm,1.48,1.49 Record.pm,1.90,1.91
ivan
ivan at pouncequick.420.am
Mon Nov 22 10:20:25 PST 2004
- Previous message: freeside/httemplate/docs upgrade10.html,1.34,1.35 schema.html,1.44,1.45
- Next message: freeside/fs_signup/FS-SignupClient/cgi promocode.html,NONE,1.1 signup-billaddress.html,NONE,1.1 signup.cgi,1.52,1.53 signup.html,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv15879/FS/FS
Modified Files:
part_pkg.pm cust_pkg.pm Record.pm
Log Message:
promo codes and separate signup addresses for hdn
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- Record.pm 26 Oct 2004 11:26:33 -0000 1.90
+++ Record.pm 22 Nov 2004 18:20:21 -0000 1.91
@@ -1424,7 +1424,7 @@
sub ut_foreign_key {
my( $self, $field, $table, $foreign ) = @_;
qsearchs($table, { $foreign => $self->getfield($field) })
- or return "Can't find $field ". $self->getfield($field).
+ or return "Can't find ". $self->table. ".$field ". $self->getfield($field).
" in $table.$foreign";
'';
}
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cust_pkg.pm 26 Oct 2004 11:26:33 -0000 1.48
+++ cust_pkg.pm 22 Nov 2004 18:20:21 -0000 1.49
@@ -145,32 +145,9 @@
Adds this billing item to the database ("Orders" the item). If there is an
error, returns the error, otherwise returns false.
-=cut
-
-sub insert {
- my $self = shift;
-
- # custnum might not have have been defined in sub check (for one-shot new
- # customers), so check it here instead
- # (is this still necessary with transactions?)
-
- my $error = $self->ut_number('custnum');
- return $error if $error;
-
- my $cust_main = $self->cust_main;
- return "Unknown custnum: ". $self->custnum unless $cust_main;
-
- unless ( $disable_agentcheck ) {
- my $agent = qsearchs( 'agent', { 'agentnum' => $cust_main->agentnum } );
- my $pkgpart_href = $agent->pkgpart_hashref;
- return "agent ". $agent->agentnum.
- " can't purchase pkgpart ". $self->pkgpart
- unless $pkgpart_href->{ $self->pkgpart };
- }
-
- $self->SUPER::insert;
-
-}
+If the additional field I<promo_code> is defined instead of I<pkgpart>, it
+will be used to look up the package definition and agent restrictions will be
+ignored.
=item delete
@@ -233,8 +210,8 @@
my $error =
$self->ut_numbern('pkgnum')
- || $self->ut_numbern('custnum')
- || $self->ut_number('pkgpart')
+ || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
+ || $self->ut_numbern('pkgpart')
|| $self->ut_numbern('setup')
|| $self->ut_numbern('bill')
|| $self->ut_numbern('susp')
@@ -242,12 +219,31 @@
;
return $error if $error;
- if ( $self->custnum ) {
- return "Unknown customer ". $self->custnum unless $self->cust_main;
- }
+ if ( $self->promo_code ) {
- return "Unknown pkgpart: ". $self->pkgpart
- unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
+ my $promo_part_pkg =
+ qsearchs('part_pkg', {
+ 'pkgpart' => $self->pkgpart,
+ 'promo_code' => { op=>'ILIKE', value=>$self->promo_code },
+ } );
+ return 'Unknown promotional code' unless $promo_part_pkg;
+ $self->pkgpart($promo_part_pkg->pkgpart);
+
+ } else {
+
+ unless ( $disable_agentcheck ) {
+ my $agent =
+ qsearchs( 'agent', { 'agentnum' => $self->cust_main->agentnum } );
+ my $pkgpart_href = $agent->pkgpart_hashref;
+ return "agent ". $agent->agentnum.
+ " can't purchase pkgpart ". $self->pkgpart
+ unless $pkgpart_href->{ $self->pkgpart };
+ }
+
+ $error = $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' );
+ return $error if $error;
+
+ }
$self->otaker(getotaker) unless $self->otaker;
$self->otaker =~ /^([\w\.\-]{0,16})$/ or return "Illegal otaker";
Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- part_pkg.pm 8 Nov 2004 09:24:54 -0000 1.28
+++ part_pkg.pm 22 Nov 2004 18:20:21 -0000 1.29
@@ -54,6 +54,8 @@
=item comment - Text name of this package definition (non-customer-viewable)
+=item promo_code - Promotional code
+
=item setup - Setup fee expression (deprecated)
=item freq - Frequency of recurring fee
@@ -288,6 +290,7 @@
my $error = $self->ut_numbern('pkgpart')
|| $self->ut_text('pkg')
|| $self->ut_text('comment')
+ || $self->ut_textn('promo_code')
|| $self->ut_alphan('plan')
|| $self->ut_enum('setuptax', [ '', 'Y' ] )
|| $self->ut_enum('recurtax', [ '', 'Y' ] )
- Previous message: freeside/httemplate/docs upgrade10.html,1.34,1.35 schema.html,1.44,1.45
- Next message: freeside/fs_signup/FS-SignupClient/cgi promocode.html,NONE,1.1 signup-billaddress.html,NONE,1.1 signup.cgi,1.52,1.53 signup.html,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list