mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6158 from turbo124/v5-develop
Fixes for subscriptions
This commit is contained in:
commit
1ac4aa61a9
@ -319,7 +319,8 @@ class PaymentController extends Controller
|
||||
* @return Response The response view
|
||||
*/
|
||||
public function credit_response(Request $request)
|
||||
{
|
||||
{
|
||||
|
||||
$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}");
|
||||
@ -514,7 +522,7 @@ class SubscriptionService
|
||||
*/
|
||||
private function handlePlanChange($payment_hash)
|
||||
{
|
||||
|
||||
nlog("handle plan change");
|
||||
$old_recurring_invoice = RecurringInvoice::find($payment_hash->data->billing_context->recurring_invoice);
|
||||
|
||||
$recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice);
|
||||
|
@ -15,7 +15,7 @@ return [
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => '5.2.7',
|
||||
'app_tag' => '5.2.7-release',
|
||||
'app_tag' => '5.2.7',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
|
Loading…
x
Reference in New Issue
Block a user