From 87347f0df448968f16115476e9ef752187bbe24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= Date: Sun, 3 Jul 2022 14:57:36 +0300 Subject: [PATCH 1/2] transaction edit url fixed --- resources/assets/js/views/common/documents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 62b65309c..356dc19a5 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -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:{} From 14cd394563628d576dedc1297277cdce53b5564e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= Date: Sun, 3 Jul 2022 14:59:17 +0300 Subject: [PATCH 2/2] document payment update errors fixed --- .../Modals/DocumentTransactions.php | 26 +++++++++---------- .../UpdateBankingDocumentTransaction.php | 6 ++--- .../views/modals/documents/payment.blade.php | 4 +-- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/Modals/DocumentTransactions.php b/app/Http/Controllers/Modals/DocumentTransactions.php index b532ce862..dfb3d9355 100644 --- a/app/Http/Controllers/Modals/DocumentTransactions.php +++ b/app/Http/Controllers/Modals/DocumentTransactions.php @@ -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, diff --git a/app/Jobs/Banking/UpdateBankingDocumentTransaction.php b/app/Jobs/Banking/UpdateBankingDocumentTransaction.php index f4b883097..914735cf7 100644 --- a/app/Jobs/Banking/UpdateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/UpdateBankingDocumentTransaction.php @@ -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')) { diff --git a/resources/views/modals/documents/payment.blade.php b/resources/views/modals/documents/payment.blade.php index c68487dce..455e44b1a 100644 --- a/resources/views/modals/documents/payment.blade.php +++ b/resources/views/modals/documents/payment.blade.php @@ -1,4 +1,4 @@ - +

@@ -40,7 +40,7 @@
- +