Changeset 740
- Timestamp:
- Jul 3, 2015, 11:36:07 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/FormClasses.php
r738 r740 68 68 'ReadOnly' => true), 69 69 'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 70 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.71 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.` Direction` = 1))'),70 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 71 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`ValueSign` = 1))'), 72 72 'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 73 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.74 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.` Direction` = -1))'),73 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 74 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`ValueSign` = -1))'), 75 75 'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 76 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.76 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 77 77 'AND (`FinanceOperation`.`Time` >= `DateStart`))'), 78 78 'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 79 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.80 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.` Direction` = 1))'),79 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 80 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.`ValueSign` = 1))'), 81 81 'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 82 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.83 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.` Direction` = -1))'),82 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 83 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperation`.`ValueSign` = -1))'), 84 84 'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 85 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.85 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '. 86 86 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'), 87 87 'Claims' => array('Type' => 'Integer', 'Caption' => 'Pohledávky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 88 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.` Direction`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.89 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoice`.` Direction` = 1))'),88 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.`ValueSign`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '. 89 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoice`.`ValueSign` = 1))'), 90 90 'Liabilities' => array('Type' => 'Integer', 'Caption' => 'Závazky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 91 'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.` Direction`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.92 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoice`.` Direction` = -1))'),91 'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.`ValueSign`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '. 92 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoice`.`ValueSign` = -1))'), 93 93 'InvoiceBalance' => array('Type' => 'Integer', 'Caption' => 'Fakturační rozdíl', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 94 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.` Direction`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.94 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.`ValueSign`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '. 95 95 'AND (`FinanceInvoice`.`Time` >= `DateStart`))'), 96 96 ), -
trunk/Common/Setup/Updates.php
r739 r740 1354 1354 `Address` varchar(255) NOT NULL, 1355 1355 `Domain` int(11) NOT NULL, 1356 `Sequence` int(11) NOT NULL 1356 `Sequence` int(11) NOT NULL, 1357 1357 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 1358 1358 … … 1362 1362 $Manager->Execute('ALTER TABLE `NetworkDomainServer` 1363 1363 ADD CONSTRAINT `NetworkDomainServer_ibfk_1` FOREIGN KEY (`Domain`) REFERENCES `NetworkDomain` (`Id`);'); 1364 1364 } 1365 1366 function UpdateTo740($Manager) 1367 { 1368 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceGroup` ( 1369 `Id` int(11) NOT NULL AUTO_INCREMENT, 1370 `Name` varchar(255) NOT NULL, 1371 `DocumentLine` int(11) NOT NULL, 1372 `ValueSign` int(11) NOT NULL, 1373 PRIMARY KEY (`Id`), 1374 KEY `DocumentLine` (`DocumentLine`) 1375 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 1376 $Manager->Execute('ALTER TABLE `FinanceInvoiceGroup` 1377 ADD CONSTRAINT `FinanceInvoiceGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); 1378 $Manager->Execute('INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES 1379 (1, "Přijaté faktury", 5, -1), 1380 (2, "Vydané faktury", 6, 1);'); 1381 1382 // Transform FinanceInvoice.DocumentLine reference to FinanceInvoiceGroup 1383 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Group` INT NULL AFTER `Id`;'); 1384 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD INDEX(`Group`);'); 1385 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceInvoiceGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1386 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE `DocumentLine`=5'); 1387 $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE `DocumentLine`=6'); 1388 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP FOREIGN KEY `FinanceInvoice_ibfk_3`;'); 1389 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `DocumentLine`;'); 1390 1391 $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceOperationGroup` ( 1392 `Id` int(11) NOT NULL AUTO_INCREMENT, 1393 `Name` varchar(255) NOT NULL, 1394 `DocumentLine` int(11) NOT NULL, 1395 `ValueSign` int(11) NOT NULL, 1396 PRIMARY KEY (`Id`), 1397 KEY `DocumentLine` (`DocumentLine`) 1398 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;'); 1399 $Manager->Execute('ALTER TABLE `FinanceOperationGroup` 1400 ADD CONSTRAINT `FinanceOperationGroup_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); 1401 $Manager->Execute('INSERT INTO `FinanceOperationGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`) VALUES 1402 (1, "Příjem do pokladny", 1, 1), 1403 (2, "Výdej z pokladny", 2, -1), 1404 (3, "Příjem na účet", 3, 1), 1405 (4, "Výdej z účtu", 4, -1), 1406 (5, "Nezařazené (ručně vyčistit)", 1, 1);'); 1407 1408 // Transform FinanceOperation.DocumentLine reference to FinanceOperationGroup 1409 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Group` INT NULL AFTER `Id`;'); 1410 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD INDEX (`Group`);'); 1411 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`Group`) REFERENCES `FinanceOperationGroup`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1412 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE `DocumentLine`=1'); 1413 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE `DocumentLine`=2'); 1414 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE `DocumentLine`=3'); 1415 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE `DocumentLine`=4'); 1416 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=10'); 1417 $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=5 WHERE `DocumentLine`=5'); 1418 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_6`;'); 1419 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `DocumentLine`;'); 1420 1421 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;'); 1422 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Direction` `ValueSign` INT(11) NOT NULL;'); 1365 1423 } 1366 1424 -
trunk/Modules/Finance/Bill.php
r738 r740 79 79 80 80 // If negative value => switch sides 81 if($Invoice[' Direction'] == -1)81 if($Invoice['ValueSign'] == -1) 82 82 { 83 83 $Subject = $SubjectTo; … … 162 162 163 163 $BooleanText = array('Ne', 'Ano'); 164 if($Operation[' Direction'] == -1)164 if($Operation['ValueSign'] == -1) 165 165 $Desc = array( 166 166 'Type' => 'VÝDAJOVÝ', … … 168 168 'Target' => 'Vydáno komu', 169 169 ); 170 else if($Operation[' Direction'] == 1)170 else if($Operation['ValueSign'] == 1) 171 171 $Desc = array( 172 172 'Type' => 'PŘÍJMOVÝ', -
trunk/Modules/Finance/Finance.php
r738 r740 10 10 define('TARIFF_FREE', 7); 11 11 define('INVOICE_DUE_DAYS', 15); 12 define(' DOC_LINE_TREASURY_IN', 1);13 define(' DOC_LINE_TREASURY_OUT', 2);14 define(' DOC_LINE_ACCOUNT_IN', 3);15 define(' DOC_LINE_ACCOUNT_OUT', 4);16 define(' DOC_LINE_INVOICE_IN', 5);17 define(' DOC_LINE_INVOICE_OUT', 6);12 define('OPERATION_GROUP_TREASURY_IN', 1); 13 define('OPERATION_GROUP_TREASURY_OUT', 2); 14 define('OPERATION_GROUP_ACCOUNT_IN', 3); 15 define('OPERATION_GROUP_ACCOUNT_OUT', 4); 16 define('INVOICE_GROUP_IN', 1); 17 define('INVOICE_GROUP_OUT', 2); 18 18 define('VAT_TYPE_BASE', 2); 19 19 … … 108 108 } 109 109 110 function GetFinanceGroupById($Id, $Table) 111 { 112 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); 113 if($DbResult->num_rows == 1) { 114 $Group = $DbResult->fetch_assoc(); 115 return($Group); 116 } else die('Finance group not found'); 117 } 118 110 119 function RecalculateMemberPayment() 111 120 { … … 115 124 while($Member = $DbResult->fetch_assoc()) 116 125 { 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'.119 'WHERE Subject='.$Member['Subject'].')) AS Cash');126 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value` * `ValueSign`), 0) FROM `FinanceOperation` '. 127 'WHERE `Subject`='.$Member['Subject'].') - (SELECT COALESCE(SUM(`Value` * `ValueSign`), 0) FROM `FinanceInvoice` '. 128 'WHERE `Subject`='.$Member['Subject'].')) AS `Cash`'); 120 129 $Cash = $DbResult2->fetch_row(); 121 130 $Cash = $Cash[0]; … … 204 213 'DefaultSortOrder' => 1, 205 214 'Items' => array( 206 'Direction' => array('Type' => 'TFinanceOperationDirection', 'Caption' => 'Směr', 'Default' => '1'), 207 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 208 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 215 'Group' => array('Type' => 'TFinanceOperationGroup', 'Caption' => 'Skupina', 'Default' => ''), 216 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => '', 'ReadOnly' => true), 209 217 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), 210 218 'Time' => array('Type' => 'Date', 'Caption' => 'Čas realizace', 'Default' => ''), 211 219 'Cash' => array('Type' => 'Boolean', 'Caption' => 'Hotově', 'Default' => ''), 212 220 'Taxable' => array('Type' => 'Boolean', 'Caption' => 'Zdanitelné', 'Default' => ''), 221 'ValueSign' => array('Type' => 'TFinanceOperationValueSign', 'Caption' => 'Znaménko', 'Default' => '1'), 213 222 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'), 214 223 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), … … 225 234 $this->System->FormManager->RegisterClass('FinanceTreasuryIn', $this->System->FormManager->Classes['FinanceOperation']); 226 235 $this->System->FormManager->Classes['FinanceTreasuryIn']['Title'] = 'Pokladní příjmy'; 227 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items'][' Direction']['Default'] = 1;228 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items'][' Direction']['Hidden'] = true;229 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items'][' Direction']['Filter'] = true;230 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items'][' DocumentLine']['Default'] = DOC_LINE_TREASURY_IN;231 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items'][' DocumentLine']['Hidden'] = true;232 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items'][' DocumentLine']['Filter'] = true;236 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Group']['Default'] = OPERATION_GROUP_TREASURY_IN; 237 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Group']['Hidden'] = true; 238 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Group']['Filter'] = true; 239 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 1; 240 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true; 241 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false; 233 242 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['BankAccount']['Hidden'] = true; 234 243 235 244 $this->System->FormManager->RegisterClass('FinanceTreasuryOut', $this->System->FormManager->Classes['FinanceOperation']); 236 245 $this->System->FormManager->Classes['FinanceTreasuryOut']['Title'] = 'Pokladní výdeje'; 237 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items'][' Direction']['Default'] = -1;238 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items'][' Direction']['Hidden'] = true;239 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items'][' Direction']['Filter'] = true;240 $this->System->FormManager->Classes['FinanceTreasury Out']['Items']['DocumentLine']['Default'] = DOC_LINE_TREASURY_OUT;241 $this->System->FormManager->Classes['FinanceTreasury Out']['Items']['DocumentLine']['Hidden'] = true;242 $this->System->FormManager->Classes['FinanceTreasury Out']['Items']['DocumentLine']['Filter'] = true;246 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Group']['Default'] = OPERATION_GROUP_TREASURY_OUT; 247 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Group']['Hidden'] = true; 248 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Group']['Filter'] = true; 249 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 1; 250 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true; 251 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false; 243 252 $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['BankAccount']['Hidden'] = true; 244 253 245 254 $this->System->FormManager->RegisterClass('FinanceAccountIn', $this->System->FormManager->Classes['FinanceOperation']); 246 255 $this->System->FormManager->Classes['FinanceAccountIn']['Title'] = 'Příjmy na účet'; 247 $this->System->FormManager->Classes['FinanceAccountIn']['Items'][' Direction']['Default'] = 1;248 $this->System->FormManager->Classes['FinanceAccountIn']['Items'][' Direction']['Hidden'] = true;249 $this->System->FormManager->Classes['FinanceAccountIn']['Items'][' Direction']['Filter'] = true;250 $this->System->FormManager->Classes['Finance AccountIn']['Items']['DocumentLine']['Default'] = DOC_LINE_ACCOUNT_IN;251 $this->System->FormManager->Classes['Finance AccountIn']['Items']['DocumentLine']['Hidden'] = true;252 $this->System->FormManager->Classes['Finance AccountIn']['Items']['DocumentLine']['Filter'] = true;256 $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Group']['Default'] = OPERATION_GROUP_ACCOUNT_IN; 257 $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Group']['Hidden'] = true; 258 $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Group']['Filter'] = true; 259 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 0; 260 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true; 261 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false; 253 262 $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Treasury']['Hidden'] = true; 254 255 263 256 264 $this->System->FormManager->RegisterClass('FinanceAccountOut', $this->System->FormManager->Classes['FinanceOperation']); 257 265 $this->System->FormManager->Classes['FinanceAccountOut']['Title'] = 'Výdeje z účtu'; 258 $this->System->FormManager->Classes['FinanceAccountOut']['Items'][' Direction']['Default'] = -1;259 $this->System->FormManager->Classes['FinanceAccountOut']['Items'][' Direction']['Hidden'] = true;260 $this->System->FormManager->Classes['FinanceAccountOut']['Items'][' Direction']['Filter'] = true;261 $this->System->FormManager->Classes['Finance AccountOut']['Items']['DocumentLine']['Default'] = DOC_LINE_ACCOUNT_OUT;262 $this->System->FormManager->Classes['Finance AccountOut']['Items']['DocumentLine']['Hidden'] = true;263 $this->System->FormManager->Classes['Finance AccountOut']['Items']['DocumentLine']['Filter'] = true;266 $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Group']['Default'] = OPERATION_GROUP_ACCOUNT_OUT; 267 $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Group']['Hidden'] = true; 268 $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Group']['Filter'] = true; 269 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 0; 270 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true; 271 $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false; 264 272 $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Treasury']['Hidden'] = true; 265 273 266 $this->System->FormManager->RegisterFormType('TFinanceOperationDirection', array( 274 $this->System->FormManager->RegisterClass('FinanceOperationGroup', array( 275 'Title' => 'Skupina finančních operací', 276 'Table' => 'FinanceOperationGroup', 277 'Items' => array( 278 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'), 279 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'), 280 'ValueSign' => array('Type' => 'TFinanceInvoiceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'), 281 ), 282 )); 283 $this->System->FormManager->RegisterFormType('TFinanceOperationGroup', array( 284 'Type' => 'Reference', 285 'Table' => 'FinanceOperationGroup', 286 'Id' => 'Id', 287 'Name' => 'Name', 288 'Filter' => '1', 289 )); 290 $this->System->FormManager->RegisterFormType('TFinanceOperationValueSign', array( 267 291 'Type' => 'Enumeration', 268 'States' => array(-1 => ' Výdej', 1 => 'Příjem'),292 'States' => array(-1 => 'Mínus', 1 => 'Plus'), 269 293 )); 270 294 $this->System->FormManager->RegisterClass('FinanceInvoice', array( … … 274 298 'DefaultSortOrder' => 1, 275 299 'Items' => array( 276 'Direction' => array('Type' => 'TFinanceInvoiceDirection', 'Caption' => 'Směr', 'Default' => '1'), 277 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 278 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 300 'Group' => array('Type' => 'TFinanceInvoiceGroup', 'Caption' => 'Skupina', 'Default' => ''), 301 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => '', 'ReadOnly' => true), 279 302 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), 280 303 'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''), 281 304 'TimeDue' => array('Type' => 'Date', 'Caption' => 'Čas splatnosti', 'Default' => ''), 282 305 'TimePayment' => array('Type' => 'Date', 'Caption' => 'Čas zaplacení', 'Default' => '', 'Null' => true), 306 'ValueSign' => array('Type' => 'TFinanceInvoiceValueSign', 'Caption' => 'Znaménko', 'Default' => '1'), 283 307 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'), 284 308 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), … … 297 321 $this->System->FormManager->RegisterClass('FinanceInvoiceIn', $this->System->FormManager->Classes['FinanceInvoice']); 298 322 $this->System->FormManager->Classes['FinanceInvoiceIn']['Title'] = 'Přijaté faktury'; 299 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Direction']['Default'] = -1; 300 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Direction']['Hidden'] = true; 301 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Direction']['Filter'] = true; 302 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['DocumentLine']['Default'] = DOC_LINE_INVOICE_IN; 303 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['DocumentLine']['Hidden'] = true; 304 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['DocumentLine']['Filter'] = true; 323 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Group']['Default'] = INVOICE_GROUP_IN; 324 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Group']['Hidden'] = true; 325 $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Group']['Filter'] = true; 305 326 306 327 $this->System->FormManager->RegisterClass('FinanceInvoiceOut', $this->System->FormManager->Classes['FinanceInvoice']); 307 328 $this->System->FormManager->Classes['FinanceInvoiceOut']['Title'] = 'Vydané faktury'; 308 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Direction']['Default'] = 1; 309 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Direction']['Hidden'] = true; 310 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Direction']['Filter'] = true; 311 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['DocumentLine']['Default'] = DOC_LINE_INVOICE_OUT; 312 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['DocumentLine']['Hidden'] = true; 313 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['DocumentLine']['Filter'] = true; 314 315 $this->System->FormManager->RegisterFormType('TFinanceInvoiceDirection', array( 329 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Default'] = INVOICE_GROUP_OUT; 330 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Hidden'] = true; 331 $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Filter'] = true; 332 333 $this->System->FormManager->RegisterFormType('TFinanceInvoiceValueSign', array( 316 334 'Type' => 'Enumeration', 317 'States' => array(-1 => 'Příjem', 1 => 'Výdej'), 335 'States' => array(-1 => 'Mínus', 1 => 'Plus'), 336 )); 337 338 $this->System->FormManager->RegisterClass('FinanceInvoiceGroup', array( 339 'Title' => 'Skupina faktur', 340 'Table' => 'FinanceInvoiceGroup', 341 'Items' => array( 342 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'), 343 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'), 344 'ValueSign' => array('Type' => 'TFinanceInvoiceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'), 345 ), 346 )); 347 $this->System->FormManager->RegisterFormType('TFinanceInvoiceGroup', array( 348 'Type' => 'Reference', 349 'Table' => 'FinanceInvoiceGroup', 350 'Id' => 'Id', 351 'Name' => 'Name', 352 'Filter' => '1', 318 353 )); 319 354 … … 347 382 'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''), 348 383 'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '', 349 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`) FROM `FinanceOperation` '.384 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`) FROM `FinanceOperation` '. 350 385 'WHERE `FinanceOperation`.`Treasury`=#Id)'), 351 386 'Operations' => array('Type' => 'TFinanceOperationListTreasury', 'Caption' => 'Operace', 'Default' => ''), … … 378 413 'LastImportId' => array('Type' => 'String', 'Caption' => 'Id posledního importu', 'Default' => ''), 379 414 'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '', 380 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`) FROM `FinanceOperation` '.415 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`) FROM `FinanceOperation` '. 381 416 'WHERE `FinanceOperation`.`BankAccount`=#Id)'), 382 417 'AutoImport' => array('Type' => 'Boolean', 'Caption' => 'Automaticky stahovat z banky', 'Default' => ''), … … 511 546 if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 512 547 else $Year = date("Y", $Form->Values['ValidFrom']); 513 $ DocumentLine = $Form->Values['DocumentLine'];514 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($ DocumentLine, $Year);548 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 549 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($FinanceGroup['DocumentLine'], $Year); 515 550 return($Form->Values); 516 551 } -
trunk/Modules/Finance/Import.php
r738 r740 120 120 } 121 121 122 function InsertMoney($Subject, $Value, $ Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine)122 function InsertMoney($Subject, $Value, $ValueSign, $Cash, $Taxable, $Time, $Text, $Group) 123 123 { 124 124 $Year = date('Y', $Time); 125 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($ DocumentLine, $Year);125 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($Group['DocumentLine'], $Year); 126 126 // TODO: Fixed BankAccount=1, allow to select bank account for import 127 127 $this->Database->insert('FinanceOperation', array('Text' => $Text, 128 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, ' Direction' => $Direction,128 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'ValueSign' => $ValueSign, 129 129 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode, 130 'BankAccount' => 1 ));130 'BankAccount' => 1, 'Group' => $Group['Id'])); 131 131 } 132 132 … … 139 139 for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 140 140 { 141 // TODO: Use links to database records instead of contants142 141 if($_POST['Money'.$I] < 0) { 143 $DocumentLine = 4; 144 $Direction = -1; 142 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 145 143 } else { 146 $DocumentLine = 3; 147 $Direction = 1; 144 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 145 } 149 146 $Date = explode('-', $_POST['Date'.$I]); 150 147 $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 151 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine); 148 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $FinanceGroup['ValueSign'], 149 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 152 150 $Output .= $I.', '; 153 151 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); -
trunk/Modules/Finance/Manage.php
r738 r740 100 100 } 101 101 102 function InsertInvoice($Subject, $TimeCreation, $TimeDue, $ Direction, $Items,103 $ DocumentLine, $PeriodFrom, $PeriodTo)102 function InsertInvoice($Subject, $TimeCreation, $TimeDue, $ValueSign, $Items, 103 $Group, $PeriodFrom, $PeriodTo) 104 104 { 105 105 global $LastInsertTime; 106 106 107 107 $Year = date('Y', $TimeCreation); 108 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($ DocumentLine, $Year);108 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($Group['DocumentLine'], $Year); 109 109 $SumValue = 0; 110 foreach($Items as $Item) 110 foreach($Items as $Item) { 111 111 $SumValue = $SumValue + ceil($Item['Price'] * $Item['Quantity']); 112 } 112 113 $this->Database->insert('FinanceInvoice', array( 113 114 'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation), 114 115 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 115 ' Direction' => $Direction, 'BillCode' => $BillCode,116 'ValueSign' => $ValueSign, 'BillCode' => $BillCode, 116 117 'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo), 117 'Generate' => 1, ' DocumentLine' => $DocumentLine));118 'Generate' => 1, 'Group' => $FinanceGroup['Id'])); 118 119 $InvoiceId = $this->Database->insert_id; 119 120 foreach($Items as $Item) … … 166 167 // We can't produce negative invoice except storno invoice. 167 168 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 168 // Other subject should invoice only pos sitive items. Negative items should be somehow removed.169 // Other subject should invoice only positive items. Negative items should be somehow removed. 169 170 if($MonthlyTotal >= 0) { 170 $DocumentLine = DOC_LINE_INVOICE_OUT; 171 $Direction = 1; // Standard out invoice 171 $InvoiceGroupId = INVOICE_GROUP_OUT; 172 172 } else { 173 $DocumentLine = DOC_LINE_INVOICE_IN; 174 $Direction = -1; // In case of negative total value generate reverse invoice for other subject 175 foreach($InvoiceItems as $Index => $Item) 176 $InvoiceItems[$Index]['Price'] = -$Item['Price']; 173 $InvoiceGroupId = INVOICE_GROUP_IN; 174 } 175 176 // Load invoice group 177 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoice'); 178 foreach($InvoiceItems as $Index => $Item) { 179 $InvoiceItems[$Index]['Price'] = $Item['Price'] * $FinanceGroup['ValueSign']; 177 180 } 178 181 … … 182 185 $Output .= $TimePeriodText.': '.$MonthlyTotal.' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />'; 183 186 $this->InsertInvoice($Member['Subject'], time(), time() + 3600 * 24 * INVOICE_DUE_DAYS, 184 $ Direction, $InvoiceItems, $DocumentLine, $Period['From'], $Period['To']);187 $FinanceGroup['ValueSign'], $InvoiceItems, $FinanceGroup, $Period['From'], $Period['To']); 185 188 186 189 $Output .= $this->SendPaymentEmail($Member['Id']); … … 354 357 '<th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center; font-weight: bold;">Popis</th>'. 355 358 '<th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center; font-weight: bold;">Částka [Kč]</th></tr>'."\n"; 356 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT `Text`, `Time`, (`Value`*` Direction`) AS `Value`, `File` FROM `FinanceOperation` WHERE (`Subject`='.$Member['Subject'].')) UNION ALL '.359 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT `Text`, `Time`, (`Value`*`ValueSign`) AS `Value`, `File` FROM `FinanceOperation` WHERE (`Subject`='.$Member['Subject'].')) UNION ALL '. 357 360 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ", ") FROM `FinanceInvoiceItem` '. 358 361 'WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, '. 359 '`Time`, -(`Value`*` Direction`) AS `Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='.362 '`Time`, -(`Value`*`ValueSign`) AS `Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='. 360 363 $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")'); 361 364 while($DbRow = $DbResult->fetch_assoc()) -
trunk/Modules/Finance/UserState.php
r738 r740 9 9 function ShowFinanceOperation($Subject) 10 10 { 11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*` Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '.11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`ValueSign`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 12 12 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 13 13 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 14 '`Time`, -(`Value`*` Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')))';14 '`Time`, -(`Value`*`ValueSign`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')))'; 15 15 16 16 $Output = '<div style="text-align:center">Výpis finančních operací</div>'; … … 105 105 106 106 // Account state 107 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*` Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '.107 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`ValueSign`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 108 108 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 109 109 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 110 '`Time`, -(`Value`*` Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')) ORDER BY `Time` DESC) AS `T1`';110 '`Time`, -(`Value`*`ValueSign`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')) ORDER BY `Time` DESC) AS `T1`'; 111 111 $DbResult = $this->Database->query('SELECT SUM(`T1`.`Value`) AS `Total` FROM '.$UserOperationTableQuery); 112 112 $DbRow = $DbResult->fetch_array(); -
trunk/Modules/Finance/Zivnost.php
r738 r740 11 11 { 12 12 $Balance = array(); 13 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( Direction = 1)');13 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)'); 14 14 $Row = $DbResult->fetch_array(); 15 15 $Balance['Income']['Start'] = $Row[0] + 0; 16 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( Direction = 1)');16 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = 1)'); 17 17 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />'); 18 18 $Row = $DbResult->fetch_array(); 19 19 $Balance['Income']['End'] = $Row[0] + 0; 20 20 21 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Direction = -1)');21 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)'); 22 22 $Row = $DbResult->fetch_array(); 23 23 $Balance['Spend']['Start'] = $Row[0] + 0; 24 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Direction = -1)');24 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (ValueSign = -1)'); 25 25 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />'); 26 26 $Row = $DbResult->fetch_array(); 27 27 $Balance['Spend']['End'] = $Row[0] + 0; 28 28 29 $DbResult = $this->Database->query('SELECT SUM(Value* Direction) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = 1)');29 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)'); 30 30 $Row = $DbResult->fetch_array(); 31 31 $Balance['Claims']['Start'] = $Row[0] + 0; 32 $DbResult = $this->Database->query('SELECT SUM(Value* Direction) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = 1)');32 $DbResult = $this->Database->query('SELECT SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = 1)'); 33 33 $Row = $DbResult->fetch_array(); 34 34 $Balance['Claims']['End'] = $Row[0] + 0; 35 35 36 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = -1)');36 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)'); 37 37 $Row = $DbResult->fetch_array(); 38 38 $Balance['Liabilities']['Start'] = $Row[0] + 0; 39 $DbResult = $this->Database->query('SELECT -SUM(Value* Direction) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Direction = -1)');39 $DbResult = $this->Database->query('SELECT -SUM(Value*ValueSign) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (ValueSign = -1)'); 40 40 $Row = $DbResult->fetch_array(); 41 41 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 144 144 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 145 145 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 146 'WHERE ( Direction = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');146 'WHERE (ValueSign = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 147 147 while($Row = $DbResult->fetch_array()) 148 148 { … … 174 174 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 175 175 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 176 'WHERE ( Direction = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');176 'WHERE (ValueSign = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 177 177 while($Row = $DbResult->fetch_array()) 178 178 { … … 204 204 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 205 205 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 206 'WHERE ( Direction = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].206 'WHERE (ValueSign = 1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 207 207 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 208 208 while($Row = $DbResult->fetch_array()) … … 210 210 if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 211 211 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode']. 212 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row[' Direction']).'</td></tr>';212 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>'; 213 213 $Total += $Row['Value']; 214 214 } … … 227 227 $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '. 228 228 'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '. 229 'WHERE ( Direction = -1) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].229 'WHERE (ValueSign = -1) AND (FinanceInvoice.Time >= "'.$Year['DateStart']. 230 230 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 231 231 while($Row = $DbResult->fetch_array()) … … 234 234 $Row['Value'] = $Row['Value'] * -1; 235 235 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode']. 236 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row[' Direction']).'</td></tr>';236 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['ValueSign']).'</td></tr>'; 237 237 $Total += $Row['Value']; 238 238 } … … 245 245 $Output .= '<tr><th>Jméno</th><th>Závazky [Kč]</th><th>Pohledávky [Kč]</th><th>Příjmy [Kč]</th><th>Výdaje [Kč]</th><th>Stav účtu</th><th>Starý systém</th></tr>'; 246 246 $DbResult = $this->Database->query('SELECT Id, Name, 0 AS Cash, '. 247 '(SELECT SUM(T1.Value*T1. Direction) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.Direction = 1)) as Claims, '.248 '(SELECT SUM(T2.Value*T2. Direction) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.Direction = 1) AND (TimePayment IS NULL)) as OpenedClaims, '.249 '(SELECT -SUM(T3.Value*T3. Direction) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.Direction = -1)) as Liabilities, '.250 '(SELECT -SUM(T4.Value*T4. Direction) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.Direction = -1) AND (TimePayment IS NULL)) AS OpenedLiabilities, '.251 '(SELECT SUM(T5.Value*T5. Direction) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.Direction = 1)) AS Gains, '.252 '(SELECT SUM(T6.Value*T6. Direction) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.Direction = -1)) AS Spends '.247 '(SELECT SUM(T1.Value*T1.ValueSign) FROM FinanceInvoice AS T1 WHERE (T1.Subject = Subject.Id) AND (T1.ValueSign = 1)) as Claims, '. 248 '(SELECT SUM(T2.Value*T2.ValueSign) FROM FinanceInvoice AS T2 WHERE (T2.Subject = Subject.Id) AND (T2.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 249 '(SELECT -SUM(T3.Value*T3.ValueSign) FROM FinanceInvoice AS T3 WHERE (T3.Subject = Subject.Id) AND (T3.ValueSign = -1)) as Liabilities, '. 250 '(SELECT -SUM(T4.Value*T4.ValueSign) FROM FinanceInvoice AS T4 WHERE (T4.Subject = Subject.Id) AND (T4.ValueSign = -1) AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 251 '(SELECT SUM(T5.Value*T5.ValueSign) FROM FinanceOperation AS T5 WHERE (T5.Subject = Subject.Id) AND (T5.ValueSign = 1)) AS Gains, '. 252 '(SELECT SUM(T6.Value*T6.ValueSign) FROM FinanceOperation AS T6 WHERE (T6.Subject = Subject.Id) AND (T6.ValueSign = -1)) AS Spends '. 253 253 'FROM Subject ORDER BY Name'); 254 254 while($Row = $DbResult->fetch_assoc()) … … 280 280 { 281 281 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. 282 '</td><td>'.($Row['Value']*$Row[' Direction']).'</td><td>'.$Row['BillCode'].'</td></tr>';282 '</td><td>'.($Row['Value']*$Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>'; 283 283 } 284 284 $Output .= '</table></td><td style="vertical-align: top;">'; … … 293 293 { 294 294 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). 295 '</td><td>'.$Row['Text'].'</td><td>'.ceil($Row['Value'] * $Row[' Direction']).'</td><td>'.$Row['BillCode'].'</td></tr>';295 '</td><td>'.$Row['Text'].'</td><td>'.ceil($Row['Value'] * $Row['ValueSign']).'</td><td>'.$Row['BillCode'].'</td></tr>'; 296 296 } 297 297 $Output .= '</table></td></tr></table>'; … … 303 303 while($Row = $DbResult->fetch_array()) 304 304 { 305 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row[' Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';305 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; 306 306 } 307 307 $Output .= '</table>';*/ 308 308 309 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice. Direction) '.309 $DbResult = $this->Database->query('SELECT Id, 0 AS Cash, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 310 310 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND '. 311 '(FinanceInvoice. Direction = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.Direction) '.311 '(FinanceInvoice.ValueSign = 1)) as Claims, (SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) '. 312 312 'FROM FinanceInvoice WHERE (FinanceInvoice.Subject = Subject.Id) AND ('. 313 'FinanceInvoice. Direction = 1) AND (TimePayment IS NULL)) as OpenedClaims, '.314 '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice. Direction) FROM FinanceInvoice '.315 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice. Direction = -1)) AS '.313 'FinanceInvoice.ValueSign = 1) AND (TimePayment IS NULL)) as OpenedClaims, '. 314 '(SELECT SUM(FinanceInvoice.Value * FinanceInvoice.ValueSign) FROM FinanceInvoice '. 315 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1)) AS '. 316 316 'Liabilities, (SELECT SUM(FinanceInvoice.Value) FROM FinanceInvoice '. 317 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice. Direction = -1) '.317 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.ValueSign = -1) '. 318 318 'AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 319 '(SELECT SUM(FinanceOperation.Value*FinanceOperation. Direction) '.320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation. Direction = 1) '.321 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation. Direction) FROM FinanceOperation WHERE '.322 'FinanceOperation.Subject = Subject.Id AND FinanceOperation. Direction = -1) as Spends '.319 '(SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) '. 320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = 1) '. 321 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation.ValueSign) FROM FinanceOperation WHERE '. 322 'FinanceOperation.Subject = Subject.Id AND FinanceOperation.ValueSign = -1) as Spends '. 323 323 'FROM Subject WHERE Id='.$_GET['Id']); 324 324 $Row = $DbResult->fetch_array(); -
trunk/Modules/FinanceBankAPI/FileImport.php
r738 r740 34 34 { 35 35 $DbRow2 = $DbResult2->fetch_assoc(); 36 // TODO: Replace constants by links to real database numbers37 36 if($DbRow['Value'] >= 0) { 38 $DocumentLine = 3; // Receive money 39 $Direction = 1; 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 40 38 } else { 41 $DocumentLine = 4; // Send money 42 $Direction = -1; 39 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 43 40 } 44 41 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 45 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($ DocumentLine, $Year);42 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($FinanceGroup['DocumentLine'], $Year); 46 43 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 47 'Value' => Abs($DbRow['Value']), ' Direction' => $Direction, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,48 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, ' DocumentLine' => $DocumentLine));44 'Value' => Abs($DbRow['Value']), 'ValueSign' => $FinanceGroup['ValueSign'], 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 45 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id'])); 49 46 $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id)); 50 47 } … … 139 136 } 140 137 141 function InsertMoney($Subject, $Value, $ Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine)138 function InsertMoney($Subject, $Value, $ValueSign, $Cash, $Taxable, $Time, $Text, $Group) 142 139 { 143 140 $Year = date('Y', $Time); 144 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($ DocumentLine, $Year);141 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($Group['DocumentLine'], $Year); 145 142 $this->Database->insert('FinanceOperation', array('Text' => $Text, 146 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, ' Direction' => $Direction,143 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'ValueSign' => $ValueSign, 147 144 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode)); 148 145 } … … 155 152 for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 156 153 { 157 // TODO: Use links to database records instead of contants 158 if($_POST['Money'.$I] < 0) { 159 $DocumentLine = 4; 160 $Direction = -1; 154 if($_POST['Money'.$I] >= 0) { 155 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 161 156 } else { 162 $DocumentLine = 3; 163 $Direction = 1; 157 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 164 158 } 165 159 $Date = explode('-', $_POST['Date'.$I]); 166 160 $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 167 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine); 161 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $FinanceGroup['ValueSign'], 162 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 168 163 $Output .= $I.', '; 169 164 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r738 r740 69 69 { 70 70 $Preset = array(); 71 if($Item['Value'] < 0) $DocumentLine = DOC_LINE_ACCOUNT_OUT; 72 else $DocumentLine = DOC_LINE_ACCOUNT_IN; 71 if($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT; 72 else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN; 73 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup'); 74 73 75 $Preset = array( 74 76 'presetTime' => $Item['Time'], … … 78 80 'presetNetwork' => 1, 79 81 'presetBankAccount' => $Item['BankAccount'], 80 'presetDocumentLine' => $ DocumentLine);82 'presetDocumentLine' => $FinanceGroup['DocumentLine']); 81 83 return($Preset); 82 84 } -
trunk/Modules/IS/IS.php
r738 r740 101 101 $Output .= 'Registrovaných zařízení: '.$DbRow['0'].'<br/>'; 102 102 103 $DbResult = $this->Database->select('FinanceOperation', 'SUM(`Value` * ` Direction`)', '1');103 $DbResult = $this->Database->select('FinanceOperation', 'SUM(`Value` * `ValueSign`)', '1'); 104 104 $DbRow = $DbResult->fetch_row(); 105 105 $Output .= 'Stav placení: '.$DbRow['0'].'<br/>'; … … 423 423 { 424 424 if($TypeFilter != '') $TypeFilter .= ' AND '; 425 $TypeFilter .= '( '.$ItemIndex.'= "'.$FormItem['Default'].'")';425 $TypeFilter .= '(`'.$ItemIndex.'` = "'.$FormItem['Default'].'")'; 426 426 } 427 427 if($TypeFilter != '') -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r738 r740 1 1 <?php 2 3 /* This is script for configuration of BIND DNS server. 4 * Use "sudo aptitude install bind9" to install server under Ubuntu 5 */ 2 6 3 7 if(isset($_SERVER['REMOTE_ADDR'])) die(); -
trunk/Modules/Subject/Subject.php
r738 r740 36 36 'Invoices' => array('Type' => 'TFinanceInvoiceListSubject', 'Caption' => 'Faktury', 'Default' => ''), 37 37 'Payment' => array('Type' => 'Float', 'Caption' => 'Placení', 'Default' => '', 38 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => 'IFNULL((SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`) FROM `FinanceOperation` '.39 'WHERE `FinanceOperation`.`Subject`=#Id), 0) - IFNULL((SELECT SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.` Direction`) FROM `FinanceInvoice` '.38 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => 'IFNULL((SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`) FROM `FinanceOperation` '. 39 'WHERE `FinanceOperation`.`Subject`=#Id), 0) - IFNULL((SELECT SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.`ValueSign`) FROM `FinanceInvoice` '. 40 40 'WHERE `FinanceInvoice`.`Subject`=#Id), 0)'), 41 41 'BankAccounts' => array('Type' => 'TFinanceBankAccountListSubject', 'Caption' => 'Bankovní účety', 'Default' => ''), … … 57 57 'Id' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => '', 'ReadOnly' => true), 58 58 'Income' => array('Type' => 'Integer', 'Caption' => 'Příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 59 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.60 'AND (`FinanceOperation`.` Direction` = 1))'),59 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '. 60 'AND (`FinanceOperation`.`ValueSign` = 1))'), 61 61 'Spending' => array('Type' => 'Integer', 'Caption' => 'Výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 62 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.63 'AND (`FinanceOperation`.` Direction` = -1))'),62 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '. 63 'AND (`FinanceOperation`.`ValueSign` = -1))'), 64 64 'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true, 65 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.` Direction`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '.65 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`ValueSign`)) FROM `FinanceOperation` WHERE (`FinanceOperation`.`Subject` = TX.`Id`) '. 66 66 ')'), 67 67 ),
Note:
See TracChangeset
for help on using the changeset viewer.