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