mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-26 00:42:53 -04:00 
			
		
		
		
	,
This commit is contained in:
		
							parent
							
								
									56f05f7122
								
							
						
					
					
						commit
						deface29da
					
				| @ -25,6 +25,11 @@ class InvoiceCalc | |||||||
| 
 | 
 | ||||||
| 	protected $invoice_total; | 	protected $invoice_total; | ||||||
| 
 | 
 | ||||||
|  | 	protected $tax_map; | ||||||
|  | 
 | ||||||
|  | 	protected $total_taxes; | ||||||
|  | 
 | ||||||
|  | 	protected $total_discount; | ||||||
| 
 | 
 | ||||||
| 	public function __construct(Invoice $invoice, int $precision = 2) | 	public function __construct(Invoice $invoice, int $precision = 2) | ||||||
| 	{ | 	{ | ||||||
| @ -52,7 +57,13 @@ class InvoiceCalc | |||||||
| 			$new_line_items[] = $item_calc->getLineItem(); | 			$new_line_items[] = $item_calc->getLineItem(); | ||||||
| 
 | 
 | ||||||
| 			//set collection of itemised taxes
 | 			//set collection of itemised taxes
 | ||||||
|  | 			$this->setTaxMap($this->getTaxMap()->merge($item_calc->getGroupedTaxes())); | ||||||
|  | 
 | ||||||
| 			//set running total of taxes
 | 			//set running total of taxes
 | ||||||
|  | 			$this->setTotalTaxes($this->getTotalTaxes() + $item_calc->getTotalTaxes()); | ||||||
|  | 
 | ||||||
|  | 			//set running total of discounts
 | ||||||
|  | 			$this->setTotalDiscount($this->getTotalDiscount() + $item_calc->getTotalDiscounts()); | ||||||
| 						 | 						 | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| @ -60,6 +71,48 @@ class InvoiceCalc | |||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Getters and Setters | ||||||
|  | 	 */ | ||||||
|  | 	 | ||||||
|  | 	private function getTaxMap() | ||||||
|  | 	{ | ||||||
|  | 		return $this->tax_map; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private function setTaxMap($value) | ||||||
|  | 	{ | ||||||
|  | 		$htis->tax_map = $value; | ||||||
|  | 
 | ||||||
|  | 		return $this; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private function getTotalDiscount() | ||||||
|  | 	{ | ||||||
|  | 		return $this->total_discount; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private function setTotalDiscount($value) | ||||||
|  | 	{ | ||||||
|  | 		$this->total_discount = $value; | ||||||
|  | 
 | ||||||
|  | 		return $this; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private function getTotalTaxes() | ||||||
|  | 	{ | ||||||
|  | 		return $this->total_taxes; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private function setTotalTaxes($value) | ||||||
|  | 	{ | ||||||
|  | 		$this->total_taxes = $value; | ||||||
|  | 
 | ||||||
|  | 		return $this; | ||||||
|  | 	} | ||||||
| /* | /* | ||||||
| 	private function setDiscount($amount, $discount, $is_amount_discount) | 	private function setDiscount($amount, $discount, $is_amount_discount) | ||||||
| 	{ | 	{ | ||||||
|  | |||||||
| @ -109,18 +109,10 @@ class InvoiceItemCalc | |||||||
| 
 | 
 | ||||||
| 		$group_tax[$key] = ['total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate];  | 		$group_tax[$key] = ['total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate];  | ||||||
| 
 | 
 | ||||||
| 		$this->groupTaxes($group_tax); | 		$this->setGroupedTaxes($group_tax); | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private function groupTaxes($group_tax) |  | ||||||
| 	{ |  | ||||||
| 
 |  | ||||||
| 		$this->tax_collection->merge(collect($group_tax)); |  | ||||||
| 
 |  | ||||||
| 		return $this; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	/**************** | 	/**************** | ||||||
| 	* | 	* | ||||||
| 	* Getters and Setters | 	* Getters and Setters | ||||||
| @ -170,5 +162,17 @@ class InvoiceItemCalc | |||||||
| 		return $this; | 		return $this; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	public function getGroupedTaxes() | ||||||
|  | 	{ | ||||||
|  | 		return $this->tax_collection; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public function setGroupedTaxes($group_tax) | ||||||
|  | 	{ | ||||||
|  | 		$this->tax_collection->merge(collect($group_tax)); | ||||||
|  | 
 | ||||||
|  | 		return $this; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user