Compare commits

..

No commits in common. "master" and "806-restore-inventory-counters-on-processing-form" have entirely different histories.

18 changed files with 83 additions and 430 deletions

View file

@ -386,7 +386,6 @@ class RiderAppController extends ApiController
'flag_coolant' => $jo->hasCoolant(), 'flag_coolant' => $jo->hasCoolant(),
'has_motolite' => $cv->hasMotoliteBattery(), 'has_motolite' => $cv->hasMotoliteBattery(),
'delivery_status' => $jo->getDeliveryStatus(), 'delivery_status' => $jo->getDeliveryStatus(),
'flag_sealant' => $jo->hasSealant(),
] ]
]; ];
} }
@ -1325,7 +1324,7 @@ class RiderAppController extends ApiController
return new APIResponse(false, 'Invalid promo id - ' . $promo_id); return new APIResponse(false, 'Invalid promo id - ' . $promo_id);
} }
// get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method, with sealant // get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method
if (isset($items['flag_motolite_battery'])) if (isset($items['flag_motolite_battery']))
{ {
// get customer vehicle from jo // get customer vehicle from jo
@ -1360,15 +1359,6 @@ class RiderAppController extends ApiController
$jo->setModeOfPayment($payment_method); $jo->setModeOfPayment($payment_method);
} }
if (isset($items['flag_sealant']))
{
$has_sealant = $items['flag_sealant'];
if ($has_sealant == 'true')
$jo->setHasSealant(true);
else
$jo->setHasSealant(false);
}
// get capi user // get capi user
$capi_user = $this->getUser(); $capi_user = $this->getUser();
if ($capi_user == null) if ($capi_user == null)
@ -1453,13 +1443,6 @@ class RiderAppController extends ApiController
else else
$jo->setHasCoolant(false); $jo->setHasCoolant(false);
// sealant
$flag_sealant = $req->request->get('flag_sealant', 'false');
if ($flag_sealant == 'true')
$jo->setHasSealant(true);
else
$jo->setHasSealant(false);
// has motolite battery // has motolite battery
$cv = $jo->getCustomerVehicle(); $cv = $jo->getCustomerVehicle();
$has_motolite = $req->request->get('has_motolite', 'false'); $has_motolite = $req->request->get('has_motolite', 'false');
@ -1560,9 +1543,6 @@ class RiderAppController extends ApiController
// get coolant if any // get coolant if any
$flag_coolant = $jo->hasCoolant(); $flag_coolant = $jo->hasCoolant();
// get sealant if any
$flag_sealant = $jo->hasSealant();
// check if new promo is null // check if new promo is null
if ($promo == null) if ($promo == null)
{ {
@ -1581,7 +1561,6 @@ class RiderAppController extends ApiController
->setCustomerVehicle($cv) ->setCustomerVehicle($cv)
->setSource($source) ->setSource($source)
->setHasCoolant($flag_coolant) ->setHasCoolant($flag_coolant)
->setHasSealant($flag_sealant)
->setIsTaxable(); ->setIsTaxable();
// set price tier // set price tier

View file

@ -14,7 +14,6 @@ use App\Ramcar\TransactionOrigin;
use App\Entity\CustomerVehicle; use App\Entity\CustomerVehicle;
use App\Entity\Promo; use App\Entity\Promo;
use App\Entity\Battery; use App\Entity\Battery;
use App\Entity\BatterySize;
use App\Entity\Customer; use App\Entity\Customer;
use App\Entity\CustomerMetadata; use App\Entity\CustomerMetadata;
@ -120,8 +119,7 @@ class InvoiceController extends ApiController
if (!empty($trade_in_type) && !empty($trade_in_batt)) { if (!empty($trade_in_type) && !empty($trade_in_batt)) {
$ti_batt_obj = $this->em->getRepository(Battery::class)->find($trade_in_batt); $ti_batt_obj = $this->em->getRepository(Battery::class)->find($trade_in_batt);
if (!empty($ti_batt_obj)) { if (!empty($ti_batt_obj)) {
$ti_batt_size_obj = $ti_batt_obj->getSize(); $icrit->addEntry($ti_batt_obj, $trade_in_type, 1);
$icrit->addTradeInEntry($ti_batt_size_obj, $trade_in_type, 1);
} }
} }

View file

@ -35,7 +35,6 @@ use App\Ramcar\WarrantyClass;
use App\Ramcar\HubCriteria; use App\Ramcar\HubCriteria;
use App\Ramcar\DeliveryStatus; use App\Ramcar\DeliveryStatus;
use App\Entity\Battery; use App\Entity\Battery;
use App\Entity\BatterySize;
use App\Entity\Hub; use App\Entity\Hub;
use App\Entity\Promo; use App\Entity\Promo;
use App\Entity\JOEvent; use App\Entity\JOEvent;
@ -697,8 +696,7 @@ class JobOrderController extends ApiController
if (!empty($trade_in_type) && !empty($trade_in_batt)) { if (!empty($trade_in_type) && !empty($trade_in_batt)) {
$ti_batt_obj = $this->em->getRepository(Battery::class)->find($trade_in_batt); $ti_batt_obj = $this->em->getRepository(Battery::class)->find($trade_in_batt);
if (!empty($ti_batt_obj)) { if (!empty($ti_batt_obj)) {
$ti_batt_size_obj = $ti_batt_obj->getSize(); $icrit->addEntry($ti_batt_obj, $trade_in_type, 1);
$icrit->addTradeInEntry($ti_batt_size_obj, $trade_in_type, 1);
} }
} }
@ -1159,8 +1157,7 @@ class JobOrderController extends ApiController
if (!empty($trade_in_type) && !empty($trade_in_batt)) { if (!empty($trade_in_type) && !empty($trade_in_batt)) {
$ti_batt_obj = $this->em->getRepository(Battery::class)->find($trade_in_batt); $ti_batt_obj = $this->em->getRepository(Battery::class)->find($trade_in_batt);
if (!empty($ti_batt_obj)) { if (!empty($ti_batt_obj)) {
$battery_size = $ti_batt_obj->getSize(); $icrit->addEntry($ti_batt_obj, $trade_in_type, 1);
$icrit->addTradeInEntry($battery_size, $trade_in_type, 1);
} }
} }

View file

@ -754,8 +754,6 @@ class JobOrderController extends Controller
$promo_id = $req->request->get('promo'); $promo_id = $req->request->get('promo');
$cvid = $req->request->get('cvid'); $cvid = $req->request->get('cvid');
$service_charges = $req->request->get('service_charges', []); $service_charges = $req->request->get('service_charges', []);
$flag_coolant = $req->request->get('flag_coolant', false);
$flag_sealant = $req->request->get('flag_sealant', false);
// coordinates // coordinates
// need to check if lng and lat are set // need to check if lng and lat are set
@ -786,9 +784,7 @@ class JobOrderController extends Controller
->setCustomerVehicle($cv) ->setCustomerVehicle($cv)
->setIsTaxable() ->setIsTaxable()
->setSource(TransactionOrigin::CALL) ->setSource(TransactionOrigin::CALL)
->setPriceTier($price_tier) ->setPriceTier($price_tier);
->setHasCoolant($flag_coolant)
->setHasSealant($flag_sealant);
/* /*
// if it's a jumpstart or troubleshoot only, we know what to charge already // if it's a jumpstart or troubleshoot only, we know what to charge already

View file

@ -50,24 +50,10 @@ class InvoiceItem
*/ */
protected $battery; protected $battery;
// battery size for trade in items
/**
* @ORM\ManyToOne(targetEntity="BatterySize")
* @ORM\JoinColumn(name="battery_size_id", referencedColumnName="id")
*/
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()
@ -129,26 +115,4 @@ class InvoiceItem
{ {
return $this->battery; return $this->battery;
} }
public function setBatterySize(BatterySize $battery_size)
{
$this->battery_size = $battery_size;
return $this;
}
public function getBatterySize()
{
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;
}
} }

