function getBacktaxTDList($tdID) { $records = new BacktaxTDRecords(); if ($records->selectRecords($tdID)) { if (!($domDoc = $records->getDomDocument())) { return false; } else { $xmlStr = $domDoc->dump_mem(true); return $xmlStr; } } else { return false; } }
function displayBacktaxTD($tdID) { $backtaxTDRecord = array("arpNumber" => "", "class" => "", "location" => "", "year" => "", "taxDue" => ""); $BacktaxTDDetails = new SoapObject(NCCBIZ . "BacktaxTDDetails.php", "urn:Object"); $PaymentList = new SoapObject(NCCBIZ . "PaymentList.php", "urn:Object"); $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object"); if (!($xmlStr = $BacktaxTDDetails->getBacktaxTDList($tdID))) { // error xml } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc } else { $backtaxTDRecords = new BacktaxTDRecords(); $backtaxTDRecords->parseDomDocument($domDoc); $backTaxTDList = $backtaxTDRecords->getArrayList(); //$this->tpl->set_block("TDList", "BacktaxesList", "BacktaxesListBlock"); //$this->tpl->set_block("rptsTemplate", "BacktaxesDBEmpty", "BacktaxesDBEmptyBlock"); if (count($backTaxTDList)) { //$this->tpl->set_var("BacktaxesDBEmptyBlock", ""); foreach ($backTaxTDList as $key => $val) { // check Paid values from Payments and increment to paid value in BacktaxTD $condition = " WHERE backtaxTDID = '" . $val->getBacktaxTDID() . "'"; $condition .= " AND status='' "; $condition .= " ORDER BY paymentDate DESC "; if (!($xmlStr = $PaymentList->getPaymentList($condition))) { // error xmlStr. do nothing } else { if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc. do nothing } else { $paymentRecords = new PaymentRecords(); $paymentRecords->parseDomDocument($domDoc); $paymentArrayList = $paymentRecords->getArrayList(); $collectionCondition = "WHERE status='' AND ("; $paymentCount = 0; foreach ($paymentArrayList as $payment) { if ($paymentCount > 0) { $collectionCondition .= " OR"; } else { $lastPaymentDate = $payment->getPaymentDate(); } $collectionCondition .= " paymentID = '" . $payment->getPaymentID() . "' "; $paymentCount++; } $collectionCondition .= ") "; if (!($xmlStr = $CollectionList->getCollectionList($collectionCondition))) { // error xmlStr } else { if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc } else { $collectionRecords = new CollectionRecords(); $collectionRecords->parseDomDocument($domDoc); $collectionArrayList = $collectionRecords->getArrayList(); $totalPaid = 0; foreach ($collectionArrayList as $collection) { $totalPaid += $collection->getAmountPaid(); } // to avoid -0.01, 0.01 balances if ($totalPaid != $payment->getAmountPaid()) { $totalPaid = $payment->getAmountPaid(); } $totalPaid += $val->getPaid(); $val->setPaid($totalPaid); } } } } // calculate Penalties verses either today or verses the last paymentDate /* echo "backtaxTDID:".$val->getBacktaxTDID(); echo "<br>"; echo "startYear:".$val->getStartYear(); echo "<br>"; echo "startQuarter:".$val->getStartQuarter(); echo "<br>"; */ if ($lastPaymentDate != "") { $val->calculatePenalty($lastPaymentDate); //echo "val->calculatePenalty(".$lastPaymentDate.")"; // if balance is 0 leave penalty as is, otherwise calculatePenalty according to date now $balanceB = $val->getTotalTaxDue(); if (round($balanceB, 4) > 0) { $val->calculatePenalty($this->now); //echo "val->calculatePenalty(".$this->now.")"; } } else { $val->calculatePenalty($this->now); //echo "val->calculatePenalty(".$this->now.")"; } //echo "<hr>"; $this->tpl->set_var("backtaxTDID", $val->getBacktaxTDID()); $this->tpl->set_var("tdNumberB", $val->getTdNumber()); $this->tpl->set_var("startYearB", $val->getStartYear()); $this->tpl->set_var("endYearB", $val->getEndYear()); $this->tpl->set_var("startQuarterB", $val->getStartQuarter()); $this->tpl->set_var("assessedValueB", number_format($val->getAssessedValue(), 2)); $this->tpl->set_var("basicRateB", number_format($val->getBasicRate(), 2)); $this->tpl->set_var("sefRateB", number_format($val->getSEFRate(), 2)); $this->tpl->set_var("basicTaxB", number_format($val->getBasicTax(), 2)); $this->tpl->set_var("sefTaxB", number_format($val->getSEFTax(), 2)); $this->tpl->set_var("idleTaxB", number_format($val->getIdleTax(), 2)); $this->tpl->set_var("penaltiesB", number_format($val->getPenalties(), 2)); $this->tpl->set_var("paidB", number_format($val->getPaid(), 2)); $this->tpl->set_var("balanceB", number_format($val->getTotalTaxDue(), 2)); $this->tpl->set_var("totalTaxDueB", number_format($val->getTotal(), 2)); // $this->tpl->set_var("taxDue", number_format($val->getTotal(),2)); $this->formArray["totalBacktaxesDue"] = 0; $this->formArray["totalBacktaxesDue"] += $val->getBasicTax(); $this->formArray["totalBacktaxesDue"] += $val->getSefTax(); $this->formArray["totalBacktaxesDue"] += $val->getIdleTax(); $this->formArray["totalBacktaxesDue"] += $val->getPenalties(); $this->formArray["totalBacktaxesBalance"] += $val->getTotalTaxDue() + $val->getPaid(); $this->backtaxTDIDArray[] = $val->getBacktaxTDID(); $backtaxTDRecord["arpNumber"] = $val->getTdNumber(); $backtaxTDRecord["class"] = "--"; $backtaxTDRecord["location"] = "--"; $backtaxTDRecord["year"] = $val->getStartYear(); if ($val->getEndYear() != $val->getStartYear()) { $backtaxTDRecord["year"] = $val->getStartYear() . "-" . $val->getEndYear(); } $backtaxTDRecord["taxDue"] = $val->getTotalTaxDue(); $this->tdArrayList[$backtaxTDRecord["year"] . $this->tdArrayListCounter] = $backtaxTDRecord; $this->tdArrayListCounter++; unset($backtaxTDRecord); } } else { //$this->tpl->set_block("TDList", "Backtax", "BacktaxBlock"); //$this->tpl->set_var("BacktaxBlock", ""); } } } }
function displayBacktaxTD($tdID) { $BacktaxTDDetails = new SoapObject(NCCBIZ . "BacktaxTDDetails.php", "urn:Object"); $PaymentList = new SoapObject(NCCBIZ . "PaymentList.php", "urn:Object"); $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object"); if (!($xmlStr = $BacktaxTDDetails->getBacktaxTDList($tdID))) { $this->tpl->set_block("TDList", "BacktaxesTable", "BacktaxesTableBlock"); $this->tpl->set_var("BacktaxesTableBlock", "no backtaxes"); $this->tpl->set_var("BacktaxesListBlock", ""); $this->tpl->set_var("JSBacktaxesListBlock", ""); } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("TDList", "BacktaxesTable", "BacktaxesTableBlock"); $this->tpl->set_var("BacktaxesTableBlock", "no backtaxes"); $this->tpl->set_var("BacktaxesListBlock", ""); $this->tpl->set_var("JSBacktaxesListBlock", ""); } else { $backtaxTDRecords = new BacktaxTDRecords(); $backtaxTDRecords->parseDomDocument($domDoc); $backTaxTDList = $backtaxTDRecords->getArrayList(); //$this->tpl->set_block("TDList", "BacktaxesList", "BacktaxesListBlock"); //$this->tpl->set_block("rptsTemplate", "BacktaxesDBEmpty", "BacktaxesDBEmptyBlock"); if (count($backTaxTDList)) { //$this->tpl->set_var("BacktaxesDBEmptyBlock", ""); foreach ($backTaxTDList as $key => $val) { // get paymentHistory $defaultDueType = "Annual"; $allowableDueTypesArray = array("Annual", "Q1", "Q2", "Q3", "Q4"); /* alxjvr 2006.03.22 if(!$paymentHistory = $this->getPaymentHistory("",$val->getBacktaxTDID())){ $defaultDueType = "Annual"; $allowableDueTypesArray = array("Annual","Q1"); } else{ $defaultDueType = $paymentHistory->arrayList[0]->getDueType(); if($defaultDueType=="Annual"){ $allowableDueTypesArray = array("Annual"); } else{ switch($defaultDueType){ case "Q1": $allowableDueTypesArray = array("Q1", "Q2"); break; case "Q2": $allowableDueTypesArray = array("Q2", "Q3"); break; case "Q3": $allowableDueTypesArray = array("Q3", "Q4"); break; case "Q4": $allowableDueTypesArray = array("Q4"); break; } } } */ // check Paid values from Payments and increment to paid value in BacktaxTD $condition = " WHERE status='' "; $condition .= " AND backtaxTDID = '" . $val->getBacktaxTDID() . "'"; $condition .= " ORDER BY paymentDate DESC, paymentID DESC "; if (!($xmlStr = $PaymentList->getPaymentList($condition))) { // error xmlStr. do nothing } else { if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc. do nothing } else { $paymentRecords = new PaymentRecords(); $paymentRecords->parseDomDocument($domDoc); $paymentArrayList = $paymentRecords->getArrayList(); $collectionCondition = "WHERE status='' AND ("; $paymentCount = 0; foreach ($paymentArrayList as $payment) { if ($paymentCount > 0) { $collectionCondition .= " OR"; } else { $lastPaymentDate = $payment->getPaymentDate(); $lastPaymentDueType = $payment->getDueType(); $amnestyStatus = $payment->getAmnesty(); } $collectionCondition .= " paymentID = '" . $payment->getPaymentID() . "' "; $paymentCount++; } $collectionCondition .= ") "; if (!($xmlStr = $CollectionList->getCollectionList($collectionCondition))) { // error xmlStr } else { if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc } else { $collectionRecords = new CollectionRecords(); $collectionRecords->parseDomDocument($domDoc); $collectionArrayList = $collectionRecords->getArrayList(); $totalPaid = 0; foreach ($collectionArrayList as $collection) { $totalPaid += $collection->getAmountPaid(); } $totalPaid += $val->getPaid(); // to avoid -0.01, 0.01 balances if ($totalPaid != $payment->getAmountPaid()) { $totalPaid = $payment->getAmountPaid(); } $val->setPaid($totalPaid); } } } } if ($amnestyStatus == "true") { $this->tpl->set_var("btAmnesty_status", "checked"); } else { $this->tpl->set_var("btAmnesty_status", ""); } // calculate Penalties verses either today or verses the last paymentDate $treasurySettings = $this->getTreasurySettings(); $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-" . $treasurySettings->getAnnualDueDate())); if ($lastPaymentDate != "") { $val->calculatePenalty($lastPaymentDate); // if balance is 0 leave penalty as is, otherwise calculatePenalty according to date now $balanceB = $val->getTotalTaxDue(); $penaltyLUTArray = $this->getPenaltyLUTArray(); switch ($lastPaymentDueType) { case "Q1": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-03-31")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; case "Q2": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-06-30")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; case "Q3": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-09-30")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; case "Q4": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-12-31")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; } $penaltyComputeDate = $lastPaymentDate; // 0.1 is used instead of 0 because sometimes rounded off balances intended to be 0 end up appearing as 0.002 or so... if (round($balanceB, 4) > 0.1) { $val->calculatePenalty($this->now); $penaltyComputeDate = $this->now; $btBasicTax = $val->getBasicTax(); $btSefTax = $val->getSEFTax(); $btIdleTax = $val->getIdleTax(); $btTaxDue = $val->getBasicTax + $val->getSEFTax() + $val->getIdleTax(); $btPenalty = $val->getPenalties(); $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-" . $treasurySettings->getAnnualDueDate())); } } else { $val->calculatePenalty($this->now); $penaltyComputeDate = $this->now; $btBasicTax = $val->getBasicTax(); $btSefTax = $val->getSEFTax(); $btIdleTax = $val->getIdleTax(); $btTaxDue = $val->getBasicTax + $val->getSEFTax() + $val->getIdleTax(); $btPenalty = $val->getPenalties(); $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-" . $treasurySettings->getAnnualDueDate())); } // if Backtax Penalties is greater than 0, allow only "Annual" payments $defaultDueType = "Annual"; $allowableDueTypesArray = array("Annual", "Q1", "Q2", "Q3", "Q4"); /* alxjvr 2006.03.22 if($btPenalty>0){ $defaultDueType = "Annual"; $allowableDueTypesArray = array("Annual"); } */ foreach ($allowableDueTypesArray as $allowableDueType) { $this->tpl->set_var("backtaxAllowableDueType", $allowableDueType); $this->tpl->parse("BacktaxDueTypeListBlock", "BacktaxDueTypeList", true); } $this->tpl->set_var("backtaxTDID", $val->getBacktaxTDID()); $this->tpl->set_var("tdNumberB", $val->getTdNumber()); $this->tpl->set_var("startYearB", $val->getStartYear()); $this->tpl->set_var("endYearB", $val->getEndYear()); $this->tpl->set_var("startQuarterB", $val->getStartQuarter()); $this->tpl->set_var("assessedValueB", number_format($val->getAssessedValue(), 2)); $this->tpl->set_var("basicRateB", number_format($val->getBasicRate(), 2)); $this->tpl->set_var("sefRateB", number_format($val->getSEFRate(), 2)); $this->tpl->set_var("basicTaxB", number_format($val->getBasicTax(), 2)); $this->tpl->set_var("sefTaxB", number_format($val->getSEFTax(), 2)); $this->tpl->set_var("idleTaxB", number_format($val->getIdleTax(), 2)); $this->tpl->set_var("penaltiesB", number_format($val->getPenalties(), 2)); $this->tpl->set_var("paidB", number_format($val->getPaid(), 2)); $this->tpl->set_var("balanceB", number_format($val->getTotalTaxDue(), 2)); $this->tpl->set_var("totalTaxDueB", number_format($val->getTotal(), 2)); $btDueTypeArray = array(1 => "Q1", 2 => "Q2", 3 => "Q3", 4 => "Q4"); // set default backtax values based on latest payments $this->tpl->set_var("btDueDate", $btDueDate); $this->tpl->set_var("btBasicTax", formatCurrency($btBasicTax)); $this->tpl->set_var("btSefTax", formatCurrency($btSefTax)); $this->tpl->set_var("btIdleTax", formatCurrency($btIdleTax)); $this->tpl->set_var("btTaxDue", formatCurrency($btTaxDue)); $this->tpl->set_var("btAdvancedPaymentDiscount", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount", formatCurrency(0)); $this->tpl->set_var("btPenalty", formatCurrency($btPenalty)); $this->tpl->set_var("btTotalPaid", formatCurrency($val->getPaid())); $btBalance = $val->getTotalTaxDue(); if ($btBalance < 0) { $btBalance = 0; } else { if ($btBalance == "-0") { $btBalance = 0; } } $this->tpl->set_var("btBalance", formatCurrency($btBalance)); $this->tpl->set_var("btDueID[Annual]", $this->getDueIDFromBacktaxTDID($val->getBacktaxTDID(), "Annual")); $this->tpl->set_var("btDueID[Q1]", $this->getDueIDFromBacktaxTDID($val->getBacktaxTDID(), "Q1")); $this->tpl->set_var("btDueID[Q2]", $this->getDueIDFromBacktaxTDID($val->getBacktaxTDID(), "Q2")); $this->tpl->set_var("btDueID[Q3]", $this->getDueIDFromBacktaxTDID($val->getBacktaxTDID(), "Q3")); $this->tpl->set_var("btDueID[Q4]", $this->getDueIDFromBacktaxTDID($val->getBacktaxTDID(), "Q4")); $this->tpl->set_var("btDueDate[Annual]", date("M. d, Y", strtotime($val->getStartYear() . "-" . $treasurySettings->getAnnualDueDate()))); $this->tpl->set_var("btDueDate[Q1]", date("M. d, Y", strtotime($val->getStartYear() . "-03-31"))); $this->tpl->set_var("btDueDate[Q2]", date("M. d, Y", strtotime($val->getStartYear() . "-06-30"))); $this->tpl->set_var("btDueDate[Q3]", date("M. d, Y", strtotime($val->getStartYear() . "-09-30"))); $this->tpl->set_var("btDueDate[Q4]", date("M. d, Y", strtotime($val->getStartYear() . "-12-31"))); $this->tpl->set_var("btBasicTax[Annual]", formatCurrency($val->getBasicTax())); $this->tpl->set_var("btBasicTax[Q1]", roundUpNearestFiveCent($val->getBasicTax() / 4)); $this->tpl->set_var("btBasicTax[Q2]", roundUpNearestFiveCent(un_number_format($val->getBasicTax() / 4))); $this->tpl->set_var("btBasicTax[Q3]", roundUpNearestFiveCent(un_number_format($val->getBasicTax() / 4))); $this->tpl->set_var("btBasicTax[Q4]", roundUpNearestFiveCent(un_number_format($val->getBasicTax() / 4))); $this->tpl->set_var("btSefTax[Annual]", formatCurrency($val->getSEFTax())); $this->tpl->set_var("btSefTax[Q1]", roundUpNearestFiveCent(un_number_format($val->getSEFTax() / 4))); $this->tpl->set_var("btSefTax[Q2]", roundUpNearestFiveCent(un_number_format($val->getSEFTax() / 4))); $this->tpl->set_var("btSefTax[Q3]", roundUpNearestFiveCent(un_number_format($val->getSEFTax() / 4))); $this->tpl->set_var("btSefTax[Q4]", roundUpNearestFiveCent(un_number_format($val->getSEFTax() / 4))); $this->tpl->set_var("btIdleTax[Annual]", formatCurrency($val->getIdleTax())); $this->tpl->set_var("btIdleTax[Q1]", roundUpNearestFiveCent(un_number_format($val->getIdleTax() / 4))); $this->tpl->set_var("btIdleTax[Q2]", roundUpNearestFiveCent(un_number_format($val->getIdleTax() / 4))); $this->tpl->set_var("btIdleTax[Q3]", roundUpNearestFiveCent(un_number_format($val->getIdleTax() / 4))); $this->tpl->set_var("btIdleTax[Q4]", roundUpNearestFiveCent(un_number_format($val->getIdleTax() / 4))); $this->tpl->set_var("btTaxDue[Annual]", formatCurrency($val->getBasicTax() + $val->getSEFTax() + $val->getIdleTax())); $this->tpl->set_var("btTaxDue[Q1]", formatCurrency(un_number_format($this->tpl->get_var("btBasicTax[Q1]")) + un_number_format($this->tpl->get_var("btSefTax[Q1]")) + un_number_format($this->tpl->get_var("btIdleTax[Q1]")))); $this->tpl->set_var("btTaxDue[Q2]", formatCurrency(un_number_format($this->tpl->get_var("btBasicTax[Q2]")) + un_number_format($this->tpl->get_var("btSefTax[Q2]")) + un_number_format($this->tpl->get_var("btIdleTax[Q2]")))); $this->tpl->set_var("btTaxDue[Q3]", formatCurrency(un_number_format($this->tpl->get_var("btBasicTax[Q3]")) + un_number_format($this->tpl->get_var("btSefTax[Q3]")) + un_number_format($this->tpl->get_var("btIdleTax[Q3]")))); $this->tpl->set_var("btTaxDue[Q4]", formatCurrency(un_number_format($this->tpl->get_var("btBasicTax[Q4]")) + un_number_format($this->tpl->get_var("btSefTax[Q4]")) + un_number_format($this->tpl->get_var("btIdleTax[Q4]")))); $this->tpl->set_var("btAdvancedPaymentDiscount[Annual]", formatCurrency(0)); $this->tpl->set_var("btAdvancedPaymentDiscount[Q1]", formatCurrency(0)); $this->tpl->set_var("btAdvancedPaymentDiscount[Q2]", formatCurrency(0)); $this->tpl->set_var("btAdvancedPaymentDiscount[Q3]", formatCurrency(0)); $this->tpl->set_var("btAdvancedPaymentDiscount[Q4]", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount[Annual]", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount[Q1]", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount[Q2]", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount[Q3]", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount[Q4]", formatCurrency(0)); $this->tpl->set_var("btPenalty[Annual]", formatCurrency($val->getPenalties())); // compute quarterly penalties $penaltyLUTArray = $this->getPenaltyLUTArray(); foreach ($btDueTypeArray as $btDueTypeKey => $btDueType) { $btPenalty = 0; if ($lastPaymentDueType != "") { if ($btDueTypeKey > substr($lastPaymentDueType, 1, 1)) { $penaltyComputeDate = $this->now; } } if (strtotime($penaltyComputeDate) > strtotime($this->tpl->get_var("btDueDate[" . $btDueType . "]"))) { $numYears = date("Y", strtotime($penaltyComputeDate)) - date("Y", strtotime($this->tpl->get_var("btDueDate[" . $btDueType . "]"))); $numMonths = date("n", strtotime($penaltyComputeDate)) - date("n", strtotime($this->tpl->get_var("btDueDate[" . $btDueType . "]"))); $totalMonths = $this->btCalculateMonthOverDue(date("Y-m-d", strtotime($penaltyComputeDate)), $this->tpl->get_var("btDueDate[" . $btDueType . "]"), $btDueType); if ($totalMonths >= count($penaltyLUTArray)) { $penaltyPercentage = 0.72; } else { $penaltyPercentage = $penaltyLUTArray[$totalMonths]; } $btPenalty = un_number_format($this->tpl->get_var("btTaxDue[" . $btDueType . "]")) * $penaltyPercentage; } $this->tpl->set_var("btPenalty[" . $btDueType . "]", formatCurrency($btPenalty)); } // get totalPaid for backtax $totalPaid = 0; if ($paymentHistory = $this->getPaymentHistory("", $val->getBacktaxTDID())) { $paymentArrayList = $paymentHistory->getArrayList(); foreach ($paymentArrayList as $payment) { $totalPaid += $payment->getAmountPaid(); } $this->tpl->set_var("btTotalPaid[Annual]", formatCurrency($totalPaid)); } else { $this->tpl->set_var("btTotalPaid[Annual]", formatCurrency(0)); } // get quarterlyPayments for backtax $totalPaidForQuarter = 0; foreach ($btDueTypeArray as $btDueType) { if ($btQuarterPaymentHistory = $this->getBacktaxQuarterPaymentHistory($val->getBacktaxTDID(), $btDueType)) { $btQuarterPaymentArrayList = $btQuarterPaymentHistory->getArrayList(); foreach ($btQuarterPaymentArrayList as $payment) { $totalPaidForQuarter += $payment->getAmountPaid(); } $this->tpl->set_var("btTotalPaid[" . $btDueType . "]", formatCurrency($totalPaidForQuarter)); if ($lastPaymentDueType == $btDueType) { $this->tpl->set_var("btTotalPaid", formatCurrency($totalPaidForQuarter)); } $totalPaidForQuarter = 0; } else { $this->tpl->set_var("btTotalPaid[" . $btDueType . "]", formatCurrency(0)); } } // set default backtax values based on latest payments if ($defaultDueType != "Annual") { $this->tpl->set_var("btBasicTax", $this->tpl->get_var("btBasicTax[" . $defaultDueType . "]")); $this->tpl->set_var("btSefTax", $this->tpl->get_var("btSefTax[" . $defaultDueType . "]")); $this->tpl->set_var("btIdleTax", $this->tpl->get_var("btIdleTax[" . $defaultDueType . "]")); $this->tpl->set_var("btTaxDue", $this->tpl->get_var("btTaxDue[" . $defaultDueType . "]")); $this->tpl->set_var("btAdvancedPaymentDiscount", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount", formatCurrency(0)); $this->tpl->set_var("btPenalty", $this->tpl->get_var("btPenalty[" . $defaultDueType . "]")); $this->tpl->set_var("btTotalPaid", $this->tpl->get_var("btTotalPaid[" . $defaultDueType . "]")); $btBalance = un_number_format($this->tpl->get_var("btTaxDue")); if ($this->tpl->get_var("btAdvancedPaymentDiscount") > 0) { $btBalance = un_number_format($this->tpl->get_var("btTaxDue")) - un_number_format($this->tpl->get_var("btAdvancedPaymentDiscount")); } else { if ($this->tpl->get_var("btEarlyPaymentDiscount") > 0) { $btBalance = un_number_format($this->tpl->get_var("btTaxDue")) - un_number_format($this->tpl->get_var("btEarlyPaymentDiscount")); } } $btBalance += un_number_format($this->tpl->get_var("btPenalty")); $btBalance -= un_number_format($this->tpl->get_var("btTotalPaid")); $this->tpl->set_var("btBalance", formatCurrency($btBalance)); } else { $this->tpl->set_var("btBasicTax", formatCurrency($val->getBasicTax())); $this->tpl->set_var("btSefTax", formatCurrency($val->getSEFTax())); $this->tpl->set_var("btIdleTax", formatCurrency($val->getIdleTax())); $this->tpl->set_var("btTaxDue", formatCurrency($val->getBasicTax() + $val->getSEFTax() + $val->getIdleTax())); $this->tpl->set_var("btAdvancedPaymentDiscount", formatCurrency(0)); $this->tpl->set_var("btEarlyPaymentDiscount", formatCurrency(0)); $this->tpl->set_var("btPenalty", formatCurrency($val->getPenalties())); $this->tpl->set_var("btTotalPaid", formatCurrency($val->getPaid())); $this->tpl->set_var("btBalance", formatCurrency($val->getTotalTaxDue())); } $this->backtaxTDIDArray[] = $val->getBacktaxTDID(); $this->tpl->parse("BacktaxesListBlock", "BacktaxesList", true); $this->tpl->parse("JSBacktaxesListBlock", "JSBacktaxesList", true); $this->tpl->set_var("BacktaxDueTypeListBlock", ""); } } else { //$this->tpl->set_block("TDList", "Backtax", "BacktaxBlock"); //$this->tpl->set_var("BacktaxBlock", ""); } } } }
function deleteBacktax($backtaxTDIDArray) { $backtaxTDRecords = new BacktaxTDRecords(); $rows = $backtaxTDRecords->deleteRecords($backtaxTDIDArray); return $rows; }
function displayBacktaxTD($tdID) { $BacktaxTDDetails = new SoapObject(NCCBIZ . "BacktaxTDDetails.php", "urn:Object"); $PaymentList = new SoapObject(NCCBIZ . "PaymentList.php", "urn:Object"); $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object"); if (!($xmlStr = $BacktaxTDDetails->getBacktaxTDList($tdID))) { $this->tpl->set_block("TDList", "BacktaxesTable", "BacktaxesTableBlock"); $this->tpl->set_var("BacktaxesTableBlock", "no backtaxes"); } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("TDList", "BacktaxesTable", "BacktaxesTableBlock"); $this->tpl->set_var("BacktaxesTableBlock", "no backtaxes"); } else { $backtaxTDRecords = new BacktaxTDRecords(); $backtaxTDRecords->parseDomDocument($domDoc); $backTaxTDList = $backtaxTDRecords->getArrayList(); //$this->tpl->set_block("TDList", "BacktaxesList", "BacktaxesListBlock"); //$this->tpl->set_block("rptsTemplate", "BacktaxesDBEmpty", "BacktaxesDBEmptyBlock"); if (count($backTaxTDList)) { //$this->tpl->set_var("BacktaxesDBEmptyBlock", ""); foreach ($backTaxTDList as $key => $val) { // check Paid values from Payments and increment to paid value in BacktaxTD $condition = " WHERE backtaxTDID = '" . $val->getBacktaxTDID() . "'"; $condition .= " AND status='' "; $condition .= " ORDER BY paymentDate DESC "; if (!($xmlStr = $PaymentList->getPaymentList($condition))) { // error xmlStr. do nothing } else { if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc. do nothing } else { $paymentRecords = new PaymentRecords(); $paymentRecords->parseDomDocument($domDoc); $paymentArrayList = $paymentRecords->getArrayList(); $collectionCondition = "WHERE status='' AND ("; $paymentCount = 0; foreach ($paymentArrayList as $payment) { if ($paymentCount > 0) { $collectionCondition .= " OR"; } $collectionCondition .= " paymentID = '" . $payment->getPaymentID() . "' "; $paymentCount++; } $collectionCondition .= ") "; if (!($xmlStr = $CollectionList->getCollectionList($collectionCondition))) { // error xmlStr } else { if (!($domDoc = domxml_open_mem($xmlStr))) { // error domDoc } else { $collectionRecords = new CollectionRecords(); $collectionRecords->parseDomDocument($domDoc); $collectionArrayList = $collectionRecords->getArrayList(); $totalPaid = 0; foreach ($collectionArrayList as $collection) { $totalPaid += $collection->getAmountPaid(); } $totalPaid += $val->getPaid(); // to avoid -0.01, 0.01 balances if ($totalPaid != $payment->getAmountPaid()) { $totalPaid = $payment->getAmountPaid(); } $val->setPaid($totalPaid); } } } } // calculate Penalties verses either today or verses the last paymentDate /* echo "backtaxTDID:".$val->getBacktaxTDID(); echo "<br>"; echo "startYear:".$val->getStartYear(); echo "<br>"; echo "startQuarter:".$val->getStartQuarter(); echo "<br>"; */ $payment = new Payment(); if ($payment->selectRecordFromCondition("WHERE status!='cancelled' AND backtaxTDID='" . $val->getBacktaxTDID() . "'")) { $lastPaymentDate = $payment->getPaymentDate(); $lastPaymentDate = $payment->getPaymentDate(); $lastPaymentDueType = $payment->getDueType(); $amnestyStatus = $payment->getAmnesty(); } else { $lastPaymentDate = "now"; } if ($lastPaymentDate != "") { $val->calculatePenalty($lastPaymentDate); //echo "val->calculatePenalty(".$lastPaymentDate.")"; // if balance is 0 leave penalty as is, otherwise calculatePenalty according to date now $balanceB = $val->getTotalTaxDue(); $penaltyLUTArray = $this->getPenaltyLUTArray(); switch ($lastPaymentDueType) { case "Q1": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-03-31")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; case "Q2": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-06-30")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; case "Q3": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-09-30")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; case "Q4": $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-12-31")); $btBasicTax = roundUpNearestFiveCent($val->getBasicTax() / 4); $btSefTax = roundUpNearestFiveCent($val->getSEFTax() / 4); $btIdleTax = roundUpNearestFiveCent($val->getIdleTax() / 4); $btTaxDue = $btBasicTax + $btSefTax + $btIdleTax; $btPenalty = $this->btCalculateQuarterlyPenalty($lastPaymentDate, $btTaxDue, $lastPaymentDueType, $btDueDate); $balanceB = $btTaxDue + $btPenalty - $totalPaid; break; } $penaltyComputeDate = $lastPaymentDate; // 0.1 is used instead of 0 because sometimes rounded off balances intended to be 0 end up appearing as 0.002 or so... if (round($balanceB, 4) > 0.1) { $val->calculatePenalty($this->now); $penaltyComputeDate = $this->now; $btBasicTax = $val->getBasicTax(); $btSefTax = $val->getSEFTax(); $btIdleTax = $val->getIdleTax(); $btTaxDue = $val->getBasicTax + $val->getSEFTax() + $val->getIdleTax(); $btPenalty = $val->getPenalties(); $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-03-31")); } } else { $val->calculatePenalty($this->now); $penaltyComputeDate = $this->now; $btBasicTax = $val->getBasicTax(); $btSefTax = $val->getSEFTax(); $btIdleTax = $val->getIdleTax(); $btTaxDue = $val->getBasicTax + $val->getSEFTax() + $val->getIdleTax(); $btPenalty = $val->getPenalties(); $btDueDate = date("M. d, Y", strtotime($val->getStartYear() . "-03-31")); } if ($amnestyStatus == "true") { $this->tpl->set_var("amnestyB", "<= waived"); $val->setPenalties(0); } else { $this->tpl->set_var("amnestyB", ""); } $this->tpl->set_var("backtaxTDID", $val->getBacktaxTDID()); $this->tpl->set_var("tdNumberB", $val->getTdNumber()); $this->tpl->set_var("startYearB", $val->getStartYear()); $this->tpl->set_var("endYearB", $val->getEndYear()); $this->tpl->set_var("startQuarterB", $val->getStartQuarter()); $this->tpl->set_var("assessedValueB", number_format($val->getAssessedValue(), 2)); $this->tpl->set_var("basicRateB", number_format($val->getBasicRate(), 2)); $this->tpl->set_var("sefRateB", number_format($val->getSEFRate(), 2)); $this->tpl->set_var("basicTaxB", number_format($val->getBasicTax(), 2)); $this->tpl->set_var("sefTaxB", number_format($val->getSEFTax(), 2)); $this->tpl->set_var("idleTaxB", number_format($val->getIdleTax(), 2)); $this->tpl->set_var("penaltiesB", number_format($val->getPenalties(), 2)); $this->tpl->set_var("paidB", number_format($val->getPaid(), 2)); $this->tpl->set_var("balanceB", number_format($val->getTotalTaxDue(), 2)); $this->tpl->set_var("totalTaxDueB", number_format($val->getTotal(), 2)); $this->formArray["totalBacktaxesDue"] = 0; $this->formArray["totalBacktaxesDue"] += $val->getBasicTax(); $this->formArray["totalBacktaxesDue"] += $val->getSefTax(); $this->formArray["totalBacktaxesDue"] += $val->getIdleTax(); $this->formArray["totalBacktaxesDue"] += $val->getPenalties(); $this->tpl->parse("BacktaxesListBlock", "BacktaxesList", true); $this->formArray["totalBacktaxesBalance"] += $val->getTotalTaxDue() + $val->getPaid(); $this->backtaxTDIDArray[] = $val->getBacktaxTDID(); } } else { //$this->tpl->set_block("TDList", "Backtax", "BacktaxBlock"); //$this->tpl->set_var("BacktaxBlock", ""); } } } }
function getBacktaxTDYearList() { $arr = array(); $BacktaxTDDetails = new SoapObject(NCCBIZ . "BacktaxTDDetails.php", "urn:Object"); if (!($xmlStr = $BacktaxTDDetails->getBacktaxTDList($this->formArray["tdID"]))) { } else { if (!($domDoc = domxml_open_mem($xmlStr))) { } else { $backtaxTDRecords = new BacktaxTDRecords(); $backtaxTDRecords->parseDomDocument($domDoc); $backTaxTDList = $backtaxTDRecords->getArrayList(); if (count($backTaxTDList)) { foreach ($backTaxTDList as $key => $val) { $arr[] = $val->getStartYear(); } } else { } } } return $arr; }
function displayBacktaxTD() { $BacktaxTDDetails = new SoapObject(NCCBIZ . "BacktaxTDDetails.php", "urn:Object"); if (!($xmlStr = $BacktaxTDDetails->getBacktaxTDList($this->formArray["tdID"]))) { $this->tpl->set_block("rptsTemplate", "BacktaxesTable", "BacktaxesTableBlock"); $this->tpl->set_var("BacktaxesTableBlock", ""); } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "BacktaxesTable", "BacktaxesTableBlock"); $this->tpl->set_var("BacktaxesTableBlock", ""); } else { $backtaxTDRecords = new BacktaxTDRecords(); $backtaxTDRecords->parseDomDocument($domDoc); $backTaxTDList = $backtaxTDRecords->getArrayList(); $this->tpl->set_block("rptsTemplate", "BacktaxesList", "BacktaxesListBlock"); $this->tpl->set_block("rptsTemplate", "BacktaxesDBEmpty", "BacktaxesDBEmptyBlock"); if (count($backTaxTDList)) { $this->tpl->set_var("BacktaxesDBEmptyBlock", ""); foreach ($backTaxTDList as $key => $val) { $this->tpl->set_var("backtaxTDID", $val->getBacktaxTDID()); $this->tpl->set_var("tdNumber", $val->getTdNumber()); $this->tpl->set_var("startYear", $val->getStartYear()); $this->tpl->set_var("endYear", $val->getEndYear()); $this->tpl->set_var("startQuarter", $val->getStartQuarter()); $this->tpl->set_var("assessedValue", number_format($val->getAssessedValue(), 2)); $this->tpl->set_var("basicRate", number_format($val->getBasicRate(), 2)); $this->tpl->set_var("sefRate", number_format($val->getSEFRate(), 2)); $this->tpl->set_var("basicTax", number_format($val->getBasicTax(), 2)); $this->tpl->set_var("sefTax", number_format($val->getSEFTax(), 2)); $this->tpl->set_var("idleTax", number_format($val->getIdleTax(), 2)); $this->tpl->set_var("penalties", number_format($val->getPenalties(), 2)); $this->tpl->set_var("paid", number_format($val->getPaid(), 2)); $this->tpl->set_var("balance", number_format($val->getBalance(), 2)); $this->tpl->set_var("total", number_format($val->getTotal(), 2)); $totalBacktaxesDue = 0; $totalBacktaxesDue += $val->getBasicTax(); $totalBacktaxesDue += $val->getSefTax(); $totalBacktaxesDue += $val->getIdleTax(); $totalBacktaxesDue += $val->getPenalties(); $this->tpl->parse("BacktaxesListBlock", "BacktaxesList", true); } } else { $this->tpl->set_var("BacktaxesListBlock", ""); } $this->tpl->set_var("total", number_format($totalBacktaxesDue, 2)); } } }
function displayBacktaxTDBalance() { $BacktaxTDDetails = new SoapObject(NCCBIZ . "BacktaxTDDetails.php", "urn:Object"); if (!($xmlStr = $BacktaxTDDetails->getBacktaxTDList($this->formArray["tdID"]))) { $this->tpl->set_var("backtaxBalance", "-"); } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_var("backtaxBalance", "-"); } else { $backtaxTDRecords = new BacktaxTDRecords(); $backtaxTDRecords->parseDomDocument($domDoc); $backTaxTDList = $backtaxTDRecords->getArrayList(); if (count($backTaxTDList)) { $this->tpl->set_var("BacktaxesDBEmptyBlock", ""); $backtaxBalance = 0; foreach ($backTaxTDList as $key => $val) { $backtaxBalance += $val->getBalance(); } $this->tpl->set_var("backtaxBalance", number_format($backtaxBalance, 2)); } else { $this->tpl->set_var("backtaxBalance", "-"); } } } }