mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 04:07:32 -05:00 
			
		
		
		
	Invoice Test Assertions
This commit is contained in:
		
							parent
							
								
									82c1df5c6d
								
							
						
					
					
						commit
						3813d31994
					
				@ -104,9 +104,9 @@ class InvoiceCalc
 | 
			
		||||
 | 
			
		||||
		if(isset($this->invoice->id) && $this->invoice->id >= 1)
 | 
			
		||||
		{
 | 
			
		||||
            $this->invoice->balance = round($this->total - ($this->invoice->amount - $this->invoice->balance), 2);
 | 
			
		||||
            $this->balance = round($this->total - ($this->invoice->amount - $this->invoice->balance), 2);
 | 
			
		||||
        } else {
 | 
			
		||||
            $this->invoice->balance = $this->total;
 | 
			
		||||
            $this->balance = $this->total;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		return $this;
 | 
			
		||||
@ -293,6 +293,25 @@ class InvoiceCalc
 | 
			
		||||
		return $this;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function getTotal()
 | 
			
		||||
	{
 | 
			
		||||
		return $this->total;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function setTotal($value)
 | 
			
		||||
	{
 | 
			
		||||
		$this->total = $value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function getBalance()
 | 
			
		||||
	{
 | 
			
		||||
		return $this->balance;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function setBalance($value)
 | 
			
		||||
	{
 | 
			
		||||
		$this->balance = $value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
	private function setDiscount($amount, $discount, $is_amount_discount)
 | 
			
		||||
@ -305,15 +324,7 @@ class InvoiceCalc
 | 
			
		||||
        
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function getInvoiceTotal()
 | 
			
		||||
	{
 | 
			
		||||
		return $this->invoice_total;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function setInvoiceTotal($invoice_total)
 | 
			
		||||
	{
 | 
			
		||||
		$this->invoice_total = $invoice_total;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -70,5 +70,17 @@ class InvoiceTest extends TestCase
 | 
			
		||||
		$this->invoice_calc->build();
 | 
			
		||||
 | 
			
		||||
		$this->assertEquals($this->invoice_calc->getSubTotal(), 20);
 | 
			
		||||
		$this->assertEquals($this->invoice_calc->getTotal(), 20);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function testInvoiceTotalsWithDiscount()
 | 
			
		||||
	{
 | 
			
		||||
		$this->invoice->discount = 5;
 | 
			
		||||
			
 | 
			
		||||
		$this->invoice_calc->build();
 | 
			
		||||
 | 
			
		||||
		$this->assertEquals($this->invoice_calc->getSubTotal(), 20);
 | 
			
		||||
		$this->assertEquals($this->invoice_calc->getTotal(), 15);
 | 
			
		||||
		$this->assertEquals($this->invoice_calc->getBalance(), 15);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user