Skip to content

Commit

Permalink
Updated bill item
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Walls committed Sep 19, 2017
1 parent f3d88f2 commit 81729fb
Showing 1 changed file with 160 additions and 0 deletions.
160 changes: 160 additions & 0 deletions src/Builders/Items/Bill.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?php

namespace ReneDeKat\Quickbooks\Builders\Items;

class Bill extends Item
{
/**
* @param string $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->data['Amount'] = $amount;

return $this;
}

/**
* @param string $description
*
* @return $this
*/
public function setDescription($description)
{
$this->data['Description'] = $description;

return $this;
}

/**
* Set Item's name. This is not needed if name is set through setItem().
*
* @param string $name Name of Item.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function setUnitPrice($name)
{
$this->data[$this->data['DetailType']]['UnitPrice'] = $name;

return $this;
}

/**
* Set Class Reference (from Products & Services) associated to this Item.
*
* @param string $id Item ID
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function setClassRef($id)
{
$this->data[$this->data['DetailType']]['ClassRef']['value'] = $id;

return $this;
}

/**
* Set Item Reference (from Products & Services) associated to this Item.
*
* @param string $id Item ID
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function setItemRef($id)
{
$this->data[$this->data['DetailType']]['ItemRef']['value'] = $id;

return $this;
}

/**
* Set Item's quantity.
*
* @param int $quantity Item quantity.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function setQuantity($quantity)
{
$this->data[$this->data['DetailType']]['Qty'] = $quantity;

return $this;
}

/**
* Set this Item as Sales Item.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function asSalesItem()
{
$this->setDetailType('SalesItemLineDetail');

return $this;
}

/**
* Set this Item as Discount.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function asDiscount()
{
$this->setDetailType('DiscountLineDetail');

return $this;
}

/**
* Set discount's percentage value.
*
* @param float $percent Discount percentage.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function setPercent($percent)
{
$this->data[$this->data['DetailType']]['PercentBased'] = true;
$this->data[$this->data['DetailType']]['DiscountPercent'] = $percent;

return $this;
}

/**
* Set discount's value.
*
* @param float $value Discount value.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function setValue($value)
{
$this->setAmount($value);
$this->data[$this->data['DetailType']]['PercentBased'] = false;

return $this;
}

/**
* Set this item to be taxable.
*
* @param bool $taxable Set to TRUE to make it taxable or FALSE otherwise. TRUE by default.
* @param mixed $id TaxCode ID.
*
* @return \ReneDeKat\Quickbooks\Builders\Items\Invoice
*/
public function isTaxable($taxable = true, $id = 'TAX')
{
if ($taxable) {
$this->data[$this->data['DetailType']]['TaxCodeRef']['value'] = $id;
} elseif (isset($this->data[$this->data['DetailType']]['TaxCodeRef'])) {
unset($this->data[$this->data['DetailType']]['TaxCodeRef']);
}

return $this;
}
}

0 comments on commit 81729fb

Please sign in to comment.