function incrementValues($suffixKey, $payment)
 {
     $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object");
     $condition = "WHERE " . COLLECTION_TABLE . ".paymentID='" . $payment->getPaymentID() . "' AND " . COLLECTION_TABLE . ".status!='cancelled'";
     if ($xmlStr = $CollectionList->getCollectionList($condition)) {
         if ($domDoc = domxml_open_mem($xmlStr)) {
             $collectionRecords = new CollectionRecords();
             $collectionRecords->parseDomDocument($domDoc);
             if (is_array($collectionRecords->getArrayList())) {
                 $list = $collectionRecords->getArrayList();
                 foreach ($list as $collection) {
                     $receipt = $this->getReceipt($collection->getReceiptID());
                     if (is_object($receipt)) {
                         if ($receipt->getPaymentMode() == "cash") {
                             switch ($collection->getTaxType()) {
                                 case "basic":
                                     $dueDateYear = date("Y", strtotime($payment->getDueDate()));
                                     if ($dueDateYear < $this->formArray["year"]) {
                                         $this->computeIncrementValues($suffixKey, $collection, "prior", "basic");
                                     } else {
                                         $this->computeIncrementValues($suffixKey, $collection, "current", "basic");
                                     }
                                     break;
                                 case "sef":
                                     $dueDateYear = date("Y", strtotime($payment->getDueDate()));
                                     if ($dueDateYear < $this->formArray["year"]) {
                                         $this->computeIncrementValues($suffixKey, $collection, "prior", "sef");
                                     } else {
                                         $this->computeIncrementValues($suffixKey, $collection, "current", "sef");
                                     }
                                     break;
                                 case "idle":
                                     $dueDateYear = date("Y", strtotime($payment->getDueDate()));
                                     if ($dueDateYear < $this->formArray["year"]) {
                                         $this->computeIncrementValues($suffixKey, $collection, "prior", "idle");
                                     } else {
                                         $this->computeIncrementValues($suffixKey, $collection, "current", "idle");
                                     }
                                     break;
                             }
                         } else {
                             $this->formArray["totalNonCash" . $suffixKey] += $collection->getAmountPaid();
                             $this->formArray["grandTotalNetCol" . $suffixKey] += $collection->getAmountPaid();
                         }
                     }
                 }
             }
         }
     }
 }
 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", "");
             }
         }
     }
 }
Пример #3
0
 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", "");
             }
         }
     }
 }
