Пример #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
 /**
  * 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;
 }