Add trade in type to invoice item. #03
This commit is contained in:
parent
4ccdd29ae6
commit
90628f0b54
4 changed files with 29 additions and 7 deletions
|
|
@ -57,10 +57,17 @@ class InvoiceItem
|
|||
*/
|
||||
protected $battery_size;
|
||||
|
||||
// trade in type
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $trade_in_type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->title = '';
|
||||
$this->price = 0.0;
|
||||
$this->trade_in_type = '';
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -133,4 +140,15 @@ class InvoiceItem
|
|||
{
|
||||
return $this->battery_size;
|
||||
}
|
||||
|
||||
public function setTradeInType(string $trade_in_type)
|
||||
{
|
||||
$this->trade_in_type = $trade_in_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTradeInType()
|
||||
{
|
||||
return $this->trade_in_type;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class TradeIn implements InvoiceRuleInterface
|
|||
|
||||
$items[] = [
|
||||
'battery_size' => $batt_size,
|
||||
'trade_in_type' => $trade_in_type,
|
||||
'qty' => $qty,
|
||||
'title' => $this->getTitle($batt_size, $trade_in_type),
|
||||
'price' => $price,
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
|||
|
||||
$battery = null;
|
||||
$battery_size = null;
|
||||
$trade_in_type = '';
|
||||
if (isset($item['battery']))
|
||||
$battery = $item['battery'];
|
||||
|
||||
|
|
@ -225,12 +226,16 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
|||
if (isset($item['battery_size']))
|
||||
$battery_size = $item['battery_size'];
|
||||
|
||||
if (isset($item['trade_in_type']))
|
||||
$trade_in_type = $item['trade_in_type'];
|
||||
|
||||
$invoice_items[] = [
|
||||
'title' => $title,
|
||||
'quantity' => $quantity,
|
||||
'price' => $price,
|
||||
'battery' => $battery,
|
||||
'battery_size' => $battery_size,
|
||||
'trade_in_type' => $trade_in_type,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -279,7 +284,8 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
|||
$invoice_item->setInvoice($invoice)
|
||||
->setTitle($item['title'])
|
||||
->setQuantity($item['quantity'])
|
||||
->setPrice((float)$item['price']);
|
||||
->setPrice((float)$item['price'])
|
||||
->setTradeInType($item['trade_in_type']);
|
||||
|
||||
if ($item['battery'] != null)
|
||||
$invoice_item->setBattery($item['battery']);
|
||||
|
|
|
|||
|
|
@ -1240,17 +1240,14 @@ $(function() {
|
|||
console.log('populateInvoiceItems start');
|
||||
{% if invoice_items is defined %}
|
||||
{% for item in invoice_items %}
|
||||
var qty = {{ item.getQuantity }};
|
||||
{% if item.getBattery is not null %}
|
||||
var battery_id = {{ item.getBattery.getID }};
|
||||
var qty = {{ item.getQuantity }};
|
||||
var trade_in = '';
|
||||
|
||||
console.log(battery_id);
|
||||
{% else %}
|
||||
// check if it's a trade in entry
|
||||
var title = '{{ item.getTitle }}';
|
||||
if (title.includes('Trade-in')) {
|
||||
console.log(title + ' a trade in');
|
||||
}
|
||||
var battery_size = {{ item.getBatterySize.GetID }};
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue