mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-25 22:52:53 -04:00 
			
		
		
		
	INA-6 | MarkSent.php for purchase orders
This commit is contained in:
		
							parent
							
								
									93b0ebe716
								
							
						
					
					
						commit
						e2e00f0a0b
					
				
							
								
								
									
										45
									
								
								app/Services/PurchaseOrder/MarkSent.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								app/Services/PurchaseOrder/MarkSent.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| <?php | ||||
| 
 | ||||
| 
 | ||||
| namespace App\Services\PurchaseOrder; | ||||
| 
 | ||||
| 
 | ||||
| use App\Events\PurchaseOrder\PurchaseOrderWasMarkedSent; | ||||
| use App\Models\PurchaseOrder; | ||||
| use App\Utils\Ninja; | ||||
| 
 | ||||
| class MarkSent | ||||
| { | ||||
|     private $client; | ||||
| 
 | ||||
|     private $purchase_order; | ||||
| 
 | ||||
|     public function __construct($client, $purchase_order) | ||||
|     { | ||||
|         $this->client = $client; | ||||
|         $this->purchase_order = $purchase_order; | ||||
|     } | ||||
| 
 | ||||
|     public function run() | ||||
|     { | ||||
| 
 | ||||
|         /* Return immediately if status is not draft */ | ||||
|         if ($this->purchase_order->status_id != PurchaseOrder::STATUS_DRAFT) { | ||||
|             return $this->purchase_order; | ||||
|         } | ||||
| 
 | ||||
|         $this->purchase_order->markInvitationsSent(); | ||||
| 
 | ||||
|         $this->purchase_order | ||||
|             ->service() | ||||
|             ->setStatus(PurchaseOrder::STATUS_SENT) | ||||
|             ->applyNumber() | ||||
|             //  ->adjustBalance($this->purchase_order->amount)
 | ||||
|             //  ->touchPdf()
 | ||||
|             ->save(); | ||||
| 
 | ||||
|         event(new PurchaseOrderWasMarkedSent($this->purchase_order, $this->purchase_order->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); | ||||
| 
 | ||||
|         return $this->purchase_order; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user