Esempio n. 1
0
function create_bus_enterprise_nature_fee($dbLink, $trans_id, $business_id, $owner_id, $permit_id, $permit_type, $action, $creator, $nature_code = NULL)
{
    // removed bus nature code from tax_fee table instead transfer nature code to business nature code table
    if (is_array($nature_code)) {
        $nature_code_lst = "'" . join("','", $nature_code) . "'";
        $sql = " SELECT a.business_nature_code, c.tax_fee_code, c.tax_fee_desc, c.tax_account_code, c.tax_formula ";
        $sql .= " FROM ebpls_business_nature AS a ";
        $sql .= " INNER JOIN ebpls_tax_fee_table as b ON a.tax_fee_code = b.tax_fee_code WHERE a.business_nature_code IN ('{$nature_code_lst}')";
    } else {
        $sql = " SELECT a.business_nature_code, c.tax_fee_code, c.tax_fee_desc, c.tax_account_code, c.tax_formula ";
        $sql .= " FROM ebpls_business_nature AS a ";
        $sql .= " INNER JOIN ebpls_tax_fee_table as b ON a.tax_fee_code = b.tax_fee_code WHERE a.business_nature_code = '{$nature_code}'";
    }
    ebpls_db_funcs_debug("create_bus_enterprise_nature_fee : {$sql}");
    $result = mysql_query($sql, $dbLink);
    if ($result) {
        $i = 0;
        while ($row = mysql_fetch_array($result)) {
            $clsTaxFee = new EBPLTaxFeeSysRef($dbLink, false);
            $res_tax = $clsTaxFee->select($row["tax_fee_code"]);
            if (is_array($res_tax)) {
                $clsNature = new EBPLSTransactionBusinessNature($dbLink, true);
                $clsNature->setData(TRANS_BUSNATURE_TRANS_ID, $trans_id);
                $clsNature->setData(TRANS_BUSNATURE_BUSINESS_ID, $business_id);
                $clsNature->setData(TRANS_BUSNATURE_OWNER_ID, $owner_id);
                $clsNature->setData(TRANS_BUSNATURE_CAPITAL_INVESTMENT, "0.0");
                $clsNature->setData(TRANS_BUSNATURE_LAST_GROSS, "0.0");
                $clsNature->setData(TRANS_BUSNATURE_BUSINESS_NATURE_CODE, $row["business_nature_code"]);
                if ($clsNature->add() < 0) {
                    ebpls_db_funcs_debug("create_bus_enterprise_nature_fee : error on creation of business nature record");
                    return -5;
                }
                $clsTaxFormula = $res_tax["result"][0]->getData(EBPLS_TAX_FORMULA);
                $sql = "INSERT INTO ebpls_transaction_payables ( trans_id, permit_id,permit_type, tax_fee_type, tax_fee_code, tax_business_nature_code, tax_fee_desc, tax_account_code, tax_total_amount_due, ts_create, last_updated_by )";
                $sql .= " values( {$trans_id}, {$permit_id}, '{$permit_type}', 'BUSTAX','" . $row["tax_fee_code"] . "','" . $row["business_nature_code"] . "','" . $row["tax_fee_desc"] . "','" . $row["tax_account_code"] . "', 0, now(), '{$creator}')";
                ebpls_db_funcs_debug("create_bus_enterprise_nature_fee tax/fee found : {$sql}");
                $rs = mysql_query($sql, $dbLink);
                // add nature to business enterprise nature table
                if (!$rs) {
                    set_db_error($dbLink);
                    return -1;
                }
                $i++;
            } else {
                ebpls_db_funcs_debug("create_bus_enterprise_nature_fee tax/fee code not found : " . $row["tax_fee_code"]);
                set_db_error(NULL, "create_bus_enterprise_nature_fee tax/fee code not found : " . $row["tax_fee_code"]);
                return -3;
            }
        }
        return $i;
    } else {
        set_db_error($dbLink);
        return -2;
    }
}
Esempio n. 2
0
 function getLineOfBusiness()
 {
     $clsNatureList = new EBPLSTransactionBusinessNature($this->m_dbLink, false);
     $records = $clsNatureList->getList($this->data_elems[TRANS_ID]);
     return $records;
 }