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:
Kendrick Chan 2020-02-17 16:13:12 +08:00
commit 4ae899925d
4 changed files with 32 additions and 31 deletions

View file

@ -126,7 +126,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
} }
// generate invoice criteria // 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; $em = $this->em;
@ -135,7 +135,6 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
$criteria->setServiceType($jo->getServiceType()) $criteria->setServiceType($jo->getServiceType())
->setCustomerVehicle($jo->getCustomerVehicle()); ->setCustomerVehicle($jo->getCustomerVehicle());
$discount = $promo_id;
$ierror = $this->validateDiscount($criteria, $discount); $ierror = $this->validateDiscount($criteria, $discount);
if (!$ierror && !empty($invoice_items)) if (!$ierror && !empty($invoice_items))

View file

@ -352,13 +352,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
// call service to generate job order and invoice // call service to generate job order and invoice
$invoice_items = $req->request->get('invoice_items', []); $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); $invoice_change = $req->request->get('invoice_change', 0);
// check if invoice changed // check if invoice changed
if ($invoice_change) if ($invoice_change)
{ {
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $this->ic->generateInvoiceCriteria($jo, $discount, $invoice_items, $error_array);
} }
// validate // validate
@ -524,11 +524,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
} }
// get discount and set to meta // 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 // check if discount is greater than 50 or negative number
if (($discount > 50) || ($discount < 0)) 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)) if (empty($error_array))
{ {
@ -581,13 +583,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
// call service to generate job order and invoice // call service to generate job order and invoice
$invoice_items = $req->request->get('invoice_items', []); $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); $invoice_change = $req->request->get('invoice_change', 0);
// check if invoice changed // check if invoice changed
if ($invoice_change) if ($invoice_change)
{ {
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $this->ic->generateInvoiceCriteria($jo, $discount, $invoice_items, $error_array);
} }
// validate // validate
@ -2499,11 +2501,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
} }
// get discount and set to meta // 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 // check if discount is greater than 50 or negative number
if (($discount > 50) || ($discount < 0)) if (($discount > 50) || ($discount < 0))
$error_array['invoice_promo'] = 'Invalid discount specified'; $error_array['invoice_discount'] = 'Invalid discount specified';
if (empty($error_array)) if (empty($error_array))
{ {
@ -2552,13 +2554,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
// call service to generate job order and invoice // call service to generate job order and invoice
$invoice_items = $req->request->get('invoice_items', []); $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); $invoice_change = $req->request->get('invoice_change', 0);
// check if invoice changed // check if invoice changed
if ($invoice_change) if ($invoice_change)
{ {
$this->ic->generateInvoiceCriteria($jo, $promo_id, $invoice_items, $error_array); $this->ic->generateInvoiceCriteria($jo, $discount, $invoice_items, $error_array);
} }
// validate // validate

View file

@ -532,12 +532,12 @@
</div> </div>
<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>Discount Type</label> <label>Discount</label>
{% if ftags.invoice_edit %} {% 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 }}"> <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_promo"></div> <div class="form-control-feedback hide" data-field="invoice_discount"></div>
{% else %} {% 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 %} {% endif %}
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
@ -1356,7 +1356,7 @@ $(function() {
}); });
// update invoice when promo is changed // update invoice when promo is changed
$("#invoice-promo").change(function() { $("#invoice-discount").change(function() {
generateInvoice(); generateInvoice();
}); });
@ -1367,7 +1367,7 @@ $(function() {
// reset the invoice table // reset the invoice table
$("#btn-reset-invoice").click(function() { $("#btn-reset-invoice").click(function() {
$("#invoice-promo").prop('selectedIndex', 0); $("#invoice-discount").prop('selectedIndex', 0);
invoiceItems = []; invoiceItems = [];
generateInvoice(); generateInvoice();
}); });
@ -1378,7 +1378,7 @@ $(function() {
}); });
function generateInvoice() { function generateInvoice() {
var promo = $("#invoice-promo").val(); var discount = $("#invoice-discount").val();
var table = $("#invoice-table tbody"); var table = $("#invoice-table tbody");
var stype = $("#service_type").val(); var stype = $("#service_type").val();
var cvid = $("#customer-vehicle").val(); var cvid = $("#customer-vehicle").val();
@ -1390,7 +1390,7 @@ $(function() {
data: { data: {
'stype': stype, 'stype': stype,
'items': invoiceItems, 'items': invoiceItems,
'promo': promo, 'promo': discount,
'cvid': cvid 'cvid': cvid
} }
}).done(function(response) { }).done(function(response) {
@ -1399,7 +1399,7 @@ $(function() {
var invoice = response.invoice; var invoice = response.invoice;
// populate totals // populate totals
$("#invoice-promo-discount").val(invoice.discount); $("#invoice-discount").val(invoice.discount);
$("#invoice-price").val(invoice.price); $("#invoice-price").val(invoice.price);
$("#invoice-trade-in").val(invoice.trade_in); $("#invoice-trade-in").val(invoice.trade_in);
$("#invoice-vat").val(invoice.vat); $("#invoice-vat").val(invoice.vat);

View file

@ -393,12 +393,12 @@
</div> </div>
<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>Discount Type</label> <label>Discount</label>
{% if ftags.invoice_edit %} {% 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 }}"> <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_promo"></div> <div class="form-control-feedback hide" data-field="invoice_discount"></div>
{% else %} {% 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 %} {% endif %}
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
@ -936,8 +936,8 @@ var vdata = false;
generateInvoice(); generateInvoice();
}); });
// update invoice when promo is changed // update invoice when discount is changed
$("#invoice-promo").change(function() { $("#invoice-discount").change(function() {
generateInvoice(); generateInvoice();
}); });
@ -948,7 +948,7 @@ var vdata = false;
// reset the invoice table // reset the invoice table
$("#btn-reset-invoice").click(function() { $("#btn-reset-invoice").click(function() {
$("#invoice-promo").prop('selectedIndex', 0); $("#invoice-discount").prop('selectedIndex', 0);
invoiceItems = []; invoiceItems = [];
generateInvoice(); generateInvoice();
}); });
@ -959,7 +959,7 @@ var vdata = false;
}); });
function generateInvoice() { function generateInvoice() {
var promo = $("#invoice-promo").val(); var discount = $("#invoice-discount").val();
var table = $("#invoice-table tbody"); var table = $("#invoice-table tbody");
var stype = $("#service_type").val(); var stype = $("#service_type").val();
var cvid = $("#customer-vehicle").val(); var cvid = $("#customer-vehicle").val();
@ -971,7 +971,7 @@ var vdata = false;
data: { data: {
'stype': stype, 'stype': stype,
'items': invoiceItems, 'items': invoiceItems,
'promo': promo, 'promo': discount,
'cvid': cvid 'cvid': cvid
} }
}).done(function(response) { }).done(function(response) {
@ -980,7 +980,7 @@ var vdata = false;
var invoice = response.invoice; var invoice = response.invoice;
// populate totals // populate totals
$("#invoice-promo-discount").val(invoice.discount); $("#invoice-discount").val(invoice.discount);
$("#invoice-price").val(invoice.price); $("#invoice-price").val(invoice.price);
$("#invoice-trade-in").val(invoice.trade_in); $("#invoice-trade-in").val(invoice.trade_in);
$("#invoice-vat").val(invoice.vat); $("#invoice-vat").val(invoice.vat);