3 include_once($path_to_root . "/includes/banking.inc");
5 include_once($path_to_root . "/includes/db/inventory_db.inc");
7 include_once($path_to_root . "/sales/includes/db/sales_order_db.inc");
8 include_once($path_to_root . "/sales/includes/db/sales_credit_db.inc");
9 include_once($path_to_root . "/sales/includes/db/sales_invoice_db.inc");
10 include_once($path_to_root . "/sales/includes/db/custalloc_db.inc");
11 include_once($path_to_root . "/sales/includes/db/cust_trans_db.inc");
12 include_once($path_to_root . "/sales/includes/db/cust_trans_details_db.inc");
13 include_once($path_to_root . "/sales/includes/db/payment_db.inc");
14 include_once($path_to_root . "/sales/includes/db/branches_db.inc");
15 include_once($path_to_root . "/sales/includes/db/customers_db.inc");
18 //----------------------------------------------------------------------------------------
20 // $price in customer's currency
21 // $quantity is used as is (if it's neg it's neg, if it's pos it's pos)
22 // $std_cost is in home currency
23 // $show_or_hide 1 show this item in invoice/credit views, 0 to hide it (used for write-off items)
24 // $type is 10 (invoice) or 11 (credit)
26 function add_stock_move_customer($type, $stock_id, $trans_id, $location, $date_, $reference,
27 $quantity, $std_cost, $show_or_hide=1, $price=0, $discount_percent=0)
29 return add_stock_move($type, $stock_id, $trans_id, $location, $date_, $reference,
30 $quantity, $std_cost, 0, $show_or_hide, $price, $discount_percent,
31 "The customer stock movement record cannot be inserted");
34 //----------------------------------------------------------------------------------------
36 // add a debtor-related gl transaction
37 // $date_ is display date (non-sql)
38 // $amount is in CUSTOMER'S currency
40 function add_gl_trans_customer($type, $type_no, $date_, $account, $dimension, $dimension2,
41 $amount, $customer_id, $err_msg="")
44 $err_msg = "The customer GL transaction could not be inserted";
46 return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, "", $amount,
47 get_customer_currency($customer_id),
48 payment_person_types::customer(), $customer_id, $err_msg);
51 //----------------------------------------------------------------------------------------
53 function get_price ($stock_id, $debtor_no)
55 $sql = "SELECT ".TB_PREF."prices.price
56 FROM ".TB_PREF."prices, ".TB_PREF."debtors_master
57 WHERE ".TB_PREF."debtors_master.sales_type=".TB_PREF."prices.sales_type_id
58 AND ".TB_PREF."debtors_master.debtor_no='" . $debtor_no . "'
59 AND ".TB_PREF."prices.stock_id = '" . $stock_id . "'
60 AND ".TB_PREF."prices.curr_abrev = ".TB_PREF."debtors_master.curr_code";
62 $result = db_query($sql, "There was a problem retrieving the pricing information for the part $stock_id for customer");
64 if (db_num_rows($result) != 0)
66 /*There is a price from one of the above so return that */
67 $myrow = db_fetch_row($result);
77 //----------------------------------------------------------------------------------------