summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
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 c7bcb28b0..6f99f0ab1 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -674,6 +674,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 e4bdb3ee9..dece5b93e 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -772,6 +772,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 cf4c6d915..ffc11ac50 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1652,6 +1652,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;