diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-08-18 20:12:48 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-08-18 20:12:48 -0700 |
commit | d14a91ec4beae6c02225cdfd4fc3acbc3d66981b (patch) | |
tree | 6f44308093f98f3fdcfa415fab566b6c6ec77c86 /FS | |
parent | 6891db8c9287fa670e5f6961c8ad3f2e3097fc3c (diff) |
continue sales person work: customer and package selection, commissions, reporting. RT#23402
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 27 | ||||
-rw-r--r-- | FS/FS/sales.pm | 45 |
3 files changed, 46 insertions, 27 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 81fe23bbe..c2f0dcaeb 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -518,6 +518,7 @@ sub tables_hashref { 'salesnum', 'serial', '', '', '', '', 'salesperson', 'varchar', '', $char_d, '', '', 'agentnum', 'int', 'NULL', '', '', '', + 'sales_custnum', 'int', 'NULL', '', '', '', 'disabled', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'salesnum', diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 8644e8385..a2084fb96 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -34,7 +34,7 @@ use FS::reason; use FS::cust_pkg_discount; use FS::discount; use FS::UI::Web; -use Data::Dumper; +use FS::sales; # need to 'use' these instead of 'require' in sub { cancel, suspend, unsuspend, # setup } @@ -631,6 +631,8 @@ sub check { || $self->ut_numbern('pkgpart') || $self->ut_foreign_keyn('contactnum', 'contact', 'contactnum' ) || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum') + || $self->ut_foreign_keyn('salesnum', 'sales', 'salesnum') + || $self->ut_numbern('quantity') || $self->ut_numbern('start_date') || $self->ut_numbern('setup') || $self->ut_numbern('bill') @@ -2226,7 +2228,7 @@ sub abort_change { =item set_quantity QUANTITY -Change the package's quantity field. This is the one package property +Change the package's quantity field. This is one of the few package properties that can safely be changed without canceling and reordering the package (because it doesn't affect tax eligibility). Returns an error or an empty string. @@ -2236,14 +2238,29 @@ empty string. sub set_quantity { my $self = shift; $self = $self->replace_old; # just to make sure - my $qty = shift; - ($qty =~ /^\d+$/ and $qty > 0) or return "bad package quantity $qty"; - $self->set('quantity' => $qty); + $self->quantity(shift); + $self->replace; +} + +=item set_salesnum SALESNUM + +Change the package's salesnum (sales person) field. This is one of the few +package properties that can safely be changed without canceling and reordering +the package (because it doesn't affect tax eligibility). Returns an error or +an empty string. + +=cut + +sub set_salesnum { + my $self = shift; + $self = $self->replace_old; # just to make sure + $self->salesnum(shift); $self->replace; } use Storable 'thaw'; use MIME::Base64; +use Data::Dumper; sub process_bulk_cust_pkg { my $job = shift; my $param = thaw(decode_base64(shift)); diff --git a/FS/FS/sales.pm b/FS/FS/sales.pm index 3cb61fde3..00f45c0e4 100644 --- a/FS/FS/sales.pm +++ b/FS/FS/sales.pm @@ -1,18 +1,10 @@ package FS::sales; +use base qw( FS::Agent_Mixin FS::Record ); use strict; -use vars qw( @ISA ); -use base qw( FS::Record ); -use Business::CreditCard 0.28; -use FS::Record qw( dbh qsearch qsearchs ); +use FS::Record qw( qsearchs ); #qsearch qsearchs ); +use FS::agent; use FS::cust_main; -use FS::cust_pkg; -use FS::agent_type; -use FS::reg_code; -use FS::TicketSystem; -#use FS::Conf; - -@ISA = qw( FS::m2m_Common FS::Record ); =head1 NAME @@ -35,7 +27,7 @@ FS::sales - Object methods for sales records =head1 DESCRIPTION -An FS::sales object represents an example. FS::sales inherits from +An FS::sales object represents a sales person. FS::sales inherits from FS::Record. The following fields are currently supported: =over 4 @@ -61,7 +53,8 @@ disabled =item new HASHREF -Creates a new example. To add the example to the database, see L<"insert">. +Creates a new sales person. To add the sales person 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. @@ -100,7 +93,7 @@ returns the error, otherwise returns false. =item check -Checks all fields to make sure this is a valid example. If there is +Checks all fields to make sure this is a valid sales person. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. @@ -114,24 +107,32 @@ sub check { my $error = $self->ut_numbern('salesnum') - || $self->ut_numbern('agentnum') + || $self->ut_text('salesperson') + || $self->ut_foreign_key('agentnum', 'agent', 'agentnum') + || $self->ut_foreign_keyn('sales_custnum', 'cust_main', 'custnum') + || $self->ut_enum('disabled', [ '', 'Y' ]) ; return $error if $error; - if ( $self->dbdef_table->column('disabled') ) { - $error = $self->ut_enum('disabled', [ '', 'Y' ] ); - return $error if $error; - } - $self->SUPER::check; } +=item sales_cust_main + +Returns the FS::cust_main object (see L<FS::cust_main>), if any, for this +sales person. + +=cut + +sub sales_cust_main { + my $self = shift; + qsearchs( 'cust_main', { 'custnum' => $self->sales_custnum } ); +} + =back =head1 BUGS -The author forgot to customize this manpage. - =head1 SEE ALSO L<FS::Record>, schema.html from the base documentation. |