Changeset 738 for trunk/Modules/Finance/Manage.php
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Manage.php
r727 r738 109 109 $SumValue = 0; 110 110 foreach($Items as $Item) 111 $SumValue = $SumValue + ceil($Item['Price'] * $Item['Quantity']); 111 $SumValue = $SumValue + ceil($Item['Price'] * $Item['Quantity']); 112 112 $this->Database->insert('FinanceInvoice', array( 113 113 'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation), 114 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 115 114 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 115 'Direction' => $Direction, 'BillCode' => $BillCode, 116 116 'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo), 117 117 'Generate' => 1, 'DocumentLine' => $DocumentLine)); … … 163 163 $MonthlyTotal += $Service['Price']; 164 164 } 165 $PayPerPeriod = $MonthlyTotal * $Period['MonthCount']; 165 $PayPerPeriod = $MonthlyTotal * $Period['MonthCount']; 166 166 // We can't produce negative invoice except storno invoice. 167 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 168 // Other subject should invoice only possitive items. Negative items should be somehow removed. 167 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 168 // Other subject should invoice only possitive items. Negative items should be somehow removed. 169 169 if($MonthlyTotal >= 0) { 170 $DocumentLine = DOC_LINE_INVOICE_OUT;171 170 $DocumentLine = DOC_LINE_INVOICE_OUT; 171 $Direction = 1; // Standard out invoice 172 172 } else { 173 173 $DocumentLine = DOC_LINE_INVOICE_IN; 174 174 $Direction = -1; // In case of negative total value generate reverse invoice for other subject 175 175 foreach($InvoiceItems as $Index => $Item) 176 177 } 178 176 $InvoiceItems[$Index]['Price'] = -$Item['Price']; 177 } 178 179 179 if($PayPerPeriod != 0) 180 180 { … … 195 195 function TableUpdateChanges($Table) 196 196 { 197 197 $Time = time(); 198 198 $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '. 199 199 '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC'); 200 200 while($Service = $DbResult->fetch_array()) 201 201 { … … 225 225 function ProcessTableUpdates() 226 226 { 227 228 229 230 231 232 233 234 235 236 237 238 239 240 } 241 227 // Update finance charge 228 $Output = 'Měním aktuální parametry sítě...<br>'; 229 $this->TableUpdateChanges('FinanceCharge'); 230 231 // Update services 232 $Output .= 'Aktualizuji služby....<br>'; 233 $this->TableUpdateChanges('Service'); 234 235 // Update customer service selections 236 $Output .= 'Aktualizuji výběr služeb zákazníků....<br>'; 237 $this->TableUpdateChanges('ServiceCustomerRel'); 238 239 return($Output); 240 } 241 242 242 function ProcessMonthlyPayment() 243 243 { … … 246 246 247 247 $Output .= $this->ProcessTableUpdates(); 248 248 249 249 $Finance = &$this->System->Modules['Finance']; 250 250 $Finance->LoadMonthParameters(0); … … 282 282 $Output .= 'Odečítám měsíční poplatek...<br />'; 283 283 $Output .= $this->ProduceInvoices(); 284 284 285 285 $Output .= 'Přidávám měsíční přehled...<br />'; 286 286 $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE (`ChangeAction` IS NULL) LIMIT 1'); … … 327 327 328 328 $DbResult = $this->Database->query('SELECT `FinanceBankAccount`.*, '. 329 329 'CONCAT(`FinanceBankAccount`.`Number`, "/", `FinanceBank`.`Code`) AS `NumberFull` FROM `FinanceBankAccount` '. 330 330 'JOIN `FinanceBank` ON `FinanceBank`.`Id`=`FinanceBankAccount`.`Bank` '. 331 331 'WHERE (`FinanceBankAccount`.`Subject`='.$Config['Finance']['MainSubjectId'].') '. 332 332 'AND (`FinanceBankAccount`.`Use`=1)'); 333 333 $MainSubjectAccount = $DbResult->fetch_assoc(); 334 334 … … 356 356 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File` FROM `FinanceOperation` WHERE (`Subject`='.$Member['Subject'].')) UNION ALL '. 357 357 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ", ") FROM `FinanceInvoiceItem` '. 358 359 358 'WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, '. 359 '`Time`, -(`Value`*`Direction`) AS `Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='. 360 360 $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")'); 361 361 while($DbRow = $DbResult->fetch_assoc())
Note:
See TracChangeset
for help on using the changeset viewer.