Пример #4
0
 function Main()
 {
     $this->setForm();
     $this->tpl->set_block("rptsTemplate", "ReceiptPage", "ReceiptPageBlock");
     $pageNumber = 1;
     $ReceiptDetails = new SoapObject(NCCBIZ . "ReceiptDetails.php", "urn:Object");
     $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object");
     $PaymentDetails = new SoapObject(NCCBIZ . "PaymentDetails.php", "urn:Object");
     foreach ($this->formArray["receiptIDArray"] as $receiptID) {
         $this->tpl->set_var("pageNumber", $pageNumber);
         $totalAmountPaid = 0;
         $eRPTSSettings = $this->getERPTSSettingsDetails();
         if ($eRPTSSettings->getLguType() == "City") {
             $this->setvar("city", $eRPTSSettings->getLguName());
             $this->setvar("province", "");
         } else {
             $this->setvar("city", "");
             $this->setvar("province", $eRPTSSettings->getLguName());
         }
         if (!($xmlStr = $ReceiptDetails->getReceipt($receiptID))) {
             //exit("xml failed.");
         } else {
             if (!($domDoc = domxml_open_mem($xmlStr))) {
                 //exit("error domDoc");
             } else {
                 $receipt = new Receipt();
                 $receipt->parseDomDocument($domDoc);
                 $this->setvar("prevORNum", $receipt->getPreviousReceiptNumber());
                 $porMonth = "";
                 $porDay = "";
                 $porYear = "";
                 if ($receipt->getPreviousReceiptDate() != "0000-00-00") {
                     $porMonth = date("F", strtotime($receipt->getPreviousReceiptDate()));
                     $porDay = date("d", strtotime($receipt->getPreviousReceiptDate()));
                     $porYear = date("Y", strtotime($receipt->getPreviousReceiptDate()));
                 }
                 $this->setvar("porMonth", $porMonth);
                 $this->setvar("porDay", $porDay);
                 $this->setvar("porYear", $porYear);
                 $this->setvar("orNum", $receipt->getReceiptNumber());
                 $orDate = "";
                 if ($receipt->getReceiptDate() != "0000-00-00") {
                     $orDate = date("F d, Y", strtotime($receipt->getReceiptDate()));
                 }
                 $this->setvar("orDate", $orDate);
                 $this->setvar("receivedFrom", $this->getReceivedFromName($receipt->getReceivedFrom()));
                 $this->setvar("paymentMode", $receipt->getPaymentMode());
                 if ($receipt->getPaymentMode() == "check") {
                     $this->setvar("checkNumber", "using Check Number : " . $receipt->getCheckNumber());
                     $this->setvar("dateOfCheck", " dated " . date("F d, Y", strtotime($receipt->getDateOfCheck())));
                     $this->setvar("draweeBank", "(" . $receipt->getDraweeBank() . ")");
                 }
                 $this->setvar("cityTreasurer", $this->getPersonName($receipt->getCityTreasurer()));
                 $this->setvar("deputyTreasurer", $this->getPersonName($receipt->getDeputyTreasurer()));
                 if (!($collectionXmlStr = $CollectionList->getCollectionListFromReceiptID($receiptID))) {
                     // xml failed
                 } else {
                     if (!($collectionDomDoc = domxml_open_mem($collectionXmlStr))) {
                         // error domDoc
                     } else {
                         $collectionRecords = new CollectionRecords();
                         $collectionRecords->parseDomDocument($collectionDomDoc);
                         $collectionArrayList = $collectionRecords->getArrayList();
                         $i = 0;
                         foreach ($collectionArrayList as $collection) {
                             $i++;
                             if ($i <= 1) {
                                 if ($collection->getTaxType() == "basic") {
                                     $this->setvar("receiptType", "[ X ]  BASIC TAX      [  ]  SPECIAL EDUCATION FUND");
                                 } else {
                                     if ($collection->getTaxType() == "sef") {
                                         $this->setvar("receiptType", "[  ]  BASIC TAX     [ X ]  SPECIAL EDUCATION FUND");
                                     } else {
                                         if ($collection->getTaxType() == "idle") {
                                             $this->setvar("receiptType", "[  ]  BASIC TAX     [  ]  SPECIAL EDUCATION FUND     [ X ]  IDLE TAX");
                                         }
                                     }
                                 }
                             }
                             $paymentID = $collection->getPaymentID();
                             if (!($paymentXmlStr = $PaymentDetails->getPayment($paymentID))) {
                                 // xml failed
                             } else {
                                 if (!($paymentDomDoc = domxml_open_mem($paymentXmlStr))) {
                                     // error domDoc
                                 } else {
                                     $payment = new Payment();
                                     $payment->parseDomDocument($paymentDomDoc);
                                     $assessedValue = 0;
                                     // added "orYear" for fix of Feb 08, 2005
                                     $this->formArray["orYear"] = substr($payment->dueDate, 0, 4);
                                     $this->setvar("orYear", $this->formArray["orYear"], false);
                                     if ($i <= 6) {
                                         $this->setvar("ownerName" . $i, $this->getReceivedFromName($receipt->getReceivedFrom()));
                                         if ($payment->getDueID() != "" && $payment->getDueID() != "0") {
                                             // due payment
                                             $due = $this->getDue($payment->getDueID());
                                             $td = $this->getTD($due->getTdID());
                                             $afs = $this->getAFS($td->getAfsID());
                                             $tdNum = $td->getTaxDeclarationNumber();
                                             if ($td->getPropertyType() == "Land") {
                                                 $this->setvar("assessedValueLand" . $i, $afs->getTotalAssessedValue(), true);
                                             } else {
                                                 $this->setvar("assessedValueOthers" . $i, $afs->getTotalAssessedValue(), true);
                                             }
                                             $assessedValue = $afs->getTotalAssessedValue();
                                             if ($payment->getDueType() == "Annual") {
                                                 // commented out: February 08, 2005
                                                 // "fullPmt" must be total paid less penalties... (tax due)
                                                 //$this->setvar("fullPmt".$i,$collection->getBalanceDue(),true);
                                                 $this->setvar("fullPmt" . $i, $collection->getTaxDue(), true);
                                             } else {
                                                 $this->setvar("num" . $i, $payment->getDueType());
                                                 // commented out: February 08, 2005
                                                 // $this->setvar("partialPmt".$i,$collection->getBalanceDue(),true);
                                                 $this->setvar("partialPmt" . $i, $collection->getTaxDue(), true);
                                             }
                                         } else {
                                             if ($payment->getBacktaxTDID() != "" && $payment->getBacktaxTDID() != "0") {
                                                 // backtaxtd payment
                                                 $backtaxTD = $this->getBacktaxTD($payment->getBacktaxTDID());
                                                 $parentTD = $this->getTD($backtaxTD->getTdID());
                                                 $afs = $this->getAFS($parentTD->getAfsID());
                                                 $tdNum = $backtaxTD->getTDNumber();
                                                 $assessedValue = $backtaxTD->getAssessedValue();
                                                 if ($payment->getDueType() == "Annual") {
                                                     // commented out: February 08, 2005
                                                     // $this->setvar("fullPmt".$i,$collection->getBalanceDue(),true);
                                                     $this->setvar("fullPmt" . $i, $collection->getTaxDue(), true);
                                                 } else {
                                                     $this->setvar("num" . $i, $payment->getDueType());
                                                     // commented out: February 08, 2005
                                                     // $this->setvar("partialPmt".$i,$collection->getBalanceDue(),true);
                                                     $this->setvar("partialPmt" . $i, $collection->getTaxDue(), true);
                                                 }
                                             }
                                         }
                                         $od = $this->getOD($afs->getOdID());
                                         $this->setvar("lotAddress" . $i, $od->locationAddress->getStreet() . ", " . $od->locationAddress->getBarangay());
                                         $this->setvar("blockNumber" . $i, $od->getLotNumber() . ", " . $od->getBlockNumber());
                                         $this->setvar("landClass" . $i, $payment->getPropertyClassification());
                                         $this->setvar("tdNum" . $i, $tdNum);
                                         $this->setvar("dueDate" . $i, "(" . substr($payment->getDueDate(), 0, 4) . ")");
                                         $this->setvar("assessedValue" . $i, $assessedValue, true);
                                         $this->setvar("subTotal" . $i, $collection->getTaxDue(), true);
                                         if ($collection->getPenalty() > 0) {
                                             if ($collection->getAmnesty() == "true") {
                                                 //	$this->setvar("penalty".$i,round((($collection->getPenalty()/$collection->getTaxDue())*100)) . " % (amnesty)",true);
                                                 $this->setvar("penalty" . $i, $collection->getPenalty());
                                             } else {
                                                 // $this->setvar("penalty".$i,round((($collection->getPenalty()/$collection->getTaxDue())*100)) . " %",true);
                                                 $this->setvar("penalty" . $i, $collection->getPenalty());
                                             }
                                         }
                                         $this->setvar("grandTotal" . $i, $collection->getAmountPaid(), true);
                                         $totalAmountPaid += $collection->getAmountPaid();
                                         //Inserted by cht 07282008
                                         $sefTotal = $total;
                                         $netAmountPaid = $totalAmountPaid * 2;
                                         //End
                                     }
                                 }
                             }
                         }
                     }
                     // ORIG
                     //$this->setvar("total",$totalAmountPaid,true);
                     //$this->setvar("amountPaid",$totalAmountPaid,true);
                     //$totalInWords = makewords($totalAmountPaid);
                     $this->setvar("sefTotal", $totalAmountPaid, true);
                     $this->setvar("total", $totalAmountPaid, true);
                     $this->setvar("amountPaid", $netAmountPaid, true);
                     $totalInWords = makewords($netAmountPaid);
                     //						$totalInWords = "One Hundred Thousand Two Hundred Thirty Four Pesos And Fifty Seven Centavos Only";
                     if (strlen($totalInWords) < 62) {
                         $this->setvar("y1TotalInWords", "254");
                     } else {
                         $this->setvar("y1TotalInWords", "263");
                     }
                     $this->setvar("totalInWords", $totalInWords);
                 }
             }
         }
         $this->tpl->parse("ReceiptPageBlock", "ReceiptPage", true);
         $pageNumber++;
         $this->clearLine();
     }
     //exit;
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $testpdf = new PDFWriter();
     $testpdf->setOutputXML($this->tpl->get("templatePage"), "test");
     if (isset($this->formArray["print"])) {
         $testpdf->writePDF($name);
         //,$this->formArray["print"]);
     } else {
         $testpdf->writePDF($name);
     }
 }
