Bug 4817: g/l account inquiry can timeout due to slow sql. @Braath Waate.
[fa-stable.git] / admin / db / voiding_db.inc
index 70878ad40281d98b79446826d8e782165411e678..55ff9fb9079a587c4c9205248581fb34ad2b6d65 100644 (file)
@@ -26,6 +26,8 @@ function void_transaction($type, $type_no, $date_, $memo_)
                case ST_JOURNAL : // it's a journal entry
                        if (!exists_gl_trans($type, $type_no))
                                return _('Selected transaction does not exists.');
+                       if ($wo = check_wo_costing($type, $type_no))
+                               return sprintf(_('This transaction cannot be voided because it is part of Work Order %s costs.'), $wo);
                        void_journal_trans($type, $type_no);
                        break;
 
@@ -77,6 +79,10 @@ function void_transaction($type, $type_no, $date_, $memo_)
                case ST_SUPPRECEIVE : // it's a GRN
                        if (exists_grn_on_invoices($type_no))
                                return _('This GRN cannot be voided because it was already invoiced.');
+                       if (!post_void_supp_trans($type, $type_no))
+                               return _('Error encountered when voiding transaction.');
+                       break;
+
                case ST_SUPPINVOICE : // it's a suppler invoice
                case ST_SUPPCREDIT : // it's a supplier credit note
                case ST_SUPPAYMENT : // it's a supplier payment
@@ -95,12 +101,16 @@ function void_transaction($type, $type_no, $date_, $memo_)
                case ST_MANUISSUE : // it's a work order issue
                        if (!exists_work_order_issue($type_no))
                                return _('Selected transaction does not exists.');
+                       if ($wo = check_void_wo_issue($type_no))
+                               return sprintf(_('Selected document cannot be voided because related Work Order %s is already closed.'), $wo);
                        void_work_order_issue($type_no);
                        break;
 
                case ST_MANURECEIVE : // it's a work order production
                        if (!exists_work_order_produce($type_no))
                                return _('Selected transaction does not exists.');
+                       if ($wo = check_void_wo_production($type_no))
+                               return sprintf(_('Selected document cannot be voided because related Work Order %s is already closed.'), $wo);
                        void_work_order_produce($type_no);
                        break;