From 908a79a909748e1bc84639988d2c52f824d44bda Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 1 Feb 2018 00:47:52 +0800 Subject: [PATCH] Update job order form to include invoice changes and warranty class --- templates/job-order/form.html.twig | 92 ++++++++++++++++++------------ 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 84549d9c..64ffef07 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -159,6 +159,16 @@
+
+ + + +
@@ -252,21 +262,29 @@
-
- - +
+ +
-
- - +
+ +
-
- - +
+ +
-
- - +
+ + +
+
+ + +
+
+ +
@@ -276,23 +294,16 @@ Item Quantity - Price Level - Res Price
(w/ Tax) - Total Price Adj. - Final Amount - No Trade-in Item? - Battery Class - Discount Item - Percentage - Converted Rate
(in Decimal) - Discount Amount Warranty Class + Warranty + Date of Purchase + Warranty Until - + No items to display. @@ -828,7 +839,8 @@ $(function() { var unitPrice = 1000; $.each(response.data, function(index, battery) { - html += ''; + console.log(battery); + html += ''; }); field.html(html).prop('disabled', false); @@ -856,6 +868,8 @@ $(function() { var qty = $("#invoice-quantity"); var tbody = $("#invoice-table tbody"); var unitPrice = parseFloat(battery.find('option:selected').data('unit-price')); + var warrPrivate = parseInt(battery.find('option:selected').data('warr-private')); + var warrCommercial = parseInt(battery.find('option:selected').data('warr-commercial')); if (!bmfg.val() || !battery.val() || !qty.val()) { swal({ @@ -889,22 +903,24 @@ $(function() { 'subtotal': subtotal }); + var warrantyClasses = { + {% for key, class in warranty_classes %} + "{{ key }}": "{{ class }}", + {% endfor %} + }; + + var warrantyClass = $("#warranty-class").val(); + var warrantyLength = warrantyClass == warrantyClasses["private"] ? warrPrivate : warrCommercial; + // build row html // TODO: Fill with actual data for the rest of the columns var html = '' + '' + battery.find('option:selected').text() + '' + '' + qty.val() + '' + - 'Base Price' + // TODO: static for now - '' + (Math.round(unitPrice * 100) / 100).toFixed(2) + '' + // TODO: not sure if this is correct since it says w/ tax - '0.00' + // TODO: static for now - '' + (Math.round(subtotal * 100) / 100).toFixed(2) + '' + // TODO: I assumed this is unit price * qty - 'Yes' + // TODO: static for now - 'Regular' + - '' + - '' + - '' + - '' + - '' + + '' + warrantyClasses[warrantyClass] + '' + + '' + warrantyLength + ' month' + (warrantyLength > 1 ? 's' : '') + '' + + '' + // TODO: Date of Purchase, blank for now + '' + // TODO: Warranty until, blank for now '' + ''; @@ -918,10 +934,10 @@ $(function() { }); function updateInvoiceFigures() { - var amountField = $("#invoice-amount"); - var taxField = $("#invoice-tax"); + var amountField = $("#invoice-price"); + var taxField = $("#invoice-vat"); var discountField = $("#invoice-discount"); - var finalAmountField = $("#invoice-final-amount"); + var finalAmountField = $("#invoice-total-amount"); var finalAmount = invoiceTotal + invoiceTax - invoiceDiscount; amountField.val(parseFloat(Math.round(invoiceTotal * 100) / 100).toFixed(2));