diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-07-13 18:33:52 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-07-15 23:40:03 -0500 |
commit | 0f3dc497f9050e317bcde16eae7cefd2d4ad696f (patch) | |
tree | 834c85dddd50ca11854cd3b2432057ebd47294b5 /FS | |
parent | adf9c78bb78f892c031985d6b3bc65c0c7d898a7 (diff) |
RT#31594: Unapplied payment issues
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_main/Billing.pm | 4 | ||||
-rw-r--r-- | FS/FS/cust_pay.pm | 5 |
4 files changed, 13 insertions, 2 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 7e5f8e1ba..c8b9b631d 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2431,6 +2431,7 @@ sub tables_hashref { 'payunique', 'varchar', 'NULL', $char_d, '', '',#separate paybatch "unique" functions from current usage 'closed', 'char', 'NULL', 1, '', '', 'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances + 'no_auto_apply', 'char', 'NULL', 1, '', '', # cash/check deposit info fields 'bank', 'varchar', 'NULL', $char_d, '', '', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index db909309f..5052ed130 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -888,6 +888,7 @@ sub hide { =item apply_payments_and_credits [ OPTION => VALUE ... ] Applies unapplied payments and credits to this invoice. +Payments with the no_auto_apply flag set will not be applied. A hash of optional arguments may be passed. Currently "manual" is supported. If true, a payment receipt is sent instead of a statement when @@ -914,7 +915,9 @@ sub apply_payments_and_credits { $self->select_for_update; #mutex - my @payments = grep { $_->unapplied > 0 } $self->cust_main->cust_pay; + my @payments = grep { $_->unapplied > 0 } + grep { !$_->no_auto_apply } + $self->cust_main->cust_pay; my @credits = grep { $_->credited > 0 } $self->cust_main->cust_credit; if ( $conf->exists('pkg-balances') ) { diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 54ff57805..0bc0fbd39 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -2197,6 +2197,7 @@ sub due_cust_event { =item apply_payments_and_credits [ OPTION => VALUE ... ] Applies unapplied payments and credits. +Payments with the no_auto_apply flag set will not be applied. In most cases, this new method should be used in place of sequential apply_payments and apply_credits methods. @@ -2339,6 +2340,7 @@ sub apply_credits { Applies (see L<FS::cust_bill_pay>) unapplied payments (see L<FS::cust_pay>) to outstanding invoice balances in chronological order. +Payments with the no_auto_apply flag set will not be applied. #and returns the value of any remaining unapplied payments. @@ -2368,7 +2370,7 @@ sub apply_payments { #return 0 unless - my @payments = $self->unapplied_cust_pay; + my @payments = grep { !$_->no_auto_apply } $self->unapplied_cust_pay; my @invoices = $self->open_cust_bill; diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 8b4c98ad6..d135599a3 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -116,6 +116,10 @@ books closed flag, empty or `Y' Desired pkgnum when using experimental package balances. +=item no_auto_apply + +Flag to only allow manual application of payment, empty or 'Y' + =item bank The bank where the payment was deposited. @@ -539,6 +543,7 @@ sub check { || $self->ut_textn('paybatch') || $self->ut_textn('payunique') || $self->ut_enum('closed', [ '', 'Y' ]) + || $self->ut_flag('no_auto_apply') || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum') || $self->ut_textn('bank') || $self->ut_alphan('depositor') |