/**
   Apply action
   @return [boolean] true if the action
     completes successfully (or is not
     necessary at all) or [string] url
     to redirect to another page for
     further decisions/input.
 */
 public function apply()
 {
     // Is the before-tax total within range?
     if (CoreLocal::get("runningTotal") <= 4.0) {
         $totalBefore = CoreLocal::get("amtdue");
         $ret = Database::changeLttTaxCode("HST", "GST");
         if ($ret !== true) {
             TransRecord::addcomment("{$ret}");
         } else {
             Database::getsubtotals();
             $saved = $totalBefore - CoreLocal::get("amtdue");
             $comment = sprintf("OMTR OK. You saved: \$%.2f", $saved);
             TransRecord::addcomment("{$comment}");
         }
     } else {
         TransRecord::addcomment("Does NOT qualify for OMTR");
     }
     return true;
 }
Example #2
0
 /**
   Total the transaction, which the cashier thinks may be eligible for the
      Ontario Meal Tax Rebate.
   @return
    True - total successfully
    String - URL
   If ttl() returns a string, go to that URL for
   more information on the error or to resolve the
   problem. 
   The most common error, by far, is no 
   member number in which case the return value
   is the member-entry page.
   The Ontario Meal Tax Rebate refunds the provincial part of the
   Harmonized Sales Tax if the total of the transaction is not more
   than a certain amount.
   If the transaction qualifies,
    change the tax status for each item at the higher rate to the lower rate.
    Display a message that a change was made.
   Otherwise display a message about that.
   Total the transaction as usual.
 */
 public static function omtr_ttl()
 {
     // Must have gotten member number before totaling.
     if (CoreLocal::get("memberID") == "0") {
         return MiscLib::base_url() . "gui-modules/memlist.php";
     } else {
         self::addRemoveDiscountViews();
         CoreLocal::set("ttlflag", 1);
         Database::setglobalvalue("TTLFlag", 1);
         // Refresh totals after staff and member discounts.
         Database::getsubtotals();
         // Is the before-tax total within range?
         if (CoreLocal::get("runningTotal") <= 4.0) {
             $totalBefore = CoreLocal::get("amtdue");
             $ret = Database::changeLttTaxCode("HST", "GST");
             if ($ret !== True) {
                 TransRecord::addcomment("{$ret}");
             } else {
                 Database::getsubtotals();
                 $saved = $totalBefore - CoreLocal::get("amtdue");
                 $comment = sprintf("OMTR OK. You saved: \$%.2f", $saved);
                 TransRecord::addcomment("{$comment}");
             }
         } else {
             TransRecord::addcomment("Does NOT qualify for OMTR");
         }
         /* If member can do Store Charge, warn on certain conditions.
          * Important preliminary is to refresh totals.
          */
         $temp = self::chargeOk();
         if (CoreLocal::get("balance") < CoreLocal::get("memChargeTotal") && CoreLocal::get("memChargeTotal") > 0) {
             if (CoreLocal::get('msgrepeat') == 0) {
                 CoreLocal::set("boxMsg", sprintf("<b>A/R Imbalance</b><br />\n                    Total AR payments \$%.2f exceeds AR balance %.2f<br />", CoreLocal::get("memChargeTotal"), CoreLocal::get("balance")));
                 CoreLocal::set('boxMsgButtons', array('Confirm [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
                 CoreLocal::set("strEntered", "TL");
                 return MiscLib::base_url() . "gui-modules/boxMsg2.php?quiet=1";
             }
         }
         // Display discount.
         if (CoreLocal::get("percentDiscount") > 0) {
             TransRecord::addRecord(array('description' => CoreLocal::get('percentDiscount') . '% Discount', 'trans_type' => 'C', 'trans_status' => 'D', 'unitPrice' => MiscLib::truncate2(-1 * CoreLocal::get('transDiscount')), 'voided' => 5));
         }
         $amtDue = str_replace(",", "", CoreLocal::get("amtdue"));
         // Compose the member ID string for the description.
         if (CoreLocal::get("memberID") != CoreLocal::get("defaultNonMem")) {
             $memline = " #" . CoreLocal::get("memberID");
         } else {
             $memline = "";
         }
         // Put out the Subtotal line.
         $peek = self::peekItem();
         if (True || substr($peek, 0, 9) != "Subtotal ") {
             TransRecord::addRecord(array('description' => 'Subtotal ' . MiscLib::truncate2(CoreLocal::get('subtotal')) . ', Tax' . MiscLib::truncate2(CoreLocal::get('taxTotal')) . $memline, 'trans_type' => 'C', 'trans_status' => 'D', 'unitPrice' => $amtDue, 'voided' => 3));
         }
         if (CoreLocal::get("fntlflag") == 1) {
             TransRecord::addRecord(array('description' => 'Foodstamps Eligible', 'trans_type' => '0', 'trans_status' => 'D', 'unitPrice' => MiscLib::truncate2(CoreLocal::get('fsEligible')), 'voided' => 7));
         }
     }
     return True;
     // omtr_ttl
 }