mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 18:37:32 -04:00 
			
		
		
		
	Fixes for DB::rollBack
This commit is contained in:
		
							parent
							
								
									ee9b3a484f
								
							
						
					
					
						commit
						b82cdb6b77
					
				| @ -57,13 +57,13 @@ class InvoiceBalanceSanity implements Rule | |||||||
|     private function checkIfInvoiceBalanceIsSane() : bool |     private function checkIfInvoiceBalanceIsSane() : bool | ||||||
|     { |     { | ||||||
| 
 | 
 | ||||||
|  |         DB::connection(config('database.default'))->beginTransaction(); | ||||||
|  | 
 | ||||||
|  |         $this->invoice = Invoice::on(config('database.default'))->find($this->invoice->id); | ||||||
|         $this->invoice->line_items = $this->input['line_items']; |         $this->invoice->line_items = $this->input['line_items']; | ||||||
|  |         $temp_invoice = $this->invoice->calc()->getTempEntity(); | ||||||
|   |   | ||||||
|         DB::beginTransaction(); |         DB::connection(config('database.default'))->rollBack(); | ||||||
|   |  | ||||||
|             $temp_invoice = $this->invoice->calc()->getTempEntity(); |  | ||||||
|   |  | ||||||
|         DB::rollBack(); |  | ||||||
| 
 | 
 | ||||||
|         if($temp_invoice->balance < 0){ |         if($temp_invoice->balance < 0){ | ||||||
|             $this->message = 'Invoice balance cannot go negative'; |             $this->message = 'Invoice balance cannot go negative'; | ||||||
| @ -71,7 +71,7 @@ class InvoiceBalanceSanity implements Rule | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         return true; |        return true; | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -306,6 +306,10 @@ class BaseRepository | |||||||
|         /* Perform model specific tasks */ |         /* Perform model specific tasks */ | ||||||
|         if ($model instanceof Invoice) { |         if ($model instanceof Invoice) { | ||||||
|              |              | ||||||
|  |             nlog("Finished amount = " . $state['finished_amount']); | ||||||
|  |             nlog("Starting amount = " . $state['starting_amount']); | ||||||
|  |             nlog("Diff = " . ($state['finished_amount'] - $state['starting_amount'])); | ||||||
|  | 
 | ||||||
|             if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { |             if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { | ||||||
| 
 | 
 | ||||||
|                 $model->service()->updateStatus()->save(); |                 $model->service()->updateStatus()->save(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user