mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:07:33 -05:00 
			
		
		
		
	Handle scenario where task has no client
This commit is contained in:
		
							parent
							
								
									d4e0fc642d
								
							
						
					
					
						commit
						84ef064e3d
					
				@ -48,19 +48,27 @@ class PurchaseOrderService
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function fillDefaults()
 | 
					    public function fillDefaults()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // $settings = $this->purchase_order->client->getMergedSettings();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // //TODO implement design, footer, terms
 | 
					        $settings = $this->purchase_order->company->settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/
 | 
					        if (! $this->purchase_order->design_id) 
 | 
				
			||||||
        // if (!isset($this->purchase_order->exchange_rate) && $this->purchase_order->client->currency()->id != (int)$this->purchase_order->company->settings->currency_id)
 | 
					            $this->purchase_order->design_id = $this->decodePrimaryKey($settings->invoice_design_id);
 | 
				
			||||||
        //     $this->purchase_order->exchange_rate = $this->purchase_order->client->currency()->exchange_rate;
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // if (!isset($this->purchase_order->public_notes))
 | 
					        if (!isset($this->invoice->footer) || empty($this->invoice->footer)) 
 | 
				
			||||||
        //     $this->purchase_order->public_notes = $this->purchase_order->client->public_notes;
 | 
					            $this->purchase_order->footer = $settings->purchase_order_footer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!isset($this->purchase_order->terms)  || empty($this->purchase_order->terms)) 
 | 
				
			||||||
 | 
					            $this->purchase_order->terms = $settings->purchase_order_terms;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!isset($this->purchase_order->public_notes)  || empty($this->purchase_order->public_notes)) 
 | 
				
			||||||
 | 
					            $this->purchase_order->public_notes = $this->purchase_order->vendor->public_notes;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if($settings->counter_number_applied == 'when_saved'){
 | 
				
			||||||
 | 
					            $this->applyNumber()->save();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function triggeredActions($request)
 | 
					    public function triggeredActions($request)
 | 
				
			||||||
 | 
				
			|||||||
@ -41,10 +41,13 @@ class TaskTransformer extends EntityTransformer
 | 
				
			|||||||
        return $this->includeCollection($task->documents, $transformer, Document::class);
 | 
					        return $this->includeCollection($task->documents, $transformer, Document::class);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function includeClient(Task $task): Item
 | 
					    public function includeClient(Task $task): ?Item
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $transformer = new ClientTransformer($this->serializer);
 | 
					        $transformer = new ClientTransformer($this->serializer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!$task->client)
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->includeItem($task->client, $transformer, Client::class);
 | 
					        return $this->includeItem($task->client, $transformer, Client::class);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user