fixed document source
This commit is contained in:
		@@ -17,11 +17,12 @@ class CreateDocumentHistory extends Job implements HasOwner, HasSource, ShouldCr
 | 
			
		||||
 | 
			
		||||
    protected $description;
 | 
			
		||||
 | 
			
		||||
    public function __construct(Document $document, $notify = 0, $description = null)
 | 
			
		||||
    public function __construct(Document $document, $notify = 0, $description = null, $request = null)
 | 
			
		||||
    {
 | 
			
		||||
        $this->document = $document;
 | 
			
		||||
        $this->notify = $notify;
 | 
			
		||||
        $this->description = $description;
 | 
			
		||||
        $this->request = $request;
 | 
			
		||||
 | 
			
		||||
        parent::__construct($document, $notify, $description);
 | 
			
		||||
    }
 | 
			
		||||
@@ -37,10 +38,19 @@ class CreateDocumentHistory extends Job implements HasOwner, HasSource, ShouldCr
 | 
			
		||||
            'status' => $this->document->status,
 | 
			
		||||
            'notify' => $this->notify,
 | 
			
		||||
            'description' => $description,
 | 
			
		||||
            'created_from' => source_name(),
 | 
			
		||||
            'created_from' => $this->getCustomSourceName(),
 | 
			
		||||
            'created_by' => user_id(),
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        return $document_history;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getCustomSourceName(): string
 | 
			
		||||
    {
 | 
			
		||||
        if (empty($this->request) || empty($this->request['created_from'])) {
 | 
			
		||||
            return $this->getSourceName();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->request['created_from'];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -184,8 +184,8 @@ class CreateDocumentItem extends Job implements HasOwner, HasSource, ShouldCreat
 | 
			
		||||
        $this->request['discount_type'] = !empty($this->request['discount_type']) ? $this->request['discount_type'] : 'percentage';
 | 
			
		||||
        $this->request['discount_rate'] = !empty($this->request['discount']) ? $this->request['discount'] : 0;
 | 
			
		||||
        $this->request['total'] = round($item_amount, $precision);
 | 
			
		||||
        $this->request['created_from'] = source_name();
 | 
			
		||||
        $this->request['created_by'] = user_id();
 | 
			
		||||
        $this->request['created_from'] = $this->request['created_from'];
 | 
			
		||||
        $this->request['created_by'] = $this->request['created_by'];
 | 
			
		||||
 | 
			
		||||
        $document_item = DocumentItem::create($this->request);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -193,6 +193,9 @@ class CreateDocumentItemsAndTotals extends Job implements HasOwner, HasSource, S
 | 
			
		||||
                $item['item_id'] = $new_item->id;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $item['created_from'] = $this->request['created_from'];
 | 
			
		||||
            $item['created_by'] = $this->request['created_by'];
 | 
			
		||||
 | 
			
		||||
            $document_item = $this->dispatch(new CreateDocumentItem($this->document, $item));
 | 
			
		||||
 | 
			
		||||
            $item_amount = (double) $item['price'] * (double) $item['quantity'];
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user