Ignore:
Timestamp:
Jan 3, 2015, 8:20:29 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Count of customers per service removed as column from Service table. It is now calculated online as SQL subcommand.
  • Removed: Old tariffs recalculation for computation of dynamic aggregation according selected customer tariffs and maximum speed is not used further. Now static minimum and maximum speed is sufficient and it is enough general.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Finance.php

    r721 r722  
    5151  }
    5252
    53   function RecalculateTariffs()
    54   {
    55     $ResidualSpeed = $this->MaxSpeed * 1000;
    56 
    57     $this->LoadTariffs();
    58 
    59     $Column = array('Current', 'Next');
    60     $TotalMemberCount = 0;
    61     $TotalMaxSpeed = 0;
    62     foreach($this->Tariffs as $Index => $Tariff)
    63     {
    64       $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Member` '.
    65           'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Customer`=`Member`.`Id` '.
    66           'WHERE (`ServiceCustomerRel`.`Service`='.$Index.') AND (`Member`.`BillingPeriod` > 1) '.
    67           'AND (`Member`.`Blocked`=0)');
    68       $Row = $DbResult->fetch_row();
    69       $this->Tariffs[$Index]['CustomerCount'] = $Row[0];
    70       $Tariffs['CustomerCount'] = $Row[0];
    71 
    72       switch($Tariff['Category'])
    73       {
    74         case 1:
    75           $TotalMemberCount += $Tariff['CustomerCount'];
    76           $TotalMaxSpeed += $Tariff['InternetSpeedMax'] * $Tariff['CustomerCount'];
    77           break;
    78         case 2:
    79           $ResidualSpeed -= $Tariff['InternetSpeedMin'] * $Tariff['CustomerCount'];
    80           break;
    81         case 3:
    82           break;
    83       }
    84     }
    85     if($TotalMaxSpeed > 0) $Aggregation = $ResidualSpeed / $TotalMaxSpeed;
    86     else $Aggregation = 1;
    87 
    88     // Recalculate price
    89     foreach($this->Tariffs as $Index => $Tariff)
    90     {
    91       switch($Tariff['Category'])
    92       {
    93         case 1:
    94           // Přepočítávání rychlostí koliduje s rozdílovým zapisováním stromu front do mikrotiku.
    95           // Vždy při změně počtu počítačů či domácností docházelo ke změně minima a přepočtu všeho.
    96           //$Tariff['InternetSpeedMin'] = round($Tariff['InternetSpeedMax'] * $Aggregation);
    97           break;
    98         case 2:
    99           break;
    100         case 3:
    101           break;
    102       }
    103       $this->Database->update('Service', 'Id='.$Tariff['Id'],
    104           array('InternetSpeedMin' => ($Tariff['InternetSpeedMin'] / 1000),
    105               'CustomerCount' => $Tariff['CustomerCount']));
    106     }
    107     $this->LoadTariffs();
    108   }
    109 
    11053  function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month
    11154  {
     
    225168    }
    226169    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');
    227     $this->RecalculateTariffs(1);
    228     $this->RecalculateTariffs(0);
    229170    return($Output);
    230171  }
Note: See TracChangeset for help on using the changeset viewer.