Changeset 722


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.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r720 r722  
    126126      'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč'),
    127127      'VAT' => array('Type' => 'TFinanceVATType', 'Caption' => 'Sazba DPH', 'Default' => '0', 'Suffix' => ''),
    128       'CustomerCount' => array('Type' => 'Integer', 'Caption' => 'Počet zákazníků', 'Default' => '', 'ReadOnly' => true),
     128      'CustomerCount' => array('Type' => 'Integer', 'Caption' => 'Počet zákazníků', 'Default' => '', 'ReadOnly' => true,
     129        'SQL' => '(SELECT COUNT(*) FROM `ServiceCustomerRel` LEFT JOIN `Member` ON `Member`.`Id`=`ServiceCustomerRel`.`Customer` WHERE (`ServiceCustomerRel`.`Service`=#Id) AND (`Member`.`Blocked`=0))'),
    129130      'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => ''),
    130131      'InternetSpeedMin' => array('Type' => 'Integer', 'Caption' => 'Min. rychlost internetu', 'Default' => '0', 'Suffix' => 'kbit/s'),
  • trunk/Application/Version.php

    r721 r722  
    11<?php
    22
    3 $Revision = 721; // Subversion revision
    4 $DatabaseRevision = 720; // SQL structure revision
     3$Revision = 722; // Subversion revision
     4$DatabaseRevision = 722; // SQL structure revision
    55$ReleaseTime = strtotime('2015-01-03');
  • trunk/Common/Setup/Updates.php

    r720 r722  
    11221122                                "VALUES (NULL , 'Vydané', ".$DbRow['Id'].", '".$ActionId."', '1');");
    11231123        }
     1124}
     1125
     1126function UpdateTo722($Manager)
     1127{
     1128        $Manager->Execute('ALTER TABLE `Service` DROP `CustomerCount`;');
    11241129}
    11251130
     
    11821187      718 => array('Revision' => 719, 'Function' => 'UpdateTo719'),
    11831188        719 => array('Revision' => 720, 'Function' => 'UpdateTo720'),
     1189        720 => array('Revision' => 722, 'Function' => 'UpdateTo722'),
    11841190    ));
    11851191  }
  • 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.