The code fix:
--- a/core/sales/includes/db/sales_invoice_db.inc
+++ b/core/sales/includes/db/sales_invoice_db.inc
@@ -249,8 +249,9 @@ function void_sales_invoice($type, $type_no)
if ($deliveries !== 0) {
if ($type == ST_SALESINVOICE && count($deliveries) == 1 && get_reference(ST_CUSTDELIVERY, $deliveries[0]) == "auto")
{
+ $trans = get_customer_trans($deliveries[0], ST_CUSTDELIVERY);
void_sales_delivery(ST_CUSTDELIVERY, $deliveries[0], false);
- $date_ = Today();
+ $date_ = sql2date($trans['tran_date']);
add_audit_trail(ST_CUSTDELIVERY, $deliveries[0], $date_, _("Voided."));
add_voided_entry(ST_CUSTDELIVERY, $deliveries[0], $date_, "");
}
diff --git a/core/sales/includes/db/sales_order_db.inc b/core/sales/includes/db/sales_order_db.inc
index 17952e3..4b4734d 100644
--- a/core/sales/includes/db/sales_order_db.inc
+++ b/core/sales/includes/db/sales_order_db.inc
@@ -89,6 +89,8 @@ function delete_sales_order($order_no, $trans_type)
begin_transaction();
hook_db_prevoid($trans_type, $order_no);
+ $order = get_sales_order_header($order_no, $trans_type);
+
$sql = "DELETE FROM ".TB_PREF."sales_orders WHERE order_no=" . db_escape($order_no)
. " AND trans_type=".db_escape($trans_type);
@@ -98,7 +100,7 @@ function delete_sales_order($order_no, $trans_type)
.db_escape($order_no) . " AND trans_type=".db_escape($trans_type);
db_query($sql, "order Detail Delete");
- add_audit_trail($trans_type, $order_no, Today(), _("Deleted."));
+ add_audit_trail($trans_type, $order_no, sql2date($order['ord_date']), _("Deleted."));
commit_transaction();