Ignore:
Timestamp:
Jan 5, 2015, 10:01:40 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Added time designation for scheduled table change actions. This applies to tables Service, ServiceCustomerRel and FinanceCharge. Now time of taking effect is not determined just by customer pay period but by more generally by specified time.
File:
1 edited

Legend:

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

    r725 r726  
    4646
    4747    // Period parameter is not used as it have to be determined from item replacement
    48     $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE `ReplaceId` IS NULL LIMIT 1');
     48    $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE (`ChangeAction` IS NULL) LIMIT 1');
    4949    $Row = $DbResult->fetch_array();
    5050    $this->kWh = $Row['kWh'];
     
    115115    while($Member = $DbResult->fetch_assoc())
    116116    {
    117       $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(-SUM(Value*Direction), 0) FROM FinanceOperation '.
    118           'WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(-SUM(Value*Direction), 0) FROM FinanceInvoice '.
     117      $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value*Direction), 0) FROM FinanceOperation '.
     118          'WHERE Subject='.$Member['Subject'].') - (SELECT COALESCE(SUM(Value*Direction), 0) FROM FinanceInvoice '.
    119119          'WHERE Subject='.$Member['Subject'].')) AS Cash');
    120120      $Cash = $DbResult2->fetch_row();
     
    129129      $DbResult2 = $this->Database->query('SELECT SUM(`Service`.`Price`) AS `Price` '.
    130130          'FROM `ServiceCustomerRel` LEFT JOIN '.
    131           '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE `ServiceCustomerRel`.`Customer`='.
    132           $Member['Id'].' AND `ServiceCustomerRel`.`Action` IS NULL');
     131          '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE (`ServiceCustomerRel`.`Customer`='.
     132          $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)');
    133133      $DbRow = $DbResult2->fetch_assoc();
    134134      $Monthly = 0;
     
    149149      }
    150150      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'],
    151           'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet,
     151          'MonthlyInternet' => $MonthlyInet,
    152152          'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
    153153          'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
     
    430430        'BaseTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Základní cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'),
    431431        'TopTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Nejvyšší cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'),
    432         'Action' => array('Type' => 'TActionEnum', 'Caption' => 'Změna období', 'Default' => '', 'Null' => true),
    433         'ReplaceId' => array('Type' => 'TFinanceCharge', 'Caption' => 'Cílová položka', 'Default' => '0', 'Null' => true),
     432        'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true),
     433                'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true),
     434        'ChangeReplaceId' => array('Type' => 'TFinanceCharge', 'Caption' => 'Změna - položka', 'Default' => '0', 'Null' => true),
    434435      ),
    435436    ));
Note: See TracChangeset for help on using the changeset viewer.