X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fdb%2Fsales_invoice_db.inc;h=cd80b2cf939830a4d441f1cbb3711ddabf89d62d;hb=87e4961d8cb13efab395b6a5548164d6a748bf3d;hp=8ffd22e48f7ce0ec45b4ff87efefcf80c0b1a946;hpb=d99592d2715e4fea0a4c76bb8b0a5e3e70fd90dc;p=fa-stable.git diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index 8ffd22e4..cd80b2cf 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -32,6 +32,8 @@ function write_sales_invoice(&$invoice) $customer = get_customer($invoice->customer_id); + add_new_exchange_rate($customer['curr_code'], $date_, $invoice->ex_rate); + // offer price values without freight costs $items_total = $invoice->get_items_total_dispatch(); $freight_tax = $invoice->get_shipping_tax(); @@ -75,7 +77,7 @@ function write_sales_invoice(&$invoice) if ($trans_no == 0) { $invoice->trans_no = array($invoice_no=>0); - + } $total = 0; foreach ($invoice->line_items as $line_no => $invoice_line) { $qty = $invoice_line->qty_dispatched; @@ -196,19 +198,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 +219,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);