示例#1
0
 /**
  * @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);
 }
示例#2
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;
 }
示例#3
0
</td>
        <td><?php 
echo $form->error($model, 'amount');
?>
</td>
    </tr>

    <tr><td colspan="2">&nbsp;</td></tr>

    <tr>
        <td><?php 
echo $form->labelEx($model, 'cask_or_bank');
?>
</td>
        <td><?php 
echo $form->dropDownList($model, 'cask_or_bank', Incomes::toBankOrCash());
?>
</td>
        <td><?php 
echo $form->error($model, 'cask_or_bank');
?>
</td>
    </tr>

    <tr><td colspan="2">&nbsp;</td></tr>

    <tr>
        <td><?php 
echo $form->labelEx($model, 'description');
?>
</td>
示例#4
0
 /**
  * 
  * @param Expenditures $expense model
  */
 public function withdrawalFromBankIsIncome($expense)
 {
     $income = $this->find('trans_channes=:chnl && associated_id=:id', array(':chnl' => $className = get_class($expense), ':id' => $expense->primaryKey));
     $nextReceiptNo = false;
     if (empty($income)) {
         $income = new Incomes();
         $income->votehead = $expense->votehead;
         $income->trans_channes = $className;
         $income->associated_id = $expense->id;
         $income->receipt_no = NextReceiptNo::model()->receiptNo();
         $income->member = $expense->member;
         $income->description = $expense->description;
         $income->cask_or_bank = ContributionsByMembers::PAYMENT_BY_BANK;
         $income->logged_in = Yii::app()->user->id;
         $income->date = $expense->date;
         $nextReceiptNo = true;
     }
     $income->amount = $expense->amount;
     if ($income->save(false) && $nextReceiptNo) {
         NextReceiptNo::model()->updateNextReceiptNo($income->receipt_no);
     }
 }
 /**
  * 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;
     }
 }
 /**
  * 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;
 }
示例#7
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));
 }