summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-08-18 16:09:39 -0700
committerIvan Kohler <ivan@freeside.biz>2013-08-18 16:09:39 -0700
commitdc797c21faf993cec12ae92c190043c4f8bb2ab2 (patch)
tree02ea72945ecf26aa7453ceff27cb688dbc0cd380 /FS/FS
parentc38cbda56530785527927471a3ecee56a71c7a13 (diff)
continue sales person work: customer and package selection, commissions, reporting. RT#23402
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Mason.pm1
-rw-r--r--FS/FS/Schema.pm27
-rw-r--r--FS/FS/agent_pkg_class.pm10
-rw-r--r--FS/FS/sales_pkg_class.pm124
4 files changed, 151 insertions, 11 deletions
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 7993048..5cecefd 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -351,6 +351,7 @@ if ( -e $addl_handler_use_file ) {
use FS::vend_bill;
use FS::vend_pay;
use FS::vend_bill_pay;
+ use FS::sales_pkg_class;
# Sammath Naur
if ( $FS::Mason::addl_handler_use ) {
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 2e9a10a..6fca62e 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -525,6 +525,17 @@ sub tables_hashref {
'index' => [ ['typenum'] ],
},
+ 'agent_currency' => {
+ 'columns' => [
+ 'agentcurrencynum', 'serial', '', '', '', '',
+ 'agentnum', 'int', '', '', '', '',
+ 'currency', 'char', '', 3, '', '',
+ ],
+ 'primary_key' => 'agentcurrencynum',
+ 'unique' => [],
+ 'index' => [ ['agentnum'] ],
+ },
+
'sales' => {
'columns' => [
'salesnum', 'serial', '', '', '', '',
@@ -537,15 +548,17 @@ sub tables_hashref {
'index' => [ ['salesnum'], ['disabled'] ],
},
- 'agent_currency' => {
+ 'sales_pkg_class' => {
'columns' => [
- 'agentcurrencynum', 'serial', '', '', '', '',
- 'agentnum', 'int', '', '', '', '',
- 'currency', 'char', '', 3, '', '',
+ 'salespkgclassnum', 'serial', '', '', '', '',
+ 'salesnum', 'int', '', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
+ 'commission_percent', 'decimal', '', '7,4', '', '',
+ 'commission_duration', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'agentcurrencynum',
- 'unique' => [],
- 'index' => [ ['agentnum'] ],
+ 'primary_key' => 'salespkgclassnum',
+ 'unique' => [ [ 'salesnum', 'classnum' ], ],
+ 'index' => [],
},
'cust_attachment' => {
diff --git a/FS/FS/agent_pkg_class.pm b/FS/FS/agent_pkg_class.pm
index 1683c1a..5c5c3f7 100644
--- a/FS/FS/agent_pkg_class.pm
+++ b/FS/FS/agent_pkg_class.pm
@@ -1,8 +1,10 @@
package FS::agent_pkg_class;
+use base qw( FS::Record );
use strict;
-use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
+#use FS::Record qw( qsearch qsearchs );
+use FS::agent;
+use FS::pkg_class;
=head1 NAME
@@ -25,7 +27,7 @@ FS::agent_pkg_class - Object methods for agent_pkg_class records
=head1 DESCRIPTION
-An FS::agent_pkg_class object represents an commission for a specific agent
+An FS::agent_pkg_class object represents a commission for a specific agent
and package class. FS::agent_pkg_class inherits from FS::Record. The
following fields are currently supported:
@@ -109,7 +111,7 @@ sub check {
=head1 SEE ALSO
-L<FS::Record>, schema.html from the base documentation.
+L<FS::agent>, L<FS::pkg_class>, L<FS::Record>.
=cut
diff --git a/FS/FS/sales_pkg_class.pm b/FS/FS/sales_pkg_class.pm
new file mode 100644
index 0000000..0fb7e86
--- /dev/null
+++ b/FS/FS/sales_pkg_class.pm
@@ -0,0 +1,124 @@
+package FS::sales_pkg_class;
+use base qw( FS::Record );
+
+use strict;
+#use FS::Record qw( qsearch qsearchs );
+use FS::sales;
+use FS::pkg_class;
+
+=head1 NAME
+
+FS::sales_pkg_class - Object methods for sales_pkg_class records
+
+=head1 SYNOPSIS
+
+ use FS::sales_pkg_class;
+
+ $record = new FS::sales_pkg_class \%hash;
+ $record = new FS::sales_pkg_class { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::sales_pkg_class object represents a commission for a specific sales
+person and package class. FS::sales_pkg_class inherits from FS::Record. The
+following fields are currently supported:
+
+=over 4
+
+=item salespkgclassnum
+
+primary key
+
+=item salesnum
+
+salesnum
+
+=item classnum
+
+classnum
+
+=item commission_percent
+
+commission_percent
+
+=item commission_duration
+
+commission_duration
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new record. To add the record 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 { 'sales_pkg_class'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=item delete
+
+Delete this record from the database.
+
+=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.
+
+=item check
+
+Checks all fields to make sure this is a valid record. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ $self->commission_percent(0) unless length($self->commission_percent);
+
+ my $error =
+ $self->ut_numbern('salespkgclassnum')
+ || $self->ut_foreign_key('salesnum', 'sales', 'salesnum')
+ || $self->ut_foreign_keyn('classnum', 'pkg_class', 'classnum')
+ || $self->ut_float('commission_percent')
+ || $self->ut_numbern('commission_duration')
+ ;
+ return $error if $error;
+
+ $self->SUPER::check;
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::sales>, L<FS::pkg_class, L<FS::Record>.
+
+=cut
+
+1;
+