I'm building a custom report on the basis of database.
I need to know how to get 'Grand Total' that is in 'sales/order' (in other words sales_flat_order
) table by order items (from 'sales/order_item', sales_flat_order_item
table).
I need a formula to get this value using the database and not using Magento methods.
I am building MySQL query
Am I right when I say that
base_grand_total = (IFNULL(base_total_canceled,0)) + (IFNULL(base_hidden_tax_amount,0) - IFNULL(base_hidden_tax_refunded,0)) + IFNULL(base_total_offline_refunded,0) + IFNULL(base_total_online_refunded,0) + ( IFNULL(base_subtotal,0) - IFNULL(base_subtotal_canceled,0) - IFNULL(base_subtotal_refunded,0)) + (IFNULL(base_tax_amount,0) - IFNULL(base_tax_canceled,0) - IFNULL(base_tax_refunded,0)) + (IFNULL(base_shipping_amount,0) - IFNULL(base_shipping_canceled,0) - IFNULL(base_shipping_refunded,0)) + (IFNULL(base_discount_amount,0) - IFNULL(base_discount_canceled,0) - IFNULL(base_discount_refunded,0)) ?
Best Answer
You can pass the order_entity_id and get the grand total value