Merge pull request #6438 from bagisto-europe/6419

fixed #6430
This commit is contained in:
Glenn Hermans 2022-05-21 13:03:48 +02:00 committed by GitHub
commit 63ee4b6774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 93 additions and 50 deletions

View File

@ -15,7 +15,7 @@ class OrderTransactionsDataGrid extends DataGrid
{
$queryBuilder = DB::table('order_transactions')
->leftJoin('orders as ors', 'order_transactions.order_id', '=', 'ors.id')
->select('order_transactions.id as id', 'order_transactions.transaction_id as transaction_id', 'order_transactions.invoice_id as invoice_id', 'ors.increment_id as order_id', 'order_transactions.created_at as created_at');
->select('order_transactions.id as id', 'order_transactions.transaction_id as transaction_id', 'order_transactions.invoice_id as invoice_id', 'ors.increment_id as order_id', 'order_transactions.created_at as created_at', 'order_transactions.amount as amount', 'order_transactions.status as status');
$this->addFilter('id', 'order_transactions.id');
$this->addFilter('transaction_id', 'order_transactions.transaction_id');
@ -34,7 +34,7 @@ class OrderTransactionsDataGrid extends DataGrid
'type' => 'number',
'searchable' => false,
'sortable' => true,
'filterable' => true,
'filterable' => false,
]);
$this->addColumn([
@ -45,6 +45,24 @@ class OrderTransactionsDataGrid extends DataGrid
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'created_at',
'label' => trans('admin::app.datagrid.transaction-date'),
'type' => 'datetime',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'amount',
'label' => trans('admin::app.sales.transactions.transaction-amount'),
'type' => 'price',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'invoice_id',
@ -54,6 +72,7 @@ class OrderTransactionsDataGrid extends DataGrid
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'order_id',
@ -65,9 +84,9 @@ class OrderTransactionsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'created_at',
'label' => trans('admin::app.datagrid.transaction-date'),
'type' => 'datetime',
'index' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true,

View File

@ -87,40 +87,46 @@ class TransactionController extends Controller
return redirect(route('admin.sales.transactions.index'));
}
$order = $this->orderRepository->find($invoice->order_id);
if ($request->amount > $invoice->base_grand_total) {
session()->flash('info', trans('admin::app.sales.transactions.response.transaction-amount-exceeds'));
$randomId = random_bytes(20);
return redirect(route('admin.sales.transactions.create'));
} else {
$order = $this->orderRepository->find($invoice->order_id);
$this->orderTransactionRepository->create([
'transaction_id' => bin2hex($randomId),
'type' => $request->payment_method,
'payment_method' => $request->payment_method,
'invoice_id' => $invoice->id,
'order_id' => $invoice->order_id,
'amount' => $request->amount,
'status' => 'paid',
'data' => json_encode([
'paidAmount' => $request->amount,
]),
]);
$transactionTotal = $this->orderTransactionRepository->where('invoice_id', $invoice->id)->sum('amount');
if ($transactionTotal >= $invoice->base_grand_total) {
$shipments = $this->shipmentRepository->where('order_id', $invoice->order_id)->first();
if (isset($shipments)) {
$this->orderRepository->updateOrderStatus($order, 'completed');
} else {
$this->orderRepository->updateOrderStatus($order, 'processing');
$randomId = random_bytes(20);
$this->orderTransactionRepository->create([
'transaction_id' => bin2hex($randomId),
'type' => $request->payment_method,
'payment_method' => $request->payment_method,
'invoice_id' => $invoice->id,
'order_id' => $invoice->order_id,
'amount' => $request->amount,
'status' => 'paid',
'data' => json_encode([
'paidAmount' => $request->amount,
]),
]);
$transactionTotal = $this->orderTransactionRepository->where('invoice_id', $invoice->id)->sum('amount');
if ($transactionTotal >= $invoice->base_grand_total) {
$shipments = $this->shipmentRepository->where('order_id', $invoice->order_id)->first();
if (isset($shipments)) {
$this->orderRepository->updateOrderStatus($order, 'completed');
} else {
$this->orderRepository->updateOrderStatus($order, 'processing');
}
$this->invoiceRepository->updateState($invoice, 'paid');
}
$this->invoiceRepository->updateState($invoice, 'paid');
session()->flash('success', trans('admin::app.sales.transactions.response.transaction-saved'));
return redirect(route('admin.sales.transactions.index'));
}
session()->flash('success', trans('admin::app.sales.transactions.response.transaction-saved'));
return redirect(route('admin.sales.transactions.index'));
}
session()->flash('error', trans('admin::app.sales.transactions.response.invoice-missing'));

View File

@ -522,6 +522,7 @@ return [
'invoice-missing' => 'معرف الفاتورة هذا غير موجود',
'transaction-saved' => 'تم حفظ الصفقة',
'already-paid' => 'تم دفع هذه الفاتورة بالفعل',
'transaction-amount-exceeds' => 'المبلغ المحدد لهذه المعاملة أكبر من المبلغ الإجمالي للفاتورة.',
],
],
],

