summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-08-18 20:12:45 -0700
committerIvan Kohler <ivan@freeside.biz>2013-08-18 20:12:45 -0700
commite4419db2b564c53ba0b0aa32590b22a8e114650a (patch)
tree6ac22f321553084b841964eeaf31a5a998e5fe6e /FS
parented0b1255389309d81f1e87ad3b1d5bd7ab3dd9b7 (diff)
continue sales person work: customer and package selection, commissions, reporting. RT#23402
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_pkg.pm23
-rw-r--r--FS/FS/sales.pm15
3 files changed, 35 insertions, 4 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 6fca62e73..818b43741 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -541,6 +541,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 dedc6374a..3e638a686 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -632,6 +632,7 @@ sub check {
|| $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')
@@ -2227,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.
@@ -2237,9 +2238,23 @@ 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;
}
diff --git a/FS/FS/sales.pm b/FS/FS/sales.pm
index 5dba4d81b..00f45c0e4 100644
--- a/FS/FS/sales.pm
+++ b/FS/FS/sales.pm
@@ -2,7 +2,9 @@ package FS::sales;
use base qw( FS::Agent_Mixin FS::Record );
use strict;
+use FS::Record qw( qsearchs ); #qsearch qsearchs );
use FS::agent;
+use FS::cust_main;
=head1 NAME
@@ -107,6 +109,7 @@ sub check {
$self->ut_numbern('salesnum')
|| $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;
@@ -114,6 +117,18 @@ sub check {
$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