Changeset 741


Ignore:
Timestamp:
Jul 5, 2015, 6:24:33 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Added Direction column to finance operations and invoices. This column will serve as real direction where ValueSign could be different for storno operations.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r739 r741  
    11<?php
    22
    3 $Revision = 739; // Subversion revision
    4 $DatabaseRevision = 739; // SQL structure revision
    5 $ReleaseTime = strtotime('2015-05-22');
     3$Revision = 741; // Subversion revision
     4$DatabaseRevision = 741; // SQL structure revision
     5$ReleaseTime = strtotime('2015-07-05');
  • trunk/Common/Setup/Updates.php

    r740 r741  
    13551355  `Domain` int(11) NOT NULL,
    13561356  `Sequence` int(11) NOT NULL,
     1357  PRIMARY KEY (`Id`)
    13571358) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;');
    13581359
    1359   $Manager->Execute('ALTER TABLE `NetworkDomainServer`
    1360  ADD PRIMARY KEY (`Id`), ADD KEY `Domain` (`Domain`);');
     1360  $Manager->Execute('ALTER TABLE `NetworkDomainServer` ADD KEY `Domain` (`Domain`);');
    13611361
    13621362  $Manager->Execute('ALTER TABLE `NetworkDomainServer`
     
    14211421  $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;');
    14221422  $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;');
     1423}
     1424
     1425function UpdateTo741($Manager)
     1426{
     1427        // Add Direction column
     1428  $Manager->Execute('ALTER TABLE `FinanceOperationGroup` ADD `Direction` INT NOT NULL ;');
     1429  $Manager->Execute('UPDATE `FinanceOperationGroup` SET `Direction` = 1 WHERE ValueSign=-1');
     1430  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;');
     1431  $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = 1 WHERE ValueSign=-1');
     1432  $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup` ADD `Direction` INT NOT NULL ;');
     1433  $Manager->Execute('UPDATE `FinanceInvoiceGroup` SET `Direction` = 1 WHERE ValueSign=1');
     1434  $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;'); 
     1435  $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE ValueSign=1');
    14231436}
    14241437
     
    14901503      735 => array('Revision' => 736, 'Function' => 'UpdateTo736'),
    14911504      736 => array('Revision' => 739, 'Function' => 'UpdateTo739'),
     1505        739 => array('Revision' => 740, 'Function' => 'UpdateTo740'),
     1506        740 => array('Revision' => 741, 'Function' => 'UpdateTo741'),
    14921507    ));
    14931508  }
  • trunk/Modules/Finance/Bill.php

    r740 r741  
    7878    }
    7979
    80     // If negative value => switch sides
    81     if($Invoice['ValueSign'] == -1)
     80    // If direction is in => switch sides
     81    if($Invoice['Direction'] == FINANCE_DIRECTION_OUT)
     82    {           
     83    }
     84    else if($Invoice['Direction'] == FINANCE_DIRECTION_IN)
    8285    {
    8386      $Subject = $SubjectTo;
     
    8588      $SubjectFrom = $Subject;
    8689    }
     90    else throw new Exception('Wrong finance direction');
    8791
    8892    $PaymentType = array('převodem', 'hotově');
     
    162166
    163167    $BooleanText = array('Ne', 'Ano');
    164     if($Operation['ValueSign'] == -1)
     168    if($Operation['Direction'] == FINANCE_DIRECTION_OUT)
    165169    $Desc = array(
    166170      'Type' => 'VÝDAJOVÝ',
     
    168172      'Target' => 'Vydáno komu',
    169173    );
    170     else if($Operation['ValueSign'] == 1)
     174    else if($Operation['Direction'] == FINANCE_DIRECTION_IN)
    171175    $Desc = array(
    172176      'Type' => 'PŘÍJMOVÝ',
  • trunk/Modules/Finance/Finance.php

    r740 r741  
    1717define('INVOICE_GROUP_OUT', 2);
    1818define('VAT_TYPE_BASE', 2);
    19 
     19define('FINANCE_DIRECTION_OUT', 0);
     20define('FINANCE_DIRECTION_IN', 1);
    2021
    2122class Finance extends Model
     
    219220        'Cash' => array('Type' => 'Boolean', 'Caption' => 'Hotově', 'Default' => ''),
    220221        'Taxable' => array('Type' => 'Boolean', 'Caption' => 'Zdanitelné', 'Default' => ''),
    221         'ValueSign' => array('Type' => 'TFinanceOperationValueSign', 'Caption' => 'Znaménko', 'Default' => '1'),
     222        'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
     223        'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko', 'Default' => '1'),
    222224        'Value' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'),
    223225        'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true),
     
    278280        'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'),
    279281        'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'),
    280         'ValueSign' => array('Type' => 'TFinanceInvoiceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
     282        'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
     283        'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
    281284      ),
    282285    ));
     
    288291      'Filter' => '1',
    289292    ));
    290     $this->System->FormManager->RegisterFormType('TFinanceOperationValueSign', array(
     293    $this->System->FormManager->RegisterFormType('TFinanceValueSign', array(
    291294      'Type' => 'Enumeration',
    292295      'States' => array(-1 => 'Mínus', 1 => 'Plus'),
     296    ));
     297    $this->System->FormManager->RegisterFormType('TFinanceDirection', array(
     298      'Type' => 'Enumeration',
     299      'States' => array(0 => 'Příjem', 1 => 'Výdej'),
    293300    ));
    294301    $this->System->FormManager->RegisterClass('FinanceInvoice', array(
     
    304311        'TimeDue' => array('Type' => 'Date', 'Caption' => 'Čas splatnosti', 'Default' => ''),
    305312        'TimePayment' => array('Type' => 'Date', 'Caption' => 'Čas zaplacení', 'Default' => '', 'Null' => true),
    306         'ValueSign' => array('Type' => 'TFinanceInvoiceValueSign', 'Caption' => 'Znaménko', 'Default' => '1'),
     313        'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
     314        'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko', 'Default' => '1'),
    307315        'Value' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'),
    308316        'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true),
     
    331339    $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Filter'] = true;
    332340
    333     $this->System->FormManager->RegisterFormType('TFinanceInvoiceValueSign', array(
    334         'Type' => 'Enumeration',
    335         'States' => array(-1 => 'Mínus', 1 => 'Plus'),
    336     ));
    337 
    338341    $this->System->FormManager->RegisterClass('FinanceInvoiceGroup', array(
    339342      'Title' => 'Skupina faktur',
     
    342345        'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'),
    343346        'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'),
    344         'ValueSign' => array('Type' => 'TFinanceInvoiceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
     347        'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
     348        'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
    345349      ),
    346350    ));
  • trunk/Modules/Finance/Manage.php

    r740 r741  
    101101
    102102  function InsertInvoice($Subject, $TimeCreation, $TimeDue, $ValueSign, $Items,
    103   $Group, $PeriodFrom, $PeriodTo)
     103  $Group, $PeriodFrom, $PeriodTo, $Direction)
    104104  {
    105105    global $LastInsertTime;
     
    114114      'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation),
    115115      'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue,
    116       'ValueSign' => $ValueSign, 'BillCode' => $BillCode,
     116      'ValueSign' => $ValueSign, 'BillCode' => $BillCode, 'Direction' => $Direction,
    117117      'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo),
    118118      'Generate' => 1, 'Group' => $FinanceGroup['Id']));
     
    185185          $Output .= $TimePeriodText.': '.$MonthlyTotal.' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />';
    186186          $this->InsertInvoice($Member['Subject'], time(), time() + 3600 * 24 * INVOICE_DUE_DAYS,
    187             $FinanceGroup['ValueSign'], $InvoiceItems, $FinanceGroup, $Period['From'], $Period['To']);
     187            $FinanceGroup['ValueSign'], $InvoiceItems, $FinanceGroup, $Period['From'],
     188                $Period['To'], $FinanceGroup['Direction']);
    188189
    189190          $Output .= $this->SendPaymentEmail($Member['Id']);
Note: See TracChangeset for help on using the changeset viewer.