View File

@ -525,6 +525,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -497,24 +497,25 @@ return [
],
'transactions' => [
'title' => 'Transactions',
'create-title' => 'Add transaction',
'title' => 'Transaktionen',
'create-title' => 'Transaktion hinzufügen',
'id' => 'Id',
'transaction-id' => 'Transaction Id',
'payment-method' => 'Payment method',
'transaction-amount' => 'Transaction amount',
'action' => 'Action',
'view-title' => 'Transaction #:transaction_id',
'transaction-data' => 'Transaction Data',
'order-id' => 'Order Id',
'invoice-id' => 'Invoice Id',
'transaction-id' => 'Transaktions-ID',
'payment-method' => 'Bezahlverfahren',
'transaction-amount' => 'Transaktionshöhe',
'action' => 'Handlung',
'view-title' => 'Transaktion #:transaction_id',
'transaction-data' => 'Transaktionsdaten',
'order-id' => 'Auftragsnummer',
'invoice-id' => 'Rechnungs-ID',
'status' => 'Status',
'created-at' => 'Created At',
'transaction-details' => 'Transaction Details',
'created-at' => 'Hergestellt in',
'transaction-details' => 'Transaktionsdetails',
'response' => [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'invoice-missing' => 'Diese Rechnungs-ID existiert nicht',
'transaction-saved' => 'Die Transaktion wurde gespeichert',
'already-paid' => 'Diese Rechnung wurde bereits bezahlt',
'transaction-amount-exceeds' => 'Der angegebene Betrag dieser Transaktion übersteigt den Gesamtbetrag der Rechnung.',
],
],
],

View File

@ -525,6 +525,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -523,6 +523,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -520,6 +520,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -524,6 +524,7 @@ return [
'invoice-missing' => 'Cet identifiant de facture n\'existe pas',
'transaction-saved' => 'La transaction a été enregistrée',
'already-paid' => 'Cette facture a déjà été payée',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -525,6 +525,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -522,6 +522,7 @@ return [
'invoice-missing' => 'यह चालान आईडी मौजूद नहीं है',
'transaction-saved' => 'लेन-देन सहेजा गया है',
'already-paid' => 'इस चालान का भुगतान पहले ही किया जा चुका है',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -520,6 +520,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -525,6 +525,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -516,6 +516,7 @@ return [
'invoice-missing' => 'Dit factuurnummer bestaat niet',
'transaction-saved' => 'De transactie is geregistreerd',
'already-paid' => 'Dit factuur is al voldaan',
'transaction-amount-exceeds' => 'Het opgegeven bedrag van deze transactie overschrijdt het totaalbedrag van de factuur.',
],
],
],

View File

@ -516,6 +516,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -515,6 +515,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -525,6 +525,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -525,6 +525,7 @@ return [
'invoice-missing' => 'This invoice id does not exist',
'transaction-saved' => 'The transaction has been saved',
'already-paid' => 'This invoice has already been paid',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -516,6 +516,7 @@ return [
'invoice-missing' => 'Bu fatura kimliği mevcut değil',
'transaction-saved' => 'İşlem kaydedildi',
'already-paid' => 'Bu fatura zaten ödendi',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],

View File

@ -516,6 +516,7 @@ return [
'invoice-missing' => '此发票ID不存在',
'transaction-saved' => '交易已保存',
'already-paid' => '此发票已支付',
'transaction-amount-exceeds' => 'The specified amount of this transaction exceeds the total amount of the invoice.',
],
],
],