From: Maxime Bourget Date: Sun, 16 Jun 2013 09:37:22 +0000 (+0100) Subject: Fix NATURAL JOIN Bug on branch (using notes) X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=63a1e0b7d5f66e4a46acf61c7d85ac731a33ec00;p=order_line_extra.git Fix NATURAL JOIN Bug on branch (using notes) --- diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 4079f7b..5792a6c 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -306,8 +306,8 @@ function get_order_summary($location) { AND so.trans_type = sod.trans_type AND so.trans_type = ".ST_SALESORDER." ) - NATURAL JOIN ".TB_PREF."debtors_master - NATURAL JOIN ".TB_PREF."cust_branch + JOIN ".TB_PREF."debtors_master USING (debtor_no) + JOIN ".TB_PREF."cust_branch USING (debtor_no, branch_code) LEFT JOIN ($pick) p ON (detail_id = sod.id) JOIN ".TB_PREF."denorm_order_details_queue d ON (d.id = sod.id) LEFT JOIN ".TB_PREF."denorm_qoh qoh ON (qoh.stock_id = stk_code AND loc_code = '$location') diff --git a/sql/create_order_summary_view.sql b/sql/create_order_summary_view.sql index 96d66d5..5d9009a 100644 --- a/sql/create_order_summary_view.sql +++ b/sql/create_order_summary_view.sql @@ -12,8 +12,8 @@ JOIN 0_sales_orders so ON (so.order_no = sod.order_no AND so.trans_type = sod.trans_type AND so.trans_type = 30 ) -NATURAL JOIN 0_debtors_master -NATURAL JOIN 0_cust_branch +JOIN 0_debtors_master USING(debtor_no) +JOIN 0_cust_branch USING(debtor_no, branch_code) JOIN 0_denorm_order_details_queue d ON (d.id = sod.id) WHERE sod.quantity > qty_sent GROUP BY debtor_no, branch_code, stk_code