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/Finance/Import.php

    r629 r719  
    120120  }
    121121 
    122   function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $DocumentLine)
     122  function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine)
    123123  {
    124124    $Year = date('Y', $Time);
    125125    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
    126     // TODO: Fixed BankAccount=1
     126    // TODO: Fixed BankAccount=1, allow to select bank account for import
    127127    $this->Database->insert('FinanceOperation', array('Text' => $Text,
    128       'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value,
     128      'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction,
    129129      'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode,
    130130      'BankAccount' => 1));
     
    139139    for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    140140    {
    141       if($_POST['Money'.$I] < 0) $DocumentLine = 4;
    142         else $DocumentLine = 3;
     141        // TODO: Use links to database records instead of contants
     142      if($_POST['Money'.$I] < 0) {
     143        $DocumentLine = 4;
     144        $Direction = -1;
     145      } else {
     146        $DocumentLine = 3;
     147        $Direction = 1;
     148      }
    143149      $Date = explode('-', $_POST['Date'.$I]);
    144150      $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]);
    145       $this->InsertMoney($_POST['Subject'.$I], $_POST['Money'.$I], 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine);
     151      $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine);
    146152      $Output .= $I.', ';
    147153      $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
Note: See TracChangeset for help on using the changeset viewer.