Changeset 645


Ignore:
Timestamp:
Mar 25, 2014, 12:38:20 AM (11 years ago)
Author:
chronos
Message:
  • Přidáno: Typ sazby DPH jako samostatná tabulka.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r644 r645  
    142142      'Category' => array('Type' => 'TServiceCategory', 'Caption' => 'Skupina', 'Default' => '', 'Null' => true),
    143143      'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč'),
    144       'VAT' => array('Type' => 'TFinanceVAT', 'Caption' => 'Sazba DPH', 'Default' => '0', 'Suffix' => ''),
     144      'VAT' => array('Type' => 'TFinanceVATType', 'Caption' => 'Sazba DPH', 'Default' => '0', 'Suffix' => ''),
    145145      'CustomerCount' => array('Type' => 'Integer', 'Caption' => 'Počet zákazníků', 'Default' => '', 'ReadOnly' => true),
    146146      'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => ''),
     
    247247    'Filter' => '1',
    248248  ),
     249  'TFinanceVATType' => array(
     250    'Type' => 'Reference',
     251    'Table' => 'FinanceVATType',
     252    'Id' => 'Id',
     253    'Name' => 'Name',
     254    'Filter' => '1',
     255  ),
    249256  'TModule' => array(
    250257    'Type' => 'Reference',
  • trunk/Application/Version.php

    r644 r645  
    11<?php
    22
    3 $Revision = 644; // Subversion revision
    4 $DatabaseRevision = 633; // SQL structure revision
     3$Revision = 645; // Subversion revision
     4$DatabaseRevision = 645; // SQL structure revision
    55$ReleaseTime = strtotime('2014-03-24');
  • trunk/Common/Setup/Updates.php

    r644 r645  
    562562}
    563563
     564function UpdateTo645($Manager)
     565{
     566        $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceVATType` (
     567  `Id` int(11) NOT NULL,
     568  `Name` varchar(255) NOT NULL,
     569  PRIMARY KEY (`Id`)
     570) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
     571  $Manager->Execute('INSERT INTO `FinanceVATType` FROM (SELECT Id, Name FROM `FinanceVAT`)');
     572  $Manager->Execute('ALTER TABLE `FinanceVAT` ADD `ValidTo` DATE NULL ,
     573ADD `Type` INT NOT NULL ;');
     574  $Manager->Execute('UPDATE `FinanceVAT` SET `Type`=(SELECT `Id` FROM `FinanceVATType` WHERE `FinanceVATType`.`Name`=`FinanceVAT`.`Name`)');
     575  $Manager->Execute('ALTER TABLE `FinanceVAT` DROP `Name`');
     576}
     577
     578
    564579class Updates
    565580{
     
    598613      627 => array('Revision' => 632, 'Function' => 'UpdateTo632'),
    599614      632 => array('Revision' => 633, 'Function' => 'UpdateTo633'),
     615      633 => array('Revision' => 645, 'Function' => 'UpdateTo645'),
    600616    ));
    601617  }
  • trunk/Modules/Customer/Customer.php

    r586 r645  
    5151      ),
    5252      'Actions' => array(
    53         array('Caption' => 'Přepočítat', 'URL' => '/finance/manage.php?Operation=Recalculate'),
     53        array('Caption' => 'Přepočítat', 'URL' => '/finance/sprava/?Operation=Recalculate'),
    5454      ),
    5555    ));
  • trunk/Modules/Finance/Finance.php

    r642 r645  
    1818define('DOC_LINE_ACCOUNT_IN', 3);
    1919define('DOC_LINE_ACCOUNT_OUT', 4);
     20define('VAT_TYPE_BASE', 2);
    2021
    2122
     
    292293    return($Output);
    293294  }
     295 
     296  function GetVATByType($TypeId)
     297  {
     298        $Time = time();
     299        $DbResult = $this->Database->select('FinanceVAT', 'Value', '(Type='.$TypeId.
     300      ') AND (ValidFrom <= "'.TimeToMysqlDate($Time).'") AND ((ValidTo >= "'.
     301      TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1');
     302    $Row = $DbResult->fetch_array();
     303    return($Row[0]);
     304  }
    294305}
    295306
     
    383394        'Quantity' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'),
    384395        'VAT' => array('Type' => 'Integer', 'Caption' => 'Daň', 'Default' => '21', 'Suffix' => '%'),
     396        'Total' => array('Type' => 'Integer', 'Caption' => 'Celkem', 'Default' => '', 'Suffix' => 'Kč',
     397          'ReadOnly' => true, 'SQL' => '`Price` * `Quantity`'),
    385398      ),
    386399    ));
     
    459472      ),
    460473    ));
     474    $this->System->FormManager->RegisterClass('FinanceVAT', array(
     475      'Title' => 'Sazby DPH',
     476      'Table' => 'FinanceVAT',
     477      'Items' => array(
     478        'Type' => array('Type' => 'TFinanceVATType', 'Caption' => 'Typ', 'Default' => ''),
     479        'ValidFrom' => array('Type' => 'Date', 'Caption' => 'Platnost od', 'Default' => ''),
     480        'ValidTo' => array('Type' => 'Date', 'Caption' => 'Platnost do', 'Default' => '', 'Null' => true),
     481        'Value' => array('Type' => 'Integer', 'Caption' => 'Hodnota', 'Default' => '', 'Suffix' => '%'),
     482      ),
     483    ));
     484    $this->System->FormManager->RegisterClass('FinanceVATType', array(
     485      'Title' => 'Sazby DPH',
     486      'Table' => 'FinanceVATType',
     487      'Items' => array(
     488        'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
     489      ),
     490    ));
    461491
    462492    $this->System->AddModule(new Bill($this->System));
  • trunk/Modules/Finance/Manage.php

    r639 r645  
    151151        $InvoiceItems = array();
    152152        $MonthlyTotal = 0;
    153         $DbResult2 = $this->Database->query('SELECT Service.*, FinanceVAT.Value AS VAT '.
    154           'FROM ServiceCustomerRel LEFT JOIN Service '.
    155           'ON Service.Id=ServiceCustomerRel.Service '.
    156           'LEFT JOIN FinanceVAT ON FinanceVAT.Id=Service.VAT '.
    157           'WHERE (ServiceCustomerRel.Customer='.
    158           $Member['Id'].') AND (ServiceCustomerRel.Action IS NULL) ');
     153        $DbResult2 = $this->Database->query('SELECT `Service`.* '.
     154          'FROM `ServiceCustomerRel` LEFT JOIN `Service` '.
     155          'ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '.
     156          'WHERE (`ServiceCustomerRel`.`Customer`='.
     157          $Member['Id'].') AND (`ServiceCustomerRel`.`Action` IS NULL) ');
    159158        while($Service = $DbResult2->fetch_assoc())
    160159        {
    161160          $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'],
    162             'Quantity' => $Period['MonthCount'], 'VAT' => $Service['VAT']);
     161            'Quantity' => $Period['MonthCount'], 'VAT' => $this->System->Modules['Finance']->GetVATByType($Service['VAT']));
    163162          $MonthlyTotal += $Service['Price'];
    164163        }
     
    166165        {
    167166          $InvoiceItems[] = array('Description' => 'Spotřeba energie', 'Price' => -$Member['MonthlyPlus'],
    168             'Quantity' => $Period['MonthCount'], 'VAT' => 2);
     167            'Quantity' => $Period['MonthCount'], 'VAT' => $this->System->Modules['Finance']->GetVATByType(VAT_TYPE_BASE));
    169168          $MonthlyTotal -= $Member['MonthlyPlus'];
    170169        }
Note: See TracChangeset for help on using the changeset viewer.