X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fsales_db.inc;h=cd5d99974937178f2be12cb64b5de3acf89142e8;hb=5cd13431fe25eb8cd98f67020c55dab124c7e930;hp=536458369b243695db5c789535d9e2897ee2442e;hpb=ebc600101ceab69c06eac4b1bd4d1782af45de05;p=fa-stable.git diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index 53645836..cd5d9997 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -113,6 +113,23 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu $prices[$myrow['sales_type_id']][$myrow['curr_abrev']] = $myrow['price']; } $price = false; + if (isset($prices[$sales_type_id][$currency])) + { + $price = $prices[$sales_type_id][$currency]; + } + elseif (isset($prices[$base_id][$currency])) + { + $price = $prices[$base_id][$currency] * $factor; + } + elseif (isset($prices[$sales_type_id][$home_curr])) + { + $price = $prices[$sales_type_id][$home_curr] / $rate; + } + elseif (isset($prices[$base_id][$home_curr])) + { + $price = $prices[$base_id][$home_curr] * $factor / $rate; + } +/* if (isset($prices[$sales_type_id][$home_curr])) { $price = $prices[$sales_type_id][$home_curr] / $rate; @@ -125,6 +142,7 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu { $price = $prices[$base_id][$home_curr] * $factor / $rate; } +*/ elseif ($num_rows == 0 && $add_pct != -1) { $price = get_calculated_price($stock_id, $add_pct); @@ -184,12 +202,13 @@ function set_document_parent($cart) if (count($cart->src_docs) == 1) { - // if this child document has only one parent - update child link - $del_no = reset(array_keys($cart->src_docs)); + // if this child document has only one parent - update child link + $src = array_keys($cart->src_docs); + $del_no = reset($src); - $sql = 'UPDATE '.TB_PREF.'debtor_trans SET trans_link = ' . $del_no . - ' WHERE type=".db_escape($cart->trans_type)." AND trans_no='. $inv_no ; - db_query($sql, 'Child document link cannot be updated'); + $sql = 'UPDATE '.TB_PREF.'debtor_trans SET trans_link = ' . $del_no . + ' WHERE type='.db_escape($cart->trans_type).' AND trans_no='. $inv_no ; + db_query($sql, 'Child document link cannot be updated'); } if ($cart->trans_type != ST_SALESINVOICE)