Add frontend elements for testing JO saving. #744

This commit is contained in:
Korina Cordero 2023-06-07 05:30:37 -04:00
parent fa514ef26c
commit 05073f3a0c
5 changed files with 86 additions and 8 deletions

View file

@ -16,7 +16,6 @@ use App\Entity\VehicleManufacturer;
use App\Entity\Vehicle;
use App\Entity\Hub;
use App\Service\InvoiceGeneratorInterface;
use App\Service\JobOrderHandlerInterface;
use App\Service\GISManagerInterface;
use App\Service\MapTools;
@ -24,6 +23,7 @@ use App\Service\MQTTClient;
use App\Service\APNSClient;
use App\Service\InventoryManager;
use App\Service\HubSelector;
use App\Service\InvoiceManager;
use App\Service\RiderTracker;
use App\Service\MotivConnector;
@ -713,7 +713,7 @@ class JobOrderController extends Controller
}
public function generateInvoice(Request $req, InvoiceGeneratorInterface $ic)
public function generateInvoice(Request $req, InvoiceManager $ic)
{
// error_log('generating invoice...');
$error = false;
@ -724,8 +724,6 @@ class JobOrderController extends Controller
$cvid = $req->request->get('cvid');
$service_charges = $req->request->get('service_charges', []);
// TODO: set if taxable here
$em = $this->getDoctrine()->getManager();
// get customer vehicle
@ -739,7 +737,8 @@ class JobOrderController extends Controller
// instantiate invoice criteria
$criteria = new InvoiceCriteria();
$criteria->setServiceType($stype)
->setCustomerVehicle($cv);
->setCustomerVehicle($cv)
->setIsTaxable();
/*

View file

@ -29,6 +29,7 @@ use App\Entity\CustomerTag;
use App\Entity\EmergencyType;
use App\Entity\OwnershipType;
use App\Entity\CustomerLocation;
use App\Entity\Battery;
use App\Ramcar\ServiceType;
use App\Ramcar\TradeInType;
@ -3442,8 +3443,19 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// db loaded
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
$params['trade_in_bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
$params['promos'] = $em->getRepository(Promo::class)->findAll();
// list of batteries for trade-in
$ti_batteries = $em->getRepository(Battery::class)->findAll();
$trade_in_batteries = [];
foreach ($ti_batteries as $ti_battery)
{
$battery_name = $ti_battery->getModel()->getName() . ' ' . $ti_battery->getSize()->getName();
$trade_in_batteries[$ti_battery->getID()] = $battery_name;
}
$params['trade_in_batteries'] = $trade_in_batteries;
// list of emergency types
$e_types = $em->getRepository(EmergencyType::class)->findBy([], ['name' => 'ASC']);
$emergency_types = [];

View file

@ -0,0 +1,46 @@
<div class="form-group m-form__group row">
<div class="col-lg-1 hide">
<label for="invoice-trade-in-bmfg">Manufacturer</label>
<select class="form-control m-input" id="invoice-trade-in-bmfg">
{% for manufacturer in trade_in_bmfgs %}
<option value="{{ manufacturer.getID() }}">{{ manufacturer.getName() }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<label for="invoice-trade-in-battery">Battery For Trade In</label>
<select class="form-control m-input" id="invoice-trade-in-battery" data-value="">
<option value=""></option>
{% for id, battery_name in trade_in_batteries %}
<option value="{{ id }}">{{ battery_name }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-2">
<label for="invoice-trade-in-type">Trade In</label>
<select class="form-control m-input" name="invoice_trade_in_type" id="invoice-trade-in-type">
<option value="">None</option>
{% for key, type in trade_in_types %}
<option value="{{ key }}">{{ type }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-2">
<label data-field="no_trade_in_reason">No Trade In Reason</label>
<select class="form-control m-input" id="no-trade-in-reason" name="no_trade_in_reason">
<option value="">Select reason</option>
{% for key, class in no_trade_in_reasons %}
<option value="{{ key }}"{{ obj.getNoTradeInReason == key ? ' selected' }}>{{ class }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="no_trade_in_reason"></div>
</div>
<div class="col-lg-1">
<label for="invoice-trade-in-quantity">Quantity</label>
<input type="text" id="invoice-trade-in-quantity" class="form-control m-input text-right" value="1">
</div>
<div class="col-lg-3">
<div><label>&nbsp;</label></div>
<button type="button" class="btn btn-primary" id="btn-add-trade-in-to-invoice">Add</button>
</div>
</div>

View file

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

View file

@ -715,6 +715,7 @@
<option value="">Select a vehicle and manufacturer first</option>
</select>
</div>
<!--
<div class="col-lg-2">
<label for="invoice-trade-in-type">Trade In</label>
<select class="form-control m-input" name="invoice_trade_in_type" id="invoice-trade-in-type">
@ -734,6 +735,7 @@
</select>
<div class="form-control-feedback hide" data-field="no_trade_in_reason"></div>
</div>
-->
<div class="col-lg-1">
<label for="invoice-quantity">Quantity</label>
@ -748,6 +750,7 @@
<button type="button" class="btn btn-danger" id="btn-reset-invoice">Reset</button>
</div>
</div>
{% include('invoice/trade_in.html.twig') %}
{% endif %}
</div>
@ -1190,7 +1193,6 @@
<script src="/assets/vendors/custom/gmaps/gmaps.js" type="text/javascript"></script>
<script>
// location search autocomplete
var input = document.getElementById('m_gmap_address');
@ -1686,11 +1688,13 @@ $(function() {
var invoiceItems = [];
{% include 'invoice/trade_in.js.twig' %}
// add to invoice
$("#btn-add-to-invoice").click(function() {
var bmfg = $("#invoice-bmfg").val();
var battery = $("#invoice-battery").val();
var tradeIn = $("#invoice-trade-in-type").val();
// var tradeIn = $("#invoice-trade-in-type").val();
var qty = $("#invoice-quantity").val();
if (!bmfg || !battery || !qty) {
@ -1719,7 +1723,7 @@ $(function() {
invoiceItems.push({
battery: battery,
quantity: qty,
trade_in: tradeIn,
trade_in: '',
});
// regenerate the invoice