Add service type to invoice computation #27
This commit is contained in:
parent
730f18c813
commit
d4e28cd332
3 changed files with 44 additions and 7 deletions
|
|
@ -925,11 +925,36 @@ class JobOrderController extends BaseController
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = false;
|
||||||
|
|
||||||
|
$stype = $req->request->get('stype');
|
||||||
$items = $req->request->get('items');
|
$items = $req->request->get('items');
|
||||||
$promo_id = $req->request->get('promo');
|
$promo_id = $req->request->get('promo');
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
// if it's a jumpstart or troubleshoot only, we know what to charge already
|
||||||
|
if ($stype == ServiceType::JUMPSTART_TROUBLESHOOT)
|
||||||
|
{
|
||||||
|
$invoice = [
|
||||||
|
'price' => 150.00,
|
||||||
|
'discount' => 0,
|
||||||
|
'trade_in' => 0,
|
||||||
|
'vat' => 0,
|
||||||
|
'total_price' => 150.00,
|
||||||
|
'items' => []
|
||||||
|
];
|
||||||
|
$invoice['items'][] = [
|
||||||
|
'title' => 'Troubleshooting fee',
|
||||||
|
'quantity' => 1,
|
||||||
|
'unit_price' => 150.00,
|
||||||
|
'amount' => 150.00
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->json([
|
||||||
|
'success' => true,
|
||||||
|
'invoice' => $invoice
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// instantiate invoice criteria
|
// instantiate invoice criteria
|
||||||
$criteria = new InvoiceCriteria();
|
$criteria = new InvoiceCriteria();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ class ServiceType extends NameValue
|
||||||
{
|
{
|
||||||
const BATTERY_REPLACEMENT_NEW = 'battery_new';
|
const BATTERY_REPLACEMENT_NEW = 'battery_new';
|
||||||
const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty';
|
const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty';
|
||||||
|
const JUMPSTART_TROUBLESHOOT = 'jumpstart_troubleshoot';
|
||||||
const TIRE_REPAIR = 'tire';
|
const TIRE_REPAIR = 'tire';
|
||||||
const OVERHEAT_ASSITANCE = 'overheat';
|
const OVERHEAT_ASSITANCE = 'overheat';
|
||||||
const EMERGENCY_REFUEL = 'fuel';
|
const EMERGENCY_REFUEL = 'fuel';
|
||||||
|
|
@ -13,6 +14,7 @@ class ServiceType extends NameValue
|
||||||
const COLLECTION = [
|
const COLLECTION = [
|
||||||
'battery_new' => 'Battery Replacement (New)',
|
'battery_new' => 'Battery Replacement (New)',
|
||||||
'battery_warranty' => 'Battery Replacement (Under Warranty)',
|
'battery_warranty' => 'Battery Replacement (Under Warranty)',
|
||||||
|
'jumpstart_troubleshoot' => 'Jumpstart or Troubleshoot',
|
||||||
'tire' => 'Tire Repair',
|
'tire' => 'Tire Repair',
|
||||||
'overheat' => 'Overheat Assistance',
|
'overheat' => 'Overheat Assistance',
|
||||||
'fuel' => 'Emergency Refuel',
|
'fuel' => 'Emergency Refuel',
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@
|
||||||
<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 data-field="service_type">Service Type</label>
|
<label data-field="service_type">Service Type</label>
|
||||||
<select class="form-control m-input" name="service_type">
|
<select id="service_type" class="form-control m-input" name="service_type">
|
||||||
<!--<option value=""></option>-->
|
<!--<option value=""></option>-->
|
||||||
{% for key, service in service_types %}
|
{% for key, service in service_types %}
|
||||||
<option value="{{ key }}"{{ obj.getServiceType == key ? ' selected' }}>{{ service }}</option>
|
<option value="{{ key }}"{{ obj.getServiceType == key ? ' selected' }}>{{ service }}</option>
|
||||||
|
|
@ -362,13 +362,11 @@
|
||||||
<label for="invoice-quantity">Quantity</label>
|
<label for="invoice-quantity">Quantity</label>
|
||||||
<input type="text" id="invoice-quantity" class="form-control m-input text-right" value="1">
|
<input type="text" id="invoice-quantity" class="form-control m-input text-right" value="1">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-2">
|
<div class="col-lg-5">
|
||||||
<div><label> </label></div>
|
<div><label> </label></div>
|
||||||
<button type="button" class="btn btn-primary" id="btn-add-to-invoice">Add to Invoice</button>
|
<button type="button" class="btn btn-primary" id="btn-add-to-invoice">Add</button>
|
||||||
</div>
|
<button type="button" class="btn btn-success" id="btn-recompute-invoice">Recompute</button>
|
||||||
<div class="col-lg-3 text-right">
|
<button type="button" class="btn btn-danger" id="btn-reset-invoice">Reset</button>
|
||||||
<div><label> </label></div>
|
|
||||||
<button type="button" class="btn btn-danger" id="btn-reset-invoice">Reset Invoice</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -993,6 +991,11 @@ $(function() {
|
||||||
generateInvoice();
|
generateInvoice();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// trigger update when service type is changed
|
||||||
|
$("#service_type").change(function() {
|
||||||
|
generateInvoice();
|
||||||
|
});
|
||||||
|
|
||||||
// reset the invoice table
|
// reset the invoice table
|
||||||
$("#btn-reset-invoice").click(function() {
|
$("#btn-reset-invoice").click(function() {
|
||||||
$("#invoice-promo").prop('selectedIndex', 0);
|
$("#invoice-promo").prop('selectedIndex', 0);
|
||||||
|
|
@ -1000,15 +1003,22 @@ $(function() {
|
||||||
generateInvoice();
|
generateInvoice();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// recompute
|
||||||
|
$("#btn-recompute-invoice").click(function() {
|
||||||
|
generateInvoice();
|
||||||
|
});
|
||||||
|
|
||||||
function generateInvoice() {
|
function generateInvoice() {
|
||||||
var promo = $("#invoice-promo").val();
|
var promo = $("#invoice-promo").val();
|
||||||
var table = $("#invoice-table tbody");
|
var table = $("#invoice-table tbody");
|
||||||
|
var stype = $("#service_type").val();
|
||||||
|
|
||||||
// generate invoice values
|
// generate invoice values
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "{{ url('jo_gen_invoice') }}",
|
url: "{{ url('jo_gen_invoice') }}",
|
||||||
data: {
|
data: {
|
||||||
|
'stype': stype,
|
||||||
'items': invoiceItems,
|
'items': invoiceItems,
|
||||||
'promo': promo
|
'promo': promo
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue