Stable merged into unstable again (due to failure on binary file during previous...
[fa-stable.git] / sales / includes / db / sales_credit_db.inc
index d5be9c44b0b16a4a00d7b7e9637ac43f038d6187..0fb76057b1d9e059dbfe548be44132032e73545f 100644 (file)
@@ -17,8 +17,13 @@ function write_credit_note(&$credit_note, $write_off_acc)
 {
        global $Refs;
 
-       $credit_invoice =       is_array($credit_note->src_docs) ?
-                reset(array_keys($credit_note->src_docs)) : $credit_note->src_docs;
+       if (is_array($credit_note->src_docs))
+       {
+               $docs = array_keys($credit_note->src_docs);
+               $credit_invoice = reset($docs);
+       }
+       else
+               $credit_invoice = $credit_note->src_docs;
 
        $credit_date = $credit_note->document_date;
        $tax_group_id = $credit_note->tax_group_id;
@@ -74,7 +79,7 @@ function write_credit_note(&$credit_note, $write_off_acc)
                $credit_note->freight_cost, $freight_added_tax,
                $credit_note->sales_type, $credit_note->order_no, $credit_note->ship_via,
                null, $alloc, 0, $credit_note->dimension_id, $credit_note->dimension2_id,
-               $credit_note->payment); 
+               $credit_note->payment, $credit_note->tax_included); 
                // 2008-06-14 extra $alloc, 2008-11-12 dimension_id Joe Hunt
 
        if ($trans_no==0) {
@@ -171,7 +176,6 @@ function write_credit_note(&$credit_note, $write_off_acc)
 // Insert a stock movement coming back in to show the credit note and
 //     a reversing stock movement to show the write off
 //
-
 function add_credit_movements_item(&$credit_note, &$credit_line,
        $credit_type, $price, $credited_invoice=0)
 {