Ignore:
Timestamp:
Jul 3, 2015, 11:36:07 PM (9 years ago)
Author:
chronos
Message:

to group id instead of DocumentLine.

Location:
trunk/Modules/FinanceBankAPI
Files:
2 edited

Legend:

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

    r738 r740  
    3434        {
    3535          $DbRow2 = $DbResult2->fetch_assoc();
    36           // TODO: Replace constants by links to real database numbers
    3736          if($DbRow['Value'] >= 0) {
    38             $DocumentLine = 3; // Receive money
    39             $Direction = 1;
     37            $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
    4038          } else {
    41             $DocumentLine = 4; // Send money
    42             $Direction = -1;
     39            $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    4340          }
    4441          $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);
    4643          $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']));
    4946          $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id));
    5047        }
     
    139136  }
    140137
    141   function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine)
     138  function InsertMoney($Subject, $Value, $ValueSign, $Cash, $Taxable, $Time, $Text, $Group)
    142139  {
    143140    $Year = date('Y', $Time);
    144     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
     141    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($Group['DocumentLine'], $Year);
    145142    $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,
    147144      'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode));
    148145  }
     
    155152    for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    156153    {
    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');
    161156      } else {
    162         $DocumentLine = 3;
    163         $Direction = 1;
     157        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    164158      }
    165159      $Date = explode('-', $_POST['Date'.$I]);
    166160      $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);
    168163      $Output .= $I.', ';
    169164      $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r738 r740  
    6969  {
    7070    $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
    7375    $Preset = array(
    7476      'presetTime' => $Item['Time'],
     
    7880      'presetNetwork' => 1,
    7981      'presetBankAccount' => $Item['BankAccount'],
    80       'presetDocumentLine' => $DocumentLine);
     82      'presetDocumentLine' => $FinanceGroup['DocumentLine']);
    8183    return($Preset);
    8284  }
Note: See TracChangeset for help on using the changeset viewer.