コード例 #1
0
 public function executeView(sfWebRequest $request)
 {
     $this->account = $this->getRoute()->getObject();
     $this->form = $this->configuration->getForm($this->account);
     $this->startdate = $request->getParameter("startdate") ? $request->getParameter("startdate") : MyDateTime::today()->getstartofmonth()->tomysql();
     $this->enddate = $request->getParameter("enddate") ? $request->getParameter("enddate") : MyDateTime::today()->getendofmonth()->tomysql();
     $startentry = new AccountEntry();
     $startentry->setDate($this->startdate);
     $this->startdateform = new AccountentryForm($startentry);
     $endentry = new AccountEntry();
     $endentry->setDate($this->enddate);
     $this->enddateform = new AccountentryForm($endentry);
     //$accountentries=$account->getAccountEntriesDesc();
     $this->accountentries = $this->account->getAccountEntriesDescByDate($this->startdate, $this->enddate);
 }
コード例 #2
0
ファイル: Inventory.php プロジェクト: xander-mbaka/momentum
 function __construct($txId, $accountNo, $resource_id, $whenBooked, $whenCharged, $txType, $amount, $catalog_bal, $stock_bal, $description, $timestamp)
 {
     parent::__construct($txid, $accountNo, $whenBooked, $whenCharged);
     $this->resourceId = $resource_id;
     $this->stock_bal = $stock_bal;
     $this->catalog_bal = $catalog_bal;
     $this->amount = $amount;
     $this->txType = $txType;
     $this->description = $description;
     $this->timestamp = $timestamp;
     //create database entry
 }
コード例 #3
0
ファイル: index.php プロジェクト: xander-mbaka/momentum
 public function findEntries($param, $value)
 {
     if ($this->validateAdmin()) {
         echo json_encode(AccountEntry::FindEntries($param, $value));
     } else {
         echo 0;
     }
 }
コード例 #4
0
ファイル: Accounting.php プロジェクト: xander-mbaka/momentum
 public static function Reverse($txid)
 {
     try {
         $sql = 'SELECT * FROM transactions WHERE id = ' . $txid;
         // Execute the query and return the results
         $tx = DatabaseHandler::GetRow($sql);
         if (empty($tx['id'])) {
             return false;
         }
         $entries = AccountEntry::GetTransactionEntries($txid);
         foreach ($entries as $entry) {
             if ($entry['status'] == 3) {
                 return false;
             }
         }
     } catch (Exception $e) {
         Logger::Log('Transaction', 'Exception', $e->getMessage());
         return false;
     }
     $amount = new Money($tx['amount'], Currency::Get('KES'));
     $transaction = new FinancialTransaction($amount, 'Reversal for TX id: ' . $tx['id'], new Reversal());
     $cr = 0.0;
     $dr = 0.0;
     foreach ($entries as $entry) {
         switch ($entry['ledger_name']) {
             case 'Creditors':
                 $table = 'suppliers';
                 break;
             case 'Debtors':
                 $table = 'clients';
                 break;
             case 'Payroll':
                 $table = 'employees';
                 break;
             default:
                 break;
         }
         if ($entry['effect'] == 'cr') {
             $dr = $dr + $entry['amount'];
             $dramt = new Money(floatval($entry['amount']), Currency::Get('KES'));
             if ($entry['ledger_id'] == $entry['account_no']) {
                 $account = Account::GetLedger($entry['ledger_id']);
             } else {
                 $account = Account::GetAccountByNo($entry['account_no'], $table, $entry['ledger_name']);
             }
             $entry = new AccountEntry($transaction, $account, $dramt, $transaction->date, 'dr');
             $entry->reversal = 3;
             $transaction->add($entry);
         } else {
             if ($entry['effect'] == 'dr') {
                 $cr = $cr + $entry['amount'];
                 $cramt = new Money(floatval($entry['amount']), Currency::Get('KES'));
                 if ($entry['ledger_id'] == $entry['account_no']) {
                     $account = Account::GetLedger($entry['ledger_id']);
                 } else {
                     $account = Account::GetAccountByNo($entry['account_no'], $table, $entry['ledger_name']);
                 }
                 $entry = new AccountEntry($transaction, $account, $cramt, $transaction->date, 'cr');
                 $entry->reversal = 3;
                 $transaction->add($entry);
             }
         }
     }
     if ($cr - $dr == 0.0) {
         foreach ($transaction->entries as $entry) {
             $entry->post();
         }
         try {
             $sql = 'UPDATE transactions SET status = 1, entries = ' . count($transaction->entries) . ', user = "******" WHERE id = ' . $transaction->transactionId;
             DatabaseHandler::Execute($sql);
             $transaction->posted = true;
             $sqla = 'UPDATE general_ledger_entries SET status = 3 WHERE transaction_id = ' . $txid;
             DatabaseHandler::Execute($sqla);
             Logger::Log('Transaction', 'Ok', 'Transaction id:' . $transaction->transactionId . ' posted by ' . SessionManager::GetUsername());
             return true;
         } catch (Exception $e) {
         }
     } else {
         //throw new Exception("The entries are not conservative. Probable system leak!");
         Logger::Log('Transaction', 'Exception', 'The entries are not conservative. Probable system leak! CR: ' . $cr . ', DR: ' . $dr);
         return false;
     }
     //verify account and entry is of the same resource type;
     //enter the
 }
コード例 #5
0
 function __construct($eventId, Account $account, Resource $item, Quantity $quantity)
 {
     parent::__construct($eventId, $account, $item);
 }