Пример #5
0
 function getPaidTotals($dueID, $backtaxTDID, $dueType, $taxType)
 {
     $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object");
     $totalAmountPaid = 0;
     if (!($xmlStr = $CollectionList->getCollectionListFromDueTaxType($dueID, $backtaxTDID, $dueType, $taxType))) {
         return 0;
     } else {
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             return 0;
         } else {
             $collectionRecords = new CollectionRecords();
             $collectionRecords->parseDomDocument($domDoc);
             $collectionArrayList = $collectionRecords->getArrayList();
             foreach ($collectionArrayList as $collection) {
                 $totalAmountPaid += $collection->getAmountPaid();
             }
         }
     }
     return $totalAmountPaid;
 }
Пример #6
0
 function getCollectionRecordsFromPaymentID($paymentID)
 {
     $condition = " WHERE paymentID=" . $paymentID . " AND status!='cancelled' AND taxType!='idle' ";
     $collectionRecords = new CollectionRecords();
     $collectionRecords->selectRecords($condition);
     if (is_array($collectionRecords->arrayList)) {
         return $collectionRecords;
     } else {
         return false;
     }
 }
Пример #7
0
 function getCollectionRecordsFromReceiptID($receiptID)
 {
     $condition = " WHERE receiptID = '" . $receiptID . "'";
     $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object");
     if (!($xmlStr = $CollectionList->getCollectionList($condition))) {
         echo "error collectionXml";
         return false;
     } else {
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             echo "error collectionDomDoc";
             return false;
         } else {
             $collectionRecords = new CollectionRecords();
             $collectionRecords->parseDomDocument($domDoc);
             return $collectionRecords;
         }
     }
 }
