mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for subscriptions
This commit is contained in:
parent
07e4cc715a
commit
ac842d0d83
@ -319,7 +319,10 @@ class PaymentController extends Controller
|
||||
* @return Response The response view
|
||||
*/
|
||||
public function credit_response(Request $request)
|
||||
{
|
||||
{
|
||||
nlog("credit response");
|
||||
nlog($request->all());
|
||||
|
||||
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
|
||||
|
||||
/* Hydrate the $payment */
|
||||
|
@ -309,6 +309,9 @@ class SubscriptionService
|
||||
*/
|
||||
private function calculateProRataRefundItems($invoice, $is_credit = false) :array
|
||||
{
|
||||
if(!$invoice)
|
||||
return [];
|
||||
|
||||
/* depending on whether we are creating an invoice or a credit*/
|
||||
$multiplier = $is_credit ? 1 : -1;
|
||||
|
||||
@ -444,6 +447,8 @@ class SubscriptionService
|
||||
->withTrashed()
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
if(!$last_invoice)
|
||||
return true;
|
||||
|
||||
if($last_invoice->balance > 0)
|
||||
{
|
||||
@ -489,7 +494,10 @@ class SubscriptionService
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
if($last_invoice->balance > 0)
|
||||
if(!$last_invoice){
|
||||
//do nothing
|
||||
}
|
||||
else if($last_invoice->balance > 0)
|
||||
{
|
||||
$pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription);
|
||||
nlog("pro rata charge = {$pro_rata_charge_amount}");
|
||||
|
Loading…
Reference in New Issue
Block a user