Esempio n. 1
0
 /**
  * make the calculation
  */
 public function updateRow($row)
 {
     Billrun_Factory::dispatcher()->trigger('beforeCalculatorUpdateRow', array($row, $this));
     $current = $row->getRawData();
     $usage_type = $this->getLineUsageType($row);
     $volume = $this->getLineVolume($row, $usage_type);
     $rate = $this->getLineRate($row, $usage_type);
     if (isset($rate['key']) && $rate['key'] == "UNRATED") {
         return false;
     }
     $added_values = array('usaget' => $usage_type, 'usagev' => $volume, $this->ratingField => $rate ? $rate->createRef() : $rate);
     if ($rate) {
         $added_values[$this->aprField] = Billrun_Calculator_CustomerPricing::getPriceByRate($rate, $usage_type, $volume);
     }
     $newData = array_merge($current, $added_values);
     $row->setRawData($newData);
     Billrun_Factory::dispatcher()->trigger('afterCalculatorUpdateRow', array($row, $this));
     return $row;
 }
Esempio n. 2
0
 /**
  * @see Billrun_Generator_Csv::createRow
  */
 public function createRow($row)
 {
     $row->collection($this->lines_coll);
     $res = $row->getRawData();
     $res['file'] = 'cdrFile:' . $row['file'] . ' cdrNb:' . $row['record_number'];
     $res['charging_start_time'] = substr($row['charging_start_time'], 2);
     $res['charging_end_time'] = substr($row['charging_end_time'], 2);
     $res['prepaid'] = '0';
     $res['is_in_glti'] = '0';
     $res['origin_carrier'] = $this->providers[$row[$this->ild_prefix_field_name]];
     $res['records_type'] = '000';
     $res['sampleDurationInSec'] = '1';
     $row[$this->pricingField] = $res['aprice'] = round($this->access_price + Billrun_Calculator_CustomerPricing::getPriceByRate($row['arate'], $row['usaget'], $row['usagev']), 4);
     if ($row['usagev'] == '0') {
         $res['records_type'] = '005';
     } else {
         if (!$row['arate']) {
             $res['records_type'] = '002';
             $res['sampleDurationInSec'] = '0';
         }
     }
     $str = '';
     foreach ($this->data_structure as $column => $width) {
         $str .= str_pad($res[$column], $width, " ", STR_PAD_LEFT);
     }
     $str .= PHP_EOL;
     return $str;
 }