Merge branch '27-handling-jumpstart-on-invoice-computation-for-job-order' into 'master'
Resolve "Handling jumpstart on invoice computation for job order" Closes #27 See merge request jankstudio/resq!24
This commit is contained in:
commit
ec6ca96f7d
3 changed files with 44 additions and 7 deletions
|
|
@ -1018,11 +1018,36 @@ class JobOrderController extends BaseController
|
|||
{
|
||||
$error = false;
|
||||
|
||||
$stype = $req->request->get('stype');
|
||||
$items = $req->request->get('items');
|
||||
$promo_id = $req->request->get('promo');
|
||||
|
||||
$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
|
||||
$criteria = new InvoiceCriteria();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class ServiceType extends NameValue
|
|||
{
|
||||
const BATTERY_REPLACEMENT_NEW = 'battery_new';
|
||||
const BATTERY_REPLACEMENT_WARRANTY = 'battery_warranty';
|
||||
const JUMPSTART_TROUBLESHOOT = 'jumpstart_troubleshoot';
|
||||
const TIRE_REPAIR = 'tire';
|
||||
const OVERHEAT_ASSITANCE = 'overheat';
|
||||
const EMERGENCY_REFUEL = 'fuel';
|
||||
|
|
@ -13,6 +14,7 @@ class ServiceType extends NameValue
|
|||
const COLLECTION = [
|
||||
'battery_new' => 'Battery Replacement (New)',
|
||||
'battery_warranty' => 'Battery Replacement (Under Warranty)',
|
||||
'jumpstart_troubleshoot' => 'Jumpstart or Troubleshoot',
|
||||
'tire' => 'Tire Repair',
|
||||
'overheat' => 'Overheat Assistance',
|
||||
'fuel' => 'Emergency Refuel',
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<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>-->
|
||||
{% for key, service in service_types %}
|
||||
<option value="{{ key }}"{{ obj.getServiceType == key ? ' selected' }}>{{ service }}</option>
|
||||
|
|
@ -383,13 +383,11 @@
|
|||
<label for="invoice-quantity">Quantity</label>
|
||||
<input type="text" id="invoice-quantity" class="form-control m-input text-right" value="1">
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
<div class="col-lg-5">
|
||||
<div><label> </label></div>
|
||||
<button type="button" class="btn btn-primary" id="btn-add-to-invoice">Add to Invoice</button>
|
||||
</div>
|
||||
<div class="col-lg-3 text-right">
|
||||
<div><label> </label></div>
|
||||
<button type="button" class="btn btn-danger" id="btn-reset-invoice">Reset Invoice</button>
|
||||
<button type="button" class="btn btn-primary" id="btn-add-to-invoice">Add</button>
|
||||
<button type="button" class="btn btn-success" id="btn-recompute-invoice">Recompute</button>
|
||||
<button type="button" class="btn btn-danger" id="btn-reset-invoice">Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -1033,6 +1031,11 @@ $(function() {
|
|||
generateInvoice();
|
||||
});
|
||||
|
||||
// trigger update when service type is changed
|
||||
$("#service_type").change(function() {
|
||||
generateInvoice();
|
||||
});
|
||||
|
||||
// reset the invoice table
|
||||
$("#btn-reset-invoice").click(function() {
|
||||
$("#invoice-promo").prop('selectedIndex', 0);
|
||||
|
|
@ -1040,15 +1043,22 @@ $(function() {
|
|||
generateInvoice();
|
||||
});
|
||||
|
||||
// recompute
|
||||
$("#btn-recompute-invoice").click(function() {
|
||||
generateInvoice();
|
||||
});
|
||||
|
||||
function generateInvoice() {
|
||||
var promo = $("#invoice-promo").val();
|
||||
var table = $("#invoice-table tbody");
|
||||
var stype = $("#service_type").val();
|
||||
|
||||
// generate invoice values
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "{{ url('jo_gen_invoice') }}",
|
||||
data: {
|
||||
'stype': stype,
|
||||
'items': invoiceItems,
|
||||
'promo': promo
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue