コード例 #1
0
 /**
  * Method for handling single onCreate event
  * @param SeasonApplication $app
  * @return void
  * @throws Exceptions\InvalidStateException
  */
 public function onCreate(SeasonApplication $app)
 {
     $amount = null;
     $season = $app->getSeason();
     $group = $app->getSportGroup();
     try {
         $tax = $this->seasonTaxService->getSeasonTaxSG($season, $group);
         if ($tax !== null) {
             $amount = $tax->getMemberShip();
             if (empty($amount) || $amount == 0) {
                 return;
             }
         } else {
             throw new Exceptions\InvalidStateException("Season tax for season {$season} and group {$group} does not exist");
         }
     } catch (Exceptions\DataErrorException $ex) {
         $this->logger->addError("Application listener - onCreate - getSeasonTaxSG failed with - " . $ex->getMessage());
         return;
     }
     $subject = "Application for " . $app->getSportGroup()->getName() . " (" . $app->getSportGroup()->getSportType()->getName() . ") within " . $app->getSeason()->getLabel() . " season";
     $payment = new Payment();
     $payment->setOwner($app->getOwner());
     $payment->setSeason($app->getSeason());
     $payment->setSubject($subject);
     $payment->setAmount($amount);
     $payment->setDueDate($this->paymentService->getDefaultDueDate());
     $payment->setOrderedDate(new DateTime());
     $payment->setEditor($app->getEditor());
     $payment->setStatus(PaymentStatus::NOT_YET);
     $payment->setVs($this->paymentService->generateVs($payment));
     $payment->setPublicNote("");
     $payment->setProtectedNote("");
     try {
         $this->paymentService->createPayment($payment);
         $app->setPayment($payment);
         $this->seasonApplicationService->updateSeasonApplication($app);
     } catch (Exceptions\DataErrorException $ex) {
         $this->logger->addError("Application listener - onCreate - savingData failed with - " . $ex->getMessage());
         return;
     }
 }
コード例 #2
0
ファイル: AdminPresenter.php プロジェクト: fuca/sportsclub
 /**
  * Top-down handler for update payment
  * @param ArrayHash $values
  */
 public function updatePaymentHandle(ArrayHash $values)
 {
     $payment = new Payment((array) $values);
     try {
         $payment->setEditor($this->getUser()->getIdentity());
         $this->getPaymentService()->updatePayment($payment);
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataSave($values->id, "this", $ex);
     }
     $this->redirect("default");
 }
コード例 #3
0
ファイル: PaymentService.php プロジェクト: fuca/sportsclub
 private function paymentEditorTypeHandle(Payment $p)
 {
     if ($p === NULL) {
         throw new Exceptions\NullPointerException("Argument Payment was null.", 0);
     }
     try {
         $rId = $this->getMixId($p->getEditor());
         if ($this->getUsersService() !== null && $rId !== null) {
             $editor = $this->getUsersService()->getUser($rId, false);
             $p->setEditor($editor);
         }
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
     return $p;
 }