Changeset 719 for trunk/Modules/FinanceBankAPI
- Timestamp:
- Jan 2, 2015, 11:16:56 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/FileImport.php
r637 r719 34 34 { 35 35 $DbRow2 = $DbResult2->fetch_assoc(); 36 if($DbRow['Value'] >= 0) $DocumentLine = 3; // Receive money 37 else $DocumentLine = 4; // Send money 36 // TODO: Replace constants by links to real database numbers 37 if($DbRow['Value'] >= 0) { 38 $DocumentLine = 3; // Receive money 39 $Direction = 1; 40 } else { 41 $DocumentLine = 4; // Send money 42 $Direction = -1; 43 } 38 44 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 39 45 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 40 46 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 41 'Value' => $DbRow['Value'], 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,47 'Value' => Abs($DbRow['Value']), 'Direction' => $Direction, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 42 48 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'DocumentLine' => $DocumentLine)); 43 49 $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id)); … … 133 139 } 134 140 135 function InsertMoney($Subject, $Value, $ Cash, $Taxable, $Time, $Text, $DocumentLine)141 function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine) 136 142 { 137 143 $Year = date('Y', $Time); 138 144 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 139 $this->Database->insert('FinanceOperation', array('Text' => $Text, 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode)); 145 $this->Database->insert('FinanceOperation', array('Text' => $Text, 146 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction, 147 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode)); 140 148 } 141 149 … … 147 155 for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 148 156 { 149 if($_POST['Money'.$I] < 0) $DocumentLine = 4; 150 else $DocumentLine = 3; 151 $Date = explode('-', $_POST['Date'.$I]); 157 // TODO: Use links to database records instead of contants 158 if($_POST['Money'.$I] < 0) { 159 $DocumentLine = 4; 160 $Direction = -1; 161 } else { 162 $DocumentLine = 3; 163 $Direction = 1; 164 } 165 $Date = explode('-', $_POST['Date'.$I]); 152 166 $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 153 $this->InsertMoney($_POST['Subject'.$I], $_POST['Money'.$I], 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine);167 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine); 154 168 $Output .= $I.', '; 155 169 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
Note:
See TracChangeset
for help on using the changeset viewer.