本文整理汇总了PHP中Propel::getWriteConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::getWriteConnection方法的具体用法?PHP Propel::getWriteConnection怎么用?PHP Propel::getWriteConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel
的用法示例。
在下文中一共展示了Propel::getWriteConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addRepayment
public function addRepayment(Loan $loan, \Datetime $date, Money $amount, BorrowerPayment $borrowerPayment = null)
{
// Divide the payment in the lenders and the web site fee
// 1. Get the web site fee %
// 2. Get who all lended and how much
// 3. substract he website fee out of this installment
// 4. remaining money should be divided in lenders according to their proportion and added
// 5. If the loan gets completed with this payment set the loan status to complete
$calculator = $this->getRepaymentCalculator($loan, $amount);
if ($calculator->unpaidAmount()->isNegative()) {
throw new \Exception('Unpaid amount is negative');
}
$con = Propel::getWriteConnection(TransactionTableMap::DATABASE_NAME);
$con->beginTransaction();
$refundThreshold = $this->currencyService->convertFromUSD(Money::create(1), $loan->getCurrency(), $date);
$refundAmount = $calculator->refundAmount($refundThreshold);
if ($refundAmount->isPositive()) {
$this->addBorrowerRefund($con, $loan, $refundAmount);
$amount = $amount->subtract($refundAmount);
$calculator->setRepaymentAmount($amount);
}
$this->transactionService->addInstallmentTransaction($con, $amount, $loan, $date);
$nativeFeeAmount = $calculator->installmentServiceFee();
$feeAmount = $this->currencyService->convertToUSD($nativeFeeAmount, $date);
$this->transactionService->addInstallmentFeeTransaction($con, $loan, $feeAmount, $date);
$bids = BidQuery::create()->filterByLoan($loan)->filterByActive(true)->find();
$loanRepayments = $calculator->loanRepayments($bids);
/** @var $loanRepayment LoanRepayment */
foreach ($loanRepayments as $loanRepayment) {
$lender = $loanRepayment->getLender();
$nativeLenderAmount = $loanRepayment->getAmount();
$nativeLenderInviteCredit = $loanRepayment->getLenderInviteCredit();
if ($nativeLenderAmount->isPositive()) {
$lenderAmount = $this->currencyService->convertToUSD($nativeLenderAmount, $date);
$this->transactionService->addRepaymentTransaction($con, $lenderAmount, $loan, $lender, $date);
}
if ($nativeLenderInviteCredit->isPositive()) {
$lenderInviteCredit = $this->currencyService->convertToUSD($nativeLenderInviteCredit, $date);
$this->transactionService->addLenderInviteCreditRepaymentTransaction($con, $lenderInviteCredit, $loan, $date);
}
}
$updatedInstallments = $this->updateInstallmentSchedule($con, $loan, $amount, $date);
// TODO
// $database->setOntimeRepayCredit($rest4, $borrowerid, $amount);
// TODO
// $database->loanpaidback($borrowerid,$loanid);
// TODO emails/sms
}