Fixed include file issue in sales order entry.
[fa-stable.git] / sales / includes / db / sales_credit_db.inc
index 869dc538accd3e148b33764763cc5ce5ff607be8..0330efce8a9c7b39d6959369d232ff4afbc7d93a 100644 (file)
@@ -41,6 +41,8 @@ function write_credit_note(&$credit_note, $write_off_acc)
        $company_data = get_company_prefs();
        $branch_data = get_branch_accounts($credit_note->Branch);
 
+       add_new_exchange_rate(get_customer_currency($credit_note->customer_id), $credit_date, $credit_note->ex_rate);
+
        $credit_note_total = $credit_note->get_items_total_dispatch();
        $freight_tax = $credit_note->get_shipping_tax();
 
@@ -180,6 +182,9 @@ function add_credit_movements_item(&$credit_note, &$credit_line,
        $credit_type, $price, $credited_invoice=0)
 {
 
+    //Chaitanya : Stamp current cost in stock moves $credit_line does not fetch cost
+    $curr_std_cost = get_standard_cost($credit_line->stock_id);
+
        if ($credit_type == "Return") {
 
                $reference = "Return ";
@@ -193,20 +198,20 @@ function add_credit_movements_item(&$credit_note, &$credit_line,
                if ($credited_invoice)
                        $reference .= "Ex Inv: " . $credited_invoice;
 
-       add_stock_move_customer(ST_CUSTCREDIT,  $credit_line->stock_id,
-               key($credit_note->trans_no), $credit_note->Location,
-               $credit_note->document_date, $reference, -$credit_line->qty_dispatched,
-               $credit_line->standard_cost,  0, $price,
-               $credit_line->discount_percent);
-
-               }
-       add_stock_move_customer(ST_CUSTCREDIT,  $credit_line->stock_id,
-               key($credit_note->trans_no), $credit_note->Location,
-               $credit_note->document_date, $reference, $credit_line->qty_dispatched,
-               $credit_line->standard_cost,  0, $price,
-               $credit_line->discount_percent);
+               add_stock_move_customer(ST_CUSTCREDIT,  $credit_line->stock_id,
+               key($credit_note->trans_no), $credit_note->Location,
+               $credit_note->document_date, $reference, -$credit_line->qty_dispatched,
+               $curr_std_cost,  0, $price,
+               $credit_line->discount_percent);
 
        }
+    add_stock_move_customer(ST_CUSTCREDIT,  $credit_line->stock_id,
+        key($credit_note->trans_no), $credit_note->Location,
+        $credit_note->document_date, $reference, $credit_line->qty_dispatched,
+        $curr_std_cost,  0, $price,
+        $credit_line->discount_percent);
+
+}
 
 //----------------------------------------------------------------------------------------