Skip to content

Commit

Permalink
Added SalesReceipt
Browse files Browse the repository at this point in the history
Support for transaction date
  • Loading branch information
Adrian Walls committed Sep 18, 2017
1 parent 8ce6ec1 commit fba28ec
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Builders/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,32 @@ public function addTaxableAmount($amount, $id)

return $this;
}

/**
* Set due date.
*
* @param string $dueDate YYYY-MM-DD
*
* @return $this
*/
public function setDueDate($dueDate)
{
$this->data['DueDate'] = $dueDate;

return $this;
}

/**
* Set transaction date.
*
* @param string $txnDate YYYY-MM-DD
*
* @return $this
*/
public function setTxnDate($txnDate)
{
$this->data['TxnDate'] = $txnDate;

return $this;
}
}
160 changes: 160 additions & 0 deletions src/Builders/Items/SalesReceipt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?php

namespace ReneDeKat\Quickbooks\Builders\Items;

class SalesReceipt 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;
}
}

14 changes: 14 additions & 0 deletions src/Builders/SalesReceipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@ public function setTxnDate($txnDate)

return $this;
}

/**
* Set due date.
*
* @param string $dueDate YYYY-MM-DD
*
* @return $this
*/
public function setDueDate($dueDate)
{
$this->data['DueDate'] = $dueDate;

return $this;
}
}

0 comments on commit fba28ec

Please sign in to comment.