Skip to content

Commit

Permalink
Create bill
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Walls committed Sep 20, 2017
1 parent 81729fb commit 65beae4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 89 deletions.
24 changes: 22 additions & 2 deletions src/Builders/Bill.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace ReneDeKat\Quickbooks\Builders;

use ReneDeKat\Quickbooks\Builders\Traits\HasCustomer;
use ReneDeKat\Quickbooks\Builders\Traits\Itemizable;

class Bill extends Builder
{
use HasCustomer, Itemizable;
use Itemizable;

/**
* @param string $txnDate
Expand All @@ -34,4 +33,25 @@ public function setDueDate($dueDate)

return $this;
}

/**
* Set total amount.
*
* @param string $totalAmount
*
* @return $this
*/
public function setTotalAmount($totalAmount)
{
$this->data['TotalAmt'] = $totalAmount;

return $this;
}

public function setVendorRef($vendorRef)
{
$this->data['VendorRef']['value'] = $vendorRef;

return $this;
}
}
107 changes: 20 additions & 87 deletions src/Builders/Items/Bill.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

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

return $this;
}

/**
* @param string $description
*
Expand All @@ -29,122 +17,67 @@ public function setDescription($description)
}

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

return $this;
}

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

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)
public function setCustomerRef($id)
{
$this->data[$this->data['DetailType']]['ItemRef']['value'] = $id;

$this->data['ItemBasedExpenseLineDetail']['CustomerRef']['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()
public function setAccountRef($id)
{
$this->setDetailType('DiscountLineDetail');
$this->data['ItemBasedExpenseLineDetail']['AccountRef']['value'] = $id;

return $this;
}

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

return $this;
}

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

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
* @return \ReneDeKat\Quickbooks\Builders\Items\Bill
*/
public function isTaxable($taxable = true, $id = 'TAX')
{
Expand Down

0 comments on commit 65beae4

Please sign in to comment.