Unable to void a sales invoice. Fixed by @BraaathWaate.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 14 Aug 2021 19:07:28 +0000 (21:07 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 14 Aug 2021 19:07:28 +0000 (21:07 +0200)
sales/includes/db/sales_invoice_db.inc
sales/includes/db/sales_order_db.inc

index b1cbfa3f8209fbc5cfde929b3a13274c7c18d447..cbafbccc9ef021064ace89e79f183888db6e85c6 100644 (file)
@@ -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_, "");
                        }
index dcf69e93ea7116aa81f830cc83853b1ee5d442d9..9d43fb3af94b8427c5cc9cb3d2da0f8e9ba81beb 100644 (file)
@@ -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();
 }