Add post replacement and recharge in invoice creator #80
This commit is contained in:
parent
f254fb2cb2
commit
af6765f662
1 changed files with 34 additions and 3 deletions
|
|
@ -56,7 +56,7 @@ class InvoiceCreator
|
|||
|
||||
protected function processEntries(&$total, InvoiceCriteria $criteria, Invoice $invoice)
|
||||
{
|
||||
error_log('processing entries...');
|
||||
// error_log('processing entries...');
|
||||
$entries = $criteria->getEntries();
|
||||
|
||||
$con_batts = [];
|
||||
|
|
@ -203,9 +203,35 @@ class InvoiceCreator
|
|||
$total['total_price'] = 150.00;
|
||||
}
|
||||
|
||||
public function processRecharge(&$total, $invoice)
|
||||
{
|
||||
// add recharge fee
|
||||
$item = new InvoiceItem();
|
||||
$item->setInvoice($invoice)
|
||||
->setTitle('Recharge fee')
|
||||
->setQuantity(1)
|
||||
->setPrice(300.00);
|
||||
$invoice->addItem($item);
|
||||
|
||||
$total['sell_price'] = 300.00;
|
||||
$total['vat_ex_price'] = 300.00;
|
||||
$total['total_price'] = 300.00;
|
||||
}
|
||||
|
||||
public function processReplacement(&$total, $invoice)
|
||||
{
|
||||
// add recharge fee
|
||||
$item = new InvoiceItem();
|
||||
$item->setInvoice($invoice)
|
||||
->setTitle('Battery replacement')
|
||||
->setQuantity(1)
|
||||
->setPrice(0.00);
|
||||
$invoice->addItem($item);
|
||||
}
|
||||
|
||||
public function processWarranty(&$total, InvoiceCriteria $criteria, $invoice)
|
||||
{
|
||||
error_log('processing warranty');
|
||||
// error_log('processing warranty');
|
||||
$entries = $criteria->getEntries();
|
||||
foreach ($entries as $entry)
|
||||
{
|
||||
|
|
@ -233,7 +259,7 @@ class InvoiceCreator
|
|||
];
|
||||
|
||||
$stype = $criteria->getServiceType();
|
||||
error_log($stype);
|
||||
// error_log($stype);
|
||||
switch ($stype)
|
||||
{
|
||||
case ServiceType::JUMPSTART_TROUBLESHOOT:
|
||||
|
|
@ -252,6 +278,11 @@ class InvoiceCreator
|
|||
case ServiceType::BATTERY_REPLACEMENT_WARRANTY:
|
||||
$this->processWarranty($total, $criteria, $invoice);
|
||||
break;
|
||||
case ServiceType::POST_RECHARGED:
|
||||
$this->processRecharge($total, $invoice);
|
||||
break;
|
||||
case ServiceType::POST_REPLACEMENT:
|
||||
$this->processReplacement($total, $invoice);
|
||||
}
|
||||
|
||||
// TODO: check if any promo is applied
|
||||
|
|
|
|||
Loading…
Reference in a new issue