Ignore:
Timestamp:
Sep 21, 2015, 12:12:26 AM (9 years ago)
Author:
chronos
Message:

This solves problem with inconsistency between invoice and invoice items values and inconsistency between selected document line and incorrect positive or negative values.

File:
1 edited

Legend:

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

    r740 r747  
    4040          }
    4141          $Year = date('Y', MysqlDateToTime($DbRow['Time']));
    42           $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($FinanceGroup['DocumentLine'], $Year);
     42          $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    4343          $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
    44             'Value' => Abs($DbRow['Value']), 'ValueSign' => $FinanceGroup['ValueSign'], 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
     44            'Value' => Abs($DbRow['Value']), 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
    4545            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id']));
    4646          $this->Database->update('FinanceBankImport', 'Id='.$DbRow['Id'], array('FinanceOperation' => $this->Database->insert_id));
     
    136136  }
    137137
    138   function InsertMoney($Subject, $Value, $ValueSign, $Cash, $Taxable, $Time, $Text, $Group)
     138  function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group)
    139139  {
    140140    $Year = date('Y', $Time);
    141     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($Group['DocumentLine'], $Year);
     141    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(
     142      $Group['DocumentLine'], $Year);
    142143    $this->Database->insert('FinanceOperation', array('Text' => $Text,
    143       'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'ValueSign' => $ValueSign,
     144      'Subject' => $Subject, 'Cash' => $Cash, 'ValueUser' => $Value, 'Value' => $Value * $Group['ValueSign'],
    144145      'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode));
    145146  }
     
    153154    {
    154155      if($_POST['Money'.$I] >= 0) {
    155         $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
     156        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN,
     157          'FinanceOperationGroup');
    156158      } else {
    157         $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
     159        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT,
     160          'FinanceOperationGroup');
    158161      }
    159162      $Date = explode('-', $_POST['Date'.$I]);
    160163      $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]);
    161       $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $FinanceGroup['ValueSign'],
     164      $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]),
    162165        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    163166      $Output .= $I.', ';
Note: See TracChangeset for help on using the changeset viewer.