Ignore:
Timestamp:
Jan 2, 2015, 11:16:56 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for Hidden items in form types values.
  • Added: Support for Filtered items in form types values.
  • Modified: FinanceOperation Value splitted to (Direction * Value). Direction can be +1 or -1 depends on if money goes out or in company.
  • Added: Menu "Incomes and spends" is now splitted to incomes/spends of bank account or treasury. Direction and document line is filled automatically.
File:
1 edited

Legend:

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

    r718 r719  
    99define('TARIFF_FREE', 7);
    1010define('INVOICE_DUE_DAYS', 15);
    11 define('DOC_LINE_INVOICE_OUT', 6);
     11define('DOC_LINE_TREASURY_IN', 1);
     12define('DOC_LINE_TREASURY_OUT', 2);
    1213define('DOC_LINE_ACCOUNT_IN', 3);
    1314define('DOC_LINE_ACCOUNT_OUT', 4);
     15define('DOC_LINE_INVOICE_IN', 5);
     16define('DOC_LINE_INVOICE_OUT', 6);
    1417define('VAT_TYPE_BASE', 2);
    1518
     
    2326  var $InternetUsers;
    2427  var $SpravaUsers;
    25   var $InternetSegmentId = 21;
    2628  var $MaxSpeed;
    2729  var $RealMaxSpeed;
    2830  var $SpeedReserve;
    2931  var $BaseSpeedElement;
    30   var $UserIdNetwork = 46;
    3132  var $BaseTariffPrice;
    3233  var $TopTariffPrice;
     
    3435  var $TotalInternetPaid;
    3536  var $Tariffs;
    36   var $ExternalSubject = 96;
    3737  var $MainSubject;
    3838  var $BillingPeriods;
     
    186186    while($Member = $DbResult->fetch_assoc())
    187187    {
    188       $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation '.
     188      $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(-Value*Direction), 0) FROM FinanceOperation '.
    189189          'WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceInvoice '.
    190190          'WHERE Subject='.$Member['Subject'].')) as Cash');
     
    277277      'DefaultSortOrder' => 1,
    278278      'Items' => array(
    279         'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
     279        'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '1'),
     280        'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
    280281        'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''),
    281282        'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
     
    293294      ),
    294295      'BeforeInsert' => array($this, 'BeforeInsertFinanceOperation'),
     296    ));
     297   
     298    $this->System->FormManager->RegisterClass('FinanceTreasuryIn', $this->System->FormManager->Classes['FinanceOperation']);
     299    $this->System->FormManager->Classes['FinanceTreasuryIn']['Title'] = 'Pokladní příjmy';
     300    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Direction']['Default'] = 1;
     301    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Direction']['Hidden'] = true;
     302    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Direction']['Filter'] = true;
     303    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['DocumentLine']['Default'] = DOC_LINE_TREASURY_IN;
     304    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['DocumentLine']['Hidden'] = true;
     305    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['DocumentLine']['Filter'] = true;
     306    $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['BankAccount']['Hidden'] = true;
     307       
     308    $this->System->FormManager->RegisterClass('FinanceTreasuryOut', $this->System->FormManager->Classes['FinanceOperation']);
     309    $this->System->FormManager->Classes['FinanceTreasuryOut']['Title'] = 'Pokladní výdeje';
     310    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Direction']['Default'] = -1;
     311    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Direction']['Hidden'] = true;
     312    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Direction']['Filter'] = true;
     313    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['DocumentLine']['Default'] = DOC_LINE_TREASURY_OUT;
     314    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['DocumentLine']['Hidden'] = true;
     315    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['DocumentLine']['Filter'] = true;
     316    $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['BankAccount']['Hidden'] = true;
     317   
     318    $this->System->FormManager->RegisterClass('FinanceAccountIn', $this->System->FormManager->Classes['FinanceOperation']);
     319    $this->System->FormManager->Classes['FinanceAccountIn']['Title'] = 'Příjmy na účet';
     320    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Direction']['Default'] = 1;
     321    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Direction']['Hidden'] = true;
     322    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Direction']['Filter'] = true;
     323    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['DocumentLine']['Default'] = DOC_LINE_ACCOUNT_IN;
     324    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['DocumentLine']['Hidden'] = true;
     325    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['DocumentLine']['Filter'] = true;
     326    $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Treasury']['Hidden'] = true;
     327   
     328   
     329    $this->System->FormManager->RegisterClass('FinanceAccountOut', $this->System->FormManager->Classes['FinanceOperation']);
     330    $this->System->FormManager->Classes['FinanceAccountOut']['Title'] = 'Výdeje z účtu';
     331    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Direction']['Default'] = -1;
     332    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Direction']['Hidden'] = true;
     333    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Direction']['Filter'] = true;
     334    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['DocumentLine']['Default'] = DOC_LINE_ACCOUNT_OUT;
     335    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['DocumentLine']['Hidden'] = true;
     336    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['DocumentLine']['Filter'] = true;
     337    $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Treasury']['Hidden'] = true;
     338   
     339    $this->System->FormManager->RegisterFormType('TFinanceDirection', array(
     340      'Type' => 'Enumeration',
     341      'States' => array(-1 => 'Výdej', 1 => 'Příjem'),
    295342    ));
    296343    $this->System->FormManager->RegisterClass('FinanceInvoice', array(
     
    349396        'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
    350397        'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '',
    351           'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value`) FROM `FinanceOperation` '.
     398          'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`) FROM `FinanceOperation` '.
    352399          'WHERE `FinanceOperation`.`Treasury`=#Id)'),
    353400        'Operations' => array('Type' => 'TFinanceOperationListTreasury', 'Caption' => 'Operace', 'Default' => ''),
     
    379426        'LastImportId' => array('Type' => 'String', 'Caption' => 'Id posledního importu', 'Default' => ''),
    380427        'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '',
    381           'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value`) FROM `FinanceOperation` '.
     428          'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`) FROM `FinanceOperation` '.
    382429          'WHERE `FinanceOperation`.`BankAccount`=#Id)'),
    383430      ),
Note: See TracChangeset for help on using the changeset viewer.