From: levinse Date: Sun, 24 Apr 2011 17:05:01 +0000 (+0000) Subject: add per-customer configurable billing date, RT10813 X-Git-Tag: freeside_2_3_0~338 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=867d4f2ed3127ec20548911b79017668b771331c add per-customer configurable billing date, RT10813 --- 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; diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index e6600e689..2301a0b9c 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -96,6 +96,14 @@ return true; } + function payauto_changed(payauto_field){ + var f = (payauto_field.name == 'CARD_payauto') ? 'card_billday' : 'chek_billday'; + f = document.getElementById(f); + if ( f == null) return; + if(payauto_field.checked) f.style.display = 'inline'; + else f.style.display = 'none'; + } + <% include('/elements/init_overlib.html') %> @@ -120,6 +128,19 @@ % : $payby eq 'CHEK' ? 'CHECKED' % : $disable_payauto ? '' : 'CHECKED'; % +% sub billday_options { +% my $curr_value = shift; +% my $ret = ''; +% for my $billday ( 1 .. 28 ) { +% my $sel = ''; +% $sel = "SELECTED='SELECTED'" if $curr_value == $billday; +% $ret .= ""; +% } +% $ret; +% } +% my $billday_card_display = $payby eq 'CARD' ? 'inline' : 'none'; +% my $billday_chek_display = $payby eq 'CHEK' ? 'inline' : 'none'; +% % my %payby = ( % % 'CARD' => @@ -171,7 +192,14 @@ % qq!${r}Exact name on card !. % qq!!. % -% qq! Charge future payments to this card automatically!. +% qq! Charge future payments to this card automatically!. +% +% ( $conf->exists('cust_main-select-billday') ? +% qq! +% Charge on the day of each month! +% : '' +% ). % % '', % @@ -209,7 +237,14 @@ % ). % % -% qq! Charge future payments to this electronic check automatically!. +% qq! Charge future payments to this electronic check automatically!. +% +% ( $conf->exists('cust_main-select-billday') ? +% qq! +% Charge on the day of each month! +% : '' +% ). % % ' '. % ' '. diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 014ddaba2..efff3ed1c 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -23,6 +23,15 @@ Billing information <% $balance %> +% if ( $conf->exists('cust_main-select-billday') +% && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) { + + Billing day of month + <% $cust_main->billday %> + + +% } + Billing type