I'm not following you exactly but I think you are saying that your totals don't match correctly. If so you have the same problem I had. I ended up changing the table orders over to the table orders_total to pul the report. This made everything line up perfectly. The issue I saw was that this report recalculated every order. I have a bunch of attributes on every order and was off several dollars every day. By switching this to pull data from the other table instead of recalculating every order I eliminated this variance. It's been quite a while since I did this with help of others so I'm not 100% certain where we modified the original report. After it was correct I heavily modified it to give me a more detailed report for my specific needs. Orders_total is the table that the customer emailed receipt is saved to. So the data in that table is exactly what the customer pays from.
I think this is what you may need from the admin/includes/classes/sales_report.php
PHP Code:
// pull shipping, discounts, tax, and gift certificates used from orders_total table
$totals = $db->Execute("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $oID . "'");
while (!$totals->EOF) {
$class = $totals->fields['class'];
$value = $totals->fields['value'];
if ($class != "ot_total1" && $class != "ot_subtotal1") {
if($class == "ot_gv") {
$order_gc_used += $value;
$this->timeframe[$id]['total']['gc_used'] += $value;
$this->build_li_orders($oID, 'gc_used', $value);
$this->timeframe[$id]['total']['gc_used_qty']++;
$this->build_li_orders($oID, 'gc_used_qty', 1);
}
elseif ($class == "ot_coupon" || $class == "ot_group_pricing" || $class == "ot_better_together" || $class == "ot_reward_points" || $class == "ot_quantity_discount" || $class == "ot_gv") {
$order_discount += $value;
$this->timeframe[$id]['total']['discount'] += $value;
$this->build_li_orders($oID, 'discount', $value);
$this->timeframe[$id]['total']['discount_qty']++;
$this->build_li_orders($oID, 'discount_qty', 1);
}
elseif ($class == "ot_tip") {
$order_discount += $value;
$this->timeframe[$id]['total']['ot_tip'] += $value;
$this->build_li_orders($oID, 'ot_tip', $value);
$this->timeframe[$id]['total']['tip_qty']++;
$this->build_li_orders($oID, 'tip_qty', 1);
}
elseif ($class == "ot_cashback") {
$order_discount += $value;
$this->timeframe[$id]['total']['discount'] += $value;
$this->build_li_orders($oID, 'discount', $value);
$this->timeframe[$id]['total']['discount_qty']++;
$this->build_li_orders($oID, 'discount_qty', 1);
}
elseif ($class == "ot_tax") {
$order_recorded_tax += $value;
$this->timeframe[$id]['total']['order_recorded_tax'] += $value;
$this->build_li_orders($oID, 'order_recorded_tax', $value);
}
elseif ($class == "ot_shipping") {
$order_shipping += $value;
$this->timeframe[$id]['total']['shipping'] += $value;
$this->build_li_orders($oID, 'shipping', $value);
}
elseif ($class == "ot_subtotal") {
$order_shipping += $value;
$this->timeframe[$id]['total']['subtotal'] += $value;
$this->build_li_orders($oID, 'subtotal', $value);
}
elseif ($class == "ot_total") {
$order_shipping += $value;
$this->timeframe[$id]['total']['totalsales'] += $value;
$this->build_li_orders($oID, 'totalsales', $value);
}
// this allows for a custom discount, a la Super Orders
elseif ($value < 0) {
$order_discount += abs($value);
$this->timeframe[$id]['total']['discount'] += abs($value);
$this->build_li_orders($oID, 'discount', abs($value) );
$this->timeframe[$id]['total']['discount_qty']++;
$this->build_li_orders($oID, 'discount_qty', 1);
}
}
$totals->MoveNext();
}
Bookmarks