Merge branch '341-cmb-add-service-charge-dropdown' of gitlab.com:jankstudio/resq into 341-cmb-add-service-charge-dropdown
This commit is contained in:
commit
4ae899925d
4 changed files with 32 additions and 31 deletions
|
|
@ -126,7 +126,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
}
|
||||
|
||||
// generate invoice criteria
|
||||
public function generateInvoiceCriteria($jo, $promo_id, $invoice_items, &$error_array)
|
||||
public function generateInvoiceCriteria($jo, $discount, $invoice_items, &$error_array)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -135,7 +135,6 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
|||
$criteria->setServiceType($jo->getServiceType())
|
||||
->setCustomerVehicle($jo->getCustomerVehicle());
|
||||
|
||||
$discount = $promo_id;
|
||||
$ierror = $this->validateDiscount($criteria, $discount);
|
||||
|
||||
if (!$ierror && !empty($invoice_items))
|
||||
|
|
|
|||
|
|
@ -352,13 +352,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
// call service to generate job order and invoice
|
||||
$invoice_items = $req->request->get('invoice_items', []);
|
||||
$promo_id = $req->request->get('invoice_promo');
|
||||
$discount = $req->request->get('invoice_discount');
|
||||
$invoice_change = $req->request->get('invoice_change', 0);
|
||||
|
||||
// check if invoice changed
|
||||
if ($invoice_change)
|
||||
{
|
||||
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
|
||||
$this->ic->generateInvoiceCriteria($jo, $discount, $invoice_items, $error_array);
|
||||
}
|
||||
|
||||
// validate
|
||||
|
|
@ -524,11 +524,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// get discount and set to meta
|
||||
$discount = $req->request->get('invoice_promo');
|
||||
$discount = $req->request->get('invoice_discount');
|
||||
|
||||
// check if discount is greater than 50 or negative number
|
||||
if (($discount > 50) || ($discount < 0))
|
||||
$error_array['invoice_promo'] = 'Invalid discount specified';
|
||||
$error_array['invoice_discount'] = 'Invalid discount specified';
|
||||
|
||||
// get list of service charges
|
||||
|
||||
if (empty($error_array))
|
||||
{
|
||||
|
|
@ -581,13 +583,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
// call service to generate job order and invoice
|
||||
$invoice_items = $req->request->get('invoice_items', []);
|
||||
$promo_id = $req->request->get('invoice_promo');
|
||||
$discount = $req->request->get('invoice_discount');
|
||||
$invoice_change = $req->request->get('invoice_change', 0);
|
||||
|
||||
// check if invoice changed
|
||||
if ($invoice_change)
|
||||
{
|
||||
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
|
||||
$this->ic->generateInvoiceCriteria($jo, $discount, $invoice_items, $error_array);
|
||||
}
|
||||
|
||||
// validate
|
||||
|
|
@ -2499,11 +2501,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// get discount and set to meta
|
||||
$discount = $req->request->get('invoice_promo');
|
||||
$discount = $req->request->get('invoice_discount');
|
||||
|
||||
// check if discount is greater than 50 or negative number
|
||||
if (($discount > 50) || ($discount < 0))
|
||||
$error_array['invoice_promo'] = 'Invalid discount specified';
|
||||
$error_array['invoice_discount'] = 'Invalid discount specified';
|
||||
|
||||
if (empty($error_array))
|
||||
{
|
||||
|
|
@ -2552,13 +2554,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
// call service to generate job order and invoice
|
||||
$invoice_items = $req->request->get('invoice_items', []);
|
||||
$promo_id = $req->request->get('invoice_promo');
|
||||
$discount = $req->request->get('invoice_discount');
|
||||
$invoice_change = $req->request->get('invoice_change', 0);
|
||||
|
||||
// check if invoice changed
|
||||
if ($invoice_change)
|
||||
{
|
||||
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array);
|
||||
$this->ic->generateInvoiceCriteria($jo, $discount, $invoice_items, $error_array);
|
||||
}
|
||||
|
||||
// validate
|
||||
|
|
|
|||
|
|
@ -532,12 +532,12 @@
|
|||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<label>Discount Type</label>
|
||||
<label>Discount</label>
|
||||
{% if ftags.invoice_edit %}
|
||||
<input type="number" id="invoice-promo" name="invoice_promo" class="form-control m-input min = "0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}">
|
||||
<div class="form-control-feedback hide" data-field="invoice_promo"></div>
|
||||
<input type="number" id="invoice-discount" name="invoice_discount" class="form-control m-input min = "0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}">
|
||||
<div class="form-control-feedback hide" data-field="invoice_discount"></div>
|
||||
{% else %}
|
||||
<input type="number" id="invoice-promo" name="invoice_promo" class="form-control m-input min="0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}" disabled>
|
||||
<input type="number" id="invoice-discount" name="invoice_discount" class="form-control m-input min="0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}" disabled>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
|
|
@ -1356,7 +1356,7 @@ $(function() {
|
|||
});
|
||||
|
||||
// update invoice when promo is changed
|
||||
$("#invoice-promo").change(function() {
|
||||
$("#invoice-discount").change(function() {
|
||||
generateInvoice();
|
||||
});
|
||||
|
||||
|
|
@ -1367,7 +1367,7 @@ $(function() {
|
|||
|
||||
// reset the invoice table
|
||||
$("#btn-reset-invoice").click(function() {
|
||||
$("#invoice-promo").prop('selectedIndex', 0);
|
||||
$("#invoice-discount").prop('selectedIndex', 0);
|
||||
invoiceItems = [];
|
||||
generateInvoice();
|
||||
});
|
||||
|
|
@ -1378,7 +1378,7 @@ $(function() {
|
|||
});
|
||||
|
||||
function generateInvoice() {
|
||||
var promo = $("#invoice-promo").val();
|
||||
var discount = $("#invoice-discount").val();
|
||||
var table = $("#invoice-table tbody");
|
||||
var stype = $("#service_type").val();
|
||||
var cvid = $("#customer-vehicle").val();
|
||||
|
|
@ -1390,7 +1390,7 @@ $(function() {
|
|||
data: {
|
||||
'stype': stype,
|
||||
'items': invoiceItems,
|
||||
'promo': promo,
|
||||
'promo': discount,
|
||||
'cvid': cvid
|
||||
}
|
||||
}).done(function(response) {
|
||||
|
|
@ -1399,7 +1399,7 @@ $(function() {
|
|||
var invoice = response.invoice;
|
||||
|
||||
// populate totals
|
||||
$("#invoice-promo-discount").val(invoice.discount);
|
||||
$("#invoice-discount").val(invoice.discount);
|
||||
$("#invoice-price").val(invoice.price);
|
||||
$("#invoice-trade-in").val(invoice.trade_in);
|
||||
$("#invoice-vat").val(invoice.vat);
|
||||
|
|
|
|||
|
|
@ -393,12 +393,12 @@
|
|||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<label>Discount Type</label>
|
||||
<label>Discount</label>
|
||||
{% if ftags.invoice_edit %}
|
||||
<input type="number" id="invoice-promo" name="invoice_promo" class="form-control m-input min = "0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}">
|
||||
<div class="form-control-feedback hide" data-field="invoice_promo"></div>
|
||||
<input type="number" id="invoice-discount" name="invoice_discount" class="form-control m-input min = "0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}">
|
||||
<div class="form-control-feedback hide" data-field="invoice_discount"></div>
|
||||
{% else %}
|
||||
<input type="number" id="invoice-promo" name="invoice_promo" class="form-control m-input min="0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}" disabled>
|
||||
<input type="number" id="invoice-discount" name="invoice_discount" class="form-control m-input min="0" max="50" value="{{ obj.getInvoice ? obj.getInvoice.getDiscount }}" disabled>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
|
|
@ -936,8 +936,8 @@ var vdata = false;
|
|||
generateInvoice();
|
||||
});
|
||||
|
||||
// update invoice when promo is changed
|
||||
$("#invoice-promo").change(function() {
|
||||
// update invoice when discount is changed
|
||||
$("#invoice-discount").change(function() {
|
||||
generateInvoice();
|
||||
});
|
||||
|
||||
|
|
@ -948,7 +948,7 @@ var vdata = false;
|
|||
|
||||
// reset the invoice table
|
||||
$("#btn-reset-invoice").click(function() {
|
||||
$("#invoice-promo").prop('selectedIndex', 0);
|
||||
$("#invoice-discount").prop('selectedIndex', 0);
|
||||
invoiceItems = [];
|
||||
generateInvoice();
|
||||
});
|
||||
|
|
@ -959,7 +959,7 @@ var vdata = false;
|
|||
});
|
||||
|
||||
function generateInvoice() {
|
||||
var promo = $("#invoice-promo").val();
|
||||
var discount = $("#invoice-discount").val();
|
||||
var table = $("#invoice-table tbody");
|
||||
var stype = $("#service_type").val();
|
||||
var cvid = $("#customer-vehicle").val();
|
||||
|
|
@ -971,7 +971,7 @@ var vdata = false;
|
|||
data: {
|
||||
'stype': stype,
|
||||
'items': invoiceItems,
|
||||
'promo': promo,
|
||||
'promo': discount,
|
||||
'cvid': cvid
|
||||
}
|
||||
}).done(function(response) {
|
||||
|
|
@ -980,7 +980,7 @@ var vdata = false;
|
|||
var invoice = response.invoice;
|
||||
|
||||
// populate totals
|
||||
$("#invoice-promo-discount").val(invoice.discount);
|
||||
$("#invoice-discount").val(invoice.discount);
|
||||
$("#invoice-price").val(invoice.price);
|
||||
$("#invoice-trade-in").val(invoice.trade_in);
|
||||
$("#invoice-vat").val(invoice.vat);
|
||||
|
|
|
|||
Loading…
Reference in a new issue