View file

@ -441,12 +441,6 @@ class JobOrder
*/ */
protected $flag_cust_new; protected $flag_cust_new;
// only for tire service, if it requires sealant or not
/**
* @ORM\Column(type="boolean")
*/
protected $flag_sealant;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -464,7 +458,6 @@ class JobOrder
$this->trade_in_type = null; $this->trade_in_type = null;
$this->flag_rider_rating = false; $this->flag_rider_rating = false;
$this->flag_coolant = false; $this->flag_coolant = false;
$this->flag_sealant = false;
$this->priority = 0; $this->priority = 0;
$this->meta = []; $this->meta = [];
@ -1263,15 +1256,4 @@ class JobOrder
return $this->flag_cust_new; return $this->flag_cust_new;
} }
public function setHasSealant($flag = true)
{
$this->flag_sealant = $flag;
return $this;
}
public function hasSealant()
{
return $this->flag_sealant;
}
} }

View file

@ -6,7 +6,6 @@ use Catalyst\AuthBundle\Entity\Role as BaseRole;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/** /**
@ -17,19 +16,6 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
*/ */
class Role extends BaseRole class Role extends BaseRole
{ {
/**
* @ORM\Id
* @ORM\Column(type="string", length=80)
* @Assert\NotBlank()
*/
protected $id;
/**
* @ORM\Column(type="string", length=80)
* @Assert\NotBlank()
*/
protected $name;
/** /**
* @ORM\ManyToMany(targetEntity="User", mappedBy="roles", fetch="EXTRA_LAZY") * @ORM\ManyToMany(targetEntity="User", mappedBy="roles", fetch="EXTRA_LAZY")
*/ */

View file

@ -117,11 +117,13 @@ class BatteryReplacementWarranty implements InvoiceRuleInterface
if ($qty < 1) if ($qty < 1)
continue; continue;
if (empty($item['trade_in'])) // if this is a trade in, add trade in
{ if (!empty($item['trade_in']) && TradeInType::validate($item['trade_in']))
$trade_in = $item['trade_in'];
else
$trade_in = null; $trade_in = null;
$criteria->addEntry($battery, $trade_in, $qty);
} $criteria->addEntry($battery, $trade_in, $qty);
} }
} }

