diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-11-03 09:00:21 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-11-03 09:00:21 -0800 |
commit | a87e91ee19d14a6fc3da62f4b44a9628d32bb6a3 (patch) | |
tree | 78215b7fa3967e185b2eeea9d7a4535afb9b9cec /FS/FS | |
parent | 4fdc6b443f4f9f51f0879cc19b2fe8c5ef1dac14 (diff) | |
parent | 863c1ca1d9363c8fda3136514cef90584a1f4427 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 4 | ||||
-rw-r--r-- | FS/FS/ClientAPI/Signup.pm | 4 | ||||
-rw-r--r-- | FS/FS/Template_Mixin.pm | 28 | ||||
-rw-r--r-- | FS/FS/cdr/amcom.pm | 14 | ||||
-rw-r--r-- | FS/FS/cust_svc.pm | 3 | ||||
-rw-r--r-- | FS/FS/log_context.pm | 2 | ||||
-rw-r--r-- | FS/FS/msg_template/InitialData.pm | 17 | ||||
-rw-r--r-- | FS/FS/part_pkg/discount_Mixin.pm | 1 | ||||
-rw-r--r-- | FS/FS/svc_Common.pm | 3 | ||||
-rw-r--r-- | FS/FS/svc_circuit.pm | 14 |
10 files changed, 73 insertions, 17 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 89c70f75c..f272cd490 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -2521,8 +2521,8 @@ sub _do_bop_realtime { #this used to apply a credit, but now we can void invoices... foreach my $cust_bill (@cust_bill) { - my $voiderror = $cust_bill->void(); - warn "Error voiding cust bill after decline: $voiderror"; + my $voiderror = $cust_bill->void('automatic payment failed'); + warn "Error voiding cust bill after decline: $voiderror" if $voiderror; } } diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index bc69a5f79..5d719c490 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -830,8 +830,8 @@ sub new_customer { #this used to apply a credit, but now we can void invoices... foreach my $cust_bill (@cust_bill) { - my $voiderror = $cust_bill->void(); - warn "Error voiding cust bill after decline: $voiderror"; + my $voiderror = $cust_bill->void('automatic payment failed'); + warn "Error voiding cust bill after decline: $voiderror" if $voiderror; } #should check list for errors... diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index ffaef9707..e02aa1f87 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -712,6 +712,8 @@ sub print_generic { # "balance_date_range" unfortunately is unsuitable for this, since it # cares about application dates. We want to know the sum of all # _top-level transactions_ dated before the last invoice. + # + # still do this for the "Previous Balance" line of the summary block my @sql = map "$_ WHERE _date <= ? AND custnum = ?", ( "SELECT COALESCE( SUM(charged), 0 ) FROM cust_bill", @@ -744,19 +746,31 @@ sub print_generic { # longer stored in the database) $invoice_data{'true_previous_balance'} = $last_bill_balance; - # the change in balance from immediately after that invoice - # to immediately before this one - my $before_this_bill_balance = 0; + # Now, get all applications of credits/payments dated on or after the + # previous bill, to invoices before the current bill. (The + # credit/payment date restriction prevents these from intersecting + # the "Previous Balance" set.) + # These are "adjustments". The past due balance will be shown as + # Previous Balance - Adjustments. + my $adjustments = 0; + @sql = map { + "SELECT COALESCE(SUM(y.amount),0) FROM $_ JOIN cust_bill USING (invnum) + WHERE cust_bill._date < ? + AND x._date >= ? + AND cust_bill.custnum = ?" + } "cust_credit AS x JOIN cust_credit_bill y USING (crednum)", + "cust_pay AS x JOIN cust_bill_pay y USING (paynum)" + ; foreach (@sql) { my $delta = FS::Record->scalar_sql( $_, - $self->_date - 1, + $self->_date, + $last_bill->_date, $self->custnum, ); - $before_this_bill_balance += $delta; + $adjustments += $delta; } - $invoice_data{'balance_adjustments'} = - sprintf("%.2f", $last_bill_balance - $before_this_bill_balance); + $invoice_data{'balance_adjustments'} = sprintf("%.2f", $adjustments); warn sprintf("BALANCE ADJUSTMENTS: %.2f\n\n", $invoice_data{'balance_adjustments'} diff --git a/FS/FS/cdr/amcom.pm b/FS/FS/cdr/amcom.pm index fee81f7df..697a6827f 100644 --- a/FS/FS/cdr/amcom.pm +++ b/FS/FS/cdr/amcom.pm @@ -2,9 +2,9 @@ package FS::cdr::amcom; use strict; use base qw( FS::cdr ); -use vars qw( %info ); +use vars qw( %info %cdrtypes); use DateTime; -use FS::Record qw( qsearchs ); +use FS::Record qw( qsearch ); use FS::cdr_type; my ($tmp_mday, $tmp_mon, $tmp_year); @@ -16,6 +16,12 @@ my ($tmp_mday, $tmp_mon, $tmp_year); 'type' => 'csv', 'sep_char' => ',', 'disabled' => 0, + 'header_buffer' => sub { + + %cdrtypes = ( map { $_->cdrtypename => $_->cdrtypenum } + qsearch('cdr_type', {}) + ); + }, #listref of what to do with each field from the CDR, in order 'import_fields' => [ @@ -37,9 +43,7 @@ my ($tmp_mday, $tmp_mon, $tmp_year); sub { # 5. Call Category (LOCAL, NATIONAL, FREECALL, MOBILE) my ($cdr, $data) = @_; $data ||= 'none'; - - my $cdr_type = qsearchs('cdr_type', { 'cdrtypename' => $data } ); - $cdr->set('cdrtypenum', $cdr_type->cdrtypenum) if $cdr_type; + $cdr->cdrtypenum($cdrtypes{$data} || ''); $cdr->set('dcontext', $data); }, sub { # 6. Start Date (DDMMYYYY diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 974af6743..376ef0263 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -1205,9 +1205,10 @@ sub smart_search_param { my @or = map { my $table = $_; my $search_sql = "FS::$table"->search_sql($string); + my $addl_from = "FS::$table"->search_sql_addl_from(); "SELECT $table.svcnum AS svcnum, '$table' AS svcdb ". - "FROM $table WHERE $search_sql"; + "FROM $table $addl_from WHERE $search_sql"; } FS::part_svc->svc_tables; diff --git a/FS/FS/log_context.pm b/FS/FS/log_context.pm index bd142471c..ff3471760 100644 --- a/FS/FS/log_context.pm +++ b/FS/FS/log_context.pm @@ -18,6 +18,8 @@ my @contexts = ( qw( queue upgrade upgrade_taxable_billpkgnum + freeside-paymentech-upload + freeside-paymentech-download ) ); =head1 NAME diff --git a/FS/FS/msg_template/InitialData.pm b/FS/FS/msg_template/InitialData.pm index dbb9f4037..baf145d8b 100644 --- a/FS/FS/msg_template/InitialData.pm +++ b/FS/FS/msg_template/InitialData.pm @@ -22,6 +22,23 @@ If you did not request this password reset, you may safely ignore and delete thi END ], }, + { msgname => 'Refund receipt', + msgclass => 'email', + mime_type => 'text/html', + _conf => 'refund_receipt_msgnum', + _insert_args => [ subject => '{ $company_name } refund receipt', + body => <<'END', +Dear {$first} {$last},<BR> +<BR> +The following refund has been applied to your account.<BR> +<BR> +Refund ID: {$refundnum}<BR> +Date: {$date}<BR> +Amount: {$refund}<BR> + +END + ], + }, ]; } diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm index dcca3436f..4c8675346 100644 --- a/FS/FS/part_pkg/discount_Mixin.pm +++ b/FS/FS/part_pkg/discount_Mixin.pm @@ -4,6 +4,7 @@ use strict; use vars qw( %info ); use Time::Local qw( timelocal ); use List::Util qw( min ); +use FS::Record qw( qsearchs ); use FS::cust_pkg; use FS::cust_bill_pkg_discount; diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm index 355c38342..35415a26f 100644 --- a/FS/FS/svc_Common.pm +++ b/FS/FS/svc_Common.pm @@ -1349,6 +1349,9 @@ sub search_sql { #my( $class, $string ) = @_; '1 = 0'; #false } +sub search_sql_addl_from { + ''; +} =item search HASHREF diff --git a/FS/FS/svc_circuit.pm b/FS/FS/svc_circuit.pm index f705c68f4..408bd79e4 100644 --- a/FS/FS/svc_circuit.pm +++ b/FS/FS/svc_circuit.pm @@ -218,6 +218,20 @@ sub label { $self->get('circuit_id'); } +sub search_sql { + my ($class, $string) = @_; + my @where = (); + push @where, 'LOWER(svc_circuit.circuit_id) = \''.lc($string).'\''; + push @where, 'LOWER(circuit_provider.provider) = \''.lc($string).'\''; + push @where, 'LOWER(circuit_type.typename) = \''.lc($string).'\''; + '(' . join(' OR ', @where) . ')'; +} + +sub search_sql_addl_from { + 'LEFT JOIN circuit_provider USING ( providernum ) '. + 'LEFT JOIN circuit_type USING ( typenum )'; +} + =back =head1 SEE ALSO |