summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-07-17 11:46:37 -0700
committerIvan Kohler <ivan@freeside.biz>2015-07-17 11:46:37 -0700
commit85f0e2caa759102f68fe28278faf5f65c7b33b3c (patch)
tree9df5048c9433d786c38db9b9c0b8fdcf18182912 /FS
parentf8f4e8e6fd26a0abe8bca4fe6dd1b70b80b55a25 (diff)
parent0757f503bd30a99edddb6b18fed8ff00c9e91df8 (diff)
Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_bill.pm5
-rw-r--r--FS/FS/cust_main/Billing.pm4
-rw-r--r--FS/FS/cust_pay.pm5
4 files changed, 13 insertions, 2 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 40c61bbaa..cf5c4c1ca 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1739,6 +1739,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, '', '',
'depositor', 'varchar', 'NULL', $char_d, '', '',
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index a195e5de8..69fdc91ee 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -913,6 +913,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
@@ -939,7 +940,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 644467587..908f48697 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -2363,6 +2363,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.
@@ -2505,6 +2506,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.
@@ -2534,7 +2536,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 d2de5f80a..7952e6418 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -117,6 +117,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.
@@ -558,6 +562,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')