Merge branch 'master' into devJJ
This commit is contained in:
commit
297d780298
|
|
@ -109,10 +109,10 @@ class TransactionController extends Controller
|
|||
return redirect(route('admin.sales.transactions.index'));
|
||||
}
|
||||
|
||||
$order = $this->orderRepository->find($invoice->id);
|
||||
$order = $this->orderRepository->find($invoice->order_id);
|
||||
|
||||
$data = [
|
||||
"paidAmount" => $request->amount,
|
||||
"paidAmount" => $request->amount
|
||||
];
|
||||
|
||||
$randomId = random_bytes(20);
|
||||
|
|
@ -123,17 +123,24 @@ class TransactionController extends Controller
|
|||
$transactionData['payment_method'] = $request->payment_method;
|
||||
$transactionData['invoice_id'] = $invoice->id;
|
||||
$transactionData['order_id'] = $invoice->order_id;
|
||||
$transactionData['amount'] = $request->amount;
|
||||
$transactionData['status'] = 'paid';
|
||||
$transactionData['data'] = json_encode($data);
|
||||
|
||||
$this->orderTransactionRepository->create($transactionData);
|
||||
|
||||
if ($invoice->base_grand_total == $request->amount) {
|
||||
$this->orderRepository->updateOrderStatus($order, 'processing');
|
||||
$update = $this->invoiceRepository->updateState($invoice, "paid");
|
||||
} else {
|
||||
$this->orderRepository->updateOrderStatus($order, 'pending');
|
||||
$update = $this->invoiceRepository->updateState($invoice, "pending");
|
||||
$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");
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.sales.transactions.response.transaction-saved'));
|
||||
|
|
@ -187,4 +194,4 @@ class TransactionController extends Controller
|
|||
|
||||
return $detailsData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTransactionAmountColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('order_transactions', function (Blueprint $table) {
|
||||
$table->decimal('amount', 12, 4)->default(0)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('order_transactions', function (Blueprint $table) {
|
||||
$table->dropColumn('amount');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -273,6 +273,24 @@ class Order extends Model implements OrderContract
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if a invoice is still unpaid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOpenInvoice(): bool
|
||||
{
|
||||
$pendingInvoice = $this->invoices()->where('state', 'pending')
|
||||
->orWhere('state', 'pending_payment')
|
||||
->first();
|
||||
|
||||
if ($pendingInvoice) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if order can be canceled or not
|
||||
|
|
|
|||
|
|
@ -158,6 +158,8 @@ class ShipmentRepository extends Repository
|
|||
|
||||
if (isset($orderState)) {
|
||||
$this->orderRepository->updateOrderStatus($order, $orderState);
|
||||
} elseif ($order->hasOpenInvoice()) {
|
||||
$this->orderRepository->updateOrderStatus($order, 'pending_payment');
|
||||
} else {
|
||||
$this->orderRepository->updateOrderStatus($order);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,14 @@
|
|||
<span class="quantity-container">
|
||||
<button type="button" class="decrease" @click="decreaseQty()">-</button>
|
||||
|
||||
<input :name="controlName" class="control" :value="qty" :v-validate="validations" data-vv-as=""{{ __('shop::app.products.quantity') }}"" readonly>
|
||||
<input
|
||||
ref="quantityChanger"
|
||||
:name="controlName"
|
||||
:model="qty"
|
||||
class="control"
|
||||
v-validate="validations"
|
||||
data-vv-as=""{{ __('shop::app.products.quantity') }}""
|
||||
@keyup="setQty($event)">
|
||||
|
||||
<button type="button" class="increase" @click="increaseQty()">+</button>
|
||||
|
||||
|
|
@ -236,26 +243,30 @@
|
|||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
quantity: function (val) {
|
||||
this.qty = val;
|
||||
mounted: function() {
|
||||
this.$refs.quantityChanger.value = this.minQuantity;
|
||||
},
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty)
|
||||
watch: {
|
||||
qty: function (val) {
|
||||
this.$refs.quantityChanger.value = val;
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setQty: function({ target }) {
|
||||
this.qty = parseInt(target.value);
|
||||
},
|
||||
|
||||
decreaseQty: function() {
|
||||
if (this.qty > this.minQuantity)
|
||||
this.qty = parseInt(this.qty) - 1;
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty)
|
||||
},
|
||||
|
||||
increaseQty: function() {
|
||||
this.qty = parseInt(this.qty) + 1;
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -15,13 +15,14 @@
|
|||
<button type="button" class="decrease" @click="decreaseQty()">-</button>
|
||||
|
||||
<input
|
||||
:value="qty"
|
||||
class="control"
|
||||
ref="quantityChanger"
|
||||
:name="controlName"
|
||||
:v-validate="validations"
|
||||
:model="qty"
|
||||
class="control"
|
||||
id="quantity-changer"
|
||||
v-validate="validations"
|
||||
:data-vv-as="`"${quantityText}"`"
|
||||
readonly
|
||||
@keyup="setQty($event)"
|
||||
/>
|
||||
|
||||
<button type="button" class="increase" @click="increaseQty()">+</button>
|
||||
|
|
@ -71,25 +72,29 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
this.$refs.quantityChanger.value = this.minQuantity;
|
||||
},
|
||||
|
||||
watch: {
|
||||
quantity: function(val) {
|
||||
this.qty = val;
|
||||
qty: function(val) {
|
||||
this.$refs.quantityChanger.value = val;
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setQty: function({ target }) {
|
||||
this.qty = parseInt(target.value);
|
||||
},
|
||||
|
||||
decreaseQty: function() {
|
||||
if (this.qty > this.minQuantity) this.qty = parseInt(this.qty) - 1;
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty);
|
||||
},
|
||||
|
||||
increaseQty: function() {
|
||||
this.qty = parseInt(this.qty) + 1;
|
||||
|
||||
this.$emit('onQtyUpdated', this.qty);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue