mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 14:34:34 -04: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
|
* @return Response The response view
|
||||||
*/
|
*/
|
||||||
public function credit_response(Request $request)
|
public function credit_response(Request $request)
|
||||||
{
|
{
|
||||||
|
nlog("credit response");
|
||||||
|
nlog($request->all());
|
||||||
|
|
||||||
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
|
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
|
||||||
|
|
||||||
/* Hydrate the $payment */
|
/* Hydrate the $payment */
|
||||||
|
@ -309,6 +309,9 @@ class SubscriptionService
|
|||||||
*/
|
*/
|
||||||
private function calculateProRataRefundItems($invoice, $is_credit = false) :array
|
private function calculateProRataRefundItems($invoice, $is_credit = false) :array
|
||||||
{
|
{
|
||||||
|
if(!$invoice)
|
||||||
|
return [];
|
||||||
|
|
||||||
/* depending on whether we are creating an invoice or a credit*/
|
/* depending on whether we are creating an invoice or a credit*/
|
||||||
$multiplier = $is_credit ? 1 : -1;
|
$multiplier = $is_credit ? 1 : -1;
|
||||||
|
|
||||||
@ -444,6 +447,8 @@ class SubscriptionService
|
|||||||
->withTrashed()
|
->withTrashed()
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->first();
|
->first();
|
||||||
|
if(!$last_invoice)
|
||||||
|
return true;
|
||||||
|
|
||||||
if($last_invoice->balance > 0)
|
if($last_invoice->balance > 0)
|
||||||
{
|
{
|
||||||
@ -489,7 +494,10 @@ class SubscriptionService
|
|||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->first();
|
->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);
|
$pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription);
|
||||||
nlog("pro rata charge = {$pro_rata_charge_amount}");
|
nlog("pro rata charge = {$pro_rata_charge_amount}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user