Пример #8
0
 function getTaxType($receiptID)
 {
     $taxType = "";
     $condition = "WHERE receiptID='" . $receiptID . "'";
     $collectionRecords = new CollectionRecords();
     if ($collectionRecords->selectRecords($condition)) {
         if (count($collectionRecords->arrayList) > 0) {
             $collection = $collectionRecords->arrayList[0];
             $taxType = strtoupper($collection->getTaxType());
         }
     }
     return $taxType;
 }
Пример #9
0
 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", "");
             }
         }
     }
 }
Пример #10
0
 function getCollectionCount($condition = "")
 {
     $collectionRecords = new CollectionRecords();
     return $collectionRecords->countRecords($condition);
 }
 function incrementValues($payment)
 {
     $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object");
     $condition = "WHERE " . COLLECTION_TABLE . ".paymentID='" . $payment->getPaymentID() . "' AND " . COLLECTION_TABLE . ".status!='cancelled'";
     if ($xmlStr = $CollectionList->getCollectionList($condition)) {
         if ($domDoc = domxml_open_mem($xmlStr)) {
             $collectionRecords = new CollectionRecords();
             $collectionRecords->parseDomDocument($domDoc);
             if (is_array($collectionRecords->getArrayList())) {
                 $list = $collectionRecords->getArrayList();
                 foreach ($list as $collection) {
                     switch ($collection->getTaxType()) {
                         case "basic":
                             $this->computeIncrementValues($collection, "basic");
                             break;
                         case "sef":
                             $this->computeIncrementValues($collection, "sef");
                             break;
                         case "idle":
                             $this->computeIncrementValues($collection, "idle");
                             break;
                     }
                 }
             }
         }
     }
 }
