Ignore:
Timestamp:
Jul 27, 2014, 12:28:16 PM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Zaokrouhlovat vypočítanou cenu na celé čísla v položkách faktur.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Bill.php

    r643 r680  
    2929class BillInvoice extends Bill
    3030{
    31   var $InvoiceId; 
    32  
     31  var $InvoiceId;
     32
    3333  function ShowSubjectInfo($Subject)
    3434  {
     
    4848    $DbResult = $this->Database->select('FinanceInvoice', '*', '`Id`='.$this->InvoiceId);
    4949    $Invoice = $DbResult->fetch_assoc();
    50    
     50
    5151    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Invoice['Subject']);
    5252    $SubjectTo = $DbResult->fetch_assoc();
     
    5454    $SubjectTo['PayVAT'] = '';
    5555    $VarSym = $SubjectTo['Id'];
    56    
     56
    5757    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$this->System->Config['Finance']['MainSubjectId']);
    5858    $SubjectFrom = $DbResult->fetch_assoc();
    59    
     59
    6060    $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '.
    6161      'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
     
    6363    $SubjectFromAccount = $DbResult->fetch_assoc();
    6464    $SubjectFrom['Account'] = $SubjectFromAccount['NumberFull'];
    65    
     65
    6666    $Dodavka = array();
    6767    $InvoiceItems = array();
    68     $DbResult = $this->Database->select('FinanceInvoiceItem', '*', 'FinanceInvoice='.$this->InvoiceId);
     68    $DbResult = $this->Database->select('FinanceInvoiceItem', '*, CEIL(`Price` * `Quantity`) AS `Total`', '`FinanceInvoice`='.$this->InvoiceId);
    6969    while($Item = $DbResult->fetch_assoc())
    7070    {
    7171      $InvoiceItems[$Item['Id']] = $Item;
    7272    }
    73    
     73
    7474    // If negative value => switch sides
    7575    if($Invoice['Value'] < 0)
     
    7777        $Subject = $SubjectTo;
    7878        $SubjectTo = $SubjectFrom;
    79         $SubjectFrom = $Subject;   
     79        $SubjectFrom = $Subject;
    8080        foreach($InvoiceItems as $Index => $Item)
    8181        {
     
    8383        }
    8484    }
    85    
     85
    8686    $PaymentType = array('převodem', 'hotově');
    8787    $BooleanText = array('Ne', 'Ano');
     
    120120      '<tr><th align="left">Dodávka</th><th align="right">Množství</th><th align="right">Cena/MJ</th><th align="right">Celkem</th></tr>'.
    121121      '<tr><td colspan="4"><hr></td></tr>';
    122    
     122
    123123    $Total = 0;
    124124    foreach($InvoiceItems as $Item)
     
    126126      $Output .= '<tr><td>'.$Item['Description'].'</td><td align="right">'.
    127127        $Item['Quantity'].'</td><td align="right">'.$Item['Price'].
    128         '&nbsp;Kč</td><td align="right">'.($Item['Quantity'] * $Item['Price']).'&nbsp;Kč</td></tr>';
    129       $Total += ($Item['Quantity'] * $Item['Price']);
     128        '&nbsp;Kč</td><td align="right">'.$Item['Total'].'&nbsp;Kč</td></tr>';
     129      $Total += $Item['Total'];
    130130    }
    131131    $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.'&nbsp;Kč</th></tr>';
     
    134134      '<tr><td colspan="2"><hr></td></tr>'.
    135135      '</table>';
    136      
     136
    137137    return($Output);
    138138  }
     
    141141class BillOperation extends Bill
    142142{
    143   var $OperationId; 
    144  
     143  var $OperationId;
     144
    145145  function GenerateHTML()
    146146  {
    147147    $DbResult = $this->Database->select('FinanceOperation', '*', '`Id`='.$this->OperationId);
    148148    $Operation = $DbResult->fetch_assoc();
    149    
     149
    150150    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Operation['Subject']);
    151151    $Subject = $DbResult->fetch_assoc();
    152    
     152
    153153    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$this->System->Config['Finance']['MainSubjectId']);
    154154    $MainSubject = $DbResult->fetch_assoc();
    155    
     155
    156156    $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '.
    157157      'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
    158158      'WHERE (FinanceBankAccount.`Subject`='.$this->System->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');
    159159    $MainSubjectAccount = $DbResult->fetch_assoc();
    160    
     160
    161161    //$Dodavka = array();
    162162    //$DbResult = $this->Database->select('FinanceInvoiceItem', '*', 'FinanceInvoice='.$BillId);
     
    168168    if($Operation['Value'] < 0)
    169169    $Desc = array(
    170       'Type' => 'VÝDAJOVÝ', 
    171       'Signature' => 'Vydal', 
     170      'Type' => 'VÝDAJOVÝ',
     171      'Signature' => 'Vydal',
    172172      'Sign' => -1,
    173173      'Target' => 'Vydáno komu',
    174174    );
    175175    else $Desc = array(
    176       'Type' => 'PŘÍJMOVÝ', 
    177       'Signature' => 'Přijal', 
     176      'Type' => 'PŘÍJMOVÝ',
     177      'Signature' => 'Přijal',
    178178      'Sign' => 1,
    179179      'Target' => 'Přijato od',
     
    200200    if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    201201    if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    202     $Total = 0;
    203     $Description = '';
    204     //foreach($Dodavka as $Polozka)
    205     //{
    206     //  $Description .= $Polozka['Description'].'<br>';
    207     //  $Total += ($Polozka['Quantity'] * $Polozka['Price']);
    208     //}
    209202    $Description = $Operation['Text'];
    210203    $Total = $Operation['Value'] * $Desc['Sign'];
Note: See TracChangeset for help on using the changeset viewer.