Ignore:
Timestamp:
Jan 3, 2015, 5:55:34 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Invoice negative values replaced by Direction column which is used to determine if invoice is in or out invoice.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Updates.php

    r719 r720  
    10551055  $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = -1 WHERE `Value` < 0 ;');
    10561056  $Manager->Execute('UPDATE `FinanceOperation` SET `Value` = -`Value` WHERE `Value` < 0 ;');
    1057 
     1057  // Set missing FinanceOperation DocumentLine according BillCode
     1058  $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 1 WHERE (`BillCode` LIKE "PP%") AND (`DocumentLine` IS NULL)');
     1059  $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 2 WHERE (`BillCode` LIKE "VP%") AND (`DocumentLine` IS NULL)');
     1060  $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 3 WHERE (`BillCode` LIKE "BV%") AND (`DocumentLine` IS NULL)');
     1061  $Manager->Execute('UPDATE `FinanceOperation` SET `DocumentLine` = 4 WHERE (`BillCode` LIKE "PR%") AND (`DocumentLine` IS NULL)');
     1062 
    10581063  // IS menu item
    10591064  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Příjmy a výdaje"');
     
    10861091      "VALUES (NULL , 'Výdej z účtu', ".$DbRow['Id'].", '".$ActionId."', '1');");
    10871092  }
     1093}
     1094
     1095function UpdateTo720($Manager)
     1096{
     1097        $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;');
     1098        $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE `Value` >= 0 ;');
     1099        $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = -1 WHERE `Value` < 0 ;');
     1100        $Manager->Execute('UPDATE `FinanceInvoice` SET `Value` = -`Value` WHERE `Value` < 0 ;');
     1101        // Set missing FinanceInvoice DocumentLine according BillCode
     1102        $Manager->Execute('UPDATE `FinanceInvoice` SET `DocumentLine` = 5 WHERE (`BillCode` LIKE "PF%") AND (`DocumentLine` IS NULL)');
     1103        $Manager->Execute('UPDATE `FinanceInvoice` SET `DocumentLine` = 6 WHERE (`BillCode` LIKE "VF%") AND (`DocumentLine` IS NULL)');
     1104       
     1105        // IS menu item
     1106        $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Závazky a pohledávky"');
     1107        if($DbResult->num_rows > 0)
     1108        {
     1109                $DbRow = $DbResult->fetch_assoc();
     1110                $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     1111    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     1112    NULL , "", "Příjaté", "1", "/is/?t=FinanceInvoiceIn&a=list", NULL , NULL , NULL , "1");');
     1113                $ActionId = $Manager->Database->insert_id;
     1114                $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     1115                                "VALUES (NULL , 'Přijaté', ".$DbRow['Id'].", '".$ActionId."', '1');");
     1116               
     1117                $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     1118    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     1119    NULL , "", "Vydané", "1", "/is/?t=FinanceInvoiceOut&a=list", NULL , NULL , NULL , "1");');
     1120                $ActionId = $Manager->Database->insert_id;
     1121                $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     1122                                "VALUES (NULL , 'Vydané', ".$DbRow['Id'].", '".$ActionId."', '1');");
     1123        }
    10881124}
    10891125
     
    11451181      715 => array('Revision' => 718, 'Function' => 'UpdateTo718'),
    11461182      718 => array('Revision' => 719, 'Function' => 'UpdateTo719'),
     1183        719 => array('Revision' => 720, 'Function' => 'UpdateTo720'),
    11471184    ));
    11481185  }
Note: See TracChangeset for help on using the changeset viewer.