mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 06:37:33 -05:00 
			
		
		
		
	Fixes for restored user activity
This commit is contained in:
		
							parent
							
								
									9706a52716
								
							
						
					
					
						commit
						a9ca93f723
					
				@ -43,7 +43,7 @@ class RestoredUserActivity implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $fields = new stdClass;
 | 
					        $fields = new stdClass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $fields->user_id = $creating_user->user->id;
 | 
					        $fields->user_id = $event->user->id;
 | 
				
			||||||
        $fields->notes = $event->creating_user->present()->name() . " Restored user " . $event->user->present()->name();
 | 
					        $fields->notes = $event->creating_user->present()->name() . " Restored user " . $event->user->present()->name();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $fields->company_id = $event->company->id;
 | 
					        $fields->company_id = $event->company->id;
 | 
				
			||||||
 | 
				
			|||||||
@ -385,8 +385,6 @@ class SubscriptionService
 | 
				
			|||||||
        $pro_rata_charge_amount = 0;
 | 
					        $pro_rata_charge_amount = 0;
 | 
				
			||||||
        $pro_rata_refund_amount = 0;
 | 
					        $pro_rata_refund_amount = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $is_credit = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
 | 
					        $last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
 | 
				
			||||||
                                         ->where('client_id', $recurring_invoice->client_id)
 | 
					                                         ->where('client_id', $recurring_invoice->client_id)
 | 
				
			||||||
                                         ->where('is_deleted', 0)
 | 
					                                         ->where('is_deleted', 0)
 | 
				
			||||||
@ -394,24 +392,7 @@ class SubscriptionService
 | 
				
			|||||||
                                         ->orderBy('id', 'desc')
 | 
					                                         ->orderBy('id', 'desc')
 | 
				
			||||||
                                         ->first();
 | 
					                                         ->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!$last_invoice)
 | 
					        if($last_invoice->balance > 0)
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $last_invoice = Credit::where('subscription_id', $recurring_invoice->subscription_id)
 | 
					 | 
				
			||||||
                                 ->where('client_id', $recurring_invoice->client_id)
 | 
					 | 
				
			||||||
                                 ->where('is_deleted', 0)
 | 
					 | 
				
			||||||
                                 ->withTrashed()
 | 
					 | 
				
			||||||
                                 ->orderBy('id', 'desc')
 | 
					 | 
				
			||||||
                                 ->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $is_credit = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if($is_credit)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1;
 | 
					 | 
				
			||||||
            nlog("pro rata refund = {$pro_rata_refund_amount}");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        elseif($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}");
 | 
				
			||||||
@ -456,7 +437,6 @@ class SubscriptionService
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $pro_rata_charge_amount = 0;
 | 
					        $pro_rata_charge_amount = 0;
 | 
				
			||||||
        $pro_rata_refund_amount = 0;
 | 
					        $pro_rata_refund_amount = 0;
 | 
				
			||||||
        $is_credit = false;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
 | 
					        $last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
 | 
				
			||||||
                                         ->where('client_id', $recurring_invoice->client_id)
 | 
					                                         ->where('client_id', $recurring_invoice->client_id)
 | 
				
			||||||
@ -465,24 +445,7 @@ class SubscriptionService
 | 
				
			|||||||
                                         ->orderBy('id', 'desc')
 | 
					                                         ->orderBy('id', 'desc')
 | 
				
			||||||
                                         ->first();
 | 
					                                         ->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!$last_invoice)
 | 
					        if($last_invoice->balance > 0)
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $last_invoice = Credit::where('subscription_id', $recurring_invoice->subscription_id)
 | 
					 | 
				
			||||||
                                 ->where('client_id', $recurring_invoice->client_id)
 | 
					 | 
				
			||||||
                                 ->where('is_deleted', 0)
 | 
					 | 
				
			||||||
                                 ->withTrashed()
 | 
					 | 
				
			||||||
                                 ->orderBy('id', 'desc')
 | 
					 | 
				
			||||||
                                 ->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $is_credit = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if($is_credit)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1;
 | 
					 | 
				
			||||||
            nlog("pro rata refund = {$pro_rata_refund_amount}");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        elseif($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