0002615: voiding an allocated currency invoice doesn't clear FX account
authorJoe <unknown>
Thu, 16 Jan 2014 18:34:20 +0000 (19:34 +0100)
committerJoe <unknown>
Thu, 16 Jan 2014 18:34:20 +0000 (19:34 +0100)
purchasing/includes/db/suppalloc_db.inc
sales/includes/db/custalloc_db.inc

index f13d2e4e17f0f46c78b5cd39423c2369aac2f1de..7a43b56fcbad560a30a0b7104dc26b84b820cb68 100644 (file)
@@ -91,13 +91,16 @@ function clear_supp_alloctions($type, $type_no, $date="")
                $sql = "UPDATE ".TB_PREF."supp_trans SET alloc=alloc - " . $row['amt'] . "
                        WHERE (type= " . $row['trans_type_from'] . " AND trans_no=" . $row['trans_no_from'] . ")
                        OR (type=" . $row['trans_type_to'] . " AND trans_no=" . $row['trans_no_to'] . ")";
-               //$sql = "UPDATE ".TB_PREF."supp_trans SET alloc=alloc - " . $row['amt'] . "
-               //      WHERE type=" . $row['trans_type_to'] . " AND trans_no=" . $row['trans_no_to'];
                db_query($sql, "could not clear allocation");
+
                // 2008-09-20 Joe Hunt
                if ($date != "")
                        exchange_variation($type, $type_no, $row['trans_type_to'], $row['trans_no_to'], $date,
                                $row['amt'], PT_SUPPLIER, true);
+               // 2014-01-16 Joe Hunt. Fix for voiding allocated currency supp_invoices.               
+               elseif ($type == ST_SUPPINVOICE && $row['trans_type_to'] == $type && $row['trans_no_to'] == $type_no)           
+                       exchange_variation($row['trans_type_from'], $row['trans_no_from'], $row['trans_type_to'], $row['trans_no_to'], 
+                               sql2date($row['date_alloc']), $row['amt'], PT_SUPPLIER, true);
                //////////////////////
        }
 
index b7c4607383ce421335ef3d33b32631b1dc7c9c46..3010931d59ead0b720cae0fc00f605b2b4084362 100644 (file)
@@ -75,6 +75,10 @@ function clear_cust_alloctions($type, $type_no, $date="")
                if ($date != "")
                        exchange_variation($type, $type_no, $row['trans_type_to'], $row['trans_no_to'], $date,
                                $row['amt'], PT_CUSTOMER, true);
+               // 2014-01-16 Joe Hunt. Fix for voiding allocated currency sales_invoices.              
+               elseif ($type == ST_SALESINVOICE && $row['trans_type_to'] == $type && $row['trans_no_to'] == $type_no)          
+                       exchange_variation($row['trans_type_from'], $row['trans_no_from'], $row['trans_type_to'], $row['trans_no_to'], 
+                               sql2date($row['date_alloc']), $row['amt'], PT_SUPPLIER, true);
                //////////////////////
        }