Compare commits

...

11 commits

Author SHA1 Message Date
Ramon Gutierrez
630796df85 Merge branch '811-add-sealant-fee' into 'master'
Resolve "Add sealant fee"

Closes #811

See merge request jankstudio/resq!924
2024-12-08 14:35:58 +00:00
dedfb58a28 Fix issue of sealant and coolant fee not displaying in open edit form. #811 2024-12-05 01:48:39 -05:00
1b24e68f6b Add processing of sealant fee for tire repair service. #811 2024-12-04 02:51:50 -05:00
Ramon Gutierrez
dc4d5f90a7 Merge branch '808-add-form-validation-to-role' into 'master'
Validate role ID and name are not blank #808

Closes #808

See merge request jankstudio/resq!923
2024-10-02 05:58:32 +00:00
Ramon Gutierrez
0179a1b87e Validate role ID and name are not blank #808 2024-10-02 13:58:03 +08:00
Ramon Gutierrez
f1609b2273 Merge branch '807-disable-sms-for-certain-rejection-reasons' into 'master'
Resolve "Disable SMS for certain Rejection Reasons"

Closes #807 and #792

See merge request jankstudio/resq!922
2024-09-24 07:15:30 +00:00
22215ff9f6 Merge branch '807-disable-sms-for-certain-rejection-reasons' of gitlab.com:jankstudio/resq into 807-disable-sms-for-certain-rejection-reasons 2024-09-24 02:47:11 -04:00
Ramon Gutierrez
6994d69020 Merge branch '792-battery-facilitated-by-issue' into 'master'
Resolve "Battery Facilitated By issue"

Closes #792

See merge request jankstudio/resq!903
2024-09-24 02:45:43 -04:00
Ramon Gutierrez
83bdb5c626 Merge branch '792-battery-facilitated-by-issue' into 'master'
Resolve "Battery Facilitated By issue"

Closes #792

See merge request jankstudio/resq!903
2024-09-24 04:40:00 +00:00
Ramon Gutierrez
5a5113b166 Merge branch '803-fix-invoice-data-disappearing-on-open-edit-form' into 'master'
Fix invoice data on open edit form

Closes #803

See merge request jankstudio/resq!918
2024-09-24 04:23:02 +00:00
5ddebcd95f Add saving of facilitated hub data when reassigning hub. Fix display of dropdown for facilitated hubs. #792 2024-03-04 22:45:57 -05:00
10 changed files with 219 additions and 13 deletions

View file

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

View file

@ -754,6 +754,8 @@ class JobOrderController extends Controller
$promo_id = $req->request->get('promo');
$cvid = $req->request->get('cvid');
$service_charges = $req->request->get('service_charges', []);
$flag_coolant = $req->request->get('flag_coolant', false);
$flag_sealant = $req->request->get('flag_sealant', false);
// coordinates
// need to check if lng and lat are set
@ -784,7 +786,9 @@ class JobOrderController extends Controller
->setCustomerVehicle($cv)
->setIsTaxable()
->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

View file

@ -441,6 +441,12 @@ class JobOrder
*/
protected $flag_cust_new;
// only for tire service, if it requires sealant or not
/**
* @ORM\Column(type="boolean")
*/
protected $flag_sealant;
public function __construct()
{
$this->date_create = new DateTime();
@ -458,6 +464,7 @@ class JobOrder
$this->trade_in_type = null;
$this->flag_rider_rating = false;
$this->flag_coolant = false;
$this->flag_sealant = false;
$this->priority = 0;
$this->meta = [];
@ -1256,4 +1263,15 @@ class JobOrder
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,6 +6,7 @@ use Catalyst\AuthBundle\Entity\Role as BaseRole;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
@ -16,6 +17,19 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
*/
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")
*/

View file

@ -31,6 +31,7 @@ class TireRepair implements InvoiceRuleInterface
public function compute($criteria, &$total)
{
$stype = $criteria->getServiceType();
$has_sealant = $criteria->hasSealant();
$pt_id = $criteria->getPriceTier();
$items = [];
@ -56,8 +57,28 @@ class TireRepair implements InvoiceRuleInterface
'price' => $price,
];
$qty_price = bcmul($price, $qty, 2);
$total['total_price'] = bcadd($total['total_price'], $qty_price, 2);
$qty_fee = bcmul($qty, $price, 2);
$total_price = $qty_fee;
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;
@ -131,4 +152,28 @@ class TireRepair implements InvoiceRuleInterface
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

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

View file

@ -69,6 +69,14 @@ class InvoiceManager implements InvoiceGeneratorInterface
->setCustomerVehicle($jo->getCustomerVehicle())
->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
// 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

View file

@ -1612,6 +1612,26 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$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
$old_hub = $obj->getHub();
@ -1672,6 +1692,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setOwnershipType($owner_type)
->setCustomerLocation($cust_location)
->setInventoryCount($req->request->get('hub_inv_count', 0))
->setFacilitatedType($fac_type)
->setFacilitatedBy($fac_by)
->clearRider();
if ($user != null)
@ -4345,12 +4367,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$phone_number = $this->country_code . $notif_number;
// check if reason is administrative
if ($rejection->getReason() == JORejectionReason::ADMINISTRATIVE)
return null;
// check if reason is in the list of rejection reason
$flag_send_sms = $this->checkRejectionReason($rejection->getReason());
// check if reason is discount
if ($rejection->getReason() == JORejectionReason::DISCOUNT)
if (!$flag_send_sms)
return null;
// sms content
@ -4384,6 +4404,43 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$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
{
$long = $coordinates->getLongitude();

View file

@ -831,20 +831,28 @@
<div class="m-form__section">
<div class="form-group m-form__group row">
<div class="col-lg-2">
<label for="faciliateted-type">Battery Facilitated By</label>
<label for="facilitated-type">Battery Facilitated By</label>
<select name="facilitated_type" class="form-control m-input" id="facilitated-type">
<option value="">None</option>
{% for key, type in facilitated_types %}
<option value="{{ key }}">{{ type }}</option>
{% if obj.getFacilitatedType %}
<option value="{{ key }}"{{ obj.getFacilitatedType == key ? ' selected' }}>{{ type }}</option>
{% else %}
<option value="{{ key }}">{{ type }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="col-lg-8">
<label for="faciliateted-by">&nbsp;</label>
<label for="facilitated-by">&nbsp;</label>
<select name="facilitated_by" class="form-control m-input" id="facilitated-by">
<option value="">None</option>
{% for key, name in facilitated_hubs %}
<option value="{{ key }}">{{ name }}</option>
{% if obj.getFacilitatedBy %}
<option value="{{ key }}"{{ obj.getFacilitatedBy.getID == key ? ' selected' }}>{{ name }}</option>
{% else %}
<option value="{{ key }}">{{ name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
@ -1199,6 +1207,8 @@
<script>
var invoiceItems = [];
var hasCoolant = 0;
var hasSealant = 0;
// location search autocomplete
var input = document.getElementById('m_gmap_address');
@ -1262,6 +1272,19 @@ $(function() {
{% 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 %}
}
@ -1822,6 +1845,8 @@ $(function() {
'cvid': cvid,
'coord_lng': lng,
'coord_lat': lat,
'flag_coolant': hasCoolant,
'flag_sealant': hasSealant,
}
}).done(function(response) {
// mark as invoice changed

View file

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