Merge pull request #1691 from burakcakirel/income-expense-type-for-document-transactions
Add Income/Expense type for document transactions
This commit is contained in:
commit
eccaaad06b
@ -164,6 +164,7 @@ abstract class PaymentController extends BaseController
|
||||
$request['amount'] = $invoice->amount;
|
||||
$request['payment_method'] = $this->alias;
|
||||
$request['reference'] = $this->getReference($invoice);
|
||||
$request['type'] = 'income';
|
||||
|
||||
event(new PaymentReceived($invoice, $request));
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class Bills extends BulkAction
|
||||
$bills = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($bills as $bill) {
|
||||
$this->dispatch(new CreateBankingDocumentTransaction($bill, []));
|
||||
$this->dispatch(new CreateBankingDocumentTransaction($bill, ['type' => 'expense']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class Invoices extends BulkAction
|
||||
$invoices = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
event(new PaymentReceived($invoice));
|
||||
event(new PaymentReceived($invoice, ['type' => 'income']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ class Bills extends Controller
|
||||
public function markPaid(Document $bill)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new CreateBankingDocumentTransaction($bill, []));
|
||||
$this->dispatch(new CreateBankingDocumentTransaction($bill, ['type' => 'expense']));
|
||||
|
||||
$message = trans('general.messages.marked_paid', ['type' => trans_choice('general.bills', 1)]);
|
||||
|
||||
|
@ -358,7 +358,7 @@ class Invoices extends Controller
|
||||
public function markPaid(Document $invoice)
|
||||
{
|
||||
try {
|
||||
event(new \App\Events\Document\PaymentReceived($invoice));
|
||||
event(new \App\Events\Document\PaymentReceived($invoice, ['type' => 'income']));
|
||||
|
||||
$message = trans('general.messages.marked_paid', ['type' => trans_choice('general.invoices', 1)]);
|
||||
|
||||
|
@ -73,7 +73,6 @@ class CreateBankingDocumentTransaction extends Job
|
||||
|
||||
$this->request['company_id'] = $this->model->company_id;
|
||||
$this->request['currency_code'] = isset($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code;
|
||||
$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');
|
||||
|
@ -23,7 +23,7 @@ class Document implements Scope
|
||||
return;
|
||||
}
|
||||
|
||||
$type = request()->get('type') ?: Str::singular(request()->segment(2, ''));
|
||||
$type = Str::singular(request()->segment(2, ''));
|
||||
|
||||
// Apply document scope
|
||||
$builder->where($model->getTable() . '.type', '=', $type);
|
||||
|
@ -327,6 +327,7 @@ class Document extends AbstractFactory
|
||||
case 'paid':
|
||||
$payment_request = [
|
||||
'paid_at' => $updated_document->due_at,
|
||||
'type' => 'income',
|
||||
];
|
||||
|
||||
if ($init_status === 'partial') {
|
||||
|
11
modules/BC21/Jobs/Banking/CreateDocumentTransaction.php
Normal file
11
modules/BC21/Jobs/Banking/CreateDocumentTransaction.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Banking;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see CreateBankingDocumentTransaction
|
||||
*/
|
||||
class CreateDocumentTransaction extends CreateBankingDocumentTransaction
|
||||
{
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
{{ trans('general.confirm') }}
|
||||
</button>
|
||||
{!! Form::hidden('payment_method', $setting['code'], ['v-model' => 'form.payment_method']) !!}
|
||||
{!! Form::hidden('type', 'income', ['v-model' => 'form.type']) !!}
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -118,7 +118,7 @@ class Payment extends PaymentController
|
||||
$total_paid_match = ((double) $request['mc_gross'] == $document->amount);
|
||||
|
||||
if ($receiver_match && $total_paid_match) {
|
||||
event(new PaymentReceived($document, $request));
|
||||
event(new PaymentReceived($document, $request->merge(['type' => 'income'])));
|
||||
}
|
||||
|
||||
if (!$receiver_match) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user