Changeset 486 for trunk/finance/manage.php
- Timestamp:
- Feb 10, 2013, 9:20:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/finance/manage.php
r482 r486 133 133 $DbRow = $DbResult->fetch_array(); 134 134 $Advances = $DbRow[0]; 135 $DbResult = $this->Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$Subject.' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1'); 135 $DbResult = $this->Database->select('FinanceInvoice', '*', 'Subject='.$Subject. 136 ' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1'); 136 137 //echo($Database->error); 137 138 if($DbResult->num_rows > 0) … … 140 141 if($Advances > $OpenedClaim['Value']) 141 142 { 142 $this->Database->update('FinanceClaimsLiabilities', 'Id='.$OpenedClaim['Id'], array('TimePayment' => TimeToMysqlDateTime($LastInsertTime))); 143 $this->Database->insert('FinanceAdvances', array('Subject' => $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In')); 143 $this->Database->update('FinanceInvoice', 'Id='.$OpenedClaim['Id'], 144 array('TimePayment' => TimeToMysqlDateTime($LastInsertTime))); 145 $this->Database->insert('FinanceAdvances', array('Subject' => 146 $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 147 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 148 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In')); 144 149 //echo($Database->LastQuery); 145 150 } else break; … … 154 159 155 160 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine); 156 $this->Database->insert('Finance ClaimsLiabilities', array('Text' => $Text,161 $this->Database->insert('FinanceInvoice', array( 157 162 'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($TimeCreation), 158 163 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $Value, 'BillCode' => $BillCode, 159 164 'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo))); 165 $InvoiceId = $this->Database->insert_id; 166 $this->Database->insert('FinanceInvoice', array('FinanceInvoice' => $InvoiceId, 167 'Description' => $Text, 'Price' => $Value, 'Quantity' => 1, 'VAT' => 0)); 160 168 $Output = '.'; //$this->Database->LastQuery.'<br />'; 161 169 //$LastInsertTime = $Time; … … 253 261 $Form->Values['DocumentLine'], NULL, NULL); 254 262 $LastId = $this->Database->insert_id; 255 $DbResult = $this->Database->select('Finance ClaimsLiabilities', 'BillCode', 'Id='.$LastId);263 $DbResult = $this->Database->select('FinanceInvoice', 'BillCode', 'Id='.$LastId); 256 264 $DbRow = $DbResult->fetch_assoc(); 257 265 $Output = $this->SystemMessage('Finance', 'Faktura vložena '.$DbRow['BillCode'].'.'); … … 360 368 $Output .= $Finance->RecalculateSegmentParameters(); 361 369 $Output .= $Finance->LoadTariffs(); 362 //$InvoiceGenerator->CustomGenerate();363 370 $Output .= $Finance->RecalculateMemberPayment(); 364 371 … … 446 453 $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'], 447 454 $BillItems, time(), time() + 3600 * 24 * INVOICE_DUE_DAYS, $BillCode, $Period['From'], $Period['To']); 448 $this->Database->insert('Finance ClaimsLiabilities', array('Value' => $PayPerPeriod,455 $this->Database->insert('FinanceInvoice', array( 449 456 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 450 'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)', 451 'Text' => 'Vyúčtování služeb za období '.$TimePeriodText, 457 'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)', 452 458 'Bill' => $BillId, 'BillCode' => $BillCode)); 459 $InvoiceId = $this->Database->insert_id; 460 $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId, 461 'Value' => $PayPerPeriod, 'Text' => 'Vyúčtování služeb za období '.$TimePeriodText, 462 'Quantity' => 1, 'VAT' => 0)); 463 453 464 $Output .= $this->SendPaymentEmail($Member['Id']); 454 465 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To']))); … … 531 542 //$Member['BillingPeriodLastDate'] = '2009-04-01'; 532 543 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '. 533 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM Finance ClaimsLiabilitiesWHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")');544 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceInvoice WHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")'); 534 545 while($DbRow = $DbResult->fetch_assoc()) 535 546 { … … 550 561 function GenerateBills() 551 562 { 552 // Finance ClaimsLiablities553 $DbResult = $this->Database->query('SELECT * FROM Finance ClaimsLiabilitiesWHERE (BillCode <> "") AND (Value != 0) AND (Bill = 0)');563 // FinanceInvoice 564 $DbResult = $this->Database->query('SELECT * FROM FinanceInvoice WHERE (BillCode <> "") AND (Value != 0) AND (Bill = 0)'); 554 565 while($Row = $DbResult->fetch_assoc()) 555 566 { … … 558 569 MysqlDateTimeToTime($Row['TimeCreation']), MysqlDateTimeToTime($Row['TimeDue']), 559 570 $Row['BillCode'], 'invoice', MysqlDateToTime($Row['PeriodFrom']), MysqlDateToTime($Row['PeriodTo'])); 560 $this->Database->update('Finance ClaimsLiabilities', 'Id='.$Row['Id'], array('Bill' => $BillId));571 $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('Bill' => $BillId)); 561 572 echo('.'); 562 573 }
Note:
See TracChangeset
for help on using the changeset viewer.