123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- /**
- *
- * PHP Pro Bid $Id$ 2WsMNNNDj0TclgB0DHZdu59pP8slMnF4TXqN60b/5gs=
- *
- * @link http://www.phpprobid.com
- * @copyright Copyright (c) 2015 Online Ventures Software & CodeCube SRL
- * @license http://www.phpprobid.com/license Commercial License
- *
- * @version 7.5
- */
- /**
- * abstract accounting/transactions table row object model
- */
- namespace Ppb\Db\Table\Row;
- abstract class AbstractAccounting extends AbstractRow
- {
- /**
- *
- * accounting/transactions row invoice details link
- *
- * @return array
- */
- public function link()
- {
- $array = array(
- 'action' => 'view-invoice',
- );
- $array['type'] = ($this->getData('transaction_type') == 'receipt') ? 'transactions' : 'accounting';
- if ($this->getData('listing_id')) {
- $array['listing_id'] = $this->getData('listing_id');
- }
- else {
- $array['id'] = $this->getData('id');
- }
- return $array;
- }
- /**
- *
- * only the admin and the owner can view the row
- *
- * @return bool
- */
- public function canView()
- {
- $user = $this->getUser();
- if ($user->getData('id') == $this->getData('user_id') || $user->getData('role') == 'Admin') {
- return true;
- }
- return false;
- }
- /**
- *
- * return the amount without tax
- *
- * @return float
- */
- public function amountNoTax()
- {
- return $this->getData('amount') - $this->taxAmount();
- }
- /**
- *
- * return the tax amount
- *
- * @return float
- */
- public function taxAmount()
- {
- $amount = $this->getData('amount');
- $taxRate = (1 + $this->getData('tax_rate') / 100);
- return round(($amount - ($amount / $taxRate)), 2);
- }
- /**
- *
- * return total amount
- *
- * @return float
- */
- public function totalAmount()
- {
- return $this->getData('amount');
- }
- /**
- *
- * return the name of the transaction row for display purposes
- *
- * @return string
- */
- public function displayName()
- {
- $name = \Ppb\Utility::unserialize($this->getData('name'));
- if (is_array($name)) {
- $translate = $this->getTranslate();
- $string = (null !== $translate) ? $translate->_($name['string']) : $name['string'];
- return vsprintf($string, $name['args']);
- }
- return $name;
- }
- abstract public function caption();
- }
|