View file

@ -103,24 +103,26 @@ class BatterySales implements InvoiceRuleInterface
// check if this is a valid battery // check if this is a valid battery
foreach ($invoice_items as $item) foreach ($invoice_items as $item)
{ {
if (isset($item['battery'])) $battery = $this->em->getRepository(Battery::class)->find($item['battery']);
if (empty($battery))
{ {
$battery = $this->em->getRepository(Battery::class)->find($item['battery']); $error = 'Invalid battery specified.';
return $error;
if (empty($battery))
{
$error = 'Invalid battery specified.';
return $error;
}
// quantity
$qty = $item['quantity'];
if ($qty < 1)
continue;
$trade_in = null;
$criteria->addEntry($battery, $trade_in, $qty);
} }
// quantity
$qty = $item['quantity'];
if ($qty < 1)
continue;
// if this is a trade in, add trade in
if (!empty($item['trade_in']) && TradeInType::validate($item['trade_in']))
$trade_in = $item['trade_in'];
else
$trade_in = null;
$criteria->addEntry($battery, $trade_in, $qty);
} }
} }

View file

@ -31,7 +31,6 @@ class TireRepair implements InvoiceRuleInterface
public function compute($criteria, &$total) public function compute($criteria, &$total)
{ {
$stype = $criteria->getServiceType(); $stype = $criteria->getServiceType();
$has_sealant = $criteria->hasSealant();
$pt_id = $criteria->getPriceTier(); $pt_id = $criteria->getPriceTier();
$items = []; $items = [];
@ -57,28 +56,8 @@ class TireRepair implements InvoiceRuleInterface
'price' => $price, 'price' => $price,
]; ];
$qty_fee = bcmul($qty, $price, 2); $qty_price = bcmul($price, $qty, 2);
$total_price = $qty_fee; $total['total_price'] = bcadd($total['total_price'], $qty_price, 2);
if ($has_sealant)
{
$sealant_fee_data = $this->getSealantFeeData();
$sealant_fee = $sealant_fee_data['fee'];
$sealant_title = $sealant_fee_data['title'];
$items[] = [
'service_type' => $this->getID(),
'qty' => $qty,
'title' => $sealant_title,
'price' => $sealant_fee,
];
$qty_price = bcmul($sealant_fee, $qty, 2);
$total_price = bcadd($total_price, $qty_price, 2);
}
$total['total_price'] = bcadd($total['total_price'], $total_price, 2);
} }
return $items; return $items;
@ -152,28 +131,4 @@ class TireRepair implements InvoiceRuleInterface
return $title; return $title;
} }
public function getSealantFeeData()
{
$data = [
'fee' => 0.00,
'title' => '',
];
$code = 'tire_sealant_fee';
// find the service fee using the code
// if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee != null)
{
$data = [
'fee' => $fee->getFee(),
'title' => $fee->getName(),
];
}
return $data;
}
} }

