コード例 #1
0
ファイル: cashBookBody.php プロジェクト: wanyos2005/hsbf
                <table style="margin: 0; padding: 0">
                    <tr>
                        <td style="width: 45px"><font size="8"></font></td>
                        <td style="width: 125px"><font size="8"></font></td>
                        <td style="width: 40px; text-align: right"><font size="8"></font></td>
                        <td style="width: 40px; text-align: right"><font size="8"></font></td>
                    </tr>
                </table>
            </td>
        </tr>

        <?php 
    if ($netBankExpenditures != $netBankIncomes || $netCashExpenditures != $netCashIncomes) {
        ?>
            <?php 
        $morrow = LoanApplications::model()->dayAfter($till);
        ?>
            <tr>
                <td style="border-right: 2px solid #000000" size="8">
                    <?php 
        if ($netBankIncomes > $netBankExpenditures || $netCashIncomes > $netCashExpenditures) {
            ?>
                        <table style="margin: 0; padding: 0">
                            <tr>
                                <td style="width: 45px"><font size="8"><?php 
            echo $morrow;
            ?>
</font></td>
                                <td style="width: 125px"><font size="8">Balance b/d</font></td>
                                <td style="width: 40px; text-align: right"><font size="8"><?php 
            if ($netBankIncomes > $netBankExpenditures) {
コード例 #2
0
ファイル: _sideLinks2.php プロジェクト: wanyos2005/hsbf
<?php

$id = Yii::app()->user->id;
?>

<?php 
$true = false;
foreach (ContributionTypes::model()->findAll('id>1') as $type) {
    if ($type->primaryKey == 4) {
        $true = $true || LoanApplications::model()->memberHasALoan($id);
    } else {
        $true = $true || ContributionsByMembers::model()->memberHasAContribution($id, $type->primaryKey);
    }
}
?>

<?php 
if ($true) {
    ?>
    <li class="<?php 
    echo isset($_REQUEST['active']) && $_REQUEST['active'] == 'papulo' ? 'active' : '';
    ?>
">
        <a
        <?php 
    if (isset($_REQUEST['active']) && $_REQUEST['active'] == 'papulo') {
        ?>

                <?php 
    } else {
        ?>
コード例 #3
0
ファイル: Incomes.php プロジェクト: wanyos2005/hsbf
 /**
  * 
  * @param array $balanceRows rows for trial balance
  * @param Person $members models
  * @param date $since yyyy-mm-dd
  * @param date $till yyyy-mm-dd
  * @return array rows for trial balance
  */
 public function balancesForMembers($balanceRows, $members, $since, $till)
 {
     foreach ($members as $member) {
         $balance = Expenditures::model()->netMembersIncomeAfterYesterday($member->id, $since, LoanApplications::model()->dayAfter($till));
         $netIncomes = $netExpenditures = $balance['income']['total'] - $balance['expenditure']['total'];
         if ($netIncomes > 0) {
             $netExpenditures = null;
         } else {
             $netExpenditures = abs($netExpenditures);
             $netIncomes = null;
         }
         if ($netExpenditures + $netIncomes > 0) {
             $balanceRows[$member->id]['name'] = "{$member->first_name} {$member->middle_name} {$member->last_name}";
             $balanceRows[$member->id]['credit'] = empty($netIncomes) ? null : $netIncomes;
             $balanceRows[$member->id]['debit'] = empty($netExpenditures) ? null : $netExpenditures;
         }
     }
     return $balanceRows;
 }
コード例 #4
0
ファイル: LoanApplications.php プロジェクト: wanyos2005/hsbf
 /**
  * Determine whether loan is due for recovery.
  * 
  * @param \LoanApplications $loan Loan application
  * @param date $dateDue Loan repayment date
  * @return boolean TRUE - $loan is due. FALSE - $loan is not due.
  */
 public function loanIsDue($loan, $dateDue)
 {
     $effectiveRepaymentDate = $this->dayBefore($this->repaymentDate($loan->borrowingDate($loan), $this->recoverLoanAfterLoanRepaymentPeriod() == true ? $loan->repayment_period : $loan->max_repayment_period));
     if ($effectiveRepaymentDate < $dateDue && $dateDue <= date('Y') . '-' . date('m') . '-' . date('d')) {
         return true;
     }
 }
コード例 #5
0
ファイル: _sideLinks.php プロジェクト: wanyos2005/hsbf
}
?>


<?php 
$currentChairman = Maofficio::model()->returnCurrentPostHolder(1);
if (!empty($currentChairman) && $currentChairman->member == $id) {
    $model = LoanApplications::model()->find("witness>0 && (loan_type!=4 || (loan_type=4 && guarantor1>0 && guarantor2>0)) && forwarded_by_secretary!='Pending' && secretary_date IS NOT NULL && forwarded_by_treasurer!='Pending' && treasurer_date IS NOT NULL && closed!='Yes' && close_date IS NULL");
} else {
    $currentSecretary = Maofficio::model()->returnCurrentPostHolder(2);
    if (!empty($currentSecretary) && $currentSecretary->member == $id) {
        $model = LoanApplications::model()->find("witness>0 && (loan_type!=4 || (loan_type=4 && guarantor1>0 && guarantor2>0)) && forwarded_by_treasurer='Pending' && treasurer_date IS NULL && approved_by_chairman='Pending' && chairman_date IS NULL && closed!='Yes' && close_date IS NULL");
    } else {
        $currentTreasurer = Maofficio::model()->returnCurrentPostHolder(3);
        if (!empty($currentTreasurer) && $currentTreasurer->member == $id) {
            $model = LoanApplications::model()->find("witness>0 && (loan_type!=4 || (loan_type=4 && guarantor1>0 && guarantor2>0)) && forwarded_by_secretary!='Pending' && secretary_date IS NOT NULL && approved_by_chairman='Pending' && chairman_date IS NULL && closed!='Yes' && close_date IS NULL");
        }
    }
}
if (!empty($model)) {
    ?>
    <li class="<?php 
    echo isset($_REQUEST['active']) && $_REQUEST['active'] == 'viandu' ? 'active' : '';
    ?>
">
        <a
        <?php 
    if (isset($_REQUEST['active']) && $_REQUEST['active'] == 'viandu') {
        ?>

                <?php 
コード例 #6
0
ファイル: statements.php プロジェクト: wanyos2005/hsbf
$types = ContributionTypes::model()->findAll('id>1');
?>

    <div class="panel panel-default">
        <div class="panel-heading"><h3 class="panel-title">Statements of Accounts</h3></div>
        <div class="panel-body">
            <div class="col-md-8 col-sm-12" style="width: 100%">
                <div style="width: 100%">

                    <div style="width: 30%; float: left">
                        <table>
                            <?php 
foreach ($types as $type) {
    ?>
                                <?php 
    if ($type->primaryKey != 4 && ContributionsByMembers::model()->memberHasAContribution($user->id, $type->primaryKey) || $type->primaryKey == 4 && LoanApplications::model()->memberHasALoan($user->id)) {
        ?>
                                    <tr>
                                        <td>
                                            <?php 
        if ($type->primaryKey != 4) {
            ?>
                                                <a class="btn btn-sm btn-primary" href="<?php 
            echo $this->createUrl('whichStatement', array('id' => $user->id, 'type' => $type->primaryKey));
            ?>
" target="_blank"><i class="icon-ok bigger-110"></i><?php 
            echo Lang::t($type->contribution_type);
            ?>
</a>
                                            <?php 
        } else {
コード例 #7
0
ファイル: servicingLoans.php プロジェクト: wanyos2005/hsbf
                        <td style="text-align: center">Repayment</td>
                    </tr>
                    <?php 
foreach ($loansMemberIsServicing as $loanApplicationId => $loanMemberIsServicing) {
    ?>
                        <?php 
    if (get_class($loanMemberIsServicing) == 'LoanRepayments') {
        $model = $loanMemberIsServicing;
        $loanMemberIsServicing = LoanApplications::model()->findByPk($loanApplicationId);
    }
    ?>
                        <?php 
    $loan = Loans::model()->findByPk($loanMemberIsServicing->loan_type);
    ?>
                        <?php 
    $amountDue = LoanApplications::model()->computeTotals(array($loanMemberIsServicing), $date);
    ?>
                        <tr>
                            <td><?php 
    echo $loan->loan_type;
    ?>
</td>
                            <td style="text-align: center"><?php 
    echo $loanMemberIsServicing->close_date;
    ?>
</td>
                            <td style="text-align: center"><?php 
    echo $form->textField($model, "[{$loanMemberIsServicing->primaryKey}]balance", array('size' => 8, 'value' => $amountDue, 'readonly' => true, 'style' => 'text-align: center'));
    ?>
</td>
                            <td style="text-align: center"><?php 
コード例 #8
0
ファイル: Savings.php プロジェクト: wanyos2005/hsbf
 /**
  * 
  * @param int $saving_id contribution by member id or savings saving_id
  * @param date $date yyyy-mm-dd
  * @return boolean true - could be withdrawn
  */
 public function savingIsWithdrawableByThisDate($saving_id, $date)
 {
     $model = $this->find('savings_id=:svng && date_of_investment<=:dt && can_be_withdrawn=:wthdrw', array(':svng' => $saving_id, ':dt' => LoanApplications::model()->dayAfter($date), ':wthdrw' => self::WITHDRAWABLE_YES));
     return is_object($model);
 }
コード例 #9
0
 /**
  * Return member's total contributions less loan balances and recoveries after this date.
  * 
  * @param int $member
  * @param date $endDate
  * @return double
  */
 public function netTotalMemberContribution($member, $endDate)
 {
     $totalContributions = $this->totalMemberContribution($member, 2, $endDate);
     $totalLoans = LoanApplications::model()->totalLoanBalances($member, $endDate);
     $totalLoanRecoveries = LoanRepayments::model()->totalLoanRecoveries($member, $endDate);
     if (empty($totalContributions)) {
         return null;
     }
     return $totalContributions - $totalLoans - $totalLoanRecoveries;
 }
コード例 #10
0
ファイル: Expenditures.php プロジェクト: wanyos2005/hsbf
 /**
  * 
  * @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));
 }
コード例 #11
0
ファイル: LoanRepayments.php プロジェクト: wanyos2005/hsbf
 /**
  * 
  * @param int $loanApplicationId loan application id
  * @param date $till yyyy-mm-dd
  * @return array loan values
  */
 public function profitEarnedOrToBeEarnedOnLoanBetweenAndIncludingTheseDates($loanApplicationId, $till)
 {
     if (is_object($loanApplication = LoanApplications::model()->returnALoanApplication($loanApplicationId))) {
         return array(self::PRINCIPAL => $loanApplication->amout_borrowed, self::AMOUNT_PAID => $totalRepayments = $this->totalRecoveries($this->memberLoanRepaymentsBtwnDatesAgain($loanApplicationId, $loanApplication->close_date, $till)), self::REDUCING_BALANCE => $loanBalance = $this->loanBalanceOfMemberAfterThisDate($loanApplication, $till), self::AMOUNT_DUE => $accumulatedAmount = $totalRepayments + $loanBalance, self::INTEREST => round($accumulatedAmount - $loanApplication->amout_borrowed, 2));
     }
     return array();
 }
コード例 #12
0
 /**
  * 
  * @param \Loanrepayments $loanRepayments models
  * @param \Loanapplications $loanApplication models
  * @param \CashWithdrawals $withdrawals models
  * @param date $startDate
  * @param date $endDate
  * @return array
  */
 public function orderLoanRepaymentTransactions($loanRepayments, $loanApplication, $startDate, $endDate)
 {
     $transactions = array();
     $separations = $this->separateRecoveriesFromRepayments($loanRepayments);
     $transactions[$count = count($transactions)][Loanrepayments::PRINCIPAL] = $loanApplication->amout_borrowed;
     $transactions[$count][Loanrepayments::AMOUNT_DUE] = null;
     $transactions[$count][Loanrepayments::INTEREST] = null;
     $transactions[$count][Loanrepayments::AMOUNT_PAID] = null;
     $transactions[$count][Loanrepayments::DEDUCTION_FROM_CONTRIBUTIONS] = null;
     $transactions[$count][Loanrepayments::REDUCING_BALANCE] = round(LoanRepayments::model()->amountDue($loanApplication->amout_borrowed, $loanApplication->interest_rate, $loanApplication->close_date, $loanApplication->close_date, 0), 3);
     $transactions[$count][ContributionsByMembers::RECEIPT] = null;
     $transactions[$count][ContributionsByMembers::DATE] = $loanApplication->close_date;
     while ($startDate <= $endDate) {
         foreach ($loanRepayments as $l => $loanRepayment) {
             if (!empty($loanRepayment->contribution_toward_loan)) {
                 if (isset($separations[self::REPAYMENTS][$loanRepayment->primaryKey])) {
                     $contribution = ContributionsByMembers::model()->findByPk($loanRepayment->contribution_toward_loan);
                     $repayment = $separations[self::REPAYMENTS][$loanRepayment->primaryKey];
                     if ($repayment->recoverydate == $startDate) {
                         $transactions[$count = count($transactions)][Loanrepayments::PRINCIPAL] = $transactions[$count - 1][LoanRepayments::REDUCING_BALANCE];
                         $transactions[$count][Loanrepayments::AMOUNT_DUE] = $loanRepayment->amount_due;
                         $transactions[$count][Loanrepayments::INTEREST] = round($transactions[$count][Loanrepayments::AMOUNT_DUE] - $transactions[$count][Loanrepayments::PRINCIPAL], 3);
                         //round($loanRepayment->amount_due - $transactions[$count - 1][LoanRepayments::REDUCING_BALANCE], 3);
                         $transactions[$count][Loanrepayments::AMOUNT_PAID] = $loanRepayment->amount_due - $loanRepayment->balance;
                         $transactions[$count][Loanrepayments::DEDUCTION_FROM_CONTRIBUTIONS] = null;
                         $transactions[$count][Loanrepayments::REDUCING_BALANCE] = $loanRepayment->balance;
                         $transactions[$count][ContributionsByMembers::RECEIPT] = $contribution->receiptno == ContributionsByMembers::FALSE_RECEIPT ? null : $contribution->receiptno;
                         $transactions[$count][ContributionsByMembers::DATE] = $startDate;
                     }
                 }
             }
             if (isset($separations[self::RECOVERIES][$loanRepayment->primaryKey])) {
                 $contribution = ContributionsByMembers::model()->findByPk($loanRepayment->contribution_toward_loan);
                 $repayment = $separations[self::RECOVERIES][$loanRepayment->primaryKey];
                 if ($repayment->recoverydate == $startDate) {
                     $transactions[$count = count($transactions)][Loanrepayments::PRINCIPAL] = $transactions[$count - 1][LoanRepayments::REDUCING_BALANCE];
                     $transactions[$count][Loanrepayments::AMOUNT_DUE] = $loanRepayment->recoveryamount;
                     $transactions[$count][Loanrepayments::INTEREST] = round($transactions[$count][Loanrepayments::AMOUNT_DUE] - $transactions[$count][Loanrepayments::PRINCIPAL], 3);
                     //round($loanRepayment->recoveryamount - $transactions[$count - 1][LoanRepayments::REDUCING_BALANCE], 3);
                     $transactions[$count][Loanrepayments::AMOUNT_PAID] = null;
                     $transactions[$count][Loanrepayments::DEDUCTION_FROM_CONTRIBUTIONS] = $loanRepayment->amountrecovered;
                     $transactions[$count][Loanrepayments::REDUCING_BALANCE] = $loanRepayment->newbalance;
                     $transactions[$count][ContributionsByMembers::RECEIPT] = Loanrepayments::INSTEAD_OF_RECEIPT;
                     $transactions[$count][ContributionsByMembers::DATE] = $startDate;
                 }
             }
         }
         $startDate = LoanApplications::model()->dayAfter($startDate);
     }
     if (count($transactions) < 2) {
         $transactions[$count = count($transactions)][Loanrepayments::PRINCIPAL] = $transactions[$count - 1][LoanRepayments::REDUCING_BALANCE];
         $transactions[$count][Loanrepayments::AMOUNT_DUE] = round(LoanRepayments::model()->amountDue($transactions[$count][Loanrepayments::PRINCIPAL], $loanApplication->interest_rate, $loanApplication->close_date, $endDate, $transactions[$count - 1][ContributionsByMembers::DATE] == $endDate ? 1 : 0), 3);
         $transactions[$count][Loanrepayments::INTEREST] = round($transactions[$count][Loanrepayments::AMOUNT_DUE] - $transactions[$count][Loanrepayments::PRINCIPAL], 3);
         $transactions[$count][Loanrepayments::AMOUNT_PAID] = null;
         $transactions[$count][Loanrepayments::DEDUCTION_FROM_CONTRIBUTIONS] = null;
         $transactions[$count][Loanrepayments::REDUCING_BALANCE] = $transactions[$count][Loanrepayments::AMOUNT_DUE];
         $transactions[$count][ContributionsByMembers::RECEIPT] = null;
         $transactions[$count][ContributionsByMembers::DATE] = $endDate;
     }
     return $transactions;
 }
コード例 #13
0
 public function actionAllMembersLoans($member)
 {
     $cri = new CDbCriteria();
     $cri->condition = "member=:mbr && forwarded_by_secretary='Yes' && forwarded_by_treasurer='Yes' && approved_by_chairman='Yes' && closed='Yes'";
     $cri->params = array(':mbr' => $member);
     $cri->order = 'close_date DESC, chairman_date DESC, witness_date DESC';
     $this->renderPartial('loansList', array('loans' => LoanApplications::model()->findAll($cri)));
 }