summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2011-04-24 17:05:01 +0000
committerlevinse <levinse>2011-04-24 17:05:01 +0000
commit867d4f2ed3127ec20548911b79017668b771331c (patch)
tree8790c0ca42f1f7663c24fa2d91e1ad4d90784cbd /FS
parent6d10f9863e64529026e2ff4ec144608e846f0a6a (diff)
add per-customer configurable billing date, RT10813
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_main.pm1
-rw-r--r--FS/FS/part_event/Condition/billday.pm30
4 files changed, 39 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 5bad05636..61cba34da 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -681,6 +681,13 @@ my %payment_gateway_options = (
'description' => 'Display a barcode on HTML and PDF invoices',
'type' => 'checkbox',
},
+
+ {
+ 'key' => 'cust_main-select-billday',
+ 'section' => 'billing',
+ 'description' => 'When used with a specific billing event, allows the selection of the day of month on which to charge credit card / bank account automatically, on a per-customer basis',
+ 'type' => 'checkbox',
+ },
{
'key' => 'encryption',
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 5dd9e13a5..0b6ea0d2b 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -871,6 +871,7 @@ sub tables_hashref {
'archived', 'char', 'NULL', 1, '', '',
'email_csv_cdr', 'char', 'NULL', 1, '', '',
'accountcode_cdr', 'char', 'NULL', 1, '', '',
+ 'billday', 'int', 'NULL', '', '', '',
],
'primary_key' => 'custnum',
'unique' => [ [ 'agentnum', 'agent_custid' ] ],
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 22c16fbaa..8345d9267 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1681,6 +1681,7 @@ sub check {
|| $self->ut_alphan('geocode')
|| $self->ut_floatn('cdr_termination_percentage')
|| $self->ut_floatn('credit_limit')
+ || $self->ut_numbern('billday')
;
#barf. need message catalogs. i18n. etc.
diff --git a/FS/FS/part_event/Condition/billday.pm b/FS/FS/part_event/Condition/billday.pm
new file mode 100644
index 000000000..b150a6cb8
--- /dev/null
+++ b/FS/FS/part_event/Condition/billday.pm
@@ -0,0 +1,30 @@
+package FS::part_event::Condition::billday;
+
+use strict;
+use Tie::IxHash;
+
+use base qw( FS::part_event::Condition );
+
+sub description {
+ "Customer's monthly billing day matches current day or customer has no billing day";
+}
+
+sub condition {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+
+ ($mday == $cust_main->billday) || (!$cust_main->billday);
+}
+
+sub condition_sql {
+ my( $self, $table ) = @_;
+
+ my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+
+ "cust_main.billday is null or cust_main.billday = $mday";
+}
+
+1;