Merge branch 'develop' into gli-3060

This commit is contained in:
amit sharma
2026-08-07 19:02:26 +05:30
199 changed files with 15858 additions and 3797 deletions

View File

@@ -754,9 +754,8 @@ class CartCore extends ObjectModel
$totalPriceByProductTaxExcl += $roomTotalPrice['total_price_tax_excl'];
}
// Rounding as per configurations
$row['total'] = Tools::processPriceRounding($totalPriceByProductTaxExcl);
$row['total_wt'] = Tools::processPriceRounding($totalPriceByProductTaxIncl);
$row['total'] = $totalPriceByProductTaxExcl;
$row['total_wt'] = $totalPriceByProductTaxIncl;
}
} else {
$row['total'] = 0;
@@ -1768,10 +1767,11 @@ class CartCore extends ObjectModel
} else {
$priceAdd = $servicePorduct['unit_price_tax_excl'];
}
$lineTotal = Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
if ($ps_round_type == Order::ROUND_TOTAL) {
$products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd * (int)$servicePorduct['quantity'];
$products_total[$id_tax_rules_group.'_'.$id_address] += $lineTotal;
} else {
$products_total[$id_tax_rules_group] += $priceAdd * (int)$servicePorduct['quantity'];
$products_total[$id_tax_rules_group] += $lineTotal;
}
}
}

View File

@@ -229,12 +229,12 @@ abstract class PaymentModuleCore extends Module
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
$cart_total_paid = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), _PS_PRICE_COMPUTE_PRECISION_);
if ($this->context->cart->is_advance_payment) {
$cart_total_paid = (float)Tools::ps_round(
(float)$this->context->cart->getOrderTotal(true, CART::ADVANCE_PAYMENT),
2
_PS_PRICE_COMPUTE_PRECISION_
);
}
@@ -314,7 +314,7 @@ abstract class PaymentModuleCore extends Module
$order->gift_message = $this->context->cart->gift_message;
$order->mobile_theme = $this->context->cart->mobile_theme;
$order->conversion_rate = $this->context->currency->conversion_rate;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, 2) : $amount_paid;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, _PS_PRICE_COMPUTE_PRECISION_) : $amount_paid;
$order->total_paid_real = 0;
$order->total_products = (float)$this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
@@ -389,7 +389,7 @@ abstract class PaymentModuleCore extends Module
(float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier),
_PS_PRICE_COMPUTE_PRECISION_
);
if ($orderTotal = $this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)) {
if ($orderTotal = Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_)) {
$order->amount_paid = (float)Tools::ps_round(
(($order->advance_paid_amount * $amount_paid) / $orderTotal),
_PS_PRICE_COMPUTE_PRECISION_
@@ -677,7 +677,7 @@ abstract class PaymentModuleCore extends Module
$orderTotals[$order->id]['excl'] -= $used['excl'];
$cart_rules[$key]['remaining'] -= $used['excl'];
}
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
@@ -850,7 +850,8 @@ abstract class PaymentModuleCore extends Module
$objCartBookingData->id_cart,
$objCartBookingData->id_guest,
$objCartBookingData->id_room,
0
0,
1
);
$objBookingDetail->date_from = $objCartBookingData->date_from;
@@ -941,8 +942,8 @@ abstract class PaymentModuleCore extends Module
);
}
$objBookingDemand->total_price_tax_excl = Tools::processPriceRounding(($objBookingDemand->unit_price_tax_excl * $numDays));
$objBookingDemand->total_price_tax_incl = Tools::processPriceRounding(($objBookingDemand->unit_price_tax_incl * $numDays));
$objBookingDemand->total_price_tax_excl = $objBookingDemand->unit_price_tax_excl * $numDays;
$objBookingDemand->total_price_tax_incl = $objBookingDemand->unit_price_tax_incl * $numDays;
$objBookingDemand->price_calc_method = $objGlobalDemand->price_calc_method;
$objBookingDemand->id_tax_rules_group = $objGlobalDemand->id_tax_rules_group;
@@ -2042,6 +2043,7 @@ abstract class PaymentModuleCore extends Module
// calculate averages now
foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
$value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
}
}
}

View File

