예제 #1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Incomes the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Incomes::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #2
0
파일: Person.php 프로젝트: wanyos2005/hsbf
 /**
  * @return Person models
  */
 public function membersForTrialBalance()
 {
     $incm = Incomes::model()->tableName();
     $exps = Expenditures::model()->tableName();
     $user = Users::model()->tableName();
     $cri = new CDbCriteria();
     $cri->select = 't.id, t.first_name, t.middle_name, t.last_name';
     $cri->distinct = true;
     $cri->condition = "(EXISTS (SELECT member FROM {$incm} WHERE member=t.id LIMIT 1) || " . "EXISTS (SELECT member FROM {$exps} WHERE member=t.id LIMIT 1)) && " . "EXISTS (SELECT id FROM {$user} WHERE id=t.id && status=:stts)";
     $cri->params = array(':stts' => Users::STATUS_ACTIVE);
     $cri->order = 't.first_name ASC, t.middle_name ASC, t.last_name ASC';
     return $this->findAll($cri);
 }
예제 #3
0
 /**
  * Save a contribution conditionally
  * then record a loan repayment appropriately
  * and update subsequent loan repayments.
  * 
  * @param \ContributionsByMembers $model
  * @param boolean $rectifySubsequentRepayments TRUE = Rectify Subsequent Loan Repayments; FALSE = Not Rectify Subsequent Loan Repayments
  */
 public function modelSave($model, $rectifySubsequentRepayments)
 {
     if (($new = $model->isNewRecord) && empty($model->amount)) {
     } else {
         if ($model->save()) {
             if ($model->contribution_type == 4 && $rectifySubsequentRepayments == true) {
                 LoanRepayments::model()->updateRepayments($model);
             }
             if ($new && $model->contribution_type == 3) {
                 Savings::model()->contributionToSavings($model);
             }
             Incomes::model()->contributionIsIncome($model);
             NextReceiptNo::model()->updateNextReceiptNo($model->receiptno);
             Yii::app()->user->setFlash('saved', 'Your contribution has been succcessfully saved');
             return true;
         }
     }
     return false;
 }
예제 #4
0
 /**
  * type of journal to generate
  */
 public function actionWhichJournal()
 {
     $dates = self::orderDates();
     switch ($_POST['type']) {
         case Voteheads::EXPENSE:
             Expenditures::model()->printExpenditureJournal($dates['since'], $dates['till']);
             break;
         case Voteheads::INCOME:
             Incomes::model()->printIncomeJournal($dates['since'], $dates['till']);
             break;
         default:
             Expenditures::model()->printExpenditureJournal($dates['since'], $dates['till']);
             break;
     }
 }
예제 #5
0
 /**
  * 
  * @param int $member person id
  * @param date $date yyyy-mm-dd
  * @param date $till yyyy-mm-dd
  * @return double net income at end of this day
  */
 public function netMembersIncomeAfterYesterday($member, $date, $till)
 {
     return array('income' => Incomes::model()->totalIncomeFromMemberFromStartToIncludingThisDate($member, LoanApplications::model()->dayBefore($date), $till), 'expenditure' => $this->totalExpenditureOnMemberFromStartToIncludingThisDate($member, LoanApplications::model()->dayBefore($date), $till));
 }