fixed document source
This commit is contained in:
parent
6379c0e903
commit
1f2b5e79f3
@ -17,11 +17,12 @@ class CreateDocumentHistory extends Job implements HasOwner, HasSource, ShouldCr
|
|||||||
|
|
||||||
protected $description;
|
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->document = $document;
|
||||||
$this->notify = $notify;
|
$this->notify = $notify;
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
|
$this->request = $request;
|
||||||
|
|
||||||
parent::__construct($document, $notify, $description);
|
parent::__construct($document, $notify, $description);
|
||||||
}
|
}
|
||||||
@ -37,10 +38,19 @@ class CreateDocumentHistory extends Job implements HasOwner, HasSource, ShouldCr
|
|||||||
'status' => $this->document->status,
|
'status' => $this->document->status,
|
||||||
'notify' => $this->notify,
|
'notify' => $this->notify,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'created_from' => source_name(),
|
'created_from' => $this->getCustomSourceName(),
|
||||||
'created_by' => user_id(),
|
'created_by' => user_id(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $document_history;
|
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_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['discount_rate'] = !empty($this->request['discount']) ? $this->request['discount'] : 0;
|
||||||
$this->request['total'] = round($item_amount, $precision);
|
$this->request['total'] = round($item_amount, $precision);
|
||||||
$this->request['created_from'] = source_name();
|
$this->request['created_from'] = $this->request['created_from'];
|
||||||
$this->request['created_by'] = user_id();
|
$this->request['created_by'] = $this->request['created_by'];
|
||||||
|
|
||||||
$document_item = DocumentItem::create($this->request);
|
$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['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));
|
$document_item = $this->dispatch(new CreateDocumentItem($this->document, $item));
|
||||||
|
|
||||||
$item_amount = (double) $item['price'] * (double) $item['quantity'];
|
$item_amount = (double) $item['price'] * (double) $item['quantity'];
|
||||||
|
@ -20,6 +20,6 @@ class CreateDocumentCreatedHistory
|
|||||||
{
|
{
|
||||||
$message = trans('messages.success.added', ['type' => $event->document->document_number]);
|
$message = trans('messages.success.added', ['type' => $event->document->document_number]);
|
||||||
|
|
||||||
$this->dispatch(new CreateDocumentHistory($event->document, 0, $message));
|
$this->dispatch(new CreateDocumentHistory($event->document, 0, $message, $event->request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class DocumentTotal extends Model
|
|||||||
|
|
||||||
protected $appends = ['title'];
|
protected $appends = ['title'];
|
||||||
|
|
||||||
protected $fillable = ['company_id', 'type', 'document_id', 'code', 'name', 'amount', 'sort_order'];
|
protected $fillable = ['company_id', 'type', 'document_id', 'code', 'name', 'amount', 'sort_order', 'created_from', 'created_by'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be cast.
|
* The attributes that should be cast.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user