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

    r741 r747  
    100100  }
    101101
    102   function InsertInvoice($Subject, $TimeCreation, $TimeDue, $ValueSign, $Items,
    103   $Group, $PeriodFrom, $PeriodTo, $Direction)
     102  function InsertInvoice($Subject, $TimeCreation, $TimeDue, $Items,
     103    $Group, $PeriodFrom, $PeriodTo)
    104104  {
    105105    global $LastInsertTime;
    106106
    107107    $Year = date('Y', $TimeCreation);
    108     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($Group['DocumentLine'], $Year);
     108    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    109109    $SumValue = 0;
    110110    foreach($Items as $Item) {
     
    113113    $this->Database->insert('FinanceInvoice', array(
    114114      'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation),
    115       'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue,
    116       'ValueSign' => $ValueSign, 'BillCode' => $BillCode, 'Direction' => $Direction,
     115      'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue * $Group['ValueSign'],
     116      'BillCode' => $BillCode,
    117117      'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo),
    118       'Generate' => 1, 'Group' => $FinanceGroup['Id']));
     118      'Generate' => 1, 'Group' => $Group['Id']));
    119119    $InvoiceId = $this->Database->insert_id;
    120120    foreach($Items as $Item)
     
    185185          $Output .= $TimePeriodText.': '.$MonthlyTotal.' * '.$Period['MonthCount'].' = '.$PayPerPeriod.'<br />';
    186186          $this->InsertInvoice($Member['Subject'], time(), time() + 3600 * 24 * INVOICE_DUE_DAYS,
    187             $FinanceGroup['ValueSign'], $InvoiceItems, $FinanceGroup, $Period['From'],
    188                 $Period['To'], $FinanceGroup['Direction']);
     187            $InvoiceItems, $FinanceGroup, $Period['From'],
     188            $Period['To']);
    189189
    190190          $Output .= $this->SendPaymentEmail($Member['Id']);
     
    358358        '<th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center; font-weight: bold;">Popis</th>'.
    359359        '<th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center; font-weight: bold;">Částka [Kč]</th></tr>'."\n";
    360       $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT `Text`, `Time`, (`Value`*`ValueSign`) AS `Value`, `File` FROM `FinanceOperation` WHERE (`Subject`='.$Member['Subject'].')) UNION ALL '.
     360      $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT `Text`, `Time`, `Value`, `File` FROM `FinanceOperation` WHERE (`Subject`='.$Member['Subject'].')) UNION ALL '.
    361361        '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ", ") FROM `FinanceInvoiceItem` '.
    362362        'WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, '.
    363         '`Time`, -(`Value`*`ValueSign`) AS `Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='.
     363        '`Time`, -`Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='.
    364364        $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")');
    365365      while($DbRow = $DbResult->fetch_assoc())
Note: See TracChangeset for help on using the changeset viewer.