Merge pull request #2503 from CihanSenturk/master
Document payment update issue fixed
This commit is contained in:
commit
005028eac4
@ -12,6 +12,7 @@ use App\Models\Setting\Currency;
|
||||
use App\Utilities\Modules;
|
||||
use App\Traits\Uploads;
|
||||
use App\Traits\Transactions;
|
||||
use Date;
|
||||
|
||||
|
||||
class DocumentTransactions extends Controller
|
||||
@ -58,6 +59,8 @@ class DocumentTransactions extends Controller
|
||||
$document->grand_total = round($document->total - $paid, $currency->precision);
|
||||
}
|
||||
|
||||
$document->paid_at = Date::now()->toDateString();
|
||||
|
||||
$buttons = [
|
||||
'cancel' => [
|
||||
'text' => trans('general.cancel'),
|
||||
@ -79,9 +82,11 @@ class DocumentTransactions extends Controller
|
||||
],
|
||||
];
|
||||
|
||||
$method = 'POST';
|
||||
|
||||
$route = ['modals.documents.document.transactions.store', $document->id];
|
||||
|
||||
$html = view('modals.documents.payment', compact('document', 'route', 'currency', 'number'))->render();
|
||||
$html = view('modals.documents.payment', compact('document', 'method', 'route', 'currency', 'number'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
@ -139,20 +144,11 @@ class DocumentTransactions extends Controller
|
||||
|
||||
$paid = $document->paid;
|
||||
|
||||
$number = $this->getNextTransactionNumber();
|
||||
$number = $transaction->number;
|
||||
|
||||
// Get document Totals
|
||||
foreach ($document->totals as $document_total) {
|
||||
$document->{$document_total->code} = $document_total->amount;
|
||||
}
|
||||
$document->grand_total = money($transaction->amount, $currency->code)->getAmount();
|
||||
|
||||
$total = money($document->total, $currency->code, true)->format();
|
||||
|
||||
$document->grand_total = money($total, $currency->code)->getAmount();
|
||||
|
||||
if (! empty($paid)) {
|
||||
$document->grand_total = round($document->total - $paid, $currency->precision);
|
||||
}
|
||||
$document->paid_at = $transaction->paid_at;
|
||||
|
||||
$buttons = [
|
||||
'cancel' => [
|
||||
@ -170,9 +166,11 @@ class DocumentTransactions extends Controller
|
||||
],
|
||||
];
|
||||
|
||||
$method = 'PATCH';
|
||||
|
||||
$route = ['modals.documents.document.transactions.update', $document->id, $transaction->id];
|
||||
|
||||
$html = view('modals.documents.payment', compact('document', 'transaction', 'route', 'currency', 'number'))->render();
|
||||
$html = view('modals.documents.payment', compact('document', 'transaction', 'method', 'route', 'currency', 'number'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Jobs\Banking;
|
||||
|
||||
use App\Abstracts\Job;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Banking\UpdateTransaction;
|
||||
use App\Jobs\Document\CreateDocumentHistory;
|
||||
use App\Events\Document\PaidAmountCalculated;
|
||||
use App\Interfaces\Job\ShouldUpdate;
|
||||
@ -21,7 +21,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
||||
$this->model = $model;
|
||||
$this->transaction = $transaction;
|
||||
|
||||
parent::__construct($request);
|
||||
$this->request = $this->getRequestInstance($request);
|
||||
}
|
||||
|
||||
public function handle(): Transaction
|
||||
@ -31,7 +31,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
||||
$this->checkAmount();
|
||||
|
||||
\DB::transaction(function () {
|
||||
$this->transaction = $this->dispatch(new CreateTransaction($this->request));
|
||||
$this->transaction = $this->dispatch(new UpdateTransaction($this->transaction, $this->request));
|
||||
|
||||
// Upload attachment
|
||||
if ($this->request->file('attachment')) {
|
||||
|
@ -696,7 +696,7 @@ const app = new Vue({
|
||||
|
||||
let payment = {
|
||||
modal: false,
|
||||
url: url + '/modals/documents/' + document_id + '/transactions/edit/' + transaction_id,
|
||||
url: url + '/modals/documents/' + document_id + '/transactions/' + transaction_id + '/edit',
|
||||
title: '',
|
||||
html: '',
|
||||
buttons:{}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<x-form id="form-transaction" :route="$route" :model="!empty($transaction) ? $transaction : false">
|
||||
<x-form id="form-transaction" :method="$method" :route="$route" :model="!empty($transaction) ? $transaction : false">
|
||||
<div class="rounded-xl px-5 py-3 mb-5 bg-red-100" v-if="typeof form.response !== 'undefined' && form.response.error">
|
||||
<p class="text-sm mb-0 text-red-600" v-html="form.response.message"></p>
|
||||
</div>
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
<div id="tab-general" data-tabs-content="general" x-show="active === 'general'">
|
||||
<div class="grid sm:grid-cols-6 gap-x-8 gap-y-6 my-3.5">
|
||||
<x-form.group.date name="paid_at" label="{{ trans('general.date') }}" icon="calendar_today" value="{{ Date::now()->toDateString() }}" show-date-format="{{ company_date_format() }}" date-format="Y-m-d" autocomplete="off" form-group-class="col-span-6" />
|
||||
<x-form.group.date name="paid_at" label="{{ trans('general.date') }}" icon="calendar_today" value="{{ $document->paid_at }}" show-date-format="{{ company_date_format() }}" date-format="Y-m-d" autocomplete="off" form-group-class="col-span-6" />
|
||||
|
||||
<x-form.group.money name="amount" label="{{ trans('general.amount') }}" value="{{ $document->grand_total }}" autofocus="autofocus" :currency="$currency" dynamicCurrency="currency" form-group-class="col-span-6" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user