Changeset 167 for www/finance/manage.php
- Timestamp:
- Mar 24, 2009, 11:44:03 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/manage.php
r165 r167 381 381 function ConvertData() 382 382 { 383 $Output = ''; 384 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 383 $Finance = $this->System->Modules['Finance']; 384 $Output = ''; 385 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 386 $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities'); 385 387 386 388 // Move time of device price transformation … … 388 390 389 391 // Transform old operations 390 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01"'); 391 while($DbRow = $DbResult->fetch_assoc()) 392 { 393 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'SourceSubject' => $DbRow['Source'], 'DestinationSubject' => $DbRow['Destination'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 394 $Output .= '.'; 395 } 392 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->ExternalSubject.')'); 393 while($DbRow = $DbResult->fetch_assoc()) 394 { 395 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Cash' => $DbRow['cash'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 396 $Output .= '.'; 397 } 398 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->ExternalSubject.')'); 399 while($DbRow = $DbResult->fetch_assoc()) 400 { 401 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Cash' => $DbRow['cash'], 'Value' => -abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 402 $Output .= '.'; 403 } 404 405 // Transform old invoices 406 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->MainSubject.')'); 407 while($DbRow = $DbResult->fetch_assoc()) 408 { 409 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Value' => -abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 410 $Output .= 'FV '.$DbRow['comment'].'<br />'; 411 } 412 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->MainSubject.')'); 413 while($DbRow = $DbResult->fetch_assoc()) 414 { 415 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Value' => abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 416 $Output .= 'FP '.$DbRow['comment'].'<br />'; 417 } 396 418 397 419 // Transfer finance before era … … 402 424 $DbRow2 = $DbResult2->fetch_assoc(); 403 425 404 if($DbRow2['money'] > 0) 405 { 406 $DestinationSubject = $Subject['Id']; 407 $SourceSubject = 96; 408 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 409 } else 410 { 411 $DestinationSubject = 71; 412 $SourceSubject = $Subject['Id']; 413 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 414 } 415 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 416 $this->Database->insert('FinanceOperation', array('SourceSubject' => $SourceSubject, 'DestinationSubject' => $DestinationSubject, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 417 $Output .= '#'; 426 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 427 if($DbRow2['money'] > 0) 428 { 429 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 430 $this->Database->insert('FinanceOperation', array('Subject' => $Subject['Id'], 'Cash' => 0, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 431 } else 432 { 433 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 434 $this->Database->insert('FinanceClaimsLiabilities', array('Subject' => $Subject['Id'], 'Value' => abs($DbRow2['money']), 'TimeCreation' => $DbRow2['date'], 'Text' => $Comment)); 435 } 436 $Output .= '#'; 418 437 } 419 438
Note:
See TracChangeset
for help on using the changeset viewer.