projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
user_list_cells Real name shows empty when not entered in user table. @kvvaradha.
[fa-stable.git]
/
taxes
/
db
/
tax_groups_db.inc
diff --git
a/taxes/db/tax_groups_db.inc
b/taxes/db/tax_groups_db.inc
index 826ad8a05865b3b6dc482b86d017b764c3fbb678..fb40bf7de1dccd349c24fd98ddd727bd682d64ed 100644
(file)
--- a/
taxes/db/tax_groups_db.inc
+++ b/
taxes/db/tax_groups_db.inc
@@
-9,40
+9,29
@@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
-function clear_shipping_tax_group() {
- $sql = "UPDATE ".TB_PREF."tax_groups SET tax_shipping=0 WHERE 1";
- db_query($sql, "could not update tax_shipping fields");
-}
-
-function add_tax_group($name, $tax_shipping, $taxes, $rates)
+function add_tax_group($name, $taxes, $tax_shippings)
{
begin_transaction();
{
begin_transaction();
- if($tax_shipping) // only one tax group for shipping
- clear_shipping_tax_group();
-
- $sql = "INSERT INTO ".TB_PREF."tax_groups (name, tax_shipping) VALUES (".db_escape($name).", ".db_escape($tax_shipping).")";
+ $sql = "INSERT INTO ".TB_PREF."tax_groups (name) VALUES (".db_escape($name).")";
db_query($sql, "could not add tax group");
$id = db_insert_id();
db_query($sql, "could not add tax group");
$id = db_insert_id();
- add_tax_group_items($id, $taxes, $
rate
s);
+ add_tax_group_items($id, $taxes, $
tax_shipping
s);
commit_transaction();
}
commit_transaction();
}
-function update_tax_group($id, $name, $tax
_shipping, $taxes, $rate
s)
+function update_tax_group($id, $name, $tax
es, $tax_shipping
s)
{
begin_transaction();
{
begin_transaction();
- if($tax_shipping) // only one tax group for shipping
- clear_shipping_tax_group();
-
- $sql = "UPDATE ".TB_PREF."tax_groups SET name=".db_escape($name).",tax_shipping=".db_escape($tax_shipping)." WHERE id=".db_escape($id);
+ $sql = "UPDATE ".TB_PREF."tax_groups SET name=".db_escape($name)." WHERE id=".db_escape($id);
db_query($sql, "could not update tax group");
delete_tax_group_items($id);
db_query($sql, "could not update tax group");
delete_tax_group_items($id);
- add_tax_group_items($id, $taxes, $
rate
s);
+ add_tax_group_items($id, $taxes, $
tax_shipping
s);
commit_transaction();
}
commit_transaction();
}
@@
-77,12
+66,12
@@
function delete_tax_group($id)
commit_transaction();
}
commit_transaction();
}
-function add_tax_group_items($id, $items, $
rate
s)
+function add_tax_group_items($id, $items, $
tax_shipping
s)
{
for ($i=0; $i < count($items); $i++)
{
{
for ($i=0; $i < count($items); $i++)
{
- $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id,
rate
)
- VALUES (".db_escape($id).", ".db_escape($items[$i]).", " . $
rate
s[$i] .")";
+ $sql = "INSERT INTO ".TB_PREF."tax_group_items (tax_group_id, tax_type_id,
tax_shipping
)
+ VALUES (".db_escape($id).", ".db_escape($items[$i]).", " . $
tax_shipping
s[$i] .")";
db_query($sql, "could not add item tax group item");
}
}
db_query($sql, "could not add item tax group item");
}
}
@@
-98,54
+87,55
@@
function delete_tax_group_items($id)
// Return all tax types with rate value updated according to tax group selected
// Call the function without arg to find shipment group taxes.
//
// Return all tax types with rate value updated according to tax group selected
// Call the function without arg to find shipment group taxes.
//
-function get_tax_group_rates($group_id=null)
+function get_tax_group_rates($group_id=null
, $tax_shipping=false
)
{
{
- global $
suppress_tax_rate
s;
+ global $
SysPref
s;
$sql =
"SELECT t.id as tax_type_id,"
$sql =
"SELECT t.id as tax_type_id,"
- .(isset($suppress_tax_rates) && $suppress_tax_rates == 1
- ? "t.name as tax_type_name,"
+ .($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,
: "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
+ 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
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 id FROM ".TB_PREF."tax_groups WHERE tax_shipping=1)")
- ." WHERE !t.inactive";
+ 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");
}
function get_tax_group_items_as_array($id)
{
return db_query($sql, "cannot get tax types as array");
}
function get_tax_group_items_as_array($id)
{
- $
active_taxes = $
ret_tax_array = array();
-
+ $ret_tax_array = array();
+
$tax_group_items = get_tax_group_rates($id);
$tax_group_items = get_tax_group_rates($id);
-
- while ($tax_group_item = db_fetch
_assoc
($tax_group_items))
+
+ while ($tax_group_item = db_fetch($tax_group_items))
{
$tax_group_item['Value'] = 0;
$ret_tax_array[$tax_group_item['tax_type_id']] = $tax_group_item;
{
$tax_group_item['Value'] = 0;
$ret_tax_array[$tax_group_item['tax_type_id']] = $tax_group_item;
- }
+ }
+
return $ret_tax_array;
}
return $ret_tax_array;
}
-
-function get_shipping_tax_as_array()
+function get_shipping_tax_as_array($id=null)
{
{
- $
active_taxes = $
ret_tax_array = array();
+ $ret_tax_array = array();
- $tax_group_items = get_tax_group_rates();
+ $tax_group_items = get_tax_group_rates(
$id, true
);
- while ($tax_group_item = db_fetch
_assoc
($tax_group_items))
+ while ($tax_group_item = db_fetch($tax_group_items))
{
$tax_group_item['Value'] = 0;
$ret_tax_array[$tax_group_item['tax_type_id']] = $tax_group_item;
}
{
$tax_group_item['Value'] = 0;
$ret_tax_array[$tax_group_item['tax_type_id']] = $tax_group_item;
}
-
+
return $ret_tax_array;
}
return $ret_tax_array;
}
-