- $sql = "SELECT ".TB_PREF."tax_group_items.*, ".TB_PREF."tax_types.name AS tax_type_name,
- ".TB_PREF."tax_types.sales_gl_code, ".TB_PREF."tax_types.purchasing_gl_code
- FROM ".TB_PREF."tax_group_items, ".TB_PREF."tax_types
- WHERE tax_group_id=".db_escape($id)."
- AND ".TB_PREF."tax_types.id=tax_type_id";
-
- return db_query($sql, "could not get item tax type group items");
+ global $SysPrefs;
+
+ $sql =
+ "SELECT t.id as tax_type_id,"
+ .($SysPrefs->suppress_tax_rates() == 1 ? "t.name as tax_type_name,"
+ : "CONCAT(t.name, ' (', t.rate, '%)') as tax_type_name,")
+ ."t.sales_gl_code,
+ t.purchasing_gl_code,
+ IF(g.tax_type_id, t.rate, NULL) as rate,
+ g.tax_shipping
+ FROM ".TB_PREF."tax_types t
+ LEFT JOIN ".TB_PREF."tax_group_items g ON t.id=g.tax_type_id
+ AND g.tax_group_id=". ($group_id ? db_escape($group_id) : "(SELECT MIN(id) FROM ".TB_PREF."tax_groups)")
+ . " WHERE !t.inactive";
+ if ($tax_shipping)
+ $sql .= " AND g.tax_shipping=1";
+
+ return db_query($sql, "cannot get tax types as array");