Merge Invoice and Bill into Document

This commit is contained in:
Burak Çakırel
2020-12-24 01:28:38 +03:00
parent 830cc05957
commit 0c1424db47
436 changed files with 31655 additions and 37350 deletions

View File

@@ -4,15 +4,14 @@ namespace App\Jobs\Banking;
use App\Abstracts\Job;
use App\Jobs\Banking\CreateTransaction;
use App\Jobs\Purchase\CreateBillHistory;
use App\Jobs\Sale\CreateInvoiceHistory;
use App\Jobs\Document\CreateDocumentHistory;
use App\Events\Document\PaidAmountCalculated;
use App\Models\Banking\Transaction;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Traits\Currencies;
use Date;
class CreateDocumentTransaction extends Job
class CreateBankingDocumentTransaction extends Job
{
use Currencies;
@@ -74,7 +73,7 @@ class CreateDocumentTransaction extends Job
$this->request['company_id'] = session('company_id');
$this->request['currency_code'] = isset($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code;
$this->request['type'] = ($this->model instanceof Invoice) ? 'income' : 'expense';
$this->request['type'] = ($this->model->type === Document::INVOICE_TYPE) ? 'income' : 'expense';
$this->request['paid_at'] = isset($this->request['paid_at']) ? $this->request['paid_at'] : Date::now()->format('Y-m-d');
$this->request['currency_rate'] = config('money.' . $this->request['currency_code'] . '.rate');
$this->request['account_id'] = isset($this->request['account_id']) ? $this->request['account_id'] : setting('default.account');
@@ -132,10 +131,6 @@ class CreateDocumentTransaction extends Job
{
$history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code, true)->format() . ' ' . trans_choice('general.payments', 1);
if ($this->model instanceof Invoice) {
$this->dispatch(new CreateInvoiceHistory($this->model, 0, $history_desc));
} else {
$this->dispatch(new CreateBillHistory($this->model, 0, $history_desc));
}
$this->dispatch(new CreateDocumentHistory($this->model, 0, $history_desc));
}
}