Пример #12
0
 function cancelReceiptList($receiptIDArray = "")
 {
     if (is_array($receiptIDArray)) {
         $collectionRecords = new CollectionRecords();
         $collection = new Collection();
         $receipt = new Receipt();
         $payment = new Payment();
         foreach ($receiptIDArray as $receiptID) {
             // find other receipts associated to payment
             $collectionRecords->selectRecords("WHERE receiptID='" . $receiptID . "'");
             $paymentID = $collectionRecords->arrayList[0]->getPaymentID();
             $collectionRecords->selectRecords("WHERE paymentID='" . $paymentID . "'");
             if (is_array($collectionRecords->getArrayList())) {
                 foreach ($collectionRecords->getArrayList() as $collection) {
                     $cancelReceiptIDArray[] = $collection->getReceiptID();
                     $cancelPaymentIDArray[] = $collection->getPaymentID();
                     $cancelCollectionIDArray[] = $collection->getCollectionID();
                 }
             }
         }
         $cancelCollectionIDArray = array_unique($cancelCollectionIDArray);
         $cancelReceiptIDArray = array_unique($cancelReceiptIDArray);
         $cancelPaymentIDArray = array_unique($cancelPaymentIDArray);
         foreach ($cancelCollectionIDArray as $collectionID) {
             $collection->selectRecord($collectionID);
             $collection->setStatus("cancelled");
             $collection->updateRecord();
         }
         $condition = " WHERE ";
         foreach ($cancelReceiptIDArray as $receiptID) {
             if ($condition != " WHERE ") {
                 $condition .= " OR ";
             }
             $condition .= " receiptID = '" . $receiptID . "' ";
             $receipt->selectRecord($receiptID);
             $receipt->setStatus("cancelled");
             $receipt->updateRecord();
         }
         foreach ($cancelPaymentIDArray as $paymentID) {
             $payment->selectRecord($paymentID);
             $payment->setStatus("cancelled");
             $payment->updateRecord();
         }
         // cancel associated mergedReceipts
         $receiptRecords = new ReceiptRecords();
         if ($receiptRecords->selectRecords($condition)) {
             if (!($domDoc = $receiptRecords->getDomDocument())) {
                 return false;
             } else {
                 $xmlStr = $domDoc->dump_mem(true);
                 return $xmlStr;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #13
0
 function buildCollectionArrayList($taxType, $receiptID)
 {
     $collectionArrayList = $taxType . "CollectionArrayList";
     $CollectionList = new SoapObject(NCCBIZ . "CollectionList.php", "urn:Object");
     if (!($collectionXmlStr = $CollectionList->getCollectionListFromReceiptID($receiptID))) {
         // xml failed
         return false;
     } else {
         if (!($collectionDomDoc = domxml_open_mem($collectionXmlStr))) {
             // error domDoc
             return false;
         } else {
             $collectionRecords = new CollectionRecords();
             $collectionRecords->parseDomDocument($collectionDomDoc);
             $arrayList = $collectionRecords->getArrayList();
             if (is_array($arrayList)) {
                 foreach ($arrayList as $collection) {
                     $this->totalAmountPaid += $collection->getAmountPaid();
                     array_push($this->{$collectionArrayList}, $collection);
                 }
             }
         }
     }
     return true;
 }