@@ -227,8 +227,20 @@ class RequestSqlCore extends ObjectModel
if (in_array($attr['expr_type'], array('operator', 'const'))) {
continue;
}
if ($attribut = $this->cutAttribute($attr['base_expr'], $from)) {
$tab[] = $attribut;
if (!empty($attr['sub_tree'])) {
foreach ($attr['sub_tree'] as $tree_item) {
if ($tree_item['expr_type'] !== 'colref') {
continue;
}
if ($attribut = $this->cutAttribute($tree_item['base_expr'], $from)) {
$tab[] = $attribut;
}
}
} else {
if ($attribut = $this->cutAttribute($attr['base_expr'], $from)) {
$tab[] = $attribut;
}
}
}
@@ -279,16 +291,25 @@ class RequestSqlCore extends ObjectModel
{
if ($alias) {
foreach ($tables as $table) {
if (isset($table['alias']) && isset($table['table']) && $table['alias']['no_quotes'] == $alias) {
return array($table['table']);
if (!isset($table['alias'])) {
continue;
}
$table_alias = $table['alias']['no_quotes'];
if ($table_alias != $alias && !(is_array($table_alias) && $table_alias['parts'][0] == $alias)) {
continue;
}
if (!isset($table['table'])) {
// derived table (subquery) - no real table name to verify columns against
return array(false);
}
return array($table['table']);
}
} elseif (count($tables) > 1) {
if ($attr !== null) {
$tab = array();
foreach ($tables as $table) {
if ($this->attributExistInTable($attr, $table['table'])) {
$tab = $table['table'];
$tab[] = $table['table'];
}
}
if (count($tab) == 1) {
@@ -322,6 +343,10 @@ class RequestSqlCore extends ObjectModel
if (is_array($table) && (count($table) == 1)) {
$table = $table[0];
}
if (!$table) {
// derived table (subquery) - no real table to verify against, assume valid
return true;
}
$attributs = $this->getAttributesByTable($table);
foreach ($attributs as $attribut) {
if ($attribut['Field'] == trim($attr, ' `')) {
@@ -382,22 +407,14 @@ class RequestSqlCore extends ObjectModel
return false;
}
if ($table['ref_type'] == 'ON' && (trim($table['join_type']) == 'LEFT' || trim($table['join_type']) == 'JOIN')) {
if ($attrs = $this->cutJoin($table['ref_clause'], $from)) {
foreach ($attrs as $attr) {
if (!$this->attributExistInTable($attr['attribut'], $attr['table'])) {
$this->error_sql['checkedFrom']['attribut'] = array($attr['attribut'], implode(', ', $attr['table']));
return false;
}
}
} else {
if (isset($this->error_sql['returnNameTable'])) {
$this->error_sql['checkedFrom'] = $this->error_sql['returnNameTable'];
return false;
} else {
$this->error_sql['checkedFrom'] = false;
$attrs = $this->cutJoin($table['ref_clause'], $from);
foreach ($attrs as $attr) {
if (!$this->attributExistInTable($attr['attribut'], $attr['table'])) {
$this->error_sql['checkedFrom']['attribut'] = array($attr['attribut'], implode(', ', $attr['table']));
return false;
}
}
// derived-table joins (subquery as table) can't be resolved by cutJoin; nothing to check, not an error
}
}
return true;
@@ -416,7 +433,7 @@ class RequestSqlCore extends ObjectModel
$nb = count($select);
for ($i = 0; $i < $nb; $i++) {
$attribut = $select[$i];
if ($attribut['base_expr'] != '*' && !preg_match('/\.$/', $attribut['base_expr'])) {
if ($attribut['base_expr'] != '*' && !preg_match('/\.\*$/', $attribut['base_expr'])) {
if ($attribut['expr_type'] == 'colref') {
if ($attr = $this->cutAttribute(trim($attribut['base_expr']), $from)) {
if (!$this->attributExistInTable($attr['attribut'], $attr['table'])) {
@@ -433,6 +450,14 @@ class RequestSqlCore extends ObjectModel
}
}
}
while (is_array($attribut['sub_tree']) && isset($attribut['sub_tree'][0])) {
if ($attribut['expr_type'] === 'function' && in_array(strtoupper($attribut['base_expr']), $this->tested['unauthorized'])) {
$this->error_sql['checkedSelect']['function'] = $attribut['base_expr'];
return false;
}
$attribut = $attribut['sub_tree'][0];
}
} elseif ($in) {
$this->error_sql['checkedSelect']['*'] = false;
return false;
@@ -454,7 +479,7 @@ class RequestSqlCore extends ObjectModel
$nb = count($where);
for ($i = 0; $i < $nb; $i++) {
$attribut = $where[$i];
if ($attribut['expr_type'] == 'colref' || $attribut['expr_type'] == 'reserved') {
if ($attribut['expr_type'] == 'colref') {
if ($attr = $this->cutAttribute(trim($attribut['base_expr']), $from)) {
if (!$this->attributExistInTable($attr['attribut'], $attr['table'])) {
$this->error_sql['checkedWhere']['attribut'] = array($attr['attribut'], implode(', ', $attr['table']));
@@ -469,6 +494,11 @@ class RequestSqlCore extends ObjectModel
return false;
}
}
} elseif ($attribut['expr_type'] == 'reserved') {
if ($attribut['base_expr'] !== 'EXISTS' || !isset($where[$i + 1]) || $where[$i + 1]['expr_type'] !== 'subquery') {
$this->error_sql['checkedWhere'] = isset($this->error_sql['returnNameTable']) ? $this->error_sql['returnNameTable'] : false;
return false;
}
} elseif ($attribut['expr_type'] == 'operator') {
if (!in_array(strtoupper($attribut['base_expr']), $this->tested['operator'])) {
$this->error_sql['checkedWhere']['operator'] = array($attribut['base_expr']);
@@ -531,7 +561,7 @@ class RequestSqlCore extends ObjectModel
public function checkedOrder($order, $from)
{
$order = $order[0];
if ($order['type'] == 'expression') {
if ($order['expr_type'] == 'colref') {
if ($attr = $this->cutAttribute(trim($order['base_expr']), $from)) {
if (!$this->attributExistInTable($attr['attribut'], $attr['table'])) {
$this->error_sql['checkedOrder']['attribut'] = array($attr['attribut'], implode(', ', $attr['table']));
@@ -560,7 +590,7 @@ class RequestSqlCore extends ObjectModel
public function checkedGroupBy($group, $from)
{
$group = $group[0];
if ($group['type'] == 'expression') {
if ($group['expr_type'] == 'colref') {
if ($attr = $this->cutAttribute(trim($group['base_expr']), $from)) {
if (!$this->attributExistInTable($attr['attribut'], $attr['table'])) {
$this->error_sql['checkedGroupBy']['attribut'] = array($attr['attribut'], implode(', ', $attr['table']));
@@ -587,7 +617,7 @@ class RequestSqlCore extends ObjectModel
*/
public function checkedLimit($limit)
{
if (!preg_match('#^[0-9]+$#', trim($limit['start'])) || !preg_match('#^[0-9]+$#', trim($limit['end']))) {
if (!preg_match('#^[0-9]+$#', trim($limit['offset'])) || !preg_match('#^[0-9]+$#', trim($limit['rowcount']))) {
$this->error_sql['checkedLimit'] = false;
return false;
}

View File

@@ -2677,7 +2677,7 @@ class OrderCore extends ObjectModel
'unit_tax_base' => $autoAddedPriceExcl / $totalAutoAddedQty,
'total_tax_base' => $autoAddedPriceExcl,
'unit_amount' => $amount,
'total_amount' => Tools::processPriceRounding($amount, $totalAutoAddedQty),
'total_amount' => Tools::processPriceRounding($amount, $totalAutoAddedQty, $this->round_type, $this->round_mode),
);
}
} else {
@@ -2724,7 +2724,7 @@ class OrderCore extends ObjectModel
foreach ($tax_calculator->getTaxesAmount($unit_price_tax_excl) as $id_tax => $unit_amount) {
$total_tax_base = 0;
$total_amount = Tools::processPriceRounding($unit_amount, $quantity);
$total_amount = Tools::processPriceRounding($unit_amount, $quantity, $this->round_type, $this->round_mode);
if (!isset($groupedTaxDetails[$id_tax])) {
$groupedTaxDetails[$id_tax] = array(