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;
|
protected $battery_size;
|
||||||
|
|
||||||
|
// trade in type
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=20)
|
||||||
|
*/
|
||||||
|
protected $trade_in_type;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->title = '';
|
$this->title = '';
|
||||||
$this->price = 0.0;
|
$this->price = 0.0;
|
||||||
|
$this->trade_in_type = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -133,4 +140,15 @@ class InvoiceItem
|
||||||
{
|
{
|
||||||
return $this->battery_size;
|
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[] = [
|
$items[] = [
|
||||||
'battery_size' => $batt_size,
|
'battery_size' => $batt_size,
|
||||||
|
'trade_in_type' => $trade_in_type,
|
||||||
'qty' => $qty,
|
'qty' => $qty,
|
||||||
'title' => $this->getTitle($batt_size, $trade_in_type),
|
'title' => $this->getTitle($batt_size, $trade_in_type),
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
|
|
||||||
$battery = null;
|
$battery = null;
|
||||||
$battery_size = null;
|
$battery_size = null;
|
||||||
|
$trade_in_type = '';
|
||||||
if (isset($item['battery']))
|
if (isset($item['battery']))
|
||||||
$battery = $item['battery'];
|
$battery = $item['battery'];
|
||||||
|
|
||||||
|
|
@ -225,12 +226,16 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
if (isset($item['battery_size']))
|
if (isset($item['battery_size']))
|
||||||
$battery_size = $item['battery_size'];
|
$battery_size = $item['battery_size'];
|
||||||
|
|
||||||
|
if (isset($item['trade_in_type']))
|
||||||
|
$trade_in_type = $item['trade_in_type'];
|
||||||
|
|
||||||
$invoice_items[] = [
|
$invoice_items[] = [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'quantity' => $quantity,
|
'quantity' => $quantity,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
'battery' => $battery,
|
'battery' => $battery,
|
||||||
'battery_size' => $battery_size,
|
'battery_size' => $battery_size,
|
||||||
|
'trade_in_type' => $trade_in_type,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +284,8 @@ class InvoiceManager implements InvoiceGeneratorInterface
|
||||||
$invoice_item->setInvoice($invoice)
|
$invoice_item->setInvoice($invoice)
|
||||||
->setTitle($item['title'])
|
->setTitle($item['title'])
|
||||||
->setQuantity($item['quantity'])
|
->setQuantity($item['quantity'])
|
||||||
->setPrice((float)$item['price']);
|
->setPrice((float)$item['price'])
|
||||||
|
->setTradeInType($item['trade_in_type']);
|
||||||
|
|
||||||
if ($item['battery'] != null)
|
if ($item['battery'] != null)
|
||||||
$invoice_item->setBattery($item['battery']);
|
$invoice_item->setBattery($item['battery']);
|
||||||
|
|
|
||||||
|
|
@ -1240,17 +1240,14 @@ $(function() {
|
||||||
console.log('populateInvoiceItems start');
|
console.log('populateInvoiceItems start');
|
||||||
{% if invoice_items is defined %}
|
{% if invoice_items is defined %}
|
||||||
{% for item in invoice_items %}
|
{% for item in invoice_items %}
|
||||||
|
var qty = {{ item.getQuantity }};
|
||||||
{% if item.getBattery is not null %}
|
{% if item.getBattery is not null %}
|
||||||
var battery_id = {{ item.getBattery.getID }};
|
var battery_id = {{ item.getBattery.getID }};
|
||||||
var qty = {{ item.getQuantity }};
|
var trade_in = '';
|
||||||
|
|
||||||
console.log(battery_id);
|
console.log(battery_id);
|
||||||
{% else %}
|
{% else %}
|
||||||
// check if it's a trade in entry
|
var battery_size = {{ item.getBatterySize.GetID }};
|
||||||
var title = '{{ item.getTitle }}';
|
|
||||||
if (title.includes('Trade-in')) {
|
|
||||||
console.log(title + ' a trade in');
|
|
||||||
}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue