resq/src/InvoiceRule/JumpstartWarranty.php
2023-07-04 06:05:34 -04:00

64 lines
1.4 KiB
PHP

<?php
namespace App\InvoiceRule;
use App\InvoiceRuleInterface;
class JumpstartWarranty implements InvoiceRuleInterface
{
public function getID()
{
return 'jumpstart_warranty';
}
public function compute($criteria, &$total)
{
$stype = $criteria->getServiceType();
$items = [];
if ($stype == $this->getID())
{
$fee = $this->getServiceTypeFee();
// add the service fee to items
$qty = 1;
$items[] = [
'service_type' => $this->getID(),
'qty' => $qty,
'title' => $this->getServiceTitle(),
'price' => $fee,
];
$qty_price = bcmul($fee, $qty, 2);
$total['total_price'] = bcadd($total['total_price'], $qty_price, 2);
}
return $items;
}
public function getServiceTypeFee()
{
// TODO: we need to to put this somewhere like in .env
// so that if any chanages are to be made, we just edit the file
// instead of the code
return 0;
}
public function validatePromo($criteria, $promo_id)
{
return false;
}
public function validateInvoiceItems($criteria, $invoice_items)
{
return null;
}
protected function getServiceTitle()
{
$title = 'Service - Troubleshooting fee';
return $title;
}
}