Changeset 377 for trunk/Modules/Finance


Ignore:
Timestamp:
Jan 20, 2012, 3:05:24 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Testována instalace čisté databáze na základě definic modulů a jejich modelů.
  • Opraveno: Doplněny definice modelů pro FinanceMonthlyOverall a FinanceCharge.
  • Přidáno: Podpora pro nastavitelnost NULL hodnoty u vlastností modelů.
  • Opraveno: Řešení správného kaskádového načítání závislostí modulů.
Location:
trunk/Modules/Finance
Files:
4 edited

Legend:

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

    r373 r377  
    8383}
    8484
     85class FinanceBillingPeriod extends Model
     86{
     87  function __construct($Database, $System)
     88  {
     89    parent::__construct($Database, $System);
     90    $this->Name = 'FinanceBillingPeriod';
     91    $this->AddPropertyString('Name');
     92    $this->AddPropertyInteger('MonthCount');
     93  }
     94}
     95
    8596class FinanceTariff extends Model
    8697{
     
    127138    $this->AddPropertyString('BillCode');
    128139    $this->AddPropertyOneToMany('Subject', 'Subject');
    129     $this->AddPropertyDateTime('TimeCreate');
     140    $this->AddPropertyDateTime('TimeCreation');
    130141    $this->AddPropertyDateTime('TimeDue');
    131142    $this->AddPropertyDateTime('TimePayment');
     
    163174    $this->AddPropertyFloat('Price');
    164175    $this->AddPropertyFloat('Quantity');
     176  }
     177}
     178
     179class FinanceCharge extends Model
     180{
     181  function __construct($Database, $System)
     182  {
     183    parent::__construct($Database, $System);
     184    $this->Name = 'FinanceCharge';
     185    $this->AddPropertyInteger('Period');
     186    $this->AddPropertyInteger('Internet');
     187    $this->AddPropertyInteger('InternetSpeed');
     188    $this->AddPropertyInteger('InternetSpeedReserve');
     189    $this->AddPropertyInteger('AdministrationPerUser');
     190    $this->AddPropertyInteger('kWh');
     191    $this->AddPropertyInteger('BaseSpeedElement');
     192    $this->AddPropertyInteger('BaseTariffPrice');
     193    $this->AddPropertyInteger('TopTariffPrice');
     194  }
     195}
     196
     197class FinanceMonthlyOverall extends Model
     198{
     199  function __construct($Database, $System)
     200  {
     201    parent::__construct($Database, $System);
     202    $this->Name = 'FinanceMonthlyOverall';
     203    $this->AddPropertyInteger('Money');
     204    $this->AddPropertyDate('Date');
     205    $this->AddPropertyInteger('Administration');
     206    $this->AddPropertyInteger('kWh');
     207    $this->AddPropertyInteger('AdministrationTotal');
     208    $this->AddPropertyInteger('ConsumptionTotal');
     209    $this->AddPropertyInteger('TotalPaid');
     210    $this->AddPropertyInteger('BaseTariffPrice');
     211    $this->AddPropertyInteger('TopTariffPrice');
     212    $this->AddPropertyInteger('MemberCount');
     213    $this->AddPropertyInteger('Investment');
    165214  }
    166215}
     
    237286    $this->License = 'GNU/GPL';
    238287    $this->Description = 'Accounting processing';
    239     $this->Dependencies = array('User');
     288    $this->Dependencies = array('User', 'Subject');
    240289    $this->Models = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence',
    241290      'FinanceTariff', 'FinanceOperation', 'FinanceClaimsLiabilities',
    242       'FinanceBills', 'FinanceBillsItems');
     291      'FinanceBills', 'FinanceBillsItems', 'FinanceBillingPeriod', 'FinanceCharge',
     292      'FinanceMonthlyOverall');
    243293    $this->Views = array('FinanceOperation', 'FinanceClaimsLiabilities');
    244294  }
     
    331381      $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    332382   
    333     $DbResult = $this->Database->query('SELECT * FROM finance_charge WHERE period='.$Period);
     383    $DbResult = $this->Database->query('SELECT * FROM FinanceCharge WHERE period='.$Period);
    334384    $Row = $DbResult->fetch_array();
    335385    $this->kWh = $Row['kWh'];
    336     $this->Internet = $Row['internet'];
    337     $this->Sprava = $Row['administration_per_user'];
    338     $this->RealMaxSpeed = $Row['internet_speed'];
    339     $this->SpeedReserve = $Row['internet_speed_reserve'];
    340     $this->BaseSpeedElement = $Row['base_speed_element'];
     386    $this->Internet = $Row['Internet'];
     387    $this->Sprava = $Row['AdministrationPerUser'];
     388    $this->RealMaxSpeed = $Row['InternetSpeed'];
     389    $this->SpeedReserve = $Row['InternetSpeedReserve'];
     390    $this->BaseSpeedElement = $Row['BaseSpeedElement'];
    341391    $this->MaxSpeed = $this->RealMaxSpeed - $this->SpeedReserve;
    342392    $this->TopTariffPrice = $Row['TopTariffPrice'];
     
    348398   
    349399    $this->SpravaUsers = $this->InternetUsers;
    350     $DbResult = $this->Database->query('SELECT SUM(`consumption`) FROM `network_segments`');
     400    $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `network_segments`');
    351401    $TotalConsumption = $DbResult->fetch_array();
    352402    $this->TotalConsumption = $TotalConsumption[0];
  • trunk/Modules/Finance/FinanceOverview.php

    r366 r377  
    2323    $Output .= '<br /><strong>Souhrn:</strong><br />';
    2424
    25     $DbResult = $this->Database->query('SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1');
     25    $DbResult = $this->Database->query('SELECT * FROM FinanceMonthlyOverall ORDER BY Date DESC LIMIT 0,1');
    2626    $Row = $DbResult->fetch_array();
    2727    $Output .= 'Platba za internetovou linku ('.$Finance->RealMaxSpeed.'/'.$Finance->RealMaxSpeed.' kbit/s): <strong>'.$Finance->Internet.' Kč</strong><br />';
     
    6060    $TotalGain = 0;
    6161    $TotalExpense = 0;
    62     $DbResult = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE used=1');
     62    $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM network_devices WHERE used=1');
    6363    $Row = $DbResult->fetch_array();
    6464    $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]);
  • trunk/Modules/Finance/Manage.php

    r375 r377  
    279279   
    280280    // Načti poslední měsíční přehled a nastavení
    281     $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC LIMIT 1');
     281    $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC LIMIT 1');
    282282    $Overall = $DbResult->fetch_array();
    283283
    284284    $Output -= 'Datum: '.date('j.n.Y').'<br />';
    285285   
    286     $Datum = explode('-', $Overall['date']);
     286    $Datum = explode('-', $Overall['Date']);
    287287    $Mesic = date('m') + 0;
    288288
     
    359359      // Update finance charge
    360360      $Output .= 'Měním aktuální parametry sítě...<br>';
    361       $this->Database->delete('finance_charge', 'period = 0');
    362       $DbResult = $this->Database->select('finance_charge', '*', 'period = 1');
     361      $this->Database->delete('FinanceCharge', 'Period = 0');
     362      $DbResult = $this->Database->select('FinanceCharge', '*', 'Period = 1');
    363363      $Charge = $DbResult->fetch_assoc();
    364364      //print_r($Charge);
    365       $DbResult = $this->Database->insert('finance_charge', array('period' => 0, 'internet' => $Charge['internet'], 'internet_speed' => $Charge['internet_speed'], 'internet_speed_reserve' => $Charge['internet_speed_reserve'], 'administration_per_user' => $Charge['administration_per_user'], 'kWh' => $Charge['kWh'], 'base_speed_element' => $Charge['base_speed_element'], 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice']));
     365      $DbResult = $this->Database->insert('FinanceCharge', array('Period' => 0,
     366         'Internet' => $Charge['Internet'], 'InternetSpeed' => $Charge['InternetSpeed'],
     367          'InternetSpeedReserve' => $Charge['InternetSpeedReserve'],
     368          'AdministrationPerUser' => $Charge['AdministrationPerUser'],
     369          'kWh' => $Charge['kWh'], 'BaseSpeedElement' => $Charge['BaseSpeedElement'],
     370          'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice']));
    366371
    367372      $Output .= 'Přidávám měsíční přehled...<br />';
    368       $this->Database->insert('finance_monthly_overall', array('date' => 'NOW()', 'money' => $Finance->Internet, 'kWh' => $Finance->kWh, 'administration' => $Finance->Sprava, 'administration_total' => $SpravaCelkem, 'consumption_total' => $TotalConsumptionCost, 'total_paid' => $Finance->TotalPaid, 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'member_count' => $Finance->InternetUsers));
     373      $this->Database->insert('FinanceMonthlyOverall', array('Date' => 'NOW()',
     374        'Money' => $Finance->Internet, 'kWh' => $Finance->kWh,
     375        'Administration' => $Finance->Sprava, 'AdministrationTotal' => $SpravaCelkem,
     376        'ConsumptionTotal' => $TotalConsumptionCost, 'TotalPaid' => $Finance->TotalPaid,
     377        'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'MemberCount' => $Finance->InternetUsers));
    369378
    370379      // Update tarrifs
  • trunk/Modules/Finance/MonthlyOverall.php

    r370 r377  
    1111
    1212    $Output = '<table class="WideTable"><tr><th>Rok</th><th>Měsíc</th><th>Internet [Kč]</th><th>Účastníků</th><th>Správa [Kč/účastníka]</th><th>Správa [Kč]</th><th>Spotřeba [Kč/kWh]</th><th>Spotřeba [Kč]</th><th>Obrat [Kč]</th><th>Průměrná cena [Kč/účastníka]</th><th align="center">Investice [Kč]</th></tr>';
    13     $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0, 'investment' => 0);
    14     $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC');
     13    $Total = array('Money' => 0, 'AdministrationTotal' => 0, 'ConsumptionTotal' => 0, 'TotalPaid' => 0, 'Investment' => 0);
     14    $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC');
    1515    while($Month = $DbResult->fetch_array())
    1616    {
    17       $DateParts = explode('-', $Month['date']);
    18       $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td><td align="center">'.$Month['investment'].'</td></tr>';
     17      $DateParts = explode('-', $Month['Date']);
     18      $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.
     19        $MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['Money'].
     20        '</td><td align="center">'.$Month['MemberCount'].'</td><td align="center">'.
     21        $Month['Administration'].'</td><td align="center">'.$Month['AdministrationTotal'].
     22        '</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.
     23        $Month['Consumption_Total'].'</td><td align="center">'.$Month['TotalPaid'].
     24        '</td><td align="center">'.round($Month['TotalPaid'] / $Month['MemberCount']).
     25        '</td><td align="center">'.$Month['Investment'].'</td></tr>';
    1926
    20       $Total['money'] += $Month['money'];
    21       $Total['administration_total'] += $Month['administration_total'];
    22       $Total['consumption_total'] += $Month['consumption_total'];
    23       $Total['total_paid'] += $Month['total_paid'];
    24           $Total['investment'] += $Month['investment'];
     27      $Total['Money'] += $Month['Money'];
     28      $Total['AdministrationTotal'] += $Month['AdministrationTotal'];
     29      $Total['ConsumptionTotal'] += $Month['ConsumptionTotal'];
     30      $Total['TotalPaid'] += $Month['TotalPaid'];
     31      $Total['Investment'] += $Month['Investment'];
    2532      //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10">&nbsp;</td></tr>');
    2633    }
    27     $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total['money'].'</th><th>&nbsp;</th><th>&nbsp;</th><th>'.$Total['administration_total'].'</th><th>&nbsp;</th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th>&nbsp;</th><th>'.$Total['investment'].'</th>';
     34    $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total['Money'].'</th><th>&nbsp;</th><th>&nbsp;</th><th>'.$Total['AdministrationTotal'].'</th><th>&nbsp;</th><th>'.$Total['ConsumptionTotal'].'</th><th>'.$Total['TotalPaid'].'</th><th>&nbsp;</th><th>'.$Total['Investment'].'</th>';
    2835    $Output .= '</table>';
    2936    return($Output);
Note: See TracChangeset for help on using the changeset viewer.