public function get_total_price_current_year()
 {
     /* 1. Get current year
      * 2. Check contract dates to see if the contract is/has:
      * 2.1 ...ended - return 0
      * 2.2 ...active alle year - return total price
      * 2.3 ...ends or starts current year - calculate price
      * 2.3.1
      */
     $date_start = phpgw::get_var('date_start');
     $date_end = phpgw::get_var('date_end');
     if (isset($date_start)) {
         $aDate = explode("/", $date_start);
         $date_start = $aDate[1] . "/" . $aDate[0] . "/" . $aDate[2];
         $timestamp_invoice_start = strtotime($date_start);
     }
     if (isset($date_end)) {
         $aDate = explode("/", $date_end);
         $date_end = $aDate[1] . "/" . $aDate[0] . "/" . $aDate[2];
         $timestamp_invoice_end = strtotime($date_end);
     }
     if (!isset($timestamp_invoice_start) || $timestamp_invoice_start == "" || !isset($timestamp_invoice_end) || $timestamp_invoice_end == "") {
         $current_year = date("Y");
         $timestamp_invoice_start = strtotime("{$current_year}-1-1");
         $timestamp_invoice_end = strtotime("{$current_year}-12-31");
     }
     $contract_dates = $this->get_contract_date();
     if (isset($contract_dates)) {
         $contract_start = $contract_dates->get_start_date();
         $contract_end = $contract_dates->get_end_date();
         if (isset($contract_end) && $contract_end < $timestamp_invoice_start) {
             return 0;
             // The contract ends before start of current year
         } else {
             if ($contract_start > $timestamp_invoice_end) {
                 return 0;
                 // The contract starts after the end of current year
             }
         }
     } else {
         return 0;
         // The contract has no dates
     }
     // The contract is active only parts of the current year, we must calculate the total sum using the billing logic
     $total_sum = 0;
     // Holding the total price of the contract current year
     $contract_price_items = rental_socontract_price_item::get_instance()->get(null, null, null, null, null, null, array('contract_id' => $this->get_id()));
     // Run through the contract price items
     foreach ($contract_price_items as $contract_price_item) {
         // ---- Period calculation ---
         // Determine start date for price item
         $contract_price_item_start = $contract_price_item->get_date_start();
         if ($contract_price_item_start == null || $contract_price_item_start == '') {
             // We just use the invoice date for our calculations
             $contract_price_item_start = $timestamp_invoice_start;
         }
         // Determine end date for price item
         $contract_price_item_end = $contract_price_item->get_date_end();
         if ($contract_price_item_end == null || $contract_price_item_end == '') {
             // We just use the invoice date for our calculations
             $contract_price_item_end = $timestamp_invoice_end;
         }
         // Sanity check - end date should never be before start date
         if ($contract_price_item_end < $contract_price_item_start) {
             continue;
             // We don't add this price item - continue to next
         }
         // Checking the start date against the invoice dates
         if ($contract_price_item_start < $timestamp_invoice_start) {
             $invoice_price_item_start = $timestamp_invoice_start;
             // We use the invoice start
         } else {
             if ($contract_price_item_start > $timestamp_invoice_end) {
                 continue;
                 // We don't add this price item - continue to next
             } else {
                 $invoice_price_item_start = $contract_price_item_start;
                 // We use the price item start
             }
         }
         // Checking the end date against invoice dates
         if ($contract_price_item_end < $timestamp_invoice_start) {
             continue;
             // We don't add this price item - continue to next
         } else {
             if ($contract_price_item_end < $timestamp_invoice_end) {
                 $invoice_price_item_end = $contract_price_item_end;
                 // We use the price item end
             } else {
                 $invoice_price_item_end = $timestamp_invoice_end;
                 // We use the invoice end
             }
         }
         // Checking the contract dates against the temporary price item dates
         if (isset($contract_start) && !$contract_price_item->is_one_time()) {
             if ($contract_start > $timestamp_invoice_end) {
                 continue;
                 //No price items for this contract will be billed
             }
             if ($contract_start > $invoice_price_item_start) {
                 $invoice_price_item_start = $contract_start;
             }
         }
         if (isset($contract_end) && !$contract_price_item->is_one_time()) {
             if ($contract_end < $timestamp_invoice_start) {
                 continue;
                 //No price items for this contract will be billed
             }
             if ($contract_end < $invoice_price_item_end) {
                 $invoice_price_item_end = $contract_end;
             }
         }
         // --- End of period calculation ---
         // Create a new invoice price item
         $invoice_price_item = new rental_invoice_price_item(2, -1, 0, $contract_price_item->get_title(), $contract_price_item->get_agresso_id(), $contract_price_item->is_area(), $contract_price_item->get_price(), $contract_price_item->get_area(), $contract_price_item->get_count(), $invoice_price_item_start, $invoice_price_item_end);
         $total_price_price_item = 0;
         // If the contract price item is of type one-time and it's dates are within the invoice period ...
         if ($contract_price_item->is_one_time()) {
             if ($contract_price_item_start >= $timestamp_invoice_start && $contract_price_item_start <= $timestamp_invoice_end) {
                 // ... set the total price of the invoice price item to the total price of the contract price item
                 $total_price_price_item = $contract_price_item->get_total_price();
             }
         } else {
             $total_price_price_item = $invoice_price_item->get_total_price();
         }
         $total_sum += round($total_price_price_item, 2);
     }
     // end of looping through the contract price items
     $total_sum = round($total_sum, 2);
     return $total_sum;
 }