diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-12-22 00:28:53 -0600 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-12-22 00:28:53 -0600 |
commit | 1259a17db297fa2352619b29f2c5bd34e313cd64 (patch) | |
tree | 644f9c30e6eb1a470f671afb8a3f9971d6bb7302 /FS/FS/cust_main/Billing_Batch.pm | |
parent | 38444ef88b5e93aa9aa724369ae8fe17c97fa480 (diff) |
RT#34295: Error when attempting to create batch payments [better handling of empty batches]
Diffstat (limited to 'FS/FS/cust_main/Billing_Batch.pm')
-rw-r--r-- | FS/FS/cust_main/Billing_Batch.pm | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/FS/FS/cust_main/Billing_Batch.pm b/FS/FS/cust_main/Billing_Batch.pm index cdaf293..f91c5fb 100644 --- a/FS/FS/cust_main/Billing_Batch.pm +++ b/FS/FS/cust_main/Billing_Batch.pm @@ -23,8 +23,6 @@ Options may include: B<amount>: the amount to be paid; defaults to the customer's balance minus any payments in transit. -B<payby>: the payment method; defaults to cust_main.payby - B<realtime>: runs this as a realtime payment instead of adding it to a batch. Deprecated. @@ -34,8 +32,9 @@ B<address1>, B<address2>, B<city>, B<state>, B<zip>, B<country>: sets the billing address for the payment; defaults to the customer's billing location. -B<payinfo>, B<paydate>, B<payname>: sets the payment account, expiration -date, and name; defaults to those fields in cust_main. +B<payby>, B<payinfo>, B<paydate>, B<payname>: sets the payment method, +payment account, expiration date, and name; defaults to those fields +in cust_main. =cut @@ -58,6 +57,13 @@ sub batch_card { my $invnum = delete $options{invnum}; + #pay fields should all come from either cust_payby or options, not both + # in theory, could just pass payby, and use it to select cust_payby, + # but nothing currently needs that, so not implementing it now + die "Incomplete payment details" + if ($options{payby} || $options{payinfo} || $options{paydate} || $options{payname}) + && !($options{payby} && $options{payinfo} && $options{paydate} && $options{payname}); + #false laziness with Billing_Realtime my @cust_payby = qsearch({ 'table' => 'cust_payby', @@ -67,7 +73,10 @@ sub batch_card { }); # batch can't try out every one like realtime, just use first one - my $cust_payby = $cust_payby[0] || $self; # somewhat dubious + my $cust_payby = $cust_payby[0]; + + die "No customer payment info found" + unless $options{payinfo} || $cust_payby; my $payby = $options{payby} || $cust_payby->payby; |