akaunting 3.0 (the last dance)
This commit is contained in:
@@ -149,7 +149,7 @@ class CreateDocumentItemsAndTotals extends Job implements HasOwner, HasSource, S
|
||||
'document_id' => $this->document->id,
|
||||
'code' => 'total',
|
||||
'name' => 'invoices.total',
|
||||
'amount' => $this->request['amount'],
|
||||
'amount' => $this->request['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
@@ -255,10 +255,12 @@ class CreateDocumentItemsAndTotals extends Job implements HasOwner, HasSource, S
|
||||
$sub = (double) $item['price'] * (double) $item['quantity'];
|
||||
|
||||
if (! empty($this->request['discount'])) {
|
||||
if ($item['discount_type'] === 'percentage') {
|
||||
$sub -= ($sub * ($item['discount'] / 100));
|
||||
} else {
|
||||
$sub -= $item['discount'];
|
||||
if (isset($item['discount']) && isset($item['discount_type'])) {
|
||||
if ($item['discount_type'] === 'percentage') {
|
||||
$sub -= ($sub * ($item['discount'] / 100));
|
||||
} else {
|
||||
$sub -= $item['discount'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
34
app/Jobs/Document/SendDocumentAsCustomMail.php
Normal file
34
app/Jobs/Document/SendDocumentAsCustomMail.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Document;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Events\Document\DocumentSent;
|
||||
use App\Models\Document\Document;
|
||||
|
||||
class SendDocumentAsCustomMail extends Job
|
||||
{
|
||||
public function __construct($request, $template_alias)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->template_alias = $template_alias;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$document = Document::find($this->request->get('document_id'));
|
||||
|
||||
$custom_mail = $this->request->only(['to', 'subject', 'body']);
|
||||
|
||||
if ($this->request->has('user_email')) {
|
||||
$custom_mail['cc'] = user()->email;
|
||||
}
|
||||
|
||||
$notification = config('type.document.' . $document->type . '.notification.class');
|
||||
|
||||
// Notify the contact
|
||||
$document->contact->notify(new $notification($document, $this->template_alias, true, $custom_mail));
|
||||
|
||||
event(new DocumentSent($document));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user