diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-08-17 22:36:35 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-08-17 22:36:35 -0700 |
commit | 35125976b65791c4b3f88827639ff44f1b13eb17 (patch) | |
tree | e5eb16ea8dfd0a87e516c59d69e08c90e0557b92 /FS | |
parent | 34411d71bd3d03966408a9747b542a7d3df08c5d (diff) |
continue sales person work: customer and package selection, commissions, reporting. RT#23402
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/AccessRight.pm | 2 | ||||
-rw-r--r-- | FS/FS/Agent_Mixin.pm | 42 | ||||
-rw-r--r-- | FS/FS/Mason.pm | 1 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 13 | ||||
-rw-r--r-- | FS/FS/access_right.pm | 1 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 4 | ||||
-rw-r--r-- | FS/FS/sales.pm | 32 | ||||
-rw-r--r-- | FS/MANIFEST | 2 |
9 files changed, 61 insertions, 38 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 3f6073e..019ea21 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -344,6 +344,8 @@ tie my %rights, 'Tie::IxHash', 'Edit advertising sources', { rightname=>'Edit global advertising sources', global=>1 }, + 'Edit sales people', + 'Edit package definitions', { rightname=>'Edit global package definitions', global=>1 }, diff --git a/FS/FS/Agent_Mixin.pm b/FS/FS/Agent_Mixin.pm new file mode 100644 index 0000000..0f84ba9 --- /dev/null +++ b/FS/FS/Agent_Mixin.pm @@ -0,0 +1,42 @@ +package FS::Agent_Mixin; + +use strict; +use FS::Record qw( qsearchs ); +use FS::agent; + +=head1 NAME + +FS::Agent_Mixin - Mixin class for objects that have an agent. + +=over 4 + +=item agent + +Returns the agent (see L<FS::agent>) for this object. + +=cut + +sub agent { + my $self = shift; + qsearchs( 'agent', { 'agentnum' => $self->agentnum } ); +} + +=item agent_name + +Returns the agent name (see L<FS::agent>) for this object. + +=cut + +sub agent_name { + my $self = shift; + $self->agent->agent; +} + +=back + +=head1 BUGS + +=cut + +1; + diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 1d4a939..7993048 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -315,7 +315,6 @@ if ( -e $addl_handler_use_file ) { use FS::tower; use FS::tower_sector; use FS::sales; - use FS::access_groupsales; use FS::contact_class; use FS::part_svc_class; use FS::upload_target; diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 2ce1794..56cd065 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1036,6 +1036,7 @@ sub tables_hashref { 'columns' => [ 'custnum', 'serial', '', '', '', '', 'agentnum', 'int', '', '', '', '', + 'salesnum', 'int', 'NULL', '', '', '', 'agent_custid', 'varchar', 'NULL', $char_d, '', '', 'classnum', 'int', 'NULL', '', '', '', 'custbatch', 'varchar', 'NULL', $char_d, '', '', @@ -1802,6 +1803,7 @@ sub tables_hashref { 'locationnum', 'int', 'NULL', '', '', '', 'otaker', 'varchar', 'NULL', 32, '', '', 'usernum', 'int', 'NULL', '', '', '', + 'salesnum', 'int', 'NULL', '', '', '', 'order_date', @date_type, '', '', 'start_date', @date_type, '', '', 'setup', @date_type, '', '', @@ -3772,17 +3774,6 @@ sub tables_hashref { 'index' => [ [ 'groupnum' ] ], }, - 'access_groupsales' => { - 'columns' => [ - 'groupsalesnum', 'serial', '', '', '', '', - 'groupnum', 'int', '', '', '', '', - 'salesnum', 'int', '', '', '', '', - ], - 'primary_key' => 'groupsalesnum', - 'unique' => [ [ 'groupnum', 'salesnum' ] ], - 'index' => [ [ 'groupnum' ] ], - }, - 'access_right' => { 'columns' => [ 'rightnum', 'serial', '', '', '', '', diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index f8e30d0..85334ed 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -235,6 +235,7 @@ sub _upgrade_data { # class method 'Change customer package' => 'Detach customer package', 'Services: Accounts' => 'Services: Cable Subscribers', 'Bulk change customer packages' => 'Bulk move customer services', + 'Configuration' => 'Edit sales people', ; foreach my $old_acl ( keys %onetime ) { diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 30d6fa0..8e7c3e7 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -76,6 +76,7 @@ use FS::cust_attachment; use FS::contact; use FS::Locales; use FS::upgrade_journal; +use FS::sales; # 1 is mostly method/subroutine entry and options # 2 traces progress of some operations @@ -1696,6 +1697,7 @@ sub check { || $self->ut_foreign_key('bill_locationnum', 'cust_location','locationnum') || $self->ut_foreign_key('ship_locationnum', 'cust_location','locationnum') || $self->ut_foreign_keyn('classnum', 'cust_class', 'classnum') + || $self->ut_foreign_keyn('salesnum', 'sales', 'salesnum') || $self->ut_textn('custbatch') || $self->ut_name('last') || $self->ut_name('first') diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 89c683e..3948c2f 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,7 @@ 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('start_date') || $self->ut_numbern('setup') || $self->ut_numbern('bill') @@ -2240,6 +2241,7 @@ sub set_quantity { 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 3cb61fd..5dba4d8 100644 --- a/FS/FS/sales.pm +++ b/FS/FS/sales.pm @@ -1,18 +1,8 @@ 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::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 ); +use FS::agent; =head1 NAME @@ -35,7 +25,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 +51,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 +91,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,15 +105,12 @@ 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_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; } @@ -130,8 +118,6 @@ sub check { =head1 BUGS -The author forgot to customize this manpage. - =head1 SEE ALSO L<FS::Record>, schema.html from the base documentation. diff --git a/FS/MANIFEST b/FS/MANIFEST index 803c521..a6e87f6 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -637,8 +637,6 @@ FS/upgrade_journal.pm t/upgrade_journal.t FS/sales.pm t/sales.t -FS/access_groupsales.pm -t/access_groupsales.t FS/part_svc_class.pm t/part_svc_class.t FS/upload_target.pm |