View file

@ -2,24 +2,12 @@
namespace App\InvoiceRule; namespace App\InvoiceRule;
use Doctrine\ORM\EntityManagerInterface;
use App\InvoiceRuleInterface; use App\InvoiceRuleInterface;
use App\Ramcar\TradeInType; use App\Ramcar\TradeInType;
use App\Ramcar\ServiceType;
use App\Entity\BatterySize;
class TradeIn implements InvoiceRuleInterface class TradeIn implements InvoiceRuleInterface
{ {
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function getID() public function getID()
{ {
return 'trade-in'; return 'trade-in';
@ -41,7 +29,16 @@ class TradeIn implements InvoiceRuleInterface
if ($trade_in_type != null) if ($trade_in_type != null)
{ {
$batt_size = $entry['battery_size']; // at this point, entry is a trade in
// need to check if battery (coming from CRM) is set
// or battery_size is set (coming from rider app)
if (isset($entry['battery']))
{
$battery = $entry['battery'];
$batt_size = $battery->getSize();
}
else
$batt_size = $entry['battery_size'];
$ti_rate = $this->getTradeInRate($batt_size, $trade_in_type); $ti_rate = $this->getTradeInRate($batt_size, $trade_in_type);
@ -53,8 +50,6 @@ class TradeIn implements InvoiceRuleInterface
$price = bcmul($ti_rate, -1, 2); $price = bcmul($ti_rate, -1, 2);
$items[] = [ $items[] = [
'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,
@ -72,42 +67,6 @@ class TradeIn implements InvoiceRuleInterface
public function validateInvoiceItems($criteria, $invoice_items) public function validateInvoiceItems($criteria, $invoice_items)
{ {
// check service type. Only battery sales and battery warranty should have invoice items.
$stype = $criteria->getServiceType();
if ($stype != ServiceType::BATTERY_REPLACEMENT_NEW)
return null;
// return error if there's a problem, false otherwise
if (!empty($invoice_items))
{
// check if this is a valid battery
foreach ($invoice_items as $item)
{
if (isset($item['battery_size']))
{
$battery_size = $this->em->getRepository(BatterySize::class)->find($item['battery_size']);
if (empty($battery_size))
{
$error = 'Invalid battery size specified.';
return $error;
}
// quantity
$qty = $item['quantity'];
if ($qty < 1)
continue;
// check if trade in is set and if trade in type if valid
if (!empty($item['trade_in']) && TradeInType::validate($item['trade_in']))
{
$trade_in = $item['trade_in'];
$criteria->addTradeInEntry($battery_size, $trade_in, $qty);
}
}
}
}
return null; return null;
} }

View file

@ -18,7 +18,6 @@ class InvoiceCriteria
protected $flag_taxable; protected $flag_taxable;
protected $source; // use Ramcar's TransactionOrigin protected $source; // use Ramcar's TransactionOrigin
protected $price_tier; protected $price_tier;
protected $flag_sealant;
// entries are battery and trade-in combos // entries are battery and trade-in combos
protected $entries; protected $entries;
@ -35,7 +34,6 @@ class InvoiceCriteria
$this->flag_taxable = false; $this->flag_taxable = false;
$this->source = ''; $this->source = '';
$this->price_tier = 0; // set to default $this->price_tier = 0; // set to default
$this->flag_sealant = false;
} }
public function setServiceType($stype) public function setServiceType($stype)
@ -204,15 +202,4 @@ class InvoiceCriteria
{ {
return $this->price_tier; return $this->price_tier;
} }
public function setHasSealant($flag = true)
{
$this->flag_sealant = $flag;
return $this;
}
public function hasSealant()
{
return $this->flag_sealant;
}
} }

View file

@ -55,7 +55,7 @@ class InvoiceManager implements InvoiceGeneratorInterface
new InvoiceRule\Fuel($this->em, $this->pt_manager), new InvoiceRule\Fuel($this->em, $this->pt_manager),
new InvoiceRule\TireRepair($this->em, $this->pt_manager), new InvoiceRule\TireRepair($this->em, $this->pt_manager),
new InvoiceRule\DiscountType($this->em), new InvoiceRule\DiscountType($this->em),
new InvoiceRule\TradeIn($this->em), new InvoiceRule\TradeIn(),
new InvoiceRule\Tax($this->em, $this->pt_manager), new InvoiceRule\Tax($this->em, $this->pt_manager),
]; ];
} }
@ -69,14 +69,6 @@ class InvoiceManager implements InvoiceGeneratorInterface
->setCustomerVehicle($jo->getCustomerVehicle()) ->setCustomerVehicle($jo->getCustomerVehicle())
->setPriceTier($price_tier); ->setPriceTier($price_tier);
if (($jo->getServiceType() == ServiceType::OVERHEAT_ASSISTANCE) &&
($jo->hasCoolant()))
$criteria->setHasCoolant(true);
if (($jo->getServiceType() == ServiceType::TIRE_REPAIR) &&
($jo->hasSealant()))
$criteria->setHasSealant(true);
// set if taxable // set if taxable
// NOTE: ideally, this should be a parameter when calling generateInvoiceCriteria. But that // NOTE: ideally, this should be a parameter when calling generateInvoiceCriteria. But that
// would mean adding it as a parameter to the call, impacting all calls // would mean adding it as a parameter to the call, impacting all calls
@ -174,7 +166,6 @@ class InvoiceManager implements InvoiceGeneratorInterface
// (3) generateInvoiceCriteria // (3) generateInvoiceCriteria
// (4) RiderAPIHandler's changeService // (4) RiderAPIHandler's changeService
// (5) TAPI's JobOrderController // (5) TAPI's JobOrderController
// (6) CAPI's RiderAppController
public function generateInvoice($criteria) public function generateInvoice($criteria)
{ {
// no need to validate since generateDraftInvoice was called before this was called // no need to validate since generateDraftInvoice was called before this was called
@ -223,27 +214,17 @@ class InvoiceManager implements InvoiceGeneratorInterface
$price = $item['price']; $price = $item['price'];
$battery = null; $battery = null;
$battery_size = null;
$trade_in_type = '';
if (isset($item['battery'])) if (isset($item['battery']))
$battery = $item['battery']; $battery = $item['battery'];
if (isset($item['promo'])) if (isset($item['promo']))
$promo = $item['promo']; $promo = $item['promo'];
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[] = [ $invoice_items[] = [
'title' => $title, 'title' => $title,
'quantity' => $quantity, 'quantity' => $quantity,
'price' => $price, 'price' => $price,
'battery' => $battery, 'battery' => $battery,
'battery_size' => $battery_size,
'trade_in_type' => $trade_in_type,
]; ];
} }
} }
@ -292,15 +273,11 @@ 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']);
if ($item['battery_size'] != null)
$invoice_item->setBatterySize($item['battery_size']);
$invoice->addItem($invoice_item); $invoice->addItem($invoice_item);
} }

