From 5ea4d80a91017eadba9db43a0f26242c57bc4c9e Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 16 Jan 2014 19:34:20 +0100 Subject: [PATCH] 0002615: voiding an allocated currency invoice doesn't clear FX account --- purchasing/includes/db/suppalloc_db.inc | 7 +++++-- sales/includes/db/custalloc_db.inc | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/purchasing/includes/db/suppalloc_db.inc b/purchasing/includes/db/suppalloc_db.inc index f13d2e4e..7a43b56f 100644 --- a/purchasing/includes/db/suppalloc_db.inc +++ b/purchasing/includes/db/suppalloc_db.inc @@ -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); ////////////////////// } diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index b7c46073..3010931d 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -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); ////////////////////// } -- 2.30.2