Changeset 740 for trunk/Modules/FinanceBankAPI
- Timestamp:
- Jul 3, 2015, 11:36:07 PM (9 years ago)
- Location:
- trunk/Modules/FinanceBankAPI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.