X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=taxes%2Fdb%2Ftax_types_db.inc;h=a9325b60b10fd8b561beffc2ff19394e0e5da2d6;hb=a5a1f885ee288c74ea2674a9eaaa402ac3c05363;hp=71096f32743c72be92210ab39b03247a4aa344b1;hpb=e29ab37ef51f39c200c3772e07eeceef0ce39214;p=fa-stable.git diff --git a/taxes/db/tax_types_db.inc b/taxes/db/tax_types_db.inc index 71096f32..a9325b60 100644 --- a/taxes/db/tax_types_db.inc +++ b/taxes/db/tax_types_db.inc @@ -29,7 +29,7 @@ function update_tax_type($type_id, $name, $sales_gl_code, $purchasing_gl_code, $ db_query($sql, "could not update tax type"); } -function get_all_tax_types() +function get_all_tax_types($all=false) { $sql = "SELECT ".TB_PREF."tax_types.*, Chart1.account_name AS SalesAccountName, @@ -39,6 +39,7 @@ function get_all_tax_types() WHERE ".TB_PREF."tax_types.sales_gl_code = Chart1.account_code AND ".TB_PREF."tax_types.purchasing_gl_code = Chart2.account_code"; + if (!$all) $sql .= " AND !".TB_PREF."tax_types.inactive"; return db_query($sql, "could not get all tax types"); } @@ -82,7 +83,7 @@ function delete_tax_type($type_id) db_query($sql, "could not delete tax type"); // also delete any item tax exemptions associated with this type - $sql = "DELETE FROM ".TB_PREF."item_tax_type_exemptions WHERE tax_type_id=$type_id"; + $sql = "DELETE FROM ".TB_PREF."item_tax_type_exemptions WHERE tax_type_id=".db_escape($type_id); db_query($sql, "could not delete item tax type exemptions"); @@ -112,4 +113,18 @@ function is_tax_gl_unique($gl_code, $gl_code2=-1, $selected_id=-1) { return $gl_code2 == -1 ? ($row[0] <= 1) : ($row[0] == 0); } -?> \ No newline at end of file + +function is_tax_account($account_code) +{ + $sql= "SELECT id FROM ".TB_PREF."tax_types WHERE + sales_gl_code=".db_escape($account_code)." OR purchasing_gl_code=".db_escape($account_code); + $result = db_query($sql, "checking account is tax account"); + if (db_num_rows($result) > 0) { + $acct = db_fetch($result); + return $acct['id']; + } else + return false; +} + + +?>