Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve order total invoice issue on backoffice orders page. #358

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,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 @@ -2638,6 +2639,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 @@ -3355,6 +3369,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 @@ -3399,6 +3423,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