fixed #3453
This commit is contained in:
parent
52206b582f
commit
04aac03bbd
|
|
@ -83,7 +83,7 @@ class InvoiceRepository extends Repository
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return \Webkul\Sales\Contracts\Invoice
|
* @return \Webkul\Sales\Contracts\Invoice
|
||||||
*/
|
*/
|
||||||
public function create(array $data)
|
public function create(array $data, $invoiceState = null, $orderState = null)
|
||||||
{
|
{
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
|
@ -94,10 +94,16 @@ class InvoiceRepository extends Repository
|
||||||
|
|
||||||
$totalQty = array_sum($data['invoice']['items']);
|
$totalQty = array_sum($data['invoice']['items']);
|
||||||
|
|
||||||
|
if (isset($invoiceState)) {
|
||||||
|
$state = $invoiceState;
|
||||||
|
} else {
|
||||||
|
$state = "paid";
|
||||||
|
}
|
||||||
|
|
||||||
$invoice = $this->model->create([
|
$invoice = $this->model->create([
|
||||||
'order_id' => $order->id,
|
'order_id' => $order->id,
|
||||||
'total_qty' => $totalQty,
|
'total_qty' => $totalQty,
|
||||||
'state' => 'paid',
|
'state' => $state,
|
||||||
'base_currency_code' => $order->base_currency_code,
|
'base_currency_code' => $order->base_currency_code,
|
||||||
'channel_currency_code' => $order->channel_currency_code,
|
'channel_currency_code' => $order->channel_currency_code,
|
||||||
'order_currency_code' => $order->order_currency_code,
|
'order_currency_code' => $order->order_currency_code,
|
||||||
|
|
@ -195,7 +201,11 @@ class InvoiceRepository extends Repository
|
||||||
|
|
||||||
$this->orderRepository->collectTotals($order);
|
$this->orderRepository->collectTotals($order);
|
||||||
|
|
||||||
|
if (isset($orderState)){
|
||||||
|
$this->orderRepository->updateOrderStatus($order, $orderState);
|
||||||
|
} else {
|
||||||
$this->orderRepository->updateOrderStatus($order);
|
$this->orderRepository->updateOrderStatus($order);
|
||||||
|
}
|
||||||
|
|
||||||
Event::dispatch('sales.invoice.save.after', $invoice);
|
Event::dispatch('sales.invoice.save.after', $invoice);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue