X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fdb%2Fvoiding_db.inc;h=7f3ddc21c432d69b22da0cd518bc8ab407cf5799;hb=523b8c69689f9ceb978b422b3e65a7eb9c089b6f;hp=5a6831359de6a81536aee88e09aa8646a1a33782;hpb=4fcb2ed2946898d413f18fe9e2be33d1b16b8749;p=fa-stable.git diff --git a/admin/db/voiding_db.inc b/admin/db/voiding_db.inc index 5a683135..7f3ddc21 100644 --- a/admin/db/voiding_db.inc +++ b/admin/db/voiding_db.inc @@ -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; @@ -43,15 +45,20 @@ function void_transaction($type, $type_no, $date_, $memo_) if (!check_void_bank_trans($type, $type_no)) return _('This transaction cannot be voided because the operation would decrease account balance below allowed limit in some point of account history.'); case ST_SALESINVOICE : // it's a customer invoice + if ($type == ST_SALESINVOICE && is_cust_invoice_credited($type_no)) + return _('This invoice cannot be voided because it was already credited.'); case ST_CUSTCREDIT : // it's a customer credit note case ST_CUSTDELIVERY : // it's a customer dispatch if (!exists_customer_trans($type, $type_no)) return _('Selected transaction does not exists.'); if ($type == ST_CUSTDELIVERY) // added 04 Oct 2008 by Joe Hunt. If delivery note has a not voided invoice, then NO. { - $childs = get_sales_child_lines($type, $type_no, false); // 2011-03-17 This had been changed. Joe - if ($childs && db_num_rows($childs)) - return _('This delivery cannot be voided because it was already invoiced.'); + $vers = get_customer_trans_version($type, $type_no); + if ($vers[$type_no] == 1) { + $childs = get_sales_child_lines($type, $type_no, false); // 2011-03-17 This had been changed. Joe + if ($childs && db_num_rows($childs)) + return _('This delivery cannot be voided because it was already invoiced.'); + } } post_void_customer_trans($type, $type_no); break; @@ -75,6 +82,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 @@ -93,12 +104,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;