From: Janusz Dobrowolski Date: Fri, 18 Jan 2013 10:49:48 +0000 (+0100) Subject: Fixes in sales credit note voiding procedures (invalid changes in delivery notes). X-Git-Tag: 2.3-final~339 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=f1d9197ac11b9b063941ec7f0c4071607fa81519;p=fa-stable.git Fixes in sales credit note voiding procedures (invalid changes in delivery notes). --- diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index 89664909..7260f0e1 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -286,7 +286,7 @@ function credit_sales_invoice_allocate($invoice_no, $credit_no, $amount, $date) $free += $unalloc; } } - if ($free < $amount) { + if (floatcmp($free, $amount)<0) { // this should never happen unless sparse credit notices were allocated to // the invoice, or summarized freight costs on credit notes is more than those on invoice. display_error(_("Unsuspected overallocation happened due to sparse credit notes exists for this invoice. diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index d710e4ec..a1f6dd5c 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -196,19 +196,18 @@ function void_sales_invoice($type, $type_no) // reverse all the changes in parent document(s) - $deliveries = get_sales_parent_numbers($type, $type_no); + $parents = get_sales_parent_numbers($type, $type_no); - if ($deliveries !== 0) { - if (count($deliveries) == 1 && get_reference(ST_CUSTDELIVERY, $deliveries[0]) == "auto") + if ($parents !== 0) { + if ($type == ST_SALESINVOICE && count($parents) == 1 && get_reference(ST_CUSTDELIVERY, $parents[0]) == "auto") { - void_sales_delivery(ST_CUSTDELIVERY, $deliveries[0], false); + void_sales_delivery(ST_CUSTDELIVERY, $parents[0], false); $date_ = Today(); - add_audit_trail(ST_CUSTDELIVERY, $deliveries[0], $date_, _("Voided.")); - add_voided_entry(ST_CUSTDELIVERY, $deliveries[0], $date_, ""); + add_audit_trail(ST_CUSTDELIVERY, $parents[0], $date_, _("Voided.")); + add_voided_entry(ST_CUSTDELIVERY, $parents[0], $date_, ""); } else { - $srcdetails = get_sales_parent_lines($type, $type_no); while ($row = db_fetch($srcdetails)) { update_parent_line($type, $row['id'], -$row['quantity']); @@ -218,6 +217,8 @@ function void_sales_invoice($type, $type_no) // clear details after they've been reversed in the sales order void_customer_trans_details($type, $type_no); + void_stock_move($type, $type_no); // in case of credit note with return + void_trans_tax_details($type, $type_no); void_cust_allocations($type, $type_no);