Ignore:
Timestamp:
Mar 24, 2014, 12:51:15 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Prohoď dodavatele a odběratele faktury pokud je záporná celková částka.
File:
1 edited

Legend:

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

    r635 r643  
    3030{
    3131  var $InvoiceId; 
     32 
     33  function ShowSubjectInfo($Subject)
     34  {
     35        $BooleanText = array('Ne', 'Ano');
     36        $Output = $Subject['Name'].'<br>'.
     37      $Subject['AddressStreet'].'<br>'.
     38      $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
     39    if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     40    if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
     41    if($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';
     42    if($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';
     43        return($Output);
     44  }
    3245
    3346  function GenerateHTML()
     
    3750   
    3851    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Invoice['Subject']);
    39     $Subject = $DbResult->fetch_assoc();
     52    $SubjectTo = $DbResult->fetch_assoc();
     53    $SubjectTo['Account'] = '';
     54    $SubjectTo['PayVAT'] = '';
     55    $VarSym = $SubjectTo['Id'];
    4056   
    4157    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$this->System->Config['Finance']['MainSubjectId']);
    42     $MainSubject = $DbResult->fetch_assoc();
     58    $SubjectFrom = $DbResult->fetch_assoc();
    4359   
    4460    $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '.
    4561      'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
    4662      'WHERE (FinanceBankAccount.`Subject`='.$this->System->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');
    47     $MainSubjectAccount = $DbResult->fetch_assoc();
     63    $SubjectFromAccount = $DbResult->fetch_assoc();
     64    $SubjectFrom['Account'] = $SubjectFromAccount['NumberFull'];
    4865   
    4966    $Dodavka = array();
     67    $InvoiceItems = array();
    5068    $DbResult = $this->Database->select('FinanceInvoiceItem', '*', 'FinanceInvoice='.$this->InvoiceId);
    5169    while($Item = $DbResult->fetch_assoc())
     
    5472    }
    5573   
     74    // If negative value => switch sides
     75    if($Invoice['Value'] < 0)
     76    {
     77        $Subject = $SubjectTo;
     78        $SubjectTo = $SubjectFrom;
     79        $SubjectFrom = $Subject;   
     80        foreach($InvoiceItems as $Index => $Item)
     81        {
     82                $InvoiceItems[$Index]['Price'] = -$InvoiceItems[$Index]['Price'];
     83        }
     84    }
     85   
    5686    $PaymentType = array('převodem', 'hotově');
    5787    $BooleanText = array('Ne', 'Ano');
     
    6191      '<hr></td></tr>'.
    6292      '<tr><td valign="top" width="50%"><strong>Dodavatel:</strong><br>'.
    63       $MainSubject['Name'].'<br>'.
    64       $MainSubject['AddressStreet'].'<br>'.
    65       $MainSubject['AddressPSC'].' '.$MainSubject['AddressTown'].'<br>'.
    66       'IČ: '.$MainSubject['IC'].'<br>'.
    67       'DIČ: '.$MainSubject['DIC'].'<br>'.
    68       'Účet: '.$MainSubjectAccount['NumberFull'].'<br>'.
    69       'Plátce DPH: '.$BooleanText[$MainSubject['PayVAT']].'<br>'.
     93      $this->ShowSubjectInfo($SubjectFrom).
    7094      '</td><td valign="top">'.
    7195      '<strong>Odběratel:</strong><br>'.
    72       $Subject['Name'].'<br>'.
    73       $Subject['AddressStreet'].'<br>'.
    74       $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
    75       if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    76       if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
     96      $this->ShowSubjectInfo($SubjectTo);
    7797    $Output .=
    7898      '</td></tr>'.
     
    81101      '<strong>Platební podmínky:</strong><br>'.
    82102      'Číslo dokladu: '.$Invoice['BillCode'].'<br>'.
    83       'Variabilní symbol: '.$Subject['Id'].'<br>'.
     103      'Variabilní symbol: '.$VarSym.'<br>'.
    84104      'Specifický symbol: '.$this->SpecificSymbol.'<br>'.
    85105      'Konstantní symbol:<br>'.
Note: See TracChangeset for help on using the changeset viewer.