Skip to content

Commit

Permalink
Merge pull request #358 from lakshya-webkul/gli-invoice-issue
Browse files Browse the repository at this point in the history
Resolve order total invoice issue on backoffice orders page.
  • Loading branch information
rohit053 authored Jun 27, 2022
2 parents 8177fab + 99f55e4 commit 70d8d6c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,7 @@ public function ajaxProcessEditProductOnOrder()
$product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to);
$old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to);
$qty_diff = $product_quantity - $old_product_quantity;

/*By webkul to validate fields before deleting the cart and order data form the tables*/
if ($id_hotel == '') {
die(json_encode(array(
Expand Down Expand Up @@ -2602,6 +2603,19 @@ public function ajaxProcessEditProductOnOrder()
}
}
}

if (isset($order_invoice)) {
// Apply changes on OrderInvoice
$order_invoice->total_paid_tax_excl = $objOrder->total_paid_tax_excl;
$order_invoice->total_paid_tax_incl = $objOrder->total_paid_tax_incl;
}


// Save order invoice
if (isset($order_invoice)) {
$res &= $order_invoice->update();
}

// change order total save
$objOrder->save();
}
Expand Down Expand Up @@ -3319,6 +3333,16 @@ public function ajaxProcessEditRoomExtraDemands()
$objBookingDemand->total_price_tax_excl = $objBookingDemand->unit_price_tax_excl * $qty;
$objBookingDemand->total_price_tax_incl = $objBookingDemand->unit_price_tax_incl * $qty;

$order_detail = new OrderDetail($objBookingDetail->id_order_detail);
// Update OrderInvoice of this OrderDetail
if ($order_detail->id_order_invoice != 0) {
// values changes as values are calculated accoding to the quantity of the product by webkul
$order_invoice = new OrderInvoice($order_detail->id_order_invoice);
$order_invoice->total_paid_tax_excl += $objBookingDemand->total_price_tax_excl;
$order_invoice->total_paid_tax_incl += $objBookingDemand->total_price_tax_incl;
$res &= $order_invoice->update();
}

// change order total
$order->total_paid_tax_excl += $objBookingDemand->total_price_tax_excl;
$order->total_paid_tax_incl += $objBookingDemand->total_price_tax_incl;
Expand Down Expand Up @@ -3363,6 +3387,16 @@ public function ajaxProcessDeleteRoomExtraDemand()
$order->total_paid_tax_incl -= $objBookingDemand->total_price_tax_incl;
$order->total_paid -= $objBookingDemand->total_price_tax_incl;
$order->save();

$order_detail = new OrderDetail($objBookingDetail->id_order_detail);
// Update OrderInvoice of this OrderDetail
if ($order_detail->id_order_invoice != 0) {
// values changes as values are calculated accoding to the quantity of the product by webkul
$order_invoice = new OrderInvoice($order_detail->id_order_invoice);
$order_invoice->total_paid_tax_excl -= $objBookingDemand->total_price_tax_excl;
$order_invoice->total_paid_tax_incl -= $objBookingDemand->total_price_tax_incl;
$res &= $order_invoice->update();
}
}
die('1');
}
Expand Down

0 comments on commit 70d8d6c

Please sign in to comment.