Пример #1
0
 function __construct($id, $clientId, $date, $description, $amount, $tax, $total, $status)
 {
     $this->id = $id;
     $this->client = Client::GetClient($clientId);
     $this->party = $this->client;
     $this->date = $date;
     $this->tax = new Money(floatval($tax), Currency::Get('KES'));
     $this->total = new Money(floatval($total), Currency::Get('KES'));
     $this->amt = new Money(floatval($amount), Currency::Get('KES'));
     $this->amount = floatval($total);
     $this->status = $status;
     $this->scope = $description;
     $this->advices[] = CreditNote::GetNote($this->id);
     /*$this->description = '';
     		foreach ($this->advices as $invoice) {
     			foreach ($invoice->lineItems as $item) {
     				$this->description .= $item->quantity.' x '.$item->itemName.' ('.$item->itemDesc.'), ';
     			}
     		}*/
     $this->description = 'Credit Note no. ' . $id;
     $extras = new stdClass();
     $extras->amount = $this->amt->amount;
     $extras->tax = $this->tax->amount;
     $extras->discount = $this->discount;
     $extras->total = $this->total->amount;
     $extras->advices = $this->advices;
     $this->extras = $extras;
     try {
         $sql = 'SELECT * FROM vouchers WHERE voucher_id = ' . $id . ' AND tx_type LIKE "%Credit Note%"';
         $res = DatabaseHandler::GetRow($sql);
         $this->transactionId = $res['transaction_id'];
         $this->user = $res['cashier'];
         if (is_null($this->user)) {
             $this->user = SessionManager::GetUsername();
         }
         $this->type = $res['tx_type'];
         $sql = 'SELECT * FROM general_ledger_entries WHERE transaction_id = ' . intval($this->transactionId) . ' AND account_no = ' . intval($clientId);
         $res2 = DatabaseHandler::GetRow($sql);
         $this->party->balance = new Money(floatval($res2['balance']), Currency::Get('KES'));
     } catch (Exception $e) {
         Logger::Log(get_class($this), 'Exception', $e->getMessage());
     }
 }