Changed so deleting of fiscal year also handles sales quotations
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 11 Sep 2009 15:06:02 +0000 (15:06 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 11 Sep 2009 15:06:02 +0000 (15:06 +0000)
CHANGELOG.txt
admin/fiscalyears.php

index b8ff716aec485b9c97306b87271877b6cc753cd4..0796ea3ef3e79a141d8b74b680063b79d0b47629 100644 (file)
@@ -19,7 +19,11 @@ Legend:
 ! -> Note
 $ -> Affected files
 
-10-Swp-2009 Joe Hunt
+11-Sep-2009 Joe Hunt
+! Changed so deleting of fiscal year also handles sales quotations
+$ /admin/fiscalyears.php
+
+10-Sep-2009 Joe Hunt
 ! By changing a simple sentence in allocation_cart.inc, the customer/supplier payments works with prompt payment discounts
 $ /includes/ui/allocation_cart.inc
 # Small typo error in types.inc
index a0cb0ced0ca90fa159b09b8cc59fb6c6a9681074..5e9e6d864b3654e1dccf009fe5e820dbbf65e39b 100644 (file)
@@ -204,20 +204,20 @@ function delete_this_fiscalyear($selected_id)
        $ref = _("Open Balance");
        $myrow = get_fiscalyear($selected_id);
        $to = $myrow['end'];
-       $sql = "SELECT order_no FROM ".TB_PREF."sales_orders WHERE ord_date <= '$to' AND type <> 1"; // don't take the templates
+       $sql = "SELECT order_no, trans_type FROM ".TB_PREF."sales_orders WHERE ord_date <= '$to' AND type <> 1"; // don't take the templates
        $result = db_query($sql, "Could not retrieve sales orders");
        while ($row = db_fetch($result))
        {
-               $sql = "SELECT SUM(qty_sent), SUM(quantity) FROM ".TB_PREF."sales_order_details WHERE order_no = {$row['order_no']}";
+               $sql = "SELECT SUM(qty_sent), SUM(quantity) FROM ".TB_PREF."sales_order_details WHERE order_no = {$row['order_no']} AND trans_type = {$row['trans_type']}";
                $res = db_query($sql, "Could not retrieve sales order details");
                $row2 = db_fetch_row($res);
                if ($row2[0] == $row2[1])
                {
-                       $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no = {$row['order_no']}";
+                       $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no = {$row['order_no']} AND trans_type = {$row['trans_type']}";
                        db_query($sql, "Could not delete sales order details");
-                       $sql = "DELETE FROM ".TB_PREF."sales_orders WHERE order_no = {$row['order_no']}";
+                       $sql = "DELETE FROM ".TB_PREF."sales_orders WHERE order_no = {$row['order_no']} AND trans_type = {$row['trans_type']}";
                        db_query($sql, "Could not delete sales order");
-                       delete_attachments_and_comments(systypes::sales_order(), $row['order_no']);
+                       delete_attachments_and_comments($row['trans_type'], $row['order_no']);
                }
        }
        $sql = "SELECT order_no FROM ".TB_PREF."purch_orders WHERE ord_date <= '$to'";