コード例 #1
0
 /**
  * makes a stock ledger entry
  * 
  * @param int $stkid stock id
  * @param char $type [c/d] whether contra should be debited/credited
  * @param int $contra contra account
  * @param string $date date of transaction
  * @param int $refno transaction reference number
  * @param float $amount transaction amount
  * @param char $vat [y/n] vat yes/no
  * @param string $details details of transaction
  * @return boolean true on success
  */
 function makeStockLedger($stkid, $type, $contra, $date, $refno, $amount, $vat, $details)
 {
     global $complete;
     if ($type == "c") {
         $debitacc = null;
         $creditacc = $contra;
     } else {
         $debitacc = $contra;
         $creditacc = null;
     }
     $this->cols = array("iid" => $stkid, "debitacc" => $debitacc, "creditacc" => $creditacc, "date" => $date, "refno" => $refno, "amount" => $amount, "details" => $details);
     if (!is_null($debitacc) && !clsIncludes::incExist("accounts", $debitacc)) {
         clsIncludes::add_account($debitacc);
     }
     if (!is_null($creditacc) && !clsIncludes::incExist("accounts", $creditacc)) {
         clsIncludes::add_account($creditacc);
     }
     if (!isset($complete["STOCK"][$stkid])) {
         $complete["STOCK"][$stkid] = new clsInfoObj("STOCK", $stkid);
         return $complete["STOCK"][$stkid]->dbMake("SELECT * FROM cubit.stock WHERE stkid='{$stkid}'");
     }
     return true;
 }