Пример #1
0
 /**
  * Recalculate all for reservation, after some of the unit details has been changed
  *
  * @abstract
  * @param RM_Reservation_Row $reservation
  * @return bool
  */
 function recalculate(RM_Reservation_Row $reservation)
 {
     $summaryModel = new RM_ReservationSummary();
     $extrasModel = new RM_Extras();
     $details = $reservation->getDetails();
     foreach ($details as $detail) {
         $summaryRows = $summaryModel->fetchByReservationDetail($detail);
         foreach ($summaryRows as $summaryRow) {
             if ($summaryRow->type == self::SUMMARY_TYPE) {
                 $extra = $extrasModel->find($summaryRow->row_id)->current();
                 if ($extra == null) {
                     //IF this is a deprecated - total value remains the same
                     continue;
                 }
                 $detailsObj = $detail->transform();
                 if ($detailsObj instanceof RM_Reservation_Details) {
                     $summaryRow->total_amount = -$extra->calculate($detailsObj) * $summaryRow->value;
                     $summaryRow->save();
                 } else {
                     RM_Log::toLog("Extras Encountered Issues: " . print_r($detailsObj, true));
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * This method internally return total reservation due for payment
  * There could be a deposit system installed and enabled
  *
  * @deprecated
  * @param RM_Reservation_Row $reservation
  * @return float
  */
 public function getTotalPrice(RM_Reservation_Row $reservation)
 {
     $totalPrice = $reservation->getTotalPrice();
     $depositSystem = RM_Environment::getInstance()->getDepositSystem();
     if ($depositSystem == null) {
         return $totalPrice;
     }
     if ($depositSystem->isDepositUsedFor($reservation->id)) {
         return $depositSystem->calculate($totalPrice);
     }
     return $totalPrice;
 }
Пример #3
0
 /**
  * Return total value of saved taxes for reservation
  *
  * @param RM_Reservation_Row $reservation
  * @return float
  */
 function getTotalTaxes(RM_Reservation_Row $reservation)
 {
     $total = 0;
     $details = $reservation->getDetails();
     $summaryModel = new RM_ReservationSummary();
     foreach ($details as $detail) {
         $summaryRows = $summaryModel->fetchByReservationDetail($detail);
         foreach ($summaryRows as $summaryRow) {
             if ($summaryRow->type == self::SUMMARY_TYPE) {
                 $total += $summaryRow->total_amount;
             }
         }
     }
     return $total;
 }
Пример #4
0
 function markPaid(RM_Reservation_Row $reservation)
 {
     $totalPrice = $reservation->getTotalPrice();
     $billingModel = new RM_Billing();
     $totalPaid = $billingModel->getPaymentsTotal($reservation);
     $total = $totalPrice - $totalPaid;
     $billingID = $billingModel->createRow(array('reservation_id' => $reservation->id, 'total_paid' => $total))->save();
     $billingPaymentsModel = new RM_BillingPayments();
     $billingPaymentsModel->createRow(array('id' => $billingID, 'provider' => 'Administrator', 'transaction_id' => '0', 'status' => 'success', 'total' => $total, 'transaction_date' => date('Y-m-d H:i:s')))->save();
     $this->confirm($reservation);
 }