Ignore:
Timestamp:
Feb 10, 2013, 9:20:06 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Příprava na zrušení tabulek dokladů a jejich převedení na tabulky File a FinanceInvoice.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/finance/manage.php

    r482 r486  
    133133      $DbRow = $DbResult->fetch_array();
    134134      $Advances = $DbRow[0];
    135       $DbResult = $this->Database->select('FinanceClaimsLiabilities', '*', 'Subject='.$Subject.' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1');
     135      $DbResult = $this->Database->select('FinanceInvoice', '*', 'Subject='.$Subject.
     136      ' AND TimePayment IS NULL AND Value > 0 ORDER BY TimeCreation LIMIT 1');
    136137      //echo($Database->error);
    137138      if($DbResult->num_rows > 0)
     
    140141        if($Advances > $OpenedClaim['Value'])
    141142        {
    142           $this->Database->update('FinanceClaimsLiabilities', 'Id='.$OpenedClaim['Id'], array('TimePayment' => TimeToMysqlDateTime($LastInsertTime)));
    143           $this->Database->insert('FinanceAdvances', array('Subject' => $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'], 'TimeCreation' => TimeToMysqlDateTime($LastInsertTime), 'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In'));
     143          $this->Database->update('FinanceInvoice', 'Id='.$OpenedClaim['Id'],
     144            array('TimePayment' => TimeToMysqlDateTime($LastInsertTime)));
     145          $this->Database->insert('FinanceAdvances', array('Subject' =>
     146            $OpenedClaim['Subject'], 'Value' => -$OpenedClaim['Value'],
     147            'TimeCreation' => TimeToMysqlDateTime($LastInsertTime),
     148            'CashFlowId' => $OpenedClaim['Id'], 'Direction' => 'In'));
    144149          //echo($Database->LastQuery);
    145150        } else break;
     
    154159
    155160    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine);
    156     $this->Database->insert('FinanceClaimsLiabilities', array('Text' => $Text,
     161    $this->Database->insert('FinanceInvoice', array(
    157162      'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($TimeCreation),
    158163      'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $Value, 'BillCode' => $BillCode,
    159164      'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo)));
     165    $InvoiceId = $this->Database->insert_id;
     166    $this->Database->insert('FinanceInvoice', array('FinanceInvoice' => $InvoiceId,
     167      'Description' => $Text, 'Price' => $Value, 'Quantity' => 1, 'VAT' => 0));
    160168    $Output = '.'; //$this->Database->LastQuery.'<br />';
    161169    //$LastInsertTime = $Time;
     
    253261      $Form->Values['DocumentLine'], NULL, NULL);
    254262    $LastId = $this->Database->insert_id;
    255     $DbResult = $this->Database->select('FinanceClaimsLiabilities', 'BillCode', 'Id='.$LastId);
     263    $DbResult = $this->Database->select('FinanceInvoice', 'BillCode', 'Id='.$LastId);
    256264    $DbRow = $DbResult->fetch_assoc();
    257265    $Output = $this->SystemMessage('Finance', 'Faktura vložena '.$DbRow['BillCode'].'.');
     
    360368    $Output .= $Finance->RecalculateSegmentParameters();
    361369    $Output .= $Finance->LoadTariffs();
    362     //$InvoiceGenerator->CustomGenerate();
    363370    $Output .= $Finance->RecalculateMemberPayment();
    364371
     
    446453          $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'],
    447454            $BillItems, time(), time() + 3600 * 24 * INVOICE_DUE_DAYS, $BillCode, $Period['From'], $Period['To']);
    448           $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod,
     455          $this->Database->insert('FinanceInvoice', array(
    449456            'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()',
    450             'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)',
    451             'Text' => 'Vyúčtování služeb za období '.$TimePeriodText,
     457            'TimeDue' => 'DATE_ADD(NOW(), INTERVAL '.INVOICE_DUE_DAYS.' DAY)',             
    452458            'Bill' => $BillId, 'BillCode' => $BillCode));
     459          $InvoiceId = $this->Database->insert_id;
     460          $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId,
     461            'Value' => $PayPerPeriod, 'Text' => 'Vyúčtování služeb za období '.$TimePeriodText,
     462           'Quantity' => 1, 'VAT' => 0));
     463         
    453464          $Output .= $this->SendPaymentEmail($Member['Id']);
    454465          $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To'])));
     
    531542      //$Member['BillingPeriodLastDate'] = '2009-04-01';
    532543      $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '.
    533       '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceClaimsLiabilities WHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")');
     544      '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceInvoice WHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")');
    534545      while($DbRow = $DbResult->fetch_assoc())
    535546      {
     
    550561  function GenerateBills()
    551562  {
    552     // FinanceClaimsLiablities
    553     $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities WHERE (BillCode <> "") AND (Value != 0) AND (Bill = 0)');
     563    // FinanceInvoice
     564    $DbResult = $this->Database->query('SELECT * FROM FinanceInvoice WHERE (BillCode <> "") AND (Value != 0) AND (Bill = 0)');
    554565    while($Row = $DbResult->fetch_assoc())
    555566    {
     
    558569        MysqlDateTimeToTime($Row['TimeCreation']), MysqlDateTimeToTime($Row['TimeDue']),
    559570        $Row['BillCode'], 'invoice', MysqlDateToTime($Row['PeriodFrom']), MysqlDateToTime($Row['PeriodTo']));
    560       $this->Database->update('FinanceClaimsLiabilities', 'Id='.$Row['Id'], array('Bill' => $BillId));
     571      $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('Bill' => $BillId));
    561572      echo('.');
    562573    }
Note: See TracChangeset for help on using the changeset viewer.