I had the same probleme too but I 'don't use promotion module to manage promotions,
my config :
product price entered without VAT (I didn't find where you manage prices are displayed with or without VAT )
I using also commerce_tax_product
one field_discount added to an order item type
I directly add promotions in module like this
$promotion = $order_item->get('field_promotion')->value;
if($promotion > 0){
// Calculate promotion
$unit_price = $order_item->getUnitPrice();
$discount_amount = $unit_price->multiply($order_item->getQuantity())->multiply('-' . strval( $promotion/100));
$adjustment = new Adjustment([
'type' => 'promotion',
'label' => t('Discount'),
'amount' => $discount_amount,
'percentage' => strval($discount/100),
'source_id' => 'custom_discount',
'locked' => TRUE,
]);
$order_item->addAdjustment($adjustment);
}
So I separated the patch to only be applied to tax module and calculations of price a ok
my price without VAT is 50 €
I steel have the same probleme on drupal 10.3 with a view_simple_math_field..
Sum was calculated exactly like the picture...
For me, it's because $field_handler->view->style_plugin->getCell(..) in views_aggregator_get_cell return also the preffix and suffix of the field but vap_num() need only the value !
So I changed views_aggregator_get_cell like this
function views_aggregator_get_cell(FieldHandlerInterface $field_handler, int $row_num, bool $rendered = FALSE): string {
if(!$rendered){
if (isset($field_handler->view->result[$row_num])) {
$row = $field_handler->view->result[$row_num];
return $field_handler->getValue($row);
}
}
if (isset($field_handler->view->style_plugin)) {
return $field_handler->view->style_plugin->getCell($field_handler, $row_num, $rendered);
}
return '';
}
And know my sum is good !
johaziel → created an issue.
Hi, I got the same error with ECK !
To reproduce this issue :
- Install eck
- Create new entity type (leave disable "author field"), create a bundle and add fields
- Try to add content admin/content/your_entity/add/your_bundle
the error appear
Edit your entity type admin/structure/eck/your_entity
and enable "author field" and the error disappear.
Regards