newtech Posted January 4, 2007 Share Posted January 4, 2007 This contrib summarizes the subtotals of cash and various credit card orders. When I have orders that have a discount, the totals this contrib generates are totally off. It grabs the discount amount (10% figure) for the subtotal of an order, instead of the actual subtotal. The problem should not be with the ot discount contrib because when I run my customers totals report everything is ok. Anyone know what I need to change in the code so it grabs actual subtotal (actually I want it to summarize the Grand Total instead of subtotals). Here is the code from the stats_bath_report.php that I believe that needs to be edited. //begin query $batch_query_raw ="select ot.value, ot.title, ot.class, o.date_purchased, o.orders_id, o.cc_type, o.cc_number, o.payment_method from ". TABLE_ORDERS . " o , " . TABLE_ORDERS_TOTAL . " ot where o.orders_id = ot.orders_id AND o.date_purchased between '" . $date1 . "' AND '" .$date2 ."'"; $batch_query = tep_db_query($batch_query_raw); $total_accumulator = 0.00; $card1_accumulator = 0.00; $card2_accumulator = 0.00; $card3_accumulator = 0.00; $card4_accumulator = 0.00; $card5_accumulator = 0.00; $non_cc_accumulator = 0.00; // $loop=0; while ($orders = tep_db_fetch_array($batch_query)){ if ($orders['class']=='ot_total'){ $total_accumulator += round($orders['value'],2) ; $loop +=1; if ($orders['payment_method']=='Credit Card'){ switch($orders[cc_type]){ case dbCARD1: $card1_accumulator += round($orders['value'],2) ; break; case dbCARD2: $card2_accumulator += round($orders['value'],2); break; case dbCARD3: $card3_accumulator += round($orders['value'],2); break; case dbCARD4: $card4_accumulator += round($orders['value'],2); break; default: $card5_accumulator += round($orders['value'],2) ; } } else { $non_cc_accumulator += round($orders['value'],2); } This takes the above order totals and combines them into a summary. Don't think you need this code, but included it anyways. <table > <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom"><?php echo CARD1 ?></td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($card1_accumulator,2)); ?></td></tr> <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom"><?php echo CARD2 ?></td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($card2_accumulator,2)); ?></td></tr> <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom"><?php echo CARD3 ?></td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($card3_accumulator,2)); ?></td></tr> <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom"><?php echo CARD4 ?></td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($card4_accumulator,2)); ?></td></tr> <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom"><?php echo CARD5 ?></td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($card5_accumulator,2)); ?></td></tr> <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom"><?php echo NOTCARD ?></td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($non_cc_accumulator,2)); ?></td></tr> <tr class="dataTableHeadingRow" ><td class="dataTableHeadingContent" width='70' align='right' valign="bottom">TOTAL</td><td class="dataTableContent" width='100' align='right'><?php echo ("$" . number_format($total_accumulator,2)); ?></td></tr> Quote Link to comment Share on other sites More sharing options...
newtech Posted January 4, 2007 Author Share Posted January 4, 2007 This contrib summarizes the subtotals of cash and various credit card orders. When I have orders that have a discount, the totals this contrib generates are totally off. It grabs the discount amount (10% figure) for the subtotal of an order, instead of the actual subtotal. The problem should not be with the ot discount contrib because when I run my customers totals report everything is ok. Anyone know what I need to change in the code so it grabs actual subtotal (actually I want it to summarize the Grand Total instead of subtotals). Here is the code from the stats_bath_report.php that I believe that needs to be edited. Note this is Contribution: http://www.oscommerce.com/community/contri...rch,stats+batch Here is an example from my credit card batch report Order ID Purchase Date Order SubTotal Credit Card Used Action 47 2007 -01-04 16:06:00 $-2.20 - - - - 46 2007-01-04 15:30:04 $10.00 - - - - 45 2007-01-04 1 3:24:15 $1.00 - - - - 44 2007-01-04 13:20:38 $13.99 - - - - It is actually more messed up than I thought. Order #47 was $10.99 with a discount of $2.20, so its subtotal should have been $8.79. The report says it is $-2.20. It obviously is taking the discount figure as the subtotal. (Note this order had a shipping charge which comes after the subtotal) Order #46 is accurate for the subtotal-no coupon code used for this order. (It had shipping which comes after the subtotal) Order #45 was $13.99 and had a discount of $2.80, so it should have been $11.19. But what it is showing is the SALES TAX amount. (Note this order had free shipping) So here is a recap from what I can tell. 1. Orders that have discounts are handled differently based upon if shipping fee is involved or not. If there is a shipping fee the report shows the discount fee. If no shipping is involved, the report shows sales tax. 2. If there is no coupon code the credit card batch report shows the correct figures. So, home how there is a problem when coupon code is used. Quote Link to comment Share on other sites More sharing options...
newtech Posted January 5, 2007 Author Share Posted January 5, 2007 So here is a recap from what I can tell. 1. Orders that have discounts are handled differently based upon if shipping fee is involved or not. If there is a shipping fee the report shows the discount fee. If no shipping is involved, the report shows sales tax. 2. If there is no coupon code the credit card batch report shows the correct figures. After more testing here is what I have come up with. The stats_batch_report.php file does the totals properly including orders with discounts. The cc_card_report.php does not work properly. But here is a problem with it. The Start and End date feature is not working properly (or how I would think it should work). If you want the totals for today's date (the same day that the sales took place) , the Start date must be today and the End date must be tomorrow. i.e. Todays date is 1/4/07 so enter 1/4/07 start 1/5/07 end If you have the Start and End date the same, it will not show any totals. i.e. Todays date is 1/4/07 so enter 1/4/07 start 1/4/07 end no totals shown Not sure what happens if you run the report a few days later. i.e. if it is 1/5/07 and you want 1/4/07 totals. If you put 1/4/07 start and 1/5/07 end, will you get the sales of 1/5/07 also? I assume not. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.