added source feature
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
namespace App\Jobs\Auth;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Auth\Role;
|
||||
|
||||
class CreateRole extends Job implements ShouldCreate
|
||||
class CreateRole extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Role
|
||||
{
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
namespace App\Jobs\Auth;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Events\Auth\UserCreated;
|
||||
use App\Events\Auth\UserCreating;
|
||||
use App\Models\Auth\User;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class CreateUser extends Job implements ShouldCreate
|
||||
class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): User
|
||||
{
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Banking\Account;
|
||||
|
||||
class CreateAccount extends Job implements HasOwner, ShouldCreate
|
||||
class CreateAccount extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Account
|
||||
{
|
||||
|
||||
@@ -4,11 +4,12 @@ namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Banking\Reconciliation;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
class CreateReconciliation extends Job implements HasOwner, ShouldCreate
|
||||
class CreateReconciliation extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Reconciliation
|
||||
{
|
||||
|
||||
@@ -6,10 +6,11 @@ use App\Abstracts\Job;
|
||||
use App\Events\Banking\TransactionCreated;
|
||||
use App\Events\Banking\TransactionCreating;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Banking\Transaction;
|
||||
|
||||
class CreateTransaction extends Job implements HasOwner, ShouldCreate
|
||||
class CreateTransaction extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Transaction
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Models\Banking\Account;
|
||||
@@ -11,7 +12,7 @@ use App\Models\Banking\Transfer;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Traits\Currencies;
|
||||
|
||||
class CreateTransfer extends Job implements HasOwner, ShouldCreate
|
||||
class CreateTransfer extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
use Currencies;
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@ use App\Abstracts\Job;
|
||||
use App\Events\Common\CompanyCreated;
|
||||
use App\Events\Common\CompanyCreating;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Common\Company;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class CreateCompany extends Job implements HasOwner, ShouldCreate
|
||||
class CreateCompany extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Company
|
||||
{
|
||||
|
||||
@@ -4,13 +4,14 @@ namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Common\Contact;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateContact extends Job implements HasOwner, ShouldCreate
|
||||
class CreateContact extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Contact
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Jobs\Common\CreateWidget;
|
||||
use App\Models\Auth\User;
|
||||
@@ -13,7 +14,7 @@ use App\Models\Common\Widget;
|
||||
use App\Utilities\Widgets;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CreateDashboard extends Job implements HasOwner, ShouldCreate
|
||||
class CreateDashboard extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Dashboard
|
||||
{
|
||||
|
||||
21
app/Jobs/Common/CreateEmailTemplate.php
Normal file
21
app/Jobs/Common/CreateEmailTemplate.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Common\EmailTemplate;
|
||||
|
||||
class CreateEmailTemplate extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): EmailTemplate
|
||||
{
|
||||
\DB::transaction(function () {
|
||||
$this->model = EmailTemplate::create($this->request->all());
|
||||
});
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@ namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Jobs\Common\CreateItemTaxes;
|
||||
use App\Models\Common\Item;
|
||||
|
||||
class CreateItem extends Job implements HasOwner, ShouldCreate
|
||||
class CreateItem extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Item
|
||||
{
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Common\ItemTax;
|
||||
|
||||
class CreateItemTaxes extends Job implements ShouldCreate
|
||||
class CreateItemTaxes extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
protected $item;
|
||||
|
||||
@@ -44,6 +46,8 @@ class CreateItemTaxes extends Job implements ShouldCreate
|
||||
'company_id' => $this->item->company_id,
|
||||
'item_id' => $this->item->id,
|
||||
'tax_id' => $tax_id,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Common\Report;
|
||||
|
||||
class CreateReport extends Job implements HasOwner, ShouldCreate
|
||||
class CreateReport extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Report
|
||||
{
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Jobs\Common;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Common\Widget;
|
||||
|
||||
class CreateWidget extends Job implements HasOwner, ShouldCreate
|
||||
class CreateWidget extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Widget
|
||||
{
|
||||
|
||||
@@ -6,12 +6,13 @@ use App\Abstracts\Job;
|
||||
use App\Events\Document\DocumentCreated;
|
||||
use App\Events\Document\DocumentCreating;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Jobs\Document\CreateDocumentItemsAndTotals;
|
||||
use App\Models\Document\Document;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateDocument extends Job implements HasOwner, ShouldCreate
|
||||
class CreateDocument extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Document
|
||||
{
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
namespace App\Jobs\Document;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Document\DocumentHistory;
|
||||
|
||||
class CreateDocumentHistory extends Job implements ShouldCreate
|
||||
class CreateDocumentHistory extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
protected $document;
|
||||
|
||||
@@ -35,6 +37,8 @@ class CreateDocumentHistory extends Job implements ShouldCreate
|
||||
'status' => $this->document->status,
|
||||
'notify' => $this->notify,
|
||||
'description' => $description,
|
||||
'created_from' => source_name(),
|
||||
'created_by' => user_id(),
|
||||
]);
|
||||
|
||||
return $document_history;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Jobs\Document;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Document\DocumentItem;
|
||||
@@ -10,7 +12,7 @@ use App\Models\Document\DocumentItemTax;
|
||||
use App\Models\Setting\Tax;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateDocumentItem extends Job implements ShouldCreate
|
||||
class CreateDocumentItem extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
protected $document;
|
||||
|
||||
@@ -182,6 +184,8 @@ class CreateDocumentItem extends Job implements ShouldCreate
|
||||
$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();
|
||||
|
||||
$document_item = DocumentItem::create($this->request);
|
||||
|
||||
@@ -197,6 +201,8 @@ class CreateDocumentItem extends Job implements ShouldCreate
|
||||
foreach ($item_taxes as $item_tax) {
|
||||
$item_tax['document_item_id'] = $document_item->id;
|
||||
$item_tax['amount'] = round(abs($item_tax['amount']), $precision);
|
||||
$item_tax['created_from'] = $this->request['created_from'];
|
||||
$item_tax['created_by'] = $this->request['created_by'];
|
||||
|
||||
DocumentItemTax::create($item_tax);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Jobs\Document;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Jobs\Common\CreateItem;
|
||||
use App\Models\Document\Document;
|
||||
@@ -10,7 +12,7 @@ use App\Models\Document\DocumentTotal;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
|
||||
class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
class CreateDocumentItemsAndTotals extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
use Currencies, DateTime;
|
||||
|
||||
@@ -40,6 +42,8 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
'name' => 'invoices.sub_total',
|
||||
'amount' => round($sub_total, $precision),
|
||||
'sort_order' => $sort_order,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
]);
|
||||
|
||||
$this->request['amount'] += $sub_total;
|
||||
@@ -56,6 +60,8 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
'name' => 'invoices.item_discount',
|
||||
'amount' => round($discount_amount_total, $precision),
|
||||
'sort_order' => $sort_order,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
@@ -68,7 +74,7 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
$discount_total = $this->request['discount'];
|
||||
}
|
||||
|
||||
DocumentTotal::create([
|
||||
DocumentTotal::create([
|
||||
'company_id' => $this->document->company_id,
|
||||
'type' => $this->document->type,
|
||||
'document_id' => $this->document->id,
|
||||
@@ -76,6 +82,8 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
'name' => 'invoices.discount',
|
||||
'amount' => round($discount_total, $precision),
|
||||
'sort_order' => $sort_order,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
]);
|
||||
|
||||
$this->request['amount'] -= $discount_total;
|
||||
@@ -94,6 +102,8 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
'name' => $tax['name'],
|
||||
'amount' => round(abs($tax['amount']), $precision),
|
||||
'sort_order' => $sort_order,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
]);
|
||||
|
||||
$this->request['amount'] += $tax['amount'];
|
||||
@@ -109,6 +119,8 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
$total['type'] = $this->document->type;
|
||||
$total['document_id'] = $this->document->id;
|
||||
$total['sort_order'] = $sort_order;
|
||||
$total['created_from'] = $this->request['created_from'];
|
||||
$total['created_by'] = $this->request['created_by'];
|
||||
|
||||
if (empty($total['code'])) {
|
||||
$total['code'] = 'extra';
|
||||
@@ -140,6 +152,8 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
'name' => 'invoices.total',
|
||||
'amount' => $this->request['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
'created_from' => $this->request['created_from'],
|
||||
'created_by' => $this->request['created_by'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -167,7 +181,7 @@ class CreateDocumentItemsAndTotals extends Job implements ShouldCreate
|
||||
'description' => $item['description'],
|
||||
'sale_price' => $item['price'],
|
||||
'purchase_price' => $item['price'],
|
||||
'enabled' => '1'
|
||||
'enabled' => '1',
|
||||
];
|
||||
|
||||
if (!empty($item['tax_ids'])) {
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Jobs\Setting;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Setting\Category;
|
||||
|
||||
class CreateCategory extends Job implements HasOwner, ShouldCreate
|
||||
class CreateCategory extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Category
|
||||
{
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Jobs\Setting;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Setting\Currency;
|
||||
|
||||
class CreateCurrency extends Job implements HasOwner, ShouldCreate
|
||||
class CreateCurrency extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Currency
|
||||
{
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Jobs\Setting;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Interfaces\Job\HasOwner;
|
||||
use App\Interfaces\Job\HasSource;
|
||||
use App\Interfaces\Job\ShouldCreate;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class CreateTax extends Job implements HasOwner, ShouldCreate
|
||||
class CreateTax extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
public function handle(): Tax
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user