Ignore:
Timestamp:
Jan 2, 2015, 11:16:56 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for Hidden items in form types values.
  • Added: Support for Filtered items in form types values.
  • Modified: FinanceOperation Value splitted to (Direction * Value). Direction can be +1 or -1 depends on if money goes out or in company.
  • Added: Menu "Incomes and spends" is now splitted to incomes/spends of bank account or treasury. Direction and document line is filled automatically.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r637 r719  
    3434        {
    3535          $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          }
    3844          $Year = date('Y', MysqlDateToTime($DbRow['Time']));
    3945          $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
    4046          $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,
    4248            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'DocumentLine' => $DocumentLine));
    4349          $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id));
     
    133139  }
    134140 
    135   function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $DocumentLine)
     141  function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine)
    136142  {
    137143    $Year = date('Y', $Time);     
    138144    $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));
    140148  }
    141149
     
    147155    for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    148156    {
    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]);
    152166      $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);
    154168      $Output .= $I.', ';
    155169      $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
Note: See TracChangeset for help on using the changeset viewer.