View file

@ -30,7 +30,6 @@ use App\Entity\EmergencyType;
use App\Entity\OwnershipType; use App\Entity\OwnershipType;
use App\Entity\CustomerLocation; use App\Entity\CustomerLocation;
use App\Entity\Battery; use App\Entity\Battery;
use App\Entity\BatterySize;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Ramcar\TradeInType; use App\Ramcar\TradeInType;
@ -1612,26 +1611,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$error_array['cust_location'] = 'Invalid customer location'; $error_array['cust_location'] = 'Invalid customer location';
} }
// check facilitated type
$fac_type = $req->request->get('facilitated_type');
if (!empty($fac_type))
{
if (!FacilitatedType::validate($fac_type))
$fac_type = null;
}
else
$fac_type = null;
// check facilitated by
$fac_by_id = $req->request->get('facilitated_by');
$fac_by = null;
if (!empty($fac_by_id))
{
$fac_by = $em->getRepository(Hub::class)->find($fac_by_id);
if (empty($fac_by))
$fac_by = null;
}
// get previously assigned hub, if any // get previously assigned hub, if any
$old_hub = $obj->getHub(); $old_hub = $obj->getHub();
@ -1692,8 +1671,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setOwnershipType($owner_type) ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location) ->setCustomerLocation($cust_location)
->setInventoryCount($req->request->get('hub_inv_count', 0)) ->setInventoryCount($req->request->get('hub_inv_count', 0))
->setFacilitatedType($fac_type)
->setFacilitatedBy($fac_by)
->clearRider(); ->clearRider();
if ($user != null) if ($user != null)
@ -2335,13 +2312,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$em = $this->em; $em = $this->em;
$jo = $em->getRepository(JobOrder::class)->find($id); $jo = $em->getRepository(JobOrder::class)->find($id);
// get the job order's invoice items
$invoice = $jo->getInvoice();
$invoice_items = [];
if ($invoice != null)
$invoice_items = $invoice->getItems();
$params['invoice_items'] = $invoice_items;
$params['obj'] = $jo; $params['obj'] = $jo;
$params['mode'] = 'open_edit'; $params['mode'] = 'open_edit';
$params['cvid'] = $jo->getCustomerVehicle()->getID(); $params['cvid'] = $jo->getCustomerVehicle()->getID();
@ -3661,15 +3631,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$params['trade_in_bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll(); $params['trade_in_bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
$params['promos'] = $em->getRepository(Promo::class)->findAll(); $params['promos'] = $em->getRepository(Promo::class)->findAll();
// list of battery sizes for trade-in // list of batteries for trade-in
$ti_batt_sizes = $em->getRepository(BatterySize::class)->findAll(); $ti_batteries = $em->getRepository(Battery::class)->findAll();
$trade_in_batt_sizes = []; $trade_in_batteries = [];
foreach ($ti_batt_sizes as $ti_batt_size) foreach ($ti_batteries as $ti_battery)
{ {
$batt_size_name = $ti_batt_size->getName(); $battery_name = $ti_battery->getModel()->getName() . ' ' . $ti_battery->getSize()->getName();
$trade_in_batt_sizes[$ti_batt_size->getID()] = $batt_size_name; $trade_in_batteries[$ti_battery->getID()] = $battery_name;
} }
$params['trade_in_batt_sizes'] = $trade_in_batt_sizes; $params['trade_in_batteries'] = $trade_in_batteries;
// list of emergency types // list of emergency types
$e_types = $em->getRepository(EmergencyType::class)->findBy([], ['name' => 'ASC']); $e_types = $em->getRepository(EmergencyType::class)->findBy([], ['name' => 'ASC']);
@ -4367,10 +4337,12 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$phone_number = $this->country_code . $notif_number; $phone_number = $this->country_code . $notif_number;
// check if reason is in the list of rejection reason // check if reason is administrative
$flag_send_sms = $this->checkRejectionReason($rejection->getReason()); if ($rejection->getReason() == JORejectionReason::ADMINISTRATIVE)
return null;
if (!$flag_send_sms) // check if reason is discount
if ($rejection->getReason() == JORejectionReason::DISCOUNT)
return null; return null;
// sms content // sms content
@ -4404,43 +4376,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $msg); $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $msg);
} }
protected function checkRejectionReason($reason): bool
{
// reason is administrative
if ($reason == JORejectionReason::ADMINISTRATIVE)
return false;
// reason is discount
if ($reason == JORejectionReason::DISCOUNT)
return false;
// reason is store closed on schedule
if ($reason == JORejectionReason::STORE_CLOSED_SCHEDULED)
return false;
// store closed half day
if ($reason == JORejectionReason::STORE_CLOSED_HALF_DAY)
return false;
// prio hub for warranty claim
if ($reason == JORejectionReason::PRIORITY_HUB_WTY_CLAIM)
return false;
// prio hub for jumpstart
if ($reason == JORejectionReason::PRIORITY_HUB_JUMPSTART)
return false;
// prio hub for RES-Q request
if ($reason == JORejectionReason::PRIORITY_HUB_RESQ_REQUEST)
return false;
// customer request
if ($reason == JORejectionReason::CUSTOMER_REQUEST)
return false;
return true;
}
protected function skipInventoryCheck(Point $coordinates): bool protected function skipInventoryCheck(Point $coordinates): bool
{ {
$long = $coordinates->getLongitude(); $long = $coordinates->getLongitude();

View file

@ -8,11 +8,11 @@
</select> </select>
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
<label for="invoice-trade-in-battery-size">Battery Size For Trade In</label> <label for="invoice-trade-in-battery">Battery For Trade In</label>
<select class="form-control m-input" id="invoice-trade-in-battery-size" data-value=""> <select class="form-control m-input" id="invoice-trade-in-battery" data-value="">
<option value=""></option> <option value=""></option>
{% for id, batt_size_name in trade_in_batt_sizes %} {% for id, battery_name in trade_in_batteries %}
<option value="{{ id }}">{{ batt_size_name }}</option> <option value="{{ id }}">{{ battery_name }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>

View file

@ -1,13 +1,13 @@
// add trade in battery to invoice // add trade in battery to invoice
$('#btn-add-trade-in-to-invoice').click(function() { $('#btn-add-trade-in-to-invoice').click(function() {
var bmfg = $("#invoice-trade-in-bmfg").val(); var bmfg = $("#invoice-trade-in-bmfg").val();
var battery_size = $("#invoice-trade-in-battery-size").val(); var battery = $("#invoice-trade-in-battery").val();
var tradeIn = $("#invoice-trade-in-type").val(); var tradeIn = $("#invoice-trade-in-type").val();
var qty = $("#invoice-trade-in-quantity").val(); var qty = $("#invoice-trade-in-quantity").val();
// add to invoice array // add to invoice array
invoiceItems.push({ invoiceItems.push({
battery_size: battery_size, battery: battery,
quantity: qty, quantity: qty,
trade_in: tradeIn, trade_in: tradeIn,
}); });

View file

@ -630,24 +630,20 @@
</div> </div>
</div> </div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-6"> <div class="col-lg-6">
<label>Discount Type</label> <label>Discount Type</label>
{% if ftags.invoice_edit %} {% if ftags.invoice_edit %}
<select class="form-control m-input" id="invoice-promo" name="invoice_promo"> <select class="form-control m-input" id="invoice-promo" name="invoice_promo">
<option value="">None</option> <option value="">None</option>
{% for promo in promos %} {% for promo in promos %}
{% if obj.getInvoice and obj.getInvoice.getPromo %} <option value="{{ promo.getID() }}">{{ promo.getName() ~ ' (' ~ promo.getDiscountRate * 100 ~ '% applied to ' ~ discount_apply[promo.getDiscountApply] ~ ')' }}</option>
<option value="{{ promo.getID() }}" {{ obj.getInvoice.getPromo.getID == promo.getID ? ' selected'}}>{{ promo.getName() ~ ' (' ~ promo.getDiscountRate * 100 ~ '% applied to ' ~ discount_apply[promo.getDiscountApply] ~ ')' }}</option> {% endfor %}
{% else %} </select>
<option value="{{ promo.getID() }}">{{ promo.getName() ~ ' (' ~ promo.getDiscountRate * 100 ~ '% applied to ' ~ discount_apply[promo.getDiscountApply] ~ ')' }}</option> <div class="form-control-feedback hide" data-field="invoice_promo"></div>
{% endif %} {% else %}
{% endfor %} <input type="text" id="invoice-promo" class="form-control m-input" value="{{ obj.getInvoice.getPromo.getName|default('None') }}" disabled>
</select> {% endif %}
<div class="form-control-feedback hide" data-field="invoice_promo"></div> </div>
{% else %}
<input type="text" id="invoice-promo" class="form-control m-input" value="{{ obj.getInvoice.getPromo.getName|default('None') }}" disabled>
{% endif %}
</div>
<div class="col-lg-3"> <div class="col-lg-3">
<label>Promo Discount</label> <label>Promo Discount</label>
<input type="text" id="invoice-promo-discount" class="form-control m-input text-right" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount|number_format(2) : '0.00' }}" disabled> <input type="text" id="invoice-promo-discount" class="form-control m-input text-right" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount|number_format(2) : '0.00' }}" disabled>
@ -831,28 +827,20 @@
<div class="m-form__section"> <div class="m-form__section">
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-2"> <div class="col-lg-2">
<label for="facilitated-type">Battery Facilitated By</label> <label for="faciliateted-type">Battery Facilitated By</label>
<select name="facilitated_type" class="form-control m-input" id="facilitated-type"> <select name="facilitated_type" class="form-control m-input" id="facilitated-type">
<option value="">None</option> <option value="">None</option>
{% for key, type in facilitated_types %} {% for key, type in facilitated_types %}
{% if obj.getFacilitatedType %} <option value="{{ key }}">{{ type }}</option>
<option value="{{ key }}"{{ obj.getFacilitatedType == key ? ' selected' }}>{{ type }}</option>
{% else %}
<option value="{{ key }}">{{ type }}</option>
{% endif %}
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="col-lg-8"> <div class="col-lg-8">
<label for="facilitated-by">&nbsp;</label> <label for="faciliateted-by">&nbsp;</label>
<select name="facilitated_by" class="form-control m-input" id="facilitated-by"> <select name="facilitated_by" class="form-control m-input" id="facilitated-by">
<option value="">None</option> <option value="">None</option>
{% for key, name in facilitated_hubs %} {% for key, name in facilitated_hubs %}
{% if obj.getFacilitatedBy %} <option value="{{ key }}">{{ name }}</option>
<option value="{{ key }}"{{ obj.getFacilitatedBy.getID == key ? ' selected' }}>{{ name }}</option>
{% else %}
<option value="{{ key }}">{{ name }}</option>
{% endif %}
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -1206,10 +1194,6 @@
<script src="/assets/vendors/custom/gmaps/gmaps.js" type="text/javascript"></script> <script src="/assets/vendors/custom/gmaps/gmaps.js" type="text/javascript"></script>
<script> <script>
var invoiceItems = [];
var hasCoolant = 0;
var hasSealant = 0;
// location search autocomplete // location search autocomplete
var input = document.getElementById('m_gmap_address'); var input = document.getElementById('m_gmap_address');
@ -1234,7 +1218,6 @@ autocomplete.addListener('place_changed', function() {
$(function() { $(function() {
var form_in_process = false; var form_in_process = false;
var invoiceItems = [];
// openstreet maps stuff // openstreet maps stuff
// TODO: move this to a service // TODO: move this to a service
@ -1245,49 +1228,6 @@ $(function() {
var markerLayerGroup = L.layerGroup().addTo(osm_map); var markerLayerGroup = L.layerGroup().addTo(osm_map);
function populateInvoiceItems()
{
{% 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 }};
invoiceItems.push({
battery: battery_id,
quantity: qty,
trade_in: '',
});
{% else %}
{% if item.getBatterySize is not null %}
var battery_size = {{ item.getBatterySize.GetID }};
var trade_in_type = '{{ item.getTradeInType }}';
// add to invoice array
invoiceItems.push({
battery_size: battery_size,
quantity: qty,
trade_in: trade_in_type,
});
{% endif %}
{% endif %}
{% endfor %}
// need to check if jo has coolant or sealant
{% if obj.getServiceType == 'overheat' %}
{% if obj.hasCoolant == 1 %}
hasCoolant = 1;
{% endif %}
{% endif %}
{% if obj.getServiceType == 'tire' %}
{% if obj.hasSealant == 1 %}
hasSealant = 1;
{% endif %}
{% endif %}
{% endif %}
}
function selectPoint(lat, lng) function selectPoint(lat, lng)
{ {
// check if point is in coverage area // check if point is in coverage area
@ -1372,11 +1312,6 @@ $(function() {
// OSM code // OSM code
var lat = {{ obj.getCoordinates.getLatitude }}; var lat = {{ obj.getCoordinates.getLatitude }};
var lng = {{ obj.getCoordinates.getLongitude }}; var lng = {{ obj.getCoordinates.getLongitude }};
var promo = $("#invoice-promo").val();
populateInvoiceItems();
selectPoint(lat, lng); selectPoint(lat, lng);
// remove placeholder text // remove placeholder text
@ -1760,6 +1695,8 @@ $(function() {
placeholder: "" placeholder: ""
}); });
var invoiceItems = [];
{% include 'invoice/trade_in.js.twig' %} {% include 'invoice/trade_in.js.twig' %}
// add to invoice // add to invoice
@ -1845,8 +1782,6 @@ $(function() {
'cvid': cvid, 'cvid': cvid,
'coord_lng': lng, 'coord_lng': lng,
'coord_lat': lat, 'coord_lat': lat,
'flag_coolant': hasCoolant,
'flag_sealant': hasSealant,
} }
}).done(function(response) { }).done(function(response) {
// mark as invoice changed // mark as invoice changed

View file

@ -1 +0,0 @@
INSERT INTO service_offering (name, code, fee) VALUES ('Tire Sealant Fee', 'tire_sealant_fee', '200.00');