From: Janusz Dobrowolski Date: Thu, 19 Mar 2015 10:05:37 +0000 (+0100) Subject: Sales invoice voiding is blocked when sales credit was issued against the invoice. X-Git-Tag: v2.4.2~19^2~238 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=3974cfebf97c03e07b0beb608ae63b84b1e0f908 Sales invoice voiding is blocked when sales credit was issued against the invoice. --- diff --git a/admin/db/voiding_db.inc b/admin/db/voiding_db.inc index 5a683135..70878ad4 100644 --- a/admin/db/voiding_db.inc +++ b/admin/db/voiding_db.inc @@ -43,6 +43,8 @@ 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 (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)) diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index f1ead0c6..73338a41 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -277,6 +277,11 @@ function void_sales_invoice($type, $type_no) commit_transaction(); } +function is_cust_invoice_credited($trans_no) +{ + return db_num_rows(get_sales_child_lines(ST_SALESINVOICE, $trans_no)); +} + function get_cust_prepayment_invoice_factor($trans_no) { $sql = "SELECT IF(dt.prep_amount>0, dt.prep_amount/so.total ,0)