Fixed: Order and invoice price calculation issues that occurred after updating an order in the back office.
Fixed: Order and invoice price calculation issues that occurred after updating an order in the back office.
This commit is contained in:
@@ -127,7 +127,7 @@
|
||||
</div>
|
||||
|
||||
{if sizeof($invoices_collection)}
|
||||
<div class="form-group">
|
||||
<div class="form-group" style="display: none;">
|
||||
<label class="control-label">{l s='Invoice'}</label>
|
||||
<select class="form-control" name="add_product[invoice]" id="add_product_product_invoice" disabled="disabled">
|
||||
<optgroup class="existing" label="{l s='Existing'}">
|
||||
|
||||
@@ -127,6 +127,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="product_invoice" style="display: none;">
|
||||
<select name="product_invoice" class="edit_product_invoice">
|
||||
{foreach from=$invoices_collection item=invoice}
|
||||
<option value="{$invoice->id}" {if $invoice->id == $data.id_order_invoice}selected="selected"{/if}>
|
||||
#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang, null, $order->id_shop)}{'%06d'|sprintf:$invoice->number}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="submitRoomChange" class="btn btn-primary"><i class="icon icon-bed"></i> {l s="Update Rooms"}</button>
|
||||
|
||||
@@ -347,9 +347,9 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
if ($type_value)
|
||||
if (isset($customer->id)) {
|
||||
$cart_obj = new Cart($this->order->id_cart);
|
||||
$order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($this->order->id, $cart_obj->id_guest, $type_value['product_id'], $customer->id, $type_value['id_order_detail']);
|
||||
$order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($this->order->id, $cart_obj->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($this->order->id, $customer->id_guest, $type_value['product_id'], 0, $type_value['id_order_detail']);
|
||||
$order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($this->order->id, $customer->id_guest, $type_value['product_id'], 0);
|
||||
}
|
||||
|
||||
$cart_htl_data[$type_key]['id_product'] = $type_value['product_id'];
|
||||
@@ -376,40 +376,9 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
|
||||
$num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int)$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += ($data_v['total_price_tax_excl']);
|
||||
|
||||
// For order refund
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room'];
|
||||
} else {
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$order_obj->id,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
$type_value['id_order_detail']
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$order_obj->id,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
$type_value['id_order_detail']
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
@@ -443,33 +412,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
0
|
||||
);
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
0,
|
||||
$data_v['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
0,
|
||||
$data_v['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
|
||||
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
@@ -480,18 +422,71 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['children'] = $data_v['children'];
|
||||
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'];
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['total_price_tax_excl'] = 0;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['total_price_tax_incl'] = 0;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = 0;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = 0;
|
||||
// For order refund
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room'];
|
||||
$totalDemandsPriceTE += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'];
|
||||
$totalDemandsPriceTI += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'];
|
||||
}
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$order_obj->id,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
$data_v['id']
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$order_obj->id,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
$data_v['id']
|
||||
);
|
||||
|
||||
$totalDemandsPriceTE += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'];
|
||||
$totalDemandsPriceTI += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'];
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['total_price_tax_excl'] += $data_v['total_price_tax_excl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['total_price_tax_incl'] += $data_v['total_price_tax_incl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
0,
|
||||
$data_v['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
0,
|
||||
$data_v['id_product'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
|
||||
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$order_obj->id,
|
||||
$type_value['product_id'],
|
||||
@@ -537,6 +532,13 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($cart_htl_data[$type_key]['date_diff'] as $date_join => $val) {
|
||||
$num_days = $val['num_days'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $val['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $val['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += ($val['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + ($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']/$num_days);
|
||||
}
|
||||
// calculate averages now
|
||||
foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
|
||||
|
||||
@@ -855,6 +855,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'order' => $objOrder,
|
||||
'invoices_collection' => $objOrder->getInvoicesCollection(),
|
||||
'currency' => new Currency($objOrder->id_currency),
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
)
|
||||
@@ -895,89 +896,92 @@ class AdminOrdersControllerCore extends AdminController
|
||||
&& ($productLineData = Tools::getValue('product_line_data'))
|
||||
) {
|
||||
$productLineData = json_decode($productLineData, true);
|
||||
if (Validate::isLoadedObject($objOrderDetail = new OrderDetail($productLineData['id_order_detail']))) {
|
||||
$productLineData['id_order_invoice'] = $objOrderDetail->id_order_invoice;
|
||||
$smartyVars = array(
|
||||
'order' => $objOrder,
|
||||
'data' => $productLineData,
|
||||
'currency' => new Currency($objOrder->id_currency),
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
'orderEdit' => 1,
|
||||
);
|
||||
|
||||
$smartyVars = array(
|
||||
'order' => $objOrder,
|
||||
'data' => $productLineData,
|
||||
'currency' => new Currency($objOrder->id_currency),
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
'orderEdit' => 1,
|
||||
);
|
||||
$objCurrency = new Currency($objOrder->id_currency);
|
||||
$smartyVars['orderCurrency'] = $objOrder->id_currency;
|
||||
$smartyVars['currencySign'] = $objCurrency->sign;
|
||||
$smartyVars['link'] = $this->context->link;
|
||||
|
||||
$objCurrency = new Currency($objOrder->id_currency);
|
||||
$smartyVars['orderCurrency'] = $objOrder->id_currency;
|
||||
$smartyVars['currencySign'] = $objCurrency->sign;
|
||||
$smartyVars['link'] = $this->context->link;
|
||||
$smartyVars['id_booking_detail'] = $productLineData['id'];
|
||||
|
||||
$smartyVars['id_booking_detail'] = $productLineData['id'];
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
// set context currency So that we can get prices in the order currency
|
||||
$this->context->currency = $objCurrency;
|
||||
|
||||
// set context currency So that we can get prices in the order currency
|
||||
$this->context->currency = $objCurrency;
|
||||
|
||||
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
$productLineData['id']
|
||||
)) {
|
||||
$smartyVars['extraDemands'] = $extraDemands;
|
||||
}
|
||||
|
||||
// get room type additional demands
|
||||
$objRoomDemands = new HotelRoomTypeDemand();
|
||||
if ($roomTypeDemands = $objRoomDemands->getRoomTypeDemands($idProduct)) {
|
||||
foreach ($roomTypeDemands as &$demand) {
|
||||
// if demand has advance options then set demand price as first advance option price.
|
||||
if (isset($demand['adv_option']) && $demand['adv_option']) {
|
||||
$demand['price'] = current($demand['adv_option'])['price'];
|
||||
}
|
||||
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
$productLineData['id']
|
||||
)) {
|
||||
$smartyVars['extraDemands'] = $extraDemands;
|
||||
}
|
||||
$smartyVars['roomTypeDemands'] = $roomTypeDemands;
|
||||
}
|
||||
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
|
||||
$productLineData['id']
|
||||
)) {
|
||||
$smartyVars['additionalServices'] = $additionalServices;
|
||||
}
|
||||
|
||||
// get room type additional demands
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
|
||||
if ($additionalServices) {
|
||||
foreach ($roomTypeServiceProducts as $key => $product) {
|
||||
if (in_array($product['id_product'], array_column($additionalServices['additional_services'], 'id_product'))) {
|
||||
unset($roomTypeServiceProducts[$key]);
|
||||
// get room type additional demands
|
||||
$objRoomDemands = new HotelRoomTypeDemand();
|
||||
if ($roomTypeDemands = $objRoomDemands->getRoomTypeDemands($idProduct)) {
|
||||
foreach ($roomTypeDemands as &$demand) {
|
||||
// if demand has advance options then set demand price as first advance option price.
|
||||
if (isset($demand['adv_option']) && $demand['adv_option']) {
|
||||
$demand['price'] = current($demand['adv_option'])['price'];
|
||||
}
|
||||
}
|
||||
$smartyVars['roomTypeDemands'] = $roomTypeDemands;
|
||||
}
|
||||
$smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts;
|
||||
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
|
||||
$productLineData['id']
|
||||
)) {
|
||||
$smartyVars['additionalServices'] = $additionalServices;
|
||||
}
|
||||
|
||||
// get room type additional demands
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
|
||||
if ($additionalServices) {
|
||||
foreach ($roomTypeServiceProducts as $key => $product) {
|
||||
if (in_array($product['id_product'], array_column($additionalServices['additional_services'], 'id_product'))) {
|
||||
unset($roomTypeServiceProducts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts;
|
||||
}
|
||||
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1);
|
||||
$smartyVars['refundReqBookings'] = $refundReqBookings;
|
||||
$smartyVars['invoices_collection'] = $objOrder->getInvoicesCollection();
|
||||
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
|
||||
$modal = array(
|
||||
'modal_id' => 'edit-room-booking-modal',
|
||||
'modal_class' => 'modal-lg order_detail_modal',
|
||||
'modal_title' => '<i class="icon icon-bed"></i>  '.$this->l('Edit Room'),
|
||||
'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_edit_room_booking.tpl'),
|
||||
);
|
||||
|
||||
$this->context->smarty->assign($modal);
|
||||
$response['hasError'] = 0;
|
||||
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
|
||||
}
|
||||
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1);
|
||||
$smartyVars['refundReqBookings'] = $refundReqBookings;
|
||||
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
|
||||
$modal = array(
|
||||
'modal_id' => 'edit-room-booking-modal',
|
||||
'modal_class' => 'modal-lg order_detail_modal',
|
||||
'modal_title' => '<i class="icon icon-bed"></i>  '.$this->l('Edit Room'),
|
||||
'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_edit_room_booking.tpl'),
|
||||
);
|
||||
|
||||
$this->context->smarty->assign($modal);
|
||||
$response['hasError'] = 0;
|
||||
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
|
||||
}
|
||||
|
||||
die(Tools::jsonEncode($response));
|
||||
@@ -4408,14 +4412,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// Create Order detail information
|
||||
$order_detail = new OrderDetail();
|
||||
$order_detail->createList($order, $cart, $order->getCurrentOrderState(), $cart->getProducts(), (isset($order_invoice) ? $order_invoice->id : 0), $use_taxes, (int)Tools::getValue('add_product_warehouse'));
|
||||
|
||||
// update totals amount of order
|
||||
$order->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
$order->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
|
||||
|
||||
// Create Order detail information
|
||||
$order_detail = new OrderDetail();
|
||||
// In case there is no room in the order the the create list will not add taxes as total_products is zero.
|
||||
$order_detail->createList($order, $cart, $order->getCurrentOrderState(), $cart->getProducts(), (isset($order_invoice) ? $order_invoice->id : 0), $use_taxes, (int)Tools::getValue('add_product_warehouse'));
|
||||
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
@@ -4871,8 +4876,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if (isset($order_invoice)) {
|
||||
// Apply changes on OrderInvoice
|
||||
$order_invoice->total_products += (float)$diff_price_tax_excl;
|
||||
$order_invoice->total_products_wt += (float)$diff_price_tax_incl;
|
||||
$order_invoice->total_paid_tax_excl += (float)$diff_price_tax_excl;
|
||||
$order_invoice->total_paid_tax_incl += (float)$diff_price_tax_incl;
|
||||
}
|
||||
@@ -4884,10 +4887,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->total_products_wt += (float)$diff_price_tax_incl;
|
||||
$order->total_products_wt = $order->total_products_wt > 0 ? $order->total_products_wt : 0;
|
||||
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
|
||||
$res &= $order->update();
|
||||
}
|
||||
|
||||
@@ -4912,10 +4911,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// Save order invoice
|
||||
if (isset($order_invoice)) {
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
|
||||
if ($qty_diff != 0) {
|
||||
$cartQty = $qty_diff;
|
||||
@@ -5041,7 +5036,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
)) {
|
||||
// update extra demands total prices if dates are changes (price calc method for each day)
|
||||
if ($extraDemands) {
|
||||
$order = new Order($id_order);
|
||||
foreach ($extraDemands as $demand) {
|
||||
if (isset($demand['extra_demands']) && $demand['extra_demands']) {
|
||||
foreach ($demand['extra_demands'] as $rDemand) {
|
||||
@@ -5066,23 +5060,23 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objBookingDemand->total_price_tax_incl = $demandPriceTI;
|
||||
|
||||
$objBookingDemand->save();
|
||||
|
||||
$order_invoice->total_paid_tax_excl -= $rDemand['total_price_tax_excl'];
|
||||
$order_invoice->total_paid_tax_incl -= $rDemand['total_price_tax_incl'];
|
||||
|
||||
$order_invoice->total_paid_tax_excl += (float)$objBookingDemand->total_price_tax_excl;
|
||||
$order_invoice->total_paid_tax_incl += (float)$objBookingDemand->total_price_tax_incl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// change order total save
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
|
||||
$order->save();
|
||||
}
|
||||
|
||||
if (isset($orderServiceProducts)
|
||||
&& is_array($orderServiceProducts)
|
||||
&& count($orderServiceProducts)
|
||||
) {
|
||||
$order = new Order((int) $id_order);
|
||||
foreach ($orderServiceProducts as $orderServiceProduct) {
|
||||
if (isset($orderServiceProduct['additional_services'])
|
||||
&& is_array($orderServiceProduct['additional_services'])
|
||||
@@ -5128,6 +5122,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objOrderDetail->product_quantity += ($newProductQuantity - $oldProductQuantity);
|
||||
$objOrderDetail->save();
|
||||
|
||||
$order_invoice->total_paid_tax_excl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
|
||||
$order_invoice->total_paid_tax_incl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
|
||||
|
||||
$order_invoice->total_paid_tax_excl += (float)$newTotalPriceTaxExcl;
|
||||
$order_invoice->total_paid_tax_incl += (float)$newTotalPriceTaxIncl;
|
||||
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl;
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl;
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $newTotalPriceTaxExcl;
|
||||
@@ -5137,14 +5137,21 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->save();
|
||||
|
||||
// Save order invoice
|
||||
if (isset($order_invoice)) {
|
||||
$order_invoice->total_products = $order_invoice->total_paid_tax_excl;
|
||||
$order_invoice->total_products_wt = $order_invoice->total_paid_tax_incl;
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
|
||||
if (is_array(Tools::getValue('product_quantity'))) {
|
||||
$view = $this->createTemplate('_customized_data.tpl')->fetch();
|
||||
} else {
|
||||
@@ -5524,8 +5531,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
// Update Order
|
||||
// values changes as values are calculated accoding to the quantity of the product by webkul
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal() - $roomExtraDemandTI, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false) - $roomExtraDemandTE, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
|
||||
$order->total_products -= ($diff_products_tax_excl + $additionlServicesTE);
|
||||
$order->total_products = $order->total_products > 0 ? $order->total_products : 0;
|
||||
@@ -5594,15 +5601,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objOrderCartRule->delete();
|
||||
}
|
||||
|
||||
// If no rooms left in the order, Update Order total and discounts to 0
|
||||
$order->total_discounts = 0;
|
||||
$order->total_discounts_tax_incl = 0;
|
||||
$order->total_discounts_tax_excl = 0;
|
||||
$order->total_paid = 0;
|
||||
$order->total_paid_tax_incl = 0;
|
||||
$order->total_paid_tax_excl = 0;
|
||||
$order->update();
|
||||
}
|
||||
// If no rooms left in the order, Update Order total and discounts to 0
|
||||
$order->total_discounts = 0;
|
||||
$order->total_discounts_tax_incl = 0;
|
||||
$order->total_discounts_tax_excl = 0;
|
||||
$order->total_paid = 0;
|
||||
$order->total_paid_tax_incl = 0;
|
||||
$order->total_paid_tax_excl = 0;
|
||||
$order->update();
|
||||
}
|
||||
|
||||
// Assign to smarty informations in order to show the new product line
|
||||
|
||||
@@ -204,7 +204,7 @@ class HotelBookingDemands extends ObjectModel
|
||||
}
|
||||
|
||||
// Rounding as per configurations
|
||||
$totalAmount += Tools::processPriceRounding($amount, $quantity);
|
||||
$totalAmount = Tools::processPriceRounding($amount, $quantity);
|
||||
|
||||
$values .= '('.(int)$this->id.','.(int)$idTax.','.(float)$amount.','.
|
||||
(float)$totalAmount.'),';
|
||||
|
||||
@@ -2231,6 +2231,10 @@ class HotelHelper
|
||||
$objProduct->price_calculation_method = $serviceProduct['price_calculation_method'];
|
||||
$objProduct->is_virtual = 1;
|
||||
$objProduct->indexed = 1;
|
||||
if ($objProduct->auto_add_to_cart && $objProduct->price_addition_type == Product::PRICE_ADDITION_TYPE_WITH_ROOM) {
|
||||
$objProduct->id_tax_rules_group = 0;
|
||||
}
|
||||
|
||||
$objProduct->save();
|
||||
$idProduct = $objProduct->id;
|
||||
|
||||
|
||||
@@ -239,6 +239,13 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
$totalPrice += $product['total_price_tax_excl'];
|
||||
}
|
||||
} else {
|
||||
$taxes = OrderDetailCore::getTaxListStatic($product['id_order_detail']);
|
||||
$tax_temp = array();
|
||||
foreach ($taxes as $tax) {
|
||||
$obj = new Tax($tax['id_tax']);
|
||||
$tax_temp[] = sprintf('%1$s%2$s%%', ($obj->rate + 0), ' ');
|
||||
}
|
||||
$product_tax_label = implode(', ', $tax_temp);
|
||||
if (isset($selectedAdditionalServices['additional_services'])) {
|
||||
$selectedAdditionalServices['total_price_tax_excl'] += $product['total_price_tax_excl'];
|
||||
$selectedAdditionalServices['total_price_tax_incl'] += $product['total_price_tax_incl'];
|
||||
@@ -257,6 +264,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
'unit_price_tax_incl' => $product['unit_price_tax_incl'],
|
||||
'total_price_tax_excl' => $product['total_price_tax_excl'],
|
||||
'total_price_tax_incl' => $product['total_price_tax_incl'],
|
||||
'product_tax_label' => $product_tax_label,
|
||||
);
|
||||
} else {
|
||||
$selectedAdditionalServices['id_order'] = $product['id_order'];
|
||||
@@ -282,6 +290,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
'unit_price_tax_incl' => $product['unit_price_tax_incl'],
|
||||
'total_price_tax_excl' => $product['total_price_tax_excl'],
|
||||
'total_price_tax_incl' => $product['total_price_tax_incl'],
|
||||
'product_tax_label' => $product_tax_label,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user