mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 19:37:32 -05:00 
			
		
		
		
	Fix for applied amount when using credits to pay invoices
This commit is contained in:
		
							parent
							
								
									a669e9342f
								
							
						
					
					
						commit
						a7e05cb3bd
					
				@ -151,14 +151,16 @@ class PaymentRepository extends BaseRepository
 | 
			
		||||
        $invoice_totals -= $credit_totals;
 | 
			
		||||
 | 
			
		||||
        //$payment->amount = $invoice_totals; //creates problems when setting amount like this.
 | 
			
		||||
 | 
			
		||||
        if ($invoice_totals == $payment->amount) {
 | 
			
		||||
        if($credit_totals == $payment->amount){
 | 
			
		||||
            $payment->applied += $credit_totals;
 | 
			
		||||
        } elseif ($invoice_totals == $payment->amount) {
 | 
			
		||||
            $payment->applied += $payment->amount;
 | 
			
		||||
        } elseif ($invoice_totals < $payment->amount) {
 | 
			
		||||
            $payment->applied += $invoice_totals;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $payment->save();
 | 
			
		||||
 | 
			
		||||
        return $payment->fresh();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ class ApplyPayment extends AbstractService
 | 
			
		||||
             ->ledger()
 | 
			
		||||
             ->updatePaymentBalance($this->payment_amount*-1);
 | 
			
		||||
 | 
			
		||||
        info("apply paymenet method - current client balance = {$this->payment->client->balance}");
 | 
			
		||||
        info("apply payment method - current client balance = {$this->payment->client->balance}");
 | 
			
		||||
 | 
			
		||||
        info("reducing client balance by payment amount {$this->payment_amount}");
 | 
			
		||||
 | 
			
		||||
@ -56,7 +56,7 @@ class ApplyPayment extends AbstractService
 | 
			
		||||
 | 
			
		||||
        $this->invoice->fresh('client');
 | 
			
		||||
 | 
			
		||||
        info("1 end of apply payment method the client balnace = {$this->invoice->client->balance}");
 | 
			
		||||
        info("1 end of apply payment method the client balance = {$this->invoice->client->balance}");
 | 
			
		||||
 | 
			
		||||
        if ($this->invoice->hasPartial()) {
 | 
			
		||||
            //is partial and amount is exactly the partial amount
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user