コード例 #1
0
ファイル: Debits.php プロジェクト: iHunt101/POS-ws-server
 public static function pay($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('pay_debit')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     // make sure the debit is not fully paid already
     $debit = DebitQuery::create()->filterByStatus('Active')->filterById($params->debit_id)->withColumn('CONVERT(Debit.Total, SIGNED) - CONVERT(Debit.Paid, SIGNED)', 'Balance')->findOne($con);
     if (!$debit) {
         throw new \Exception('Data tidak ditemukan.');
     }
     // if debit is already fully paid then stop paying
     if ($debit->getBalance() <= 0) {
         throw new \Exception('Hutang ini sudah dilunasi.');
     }
     // create new payment
     $debitPayment = new DebitPayment();
     $debitPayment->setDate($params->date)->setDebitId($params->debit_id)->setPaid($params->paid)->setCashierId($params->cashier)->setStatus('Active')->save($con);
     $payment = DebitPaymentQuery::create()->filterByStatus('Active')->filterByDebitId($params->debit_id)->withColumn('SUM(Paid)', 'paid')->select(array('paid'))->groupBy('DebitId')->findOne($con);
     $debit->setPaid($payment)->save($con);
     $results['success'] = true;
     $results['data'] = 'Yay';
     return $results;
 }
コード例 #2
0
ファイル: DebitQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Filter the query by a related \ORM\DebitPayment object
  *
  * @param \ORM\DebitPayment|ObjectCollection $debitPayment  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildDebitQuery The current query, for fluid interface
  */
 public function filterByPayment($debitPayment, $comparison = null)
 {
     if ($debitPayment instanceof \ORM\DebitPayment) {
         return $this->addUsingAlias(DebitTableMap::COL_ID, $debitPayment->getDebitId(), $comparison);
     } elseif ($debitPayment instanceof ObjectCollection) {
         return $this->usePaymentQuery()->filterByPrimaryKeys($debitPayment->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByPayment() only accepts arguments of type \\ORM\\DebitPayment or Collection');
     }
 }
コード例 #3
0
ファイル: DebitPaymentQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Exclude object from result
  *
  * @param   ChildDebitPayment $debitPayment Object to remove from the list of results
  *
  * @return $this|ChildDebitPaymentQuery The current query, for fluid interface
  */
 public function prune($debitPayment = null)
 {
     if ($debitPayment) {
         $this->addUsingAlias(DebitPaymentTableMap::COL_ID, $debitPayment->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
コード例 #4
0
ファイル: UserDetail.php プロジェクト: AlvaCorp/POS-2
 /**
  * @param ChildDebitPayment $debitPayment The ChildDebitPayment object to add.
  */
 protected function doAddDebitPayment(ChildDebitPayment $debitPayment)
 {
     $this->collDebitPayments[] = $debitPayment;
     $debitPayment->setCashier($this);
 }
コード例 #5
0
ファイル: Debit.php プロジェクト: AlvaCorp/POS-2
 /**
  * @param ChildDebitPayment $payment The ChildDebitPayment object to add.
  */
 protected function doAddPayment(ChildDebitPayment $payment)
 {
     $this->collPayments[] = $payment;
     $payment->setDebit($this);
 }