From 3ae43d015aa469126cd1cfe43605fb7fbc78823a Mon Sep 17 00:00:00 2001 From: abhijith Date: Wed, 25 Oct 2017 15:35:24 +0530 Subject: [PATCH 01/14] Added fields for cess in Invoice Product Table --- gkwebapp/templates/addinvoice.jinja2 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gkwebapp/templates/addinvoice.jinja2 b/gkwebapp/templates/addinvoice.jinja2 index 5420cdb3..54020520 100644 --- a/gkwebapp/templates/addinvoice.jinja2 +++ b/gkwebapp/templates/addinvoice.jinja2 @@ -398,8 +398,9 @@ {% trans %}Discount Amount{% endtrans %} {% trans %}Taxable Value {% endtrans %} {% trans %}CGST{% endtrans %} - {% trans %}SGST{% endtrans %} + {% trans %}SGST/UTGST{% endtrans %} {% trans %}IGST{% endtrans %} + {% trans %}CESS{% endtrans %} @@ -409,6 +410,8 @@ {% trans %}Amount{% endtrans %} {% trans %}Rate{% endtrans %} % {% trans %}Amount{% endtrans %} + {% trans %}Rate{% endtrans %} % + {% trans %}Amount{% endtrans %} @@ -460,8 +463,12 @@ - - + + + + + +
@@ -475,6 +482,7 @@ +
-- GitLab From d69ae219ebc2e925cf064e1627c9d7a56f35758a Mon Sep 17 00:00:00 2001 From: abhijith Date: Wed, 25 Oct 2017 17:19:50 +0530 Subject: [PATCH 02/14] Adjusted javascript in calculate tax functon for gst and footer of invoice product table to acommodate cess --- gkwebapp/static/js/addinvoice.js | 10 ++++++++-- gkwebapp/templates/addinvoice.jinja2 | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gkwebapp/static/js/addinvoice.js b/gkwebapp/static/js/addinvoice.js index cecdb555..cc30839f 100644 --- a/gkwebapp/static/js/addinvoice.js +++ b/gkwebapp/static/js/addinvoice.js @@ -63,6 +63,7 @@ $(document).ready(function() { var rowdiscount = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(5) input').val()).toFixed(2); var taxdetails = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails"); var taxamount = 0.00; + var cessamount = 0.00; var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. if ($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').is(":disabled") && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(3) input').is(":disabled")) { rowtaxableamount = rowprice - rowdiscount; @@ -73,6 +74,7 @@ $(document).ready(function() { var totalcgst = 0.00; var totalsgst = 0.00; var totaligst = 0.00; + var totalcess = 0.00; var totaldiscount = 0.00; var totaltaxable = 0.00; $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); //Taxable amount is displayed. @@ -80,13 +82,17 @@ $(document).ready(function() { //Checks if TAX is IGST or SGST + CGST. Amount of tax to be applied is then displayed accordingly along with calculated total amount. if (taxdetails["taxname"] == "IGST") { $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val(parseFloat(taxamount).toFixed(2)); - rowtotal = rowtaxableamount + taxamount; + let cessrate = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val()).toFixed(2); + cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. + rowtotal = rowtaxableamount + taxamount + cessamount; $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); } else if (taxdetails["taxname"] == "SGST") { $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(taxamount).toFixed(2)); $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(taxamount).toFixed(2)); - rowtotal = rowtaxableamount + (2*taxamount); + let cessrate = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val()).toFixed(2); + cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. + rowtotal = rowtaxableamount + (2*taxamount) + cessamount; $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); } //Total of discount, taxable amount, tax amounts and total are found out diff --git a/gkwebapp/templates/addinvoice.jinja2 b/gkwebapp/templates/addinvoice.jinja2 index 54020520..d4746a26 100644 --- a/gkwebapp/templates/addinvoice.jinja2 +++ b/gkwebapp/templates/addinvoice.jinja2 @@ -482,7 +482,7 @@ - + -- GitLab From 15ac5771ef44f6df0a59c296a42be3d2602a47e7 Mon Sep 17 00:00:00 2001 From: abhijith Date: Fri, 27 Oct 2017 11:01:53 +0530 Subject: [PATCH 03/14] Conditions for cess added in invoice --- gkwebapp/views/invoice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gkwebapp/views/invoice.py b/gkwebapp/views/invoice.py index 61906974..81b67a08 100644 --- a/gkwebapp/views/invoice.py +++ b/gkwebapp/views/invoice.py @@ -137,6 +137,12 @@ def getappliedtax(request): try: taxdetails = requests.get("http://127.0.0.1:6543/products?type=pt&productcode=%d&source=%s&destination=%s&taxflag=%d"%(int(request.params["productcode"]),request.params["source"],request.params["destination"],int(request.params["taxflag"])), headers=header) data = taxdetails.json()["gkresult"] + if data.has_key('VAT'): + return{"gkstatus":taxdetails.json()["gkstatus"],"taxname":"VAT","taxrate":data["VAT"]} + if data.has_key('SGST'): + if data.has_key('CESS'): + return{"gkstatus":taxdetails.json()["gkstatus"],"tax":data} + return{"gkstatus":taxdetails.json()["gkstatus"],"taxname":"SGST","taxrate":data["SGST"]} return{"gkstatus":taxdetails.json()["gkstatus"],"taxname":data["taxname"],"taxrate":data["taxrate"]} except: return {"gkstatus":1} -- GitLab From 4873f8380fa49bc0daf811f380ac269c8b94527d Mon Sep 17 00:00:00 2001 From: abhijith Date: Fri, 27 Oct 2017 13:57:09 +0530 Subject: [PATCH 04/14] Added new classes to tax fields so that they can be set blank on change of product --- gkwebapp/templates/addinvoice.jinja2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gkwebapp/templates/addinvoice.jinja2 b/gkwebapp/templates/addinvoice.jinja2 index d4746a26..59038dcb 100644 --- a/gkwebapp/templates/addinvoice.jinja2 +++ b/gkwebapp/templates/addinvoice.jinja2 @@ -453,19 +453,19 @@ - - + + - - + + - - + + - - + + -- GitLab From 37d3a934f4172a6b054dd694c2e12c835533f171 Mon Sep 17 00:00:00 2001 From: abhijith Date: Fri, 27 Oct 2017 14:51:11 +0530 Subject: [PATCH 05/14] Fixed getapplied tax --- gkwebapp/static/js/addinvoice.js | 40 ++++++++++++++++++++------------ gkwebapp/views/invoice.py | 8 +------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gkwebapp/static/js/addinvoice.js b/gkwebapp/static/js/addinvoice.js index cc30839f..0dedd77c 100644 --- a/gkwebapp/static/js/addinvoice.js +++ b/gkwebapp/static/js/addinvoice.js @@ -690,7 +690,7 @@ $(document).ready(function() { }) .done(function(resp) { if (resp["gkstatus"] == 0) { - $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['taxrate']).toFixed(2)); + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['tax']['VAT']).toFixed(2)); } else if (resp["gkstatus"] == 1) { $("#notax-alert").alert(); @@ -724,7 +724,7 @@ $(document).ready(function() { }) .fail(function() { - console.log("error"); + console.log("error"); }) .always(function() { console.log("complete"); @@ -1307,19 +1307,29 @@ $(document).ready(function() { } }) .done(function(resp) { - if (resp["gkstatus"] == 0) { - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails", {taxname: resp["taxname"], taxrate:resp["taxrate"]}); - if(resp['taxname']=='SGST'){ - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(resp['taxrate']).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(resp['taxrate']).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(0).toFixed(2)); - } - else{ - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(resp['taxrate']).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(0).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(0).toFixed(2)); - } - } + if (resp["gkstatus"] == 0) { + $(".trate", ".tname").val(parseFloat(0).toFixed(2)); //Sets all tax fields to zero on change of product + //Loads SGST rate. + if('SGST' in resp['tax']){ + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(resp['tax']['SGST']).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(resp['tax']['SGST']).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(0).toFixed(2)); + //Loads CESS rate if avaliable. + if ('CESS' in resp['tax']) { + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(13) input').val(parseFloat(resp['tax']['CESS']).toFixed(2)); + } + } + //Loads IGST rate. + else if('IGST' in resp['tax']){ + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(resp['tax']['IGST']).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(0).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(0).toFixed(2)); + //Loads CESS rate. + if ('CESS' in resp['tax']) { + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(13) input').val(parseFloat(resp['tax']['CESS']).toFixed(2)); + } + } + } else if (resp["gkstatus"] == 1) { $("#notax-alert").alert(); $("#notax-alert").fadeTo(2250, 500).slideUp(500, function() { diff --git a/gkwebapp/views/invoice.py b/gkwebapp/views/invoice.py index 81b67a08..daedeae2 100644 --- a/gkwebapp/views/invoice.py +++ b/gkwebapp/views/invoice.py @@ -137,13 +137,7 @@ def getappliedtax(request): try: taxdetails = requests.get("http://127.0.0.1:6543/products?type=pt&productcode=%d&source=%s&destination=%s&taxflag=%d"%(int(request.params["productcode"]),request.params["source"],request.params["destination"],int(request.params["taxflag"])), headers=header) data = taxdetails.json()["gkresult"] - if data.has_key('VAT'): - return{"gkstatus":taxdetails.json()["gkstatus"],"taxname":"VAT","taxrate":data["VAT"]} - if data.has_key('SGST'): - if data.has_key('CESS'): - return{"gkstatus":taxdetails.json()["gkstatus"],"tax":data} - return{"gkstatus":taxdetails.json()["gkstatus"],"taxname":"SGST","taxrate":data["SGST"]} - return{"gkstatus":taxdetails.json()["gkstatus"],"taxname":data["taxname"],"taxrate":data["taxrate"]} + return{"gkstatus":taxdetails.json()["gkstatus"],"tax":data} except: return {"gkstatus":1} -- GitLab From 970c9782c190621e467d2131295e87d355726b58 Mon Sep 17 00:00:00 2001 From: abhijith Date: Fri, 27 Oct 2017 17:02:16 +0530 Subject: [PATCH 06/14] Fixed Calculate Tax of GST in Invoice Product Table --- gkwebapp/static/js/addinvoice.js | 46 ++++++++++++++-------------- gkwebapp/templates/addinvoice.jinja2 | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gkwebapp/static/js/addinvoice.js b/gkwebapp/static/js/addinvoice.js index 0dedd77c..a4dd77cb 100644 --- a/gkwebapp/static/js/addinvoice.js +++ b/gkwebapp/static/js/addinvoice.js @@ -22,7 +22,7 @@ "Krishnakant Mane" "Ishan Masdekar " "Navin Karkera" - "Prajkta Patkar" + "Prajkta Patkar" "Vaibhav Kurhe" "Abhijith Balan" "Rohini Baraskar" @@ -61,9 +61,6 @@ $(document).ready(function() { var rowqty = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').val()).toFixed(2); var rowprice = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(4) input').val()).toFixed(2); var rowdiscount = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(5) input').val()).toFixed(2); - var taxdetails = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails"); - var taxamount = 0.00; - var cessamount = 0.00; var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. if ($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').is(":disabled") && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(3) input').is(":disabled")) { rowtaxableamount = rowprice - rowdiscount; @@ -78,30 +75,26 @@ $(document).ready(function() { var totaldiscount = 0.00; var totaltaxable = 0.00; $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); //Taxable amount is displayed. - taxamount = (rowtaxableamount * taxdetails["taxrate"])/100; //Amount of tax to be applied is found out. - //Checks if TAX is IGST or SGST + CGST. Amount of tax to be applied is then displayed accordingly along with calculated total amount. - if (taxdetails["taxname"] == "IGST") { - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val(parseFloat(taxamount).toFixed(2)); - let cessrate = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val()).toFixed(2); - cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. - rowtotal = rowtaxableamount + taxamount + cessamount; - $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); - } - else if (taxdetails["taxname"] == "SGST") { - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(taxamount).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(taxamount).toFixed(2)); - let cessrate = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val()).toFixed(2); - cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. - rowtotal = rowtaxableamount + (2*taxamount) + cessamount; - $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); - } - //Total of discount, taxable amount, tax amounts and total are found out + let sgstrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(); + let sgstamount = (rowtaxableamount * sgstrate)/100; //Amount of SGST to be applied is found out. + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(sgstamount).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(sgstamount).toFixed(2)); + let igstrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(); + let igstamount = (rowtaxableamount * igstrate)/100; //Amount of IGST to be applied is found out. + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val(parseFloat(igstamount).toFixed(2)); + let cessrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(13) input').val(); + let cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(14) input').val(parseFloat(cessamount).toFixed(2)); + rowtotal = rowtaxableamount + 2*sgstamount + igstamount + cessamount; //Sum of Taxable Amount and Tax Amount is found out. + $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); + //Total of discount, taxable amount, tax amounts and total are found out for(var i = 0; i < $("#invoice_product_table_gst tbody tr").length; i++) { totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(5) input').val()); totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(6) input').val()); totalcgst = totalcgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(8) input').val()); totalsgst = totalsgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(10) input').val()); totaligst = totaligst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(12) input').val()); + totalcess = totalcess + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(14) input').val()); totalamount = totalamount + parseFloat($('#invoice_product_table_total tbody tr:eq(' + i + ') td:eq(0) input').val()); } //Total of various columns are displayed on the footer. @@ -110,6 +103,7 @@ $(document).ready(function() { $('#totalcgst_product_gst').text(parseFloat(totalcgst).toFixed(2)); $('#totalsgst_product_gst').text(parseFloat(totalsgst).toFixed(2)); $('#totaligst_product_gst').text(parseFloat(totaligst).toFixed(2)); + $('#totalcess_product_gst').text(parseFloat(totalcess).toFixed(2)); $('#total_product_gst').text(parseFloat(totalamount).toFixed(2)); $("#totalinvoicevalue").text(parseFloat(totalamount).toFixed(2)); } @@ -658,6 +652,7 @@ $(document).ready(function() { $(document).off('change', '.product_name_vat').on('change', '.product_name_vat', function(event) { event.preventDefault(); /* Act on the event */ + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(0).toFixed(2)); var productcode = $(this).find('option:selected').val(); var curindex = $(this).closest('tbody tr').index(); var destinationstate = ""; @@ -690,7 +685,12 @@ $(document).ready(function() { }) .done(function(resp) { if (resp["gkstatus"] == 0) { - $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['tax']['VAT']).toFixed(2)); + if ('VAT' in resp['tax']) { + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['tax']['VAT']).toFixed(2)); + } + else if ('CVAT' in resp['tax']) { + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['tax']['CVAT']).toFixed(2)); + } } else if (resp["gkstatus"] == 1) { $("#notax-alert").alert(); diff --git a/gkwebapp/templates/addinvoice.jinja2 b/gkwebapp/templates/addinvoice.jinja2 index 59038dcb..57ff2c54 100644 --- a/gkwebapp/templates/addinvoice.jinja2 +++ b/gkwebapp/templates/addinvoice.jinja2 @@ -482,7 +482,7 @@ - + -- GitLab From 8dd5b6bb3554c692f3504b76ba747c61c4582ce9 Mon Sep 17 00:00:00 2001 From: abhijith Date: Fri, 27 Oct 2017 19:22:22 +0530 Subject: [PATCH 07/14] CESS gets saved and viewed properly in Invoice --- gkwebapp/static/js/addinvoice.js | 154 ++++++++++---------- gkwebapp/templates/viewsingleinvoice.jinja2 | 6 + gkwebapp/views/invoice.py | 2 +- 3 files changed, 85 insertions(+), 77 deletions(-) diff --git a/gkwebapp/static/js/addinvoice.js b/gkwebapp/static/js/addinvoice.js index a4dd77cb..b4396b7b 100644 --- a/gkwebapp/static/js/addinvoice.js +++ b/gkwebapp/static/js/addinvoice.js @@ -2042,16 +2042,17 @@ if (event.which == 13) { $('#consigneename').focus(); return false; } - var tax = {}; + var tax = {}; + var cess = {}; var contents = {}; - var freeqty = {}; - var stock = {}; + var freeqty = {}; + var stock = {}; var items = {}; var discount = {}; var consignee = {}; var bankdetails = {}; var invoicetotal = 0.00; - var productcodes = []; + var productcodes = []; var productqtys = []; var quantity; var ppu; @@ -2154,7 +2155,7 @@ if (event.which == 13) { ppu = $.trim($("#invoice_product_table_vat tbody tr:eq(" + i + ") td:eq(3) input").val()); obj[ppu] = $.trim($("#invoice_product_table_vat tbody tr:eq(" + i + ") td:eq(1) input").val()); tax[productcode] = $.trim($("#invoice_product_table_vat tbody tr:eq(" + i + ") td:eq(6) input").val()); - contents[productcode] = obj; + contents[productcode] = obj; items[productcode] = $.trim($("#invoice_product_table_vat tbody tr:eq(" + i + ") td:eq(1) input").val()); freeqty[productcode] = $.trim($("#invoice_product_table_vat tbody tr:eq(" + i + ") td:eq(2) input").val()); discount[productcode] = $.trim($("#invoice_product_table_vat tbody tr:eq(" + i + ") td:eq(4) input").val()); @@ -2167,83 +2168,84 @@ if (event.which == 13) { else if ($("#taxapplicable").val() == 7) { for (let i = 0; i < $("#invoice_product_table_gst tbody tr").length; i++) { if ($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(0) select option:selected').val() == "") { - $("#product-blank-alert").alert(); - $("#product-blank-alert").fadeTo(2250, 500).slideUp(500, function() { - $("#product-blank-alert").hide(); - }); - $('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(0) select').focus(); - return false; - } - quantity = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").val()); - if (parseFloat(quantity) === 0.00 && $('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(0) select option:selected').attr("gsflag") == '7') { - $("#quantity-blank-alert").alert(); - $("#quantity-blank-alert").fadeTo(2250, 500).slideUp(500, function() { - $("#quantity-blank-alert").hide(); - }); - $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").focus().select(); - return false; - } - if ($("#invoice_deliverynote option:selected").val() != '') { - if ((parseFloat(parseFloat(quantity).toFixed(2)) > parseFloat(parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(1) input").attr("data")).toFixed(2))) && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select option:selected').attr("gsflag") == '7') { - $("#quantity-exceed-alert").alert(); - $("#quantity-exceed-alert").fadeTo(2250, 500).slideUp(500, function() { - $("#quantity-exceed-alert").hide(); - }); - return false; - } - } + $("#product-blank-alert").alert(); + $("#product-blank-alert").fadeTo(2250, 500).slideUp(500, function() { + $("#product-blank-alert").hide(); + }); + $('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(0) select').focus(); + return false; + } + quantity = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").val()); + if (parseFloat(quantity) === 0.00 && $('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(0) select option:selected').attr("gsflag") == '7') { + $("#quantity-blank-alert").alert(); + $("#quantity-blank-alert").fadeTo(2250, 500).slideUp(500, function() { + $("#quantity-blank-alert").hide(); + }); + $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").focus().select(); + return false; + } + if ($("#invoice_deliverynote option:selected").val() != '') { + if ((parseFloat(parseFloat(quantity).toFixed(2)) > parseFloat(parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(1) input").attr("data")).toFixed(2))) && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select option:selected').attr("gsflag") == '7') { + $("#quantity-exceed-alert").alert(); + $("#quantity-exceed-alert").fadeTo(2250, 500).slideUp(500, function() { + $("#quantity-exceed-alert").hide(); + }); + return false; + } + } calculategstaxamt(i); - productqtys.push(parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val())); + productqtys.push(parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val())); let obj = {}; - productcode = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(0) select option:selected").val(); - ppu = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(4) input").val(); - obj[ppu] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val(); - contents[productcode] = obj; - tax[productcode] = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(7) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(9) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(11) input").val()); - items[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val(); - freeqty[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").val(); - discount[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(5) input").val(); - } + productcode = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(0) select option:selected").val(); + ppu = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(4) input").val(); + obj[ppu] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val(); + contents[productcode] = obj; + tax[productcode] = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(7) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(9) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(11) input").val()); + cess[productcode] = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(13) input").val()); + items[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val(); + freeqty[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").val(); + discount[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(5) input").val(); + } invoicetotal = $.trim($('#total_product_gst').html()); } - - stock["items"] = items; - - if ($("#status").val() == '9') { - stock["inout"] = 9; - issuername = ""; - designation = ""; - } else { - stock["inout"] = 15; - issuername = $("#invoice_issuer_name").val(); - designation = $("#invoice_issuer_designation").val(); - if (issuername == "") { - $("#invoice_issuer_name").focus(); - $("#issuer-blank-alert").alert(); - $("#issuer-blank-alert").fadeTo(2250, 500).slideUp(500, function() { - $("#issuer-blank-alert").hide(); - }); - return false; + stock["items"] = items; + if ($("#status").val() == '9') { + stock["inout"] = 9; + issuername = ""; + designation = ""; } - } - var form_data = new FormData(); - form_data.append("dcid", $("#invoice_deliverynote option:selected").val()); - form_data.append("custid", $("#invoice_customer option:selected").val()); - form_data.append("invoiceno", $("#invoice_challanno").val()); + else { + stock["inout"] = 15; + issuername = $("#invoice_issuer_name").val(); + designation = $("#invoice_issuer_designation").val(); + if (issuername == "") { + $("#invoice_issuer_name").focus(); + $("#issuer-blank-alert").alert(); + $("#issuer-blank-alert").fadeTo(2250, 500).slideUp(500, function() { + $("#issuer-blank-alert").hide(); + }); + return false; + } + } + var form_data = new FormData(); + form_data.append("dcid", $("#invoice_deliverynote option:selected").val()); + form_data.append("custid", $("#invoice_customer option:selected").val()); + form_data.append("invoiceno", $("#invoice_challanno").val()); form_data.append("invoicedate", $.trim($("#invoice_year").val() + '-' + $("#invoice_month").val() + '-' + $("#invoice_date").val())); - form_data.append("contents", JSON.stringify(contents)); - form_data.append("tax", JSON.stringify(tax)); - form_data.append("stock", JSON.stringify(stock)); - form_data.append("issuername", issuername); - form_data.append("designation", designation); - form_data.append("invtotal", invoicetotal); - if ($("#status").val() == 9) { - form_data.append("taxstate", $("#invoicestate option:selected").val()); - form_data.append("sourcestate", $("#invoice_customerstate option:selected").val()); - } - else if ($("#status").val() == 15) { - form_data.append("taxstate", $("#invoice_customerstate option:selected").val()); - form_data.append("sourcestate", $("#invoicestate option:selected").val()); + form_data.append("contents", JSON.stringify(contents)); + form_data.append("tax", JSON.stringify(tax)); + form_data.append("cess", JSON.stringify(cess)); + form_data.append("stock", JSON.stringify(stock)); + form_data.append("issuername", issuername); + form_data.append("designation", designation); + form_data.append("invtotal", invoicetotal); + if ($("#status").val() == 9) { + form_data.append("taxstate", $("#invoicestate option:selected").val()); + form_data.append("sourcestate", $("#invoice_customerstate option:selected").val()); + } + else if ($("#status").val() == 15) { + form_data.append("taxstate", $("#invoice_customerstate option:selected").val()); + form_data.append("sourcestate", $("#invoicestate option:selected").val()); } form_data.append("freeqty", JSON.stringify(freeqty)); form_data.append("discount", JSON.stringify(discount)); diff --git a/gkwebapp/templates/viewsingleinvoice.jinja2 b/gkwebapp/templates/viewsingleinvoice.jinja2 index 47d85f56..c9ed7292 100644 --- a/gkwebapp/templates/viewsingleinvoice.jinja2 +++ b/gkwebapp/templates/viewsingleinvoice.jinja2 @@ -244,6 +244,7 @@ {% if gkresult["taxname"]=='SGST' %}{% trans %}CGST{% endtrans %}{% endif %} {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST{% endtrans %}{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}IGST{% endtrans %}{% endif %} + {% trans %}CESS{% endtrans %} @@ -253,6 +254,8 @@ {% if gkresult["taxname"]=='SGST' %}{% trans %}Amount{% endtrans %}{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}Rate{% endtrans %} %{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}Amount{% endtrans %}{% endif %} + {% trans %}Rate{% endtrans %} % + {% trans %}Amount{% endtrans %} @@ -293,6 +296,8 @@ {% if gkresult["invcontents"][product]["taxname"]=='IGST' %}{{ gkresult["invcontents"][product]["taxrate"] }}{% endif %} {% if gkresult["invcontents"][product]["taxname"]=='IGST' %}{{ gkresult["invcontents"][product]["taxamount"] }}{% endif %} + {{ gkresult["invcontents"][product]["cessrate"] }} + {{ gkresult["invcontents"][product]["cess"] }} {% endfor %} @@ -308,6 +313,7 @@ {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} {% if gkresult["taxname"]=='IGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} + {{ gkresult["totalcessamt"] }} diff --git a/gkwebapp/views/invoice.py b/gkwebapp/views/invoice.py index daedeae2..06fd84be 100644 --- a/gkwebapp/views/invoice.py +++ b/gkwebapp/views/invoice.py @@ -81,7 +81,7 @@ def saveinvoice(request): header={"gktoken":request.headers["gktoken"]} invoicedata = {"invoiceno":request.params["invoiceno"],"taxstate":request.params["taxstate"],"invoicedate":request.params["invoicedate"], - "tax":json.loads(request.params["tax"]),"custid":request.params["custid"],"invoicetotal":request.params["invtotal"], "contents":json.loads(request.params["contents"]),"issuername":request.params["issuername"],"designation":request.params["designation"],"freeqty":json.loads(request.params["freeqty"]), "discount":json.loads(request.params["discount"]), "consignee":json.loads(request.params["consignee"]),"bankdetails":json.loads(request.params["bankdetails"]),"taxflag":request.params["taxflag"],"sourcestate":request.params["sourcestate"],"transportationmode":request.params["transportationmode"], "reversecharge":request.params["reversecharge"], "vehicleno":request.params["vehicleno"]} + "tax":json.loads(request.params["tax"]), "cess":json.loads(request.params["cess"]),"custid":request.params["custid"],"invoicetotal":request.params["invtotal"], "contents":json.loads(request.params["contents"]),"issuername":request.params["issuername"],"designation":request.params["designation"],"freeqty":json.loads(request.params["freeqty"]), "discount":json.loads(request.params["discount"]), "consignee":json.loads(request.params["consignee"]),"bankdetails":json.loads(request.params["bankdetails"]),"taxflag":request.params["taxflag"],"sourcestate":request.params["sourcestate"],"transportationmode":request.params["transportationmode"], "reversecharge":request.params["reversecharge"], "vehicleno":request.params["vehicleno"]} if request.params["dateofsupply"] != "": invoicedata["dateofsupply"] = request.params["dateofsupply"] -- GitLab From 744eb27beb4d860bf18edaa9019d4b32032fba71 Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 10:53:02 +0530 Subject: [PATCH 08/14] Invoice with CESS can now be printed --- gkwebapp/templates/printinvoice.jinja2 | 10 ++++++++-- gkwebapp/templates/viewsingleinvoice.jinja2 | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gkwebapp/templates/printinvoice.jinja2 b/gkwebapp/templates/printinvoice.jinja2 index e418ac0b..f1eb9eb4 100644 --- a/gkwebapp/templates/printinvoice.jinja2 +++ b/gkwebapp/templates/printinvoice.jinja2 @@ -327,8 +327,9 @@ {% trans %}Discount Amount{% endtrans %} {% trans %}Taxable Value {% endtrans %} {% if gkresult["taxname"]=='SGST' %}{% trans %}CGST{% endtrans %}{% endif %} - {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST{% endtrans %}{% endif %} + {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST/UTGST{% endtrans %}{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}IGST{% endtrans %}{% endif %} + {% trans %}CESS{% endtrans %} Total @@ -339,6 +340,8 @@ {% if gkresult["taxname"]=='SGST' %}{% trans %}Amount{% endtrans %}{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}Rate{% endtrans %} %{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}Amount{% endtrans %}{% endif %} + {% trans %}Rate{% endtrans %} % + {% trans %}Amount{% endtrans %} @@ -375,7 +378,9 @@ {% if gkresult["invcontents"][product]["taxname"]=='IGST' %}{{ gkresult["invcontents"][product]["taxrate"] }}{% endif %} {% if gkresult["invcontents"][product]["taxname"]=='IGST' %}{{ gkresult["invcontents"][product]["taxamount"] }}{% endif %} - {{ gkresult["invcontents"][product]["totalAmount"] }} + {{ gkresult["invcontents"][product]["cessrate"] }} + {{ gkresult["invcontents"][product]["cess"] }} + {{ gkresult["invcontents"][product]["totalAmount"] }} {% endfor %} @@ -387,6 +392,7 @@ {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} {% if gkresult["taxname"]=='IGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} + {{ gkresult["totalcessamt"] }} {{ gkresult["invoicetotal"] }} diff --git a/gkwebapp/templates/viewsingleinvoice.jinja2 b/gkwebapp/templates/viewsingleinvoice.jinja2 index c9ed7292..d539158b 100644 --- a/gkwebapp/templates/viewsingleinvoice.jinja2 +++ b/gkwebapp/templates/viewsingleinvoice.jinja2 @@ -242,7 +242,7 @@ {% trans %}Discount Amount{% endtrans %} {% trans %}Taxable Value {% endtrans %} {% if gkresult["taxname"]=='SGST' %}{% trans %}CGST{% endtrans %}{% endif %} - {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST{% endtrans %}{% endif %} + {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST/UTGST{% endtrans %}{% endif %} {% if gkresult["taxname"]=='IGST' %}{% trans %}IGST{% endtrans %}{% endif %} {% trans %}CESS{% endtrans %} -- GitLab From 3d0481222c87ccffbf06efa902c5ce74d2a7c835 Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 11:34:30 +0530 Subject: [PATCH 09/14] Added columns for CESS in Create Cashmemo. Also right aligned figures in Add Invoice footer. --- gkwebapp/templates/addcashmemo.jinja2 | 32 ++++++++++++++++----------- gkwebapp/templates/addinvoice.jinja2 | 16 +++++++------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/gkwebapp/templates/addcashmemo.jinja2 b/gkwebapp/templates/addcashmemo.jinja2 index f70c3ee1..03db4e65 100644 --- a/gkwebapp/templates/addcashmemo.jinja2 +++ b/gkwebapp/templates/addcashmemo.jinja2 @@ -260,8 +260,8 @@ {% trans %}Discount Amount{% endtrans %} {% trans %}Taxable Value {% endtrans %} {% trans %}CGST{% endtrans %} - {% trans %}SGST{% endtrans %} - + {% trans %}SGST/UTGST{% endtrans %} + {% trans %}CESS{% endtrans %} @@ -269,8 +269,9 @@ {%trans%}Amount{%endtrans%} {%trans%}Rate{%endtrans%} % {%trans%}Amount{%endtrans%} - - + {% trans %}Rate{% endtrans %} % + {% trans %}Amount{% endtrans %} + @@ -316,9 +317,12 @@ - - - + + + + + +
@@ -326,10 +330,12 @@ Total - - - - + + + + + +
@@ -349,8 +355,8 @@ - - + + diff --git a/gkwebapp/templates/addinvoice.jinja2 b/gkwebapp/templates/addinvoice.jinja2 index 57ff2c54..33a8d139 100644 --- a/gkwebapp/templates/addinvoice.jinja2 +++ b/gkwebapp/templates/addinvoice.jinja2 @@ -476,13 +476,13 @@ Total - - - + + + - - - + + + @@ -503,8 +503,8 @@ - - + + -- GitLab From 204556b23c80d6e7936b7a23bedbd8b09e698af4 Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 12:09:40 +0530 Subject: [PATCH 10/14] Made Calculate tax functions in Cash Memo more readable --- gkwebapp/static/js/addcashmemo.js | 157 +++++++++++++++--------------- 1 file changed, 80 insertions(+), 77 deletions(-) diff --git a/gkwebapp/static/js/addcashmemo.js b/gkwebapp/static/js/addcashmemo.js index 47547a97..c7d74be5 100644 --- a/gkwebapp/static/js/addcashmemo.js +++ b/gkwebapp/static/js/addcashmemo.js @@ -45,85 +45,88 @@ $(document).ready(function() { var totaltablehtml = $("#invoice_product_table_total tbody tr:first").html(); //HTML for table displaying totals in GST Product Table. var vathtml = $('#invoice_product_table_vat tbody tr:first').html(); //HTML for VAT Product Table row. -//Function to calculate gst tax amount - function calculategstaxamt(curindex) { -//Initialising variables to zero and getting values from various input fileds. -var rowqty = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').val()).toFixed(2); -var rowprice = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(4) input').val()).toFixed(2); -var rowdiscount = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(5) input').val()).toFixed(2); -var taxdetails = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails"); -var taxamount = 0.00; -var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. -if ($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').is(":disabled") && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(3) input').is(":disabled")) { - rowtaxableamount = rowprice - rowdiscount; -} + //Function to calculate gst tax amount + function calculategstaxamt(curindex) { + //Initialising variables to zero and getting values from various input fileds. + var rowqty = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').val()).toFixed(2); + var rowprice = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(4) input').val()).toFixed(2); + var rowdiscount = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(5) input').val()).toFixed(2); + var taxdetails = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails"); + var taxamount = 0.00; + var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. + if ($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').is(":disabled") && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(3) input').is(":disabled")) { + rowtaxableamount = rowprice - rowdiscount; + } -//Initialising variables for calculating total of Discount, Taxable Amount, Tax Amounts, and Total Amounts. -var rowtotal = 0.00; -var totalamount = 0.00; -var totalcgst = 0.00; -var totalsgst = 0.00; -var totaldiscount = 0.00; -var totaltaxable = 0.00; -$('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); -taxamount = (rowtaxableamount * taxdetails["taxrate"])/100; //Amount of tax to be applied is found out. -if (taxdetails["taxname"] == "SGST") { - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(taxamount).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(taxamount).toFixed(2)); - rowtotal = rowtaxableamount + (2*taxamount); - $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); -} -//Total of discount, taxable amount, tax amounts and total are found out -for(var i = 0; i < $("#invoice_product_table_gst tbody tr").length; i++) { - totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(5) input').val()); - totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(6) input').val()); - totalcgst = totalcgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(8) input').val()); - totalsgst = totalsgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(10) input').val()); - totalamount = totalamount + parseFloat($('#invoice_product_table_total tbody tr:eq(' + i + ') td:eq(0) input').val()); -} -//Total of various columns are displayed on the footer. -$('#discounttotal_product_gst').text(parseFloat(totaldiscount).toFixed(2)); -$('#taxablevaluetotal_product_gst').text(parseFloat(totaltaxable).toFixed(2)); -$('#totalcgst_product_gst').text(parseFloat(totalcgst).toFixed(2)); -$('#totalsgst_product_gst').text(parseFloat(totalsgst).toFixed(2)); -$('#total_product_gst').text(parseFloat(totalamount).toFixed(2)); -$('#totalinvoicevalue').text(parseFloat(totalamount).toFixed(2)); - } + //Initialising variables for calculating total of Discount, Taxable Amount, Tax Amounts, and Total Amounts. + var rowtotal = 0.00; + var totalamount = 0.00; + var totalcgst = 0.00; + var totalsgst = 0.00; + var totalcess = 0.00; + var totaldiscount = 0.00; + var totaltaxable = 0.00; + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); + taxamount = (rowtaxableamount * taxdetails["taxrate"])/100; //Amount of tax to be applied is found out. + if (taxdetails["taxname"] == "SGST") { + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(taxamount).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(taxamount).toFixed(2)); + rowtotal = rowtaxableamount + (2*taxamount); + $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); + } - //Function to calculate Tax Amount and Total of Discount, Taxable Amount, Tax Amounts and Total Amount. - //This is similar to the function above. - function calculatevataxamt(curindex) { -//Initialising variables to zero and getting values from various input fileds. -var rowqty = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(1) input').val()).toFixed(2); -var rowprice = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(3) input').val()).toFixed(2); -var rowdiscount = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(4) input').val()).toFixed(2); -var rowtaxrate = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val()).toFixed(2); -var taxamount = 0.00; -var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. -var rowtotal = 0.00; -var totalamount = 0.00; -var totaltax = 0.00; -var totaldiscount = 0.00; -var totaltaxable = 0.00; -$('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(5) input').val(parseFloat(rowtaxableamount).toFixed(2)); //Taxable amount is displayed. -taxamount = (rowtaxableamount * rowtaxrate)/100; //Amount of tax to be applied is found out. - $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(taxamount).toFixed(2)); - rowtotal = rowtaxableamount + taxamount; - $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(rowtotal).toFixed(2)); -//Total of discount, taxable amount, tax amounts and total are found out -for(var i = 0; i < $("#invoice_product_table_vat tbody tr").length; i++) { - totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(4) input').val()); - totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(5) input').val()); - totaltax = totaltax + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(7) input').val()); - totalamount = totalamount + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(8) input').val()); -} -//Total of various columns are displayed on the footer. -$('#discounttotal_product_vat').val(parseFloat(totaldiscount).toFixed(2)); -$('#taxablevaluetotal_product_vat').val(parseFloat(totaltaxable).toFixed(2)); -$('#totaltax').val(parseFloat(totaltax).toFixed(2)); -$('#total_product_vat').val(parseFloat(totalamount).toFixed(2)); -$("#totalinvoicevalue").text(parseFloat(totalamount).toFixed(2)); - } + //Total of discount, taxable amount, tax amounts and total are found out + for(var i = 0; i < $("#invoice_product_table_gst tbody tr").length; i++) { + totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(5) input').val()); + totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(6) input').val()); + totalcgst = totalcgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(8) input').val()); + totalsgst = totalsgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(10) input').val()); + totalamount = totalamount + parseFloat($('#invoice_product_table_total tbody tr:eq(' + i + ') td:eq(0) input').val()); + } + + //Total of various columns are displayed on the footer. + $('#discounttotal_product_gst').text(parseFloat(totaldiscount).toFixed(2)); + $('#taxablevaluetotal_product_gst').text(parseFloat(totaltaxable).toFixed(2)); + $('#totalcgst_product_gst').text(parseFloat(totalcgst).toFixed(2)); + $('#totalsgst_product_gst').text(parseFloat(totalsgst).toFixed(2)); + $('#total_product_gst').text(parseFloat(totalamount).toFixed(2)); + $('#totalinvoicevalue').text(parseFloat(totalamount).toFixed(2)); + } + + //Function to calculate Tax Amount and Total of Discount, Taxable Amount, Tax Amounts and Total Amount. + //This is similar to the function above. + function calculatevataxamt(curindex) { + //Initialising variables to zero and getting values from various input fileds. + var rowqty = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(1) input').val()).toFixed(2); + var rowprice = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(3) input').val()).toFixed(2); + var rowdiscount = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(4) input').val()).toFixed(2); + var rowtaxrate = parseFloat($('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val()).toFixed(2); + var taxamount = 0.00; + var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. + var rowtotal = 0.00; + var totalamount = 0.00; + var totaltax = 0.00; + var totaldiscount = 0.00; + var totaltaxable = 0.00; + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(5) input').val(parseFloat(rowtaxableamount).toFixed(2)); //Taxable amount is displayed. + taxamount = (rowtaxableamount * rowtaxrate)/100; //Amount of tax to be applied is found out. + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(taxamount).toFixed(2)); + rowtotal = rowtaxableamount + taxamount; + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(rowtotal).toFixed(2)); + //Total of discount, taxable amount, tax amounts and total are found out + for(var i = 0; i < $("#invoice_product_table_vat tbody tr").length; i++) { + totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(4) input').val()); + totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(5) input').val()); + totaltax = totaltax + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(7) input').val()); + totalamount = totalamount + parseFloat($('#invoice_product_table_vat tbody tr:eq(' + i + ') td:eq(8) input').val()); + } + //Total of various columns are displayed on the footer. + $('#discounttotal_product_vat').val(parseFloat(totaldiscount).toFixed(2)); + $('#taxablevaluetotal_product_vat').val(parseFloat(totaltaxable).toFixed(2)); + $('#totaltax').val(parseFloat(totaltax).toFixed(2)); + $('#total_product_vat').val(parseFloat(totalamount).toFixed(2)); + $("#totalinvoicevalue").text(parseFloat(totalamount).toFixed(2)); + } $(".invstate").show(); $(".fixed-table").removeClass('fixed-tablepurchase'); -- GitLab From 7acd9aa59be9060da733e3628e5b910418f0f6ca Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 12:19:08 +0530 Subject: [PATCH 11/14] Modified Calculate GST Tax function in cashmemo by considering CESS --- gkwebapp/static/js/addcashmemo.js | 24 +++++++++++++++--------- gkwebapp/static/js/addinvoice.js | 16 ++++++++++++---- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/gkwebapp/static/js/addcashmemo.js b/gkwebapp/static/js/addcashmemo.js index c7d74be5..76d961f6 100644 --- a/gkwebapp/static/js/addcashmemo.js +++ b/gkwebapp/static/js/addcashmemo.js @@ -51,7 +51,6 @@ $(document).ready(function() { var rowqty = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').val()).toFixed(2); var rowprice = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(4) input').val()).toFixed(2); var rowdiscount = parseFloat($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(5) input').val()).toFixed(2); - var taxdetails = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails"); var taxamount = 0.00; var rowtaxableamount=(rowqty * rowprice) - rowdiscount; //Taxable amount for each row is calculated. if ($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').is(":disabled") && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(3) input').is(":disabled")) { @@ -66,21 +65,27 @@ $(document).ready(function() { var totalcess = 0.00; var totaldiscount = 0.00; var totaltaxable = 0.00; - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); - taxamount = (rowtaxableamount * taxdetails["taxrate"])/100; //Amount of tax to be applied is found out. - if (taxdetails["taxname"] == "SGST") { - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(taxamount).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(taxamount).toFixed(2)); - rowtotal = rowtaxableamount + (2*taxamount); - $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); - } + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); + let sgstrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(); + let sgstamount = (rowtaxableamount * sgstrate)/100; //Amount of SGST to be applied is found out. + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(sgstamount).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(sgstamount).toFixed(2)); + + let cessrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(); + let cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val(parseFloat(cessamount).toFixed(2)); + + rowtotal = rowtaxableamount + 2*sgstamount + cessamount; //Sum of Taxable Amount and Tax Amount is found out. + $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); + //Total of discount, taxable amount, tax amounts and total are found out for(var i = 0; i < $("#invoice_product_table_gst tbody tr").length; i++) { totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(5) input').val()); totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(6) input').val()); totalcgst = totalcgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(8) input').val()); totalsgst = totalsgst + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(10) input').val()); + totalcess = totalcess + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(12) input').val()); totalamount = totalamount + parseFloat($('#invoice_product_table_total tbody tr:eq(' + i + ') td:eq(0) input').val()); } @@ -89,6 +94,7 @@ $(document).ready(function() { $('#taxablevaluetotal_product_gst').text(parseFloat(totaltaxable).toFixed(2)); $('#totalcgst_product_gst').text(parseFloat(totalcgst).toFixed(2)); $('#totalsgst_product_gst').text(parseFloat(totalsgst).toFixed(2)); + $('#totalcess_product_gst').text(parseFloat(totalcess).toFixed(2)); $('#total_product_gst').text(parseFloat(totalamount).toFixed(2)); $('#totalinvoicevalue').text(parseFloat(totalamount).toFixed(2)); } diff --git a/gkwebapp/static/js/addinvoice.js b/gkwebapp/static/js/addinvoice.js index b4396b7b..f4a7987e 100644 --- a/gkwebapp/static/js/addinvoice.js +++ b/gkwebapp/static/js/addinvoice.js @@ -65,6 +65,7 @@ $(document).ready(function() { if ($('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(2) input').is(":disabled") && $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(3) input').is(":disabled")) { rowtaxableamount = rowprice - rowdiscount; } + //Initialising variables for calculating total of Discount, Taxable Amount, Tax Amounts, and Total Amounts. var rowtotal = 0.00; var totalamount = 0.00; @@ -74,20 +75,26 @@ $(document).ready(function() { var totalcess = 0.00; var totaldiscount = 0.00; var totaltaxable = 0.00; + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(rowtaxableamount).toFixed(2)); //Taxable amount is displayed. + let sgstrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(); let sgstamount = (rowtaxableamount * sgstrate)/100; //Amount of SGST to be applied is found out. $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(8) input').val(parseFloat(sgstamount).toFixed(2)); $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(10) input').val(parseFloat(sgstamount).toFixed(2)); - let igstrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(); + + let igstrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(); let igstamount = (rowtaxableamount * igstrate)/100; //Amount of IGST to be applied is found out. $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(12) input').val(parseFloat(igstamount).toFixed(2)); - let cessrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(13) input').val(); + + let cessrate = $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(13) input').val(); let cessamount = (rowtaxableamount * cessrate)/100; //Amount of Cess to be applied is found out. $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(14) input').val(parseFloat(cessamount).toFixed(2)); - rowtotal = rowtaxableamount + 2*sgstamount + igstamount + cessamount; //Sum of Taxable Amount and Tax Amount is found out. + + rowtotal = rowtaxableamount + 2*sgstamount + igstamount + cessamount; //Sum of Taxable Amount and Tax Amount is found out. $('#invoice_product_table_total tbody tr:eq(' + curindex + ') td:eq(0) input').val(parseFloat(rowtotal).toFixed(2)); - //Total of discount, taxable amount, tax amounts and total are found out + + //Total of discount, taxable amount, tax amounts and total are found out for(var i = 0; i < $("#invoice_product_table_gst tbody tr").length; i++) { totaldiscount = totaldiscount + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(5) input').val()); totaltaxable = totaltaxable + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(6) input').val()); @@ -97,6 +104,7 @@ $(document).ready(function() { totalcess = totalcess + parseFloat($('#invoice_product_table_gst tbody tr:eq(' + i + ') td:eq(14) input').val()); totalamount = totalamount + parseFloat($('#invoice_product_table_total tbody tr:eq(' + i + ') td:eq(0) input').val()); } + //Total of various columns are displayed on the footer. $('#discounttotal_product_gst').text(parseFloat(totaldiscount).toFixed(2)); $('#taxablevaluetotal_product_gst').text(parseFloat(totaltaxable).toFixed(2)); -- GitLab From 453a44360deb59b398defe87f4da0ba6509b619b Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 15:23:19 +0530 Subject: [PATCH 12/14] CESS gets saved in Cash Memo. Fixed change event of product in Invoice Prouct Table --- gkwebapp/static/js/addcashmemo.js | 66 ++++++++++++++++----------- gkwebapp/static/js/addinvoice.js | 18 +++++--- gkwebapp/templates/addcashmemo.jinja2 | 12 ++--- gkwebapp/views/cashmemo.py | 4 +- 4 files changed, 58 insertions(+), 42 deletions(-) diff --git a/gkwebapp/static/js/addcashmemo.js b/gkwebapp/static/js/addcashmemo.js index 76d961f6..ca625897 100644 --- a/gkwebapp/static/js/addcashmemo.js +++ b/gkwebapp/static/js/addcashmemo.js @@ -192,7 +192,7 @@ $(document).ready(function() { $("#invoice_date").focus().select(); return false; } - else if (!invoicedate && invoicedatestring.length == 8) { + else if (!invoicedate && invoicedatestring.length == 8) { $("#date-alert").alert(); $("#date-alert").fadeTo(2250, 500).slideUp(500, function() { $("#date-alert").hide(); @@ -340,7 +340,12 @@ $(document).ready(function() { }) .done(function(resp) { if (resp["gkstatus"] == 0) { - $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['taxrate']).toFixed(2)); + if ('VAT' in resp['tax']) { + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['tax']['VAT']).toFixed(2)); + } + else if ('CVAT' in resp['tax']) { + $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(6) input').val(parseFloat(resp['tax']['CVAT']).toFixed(2)); + } } else if (resp["gkstatus"] == 1) { $("#notax-alert").alert(); @@ -443,15 +448,19 @@ $(document).ready(function() { } }); - $(document).off('change', '.product_name_gst').on('change', '.product_name_gst', function(event) { - event.preventDefault(); - /* Act on the event */ - var productcode = $(this).find('option:selected').val(); - var curindex = $(this).closest('tbody tr').index(); - var sourcestate=$("#invoice_state option:selected").val(); - - var taxflag=$("#taxapplicable").val(); - if (productcode != "") { + $(document).off('change', '.product_name_gst').on('change', '.product_name_gst', function(event) { + event.preventDefault(); + /* Act on the event */ + var productcode = $(this).find('option:selected').val(); + var curindex = $(this).closest('tbody tr').index(); + var sourcestate=$("#invoice_state option:selected").val(); + var taxflag=$("#taxapplicable").val(); + + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(0).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(0).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(0).toFixed(2)); + + if (productcode != "") { $.ajax({ url: '/invoice?action=getappliedtax', type: 'POST', @@ -464,14 +473,15 @@ $(document).ready(function() { }) .done(function(resp) { if (resp["gkstatus"] == 0) { - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(0) select').data("taxdetails", {taxname: resp["taxname"], taxrate:resp["taxrate"]}); - if(resp['taxname']=='SGST'){ - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(resp['taxrate']).toFixed(2)); - $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(resp['taxrate']).toFixed(2)); - } - - - //$('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(4) input').prop("disabled", false); + //Loads SGST rate. + if('SGST' in resp['tax']){ + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(resp['tax']['SGST']).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(resp['tax']['SGST']).toFixed(2)); + //Loads CESS rate if avaliable. + if ('CESS' in resp['tax']) { + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(resp['tax']['CESS']).toFixed(2)); + } + } } }) .fail(function() { @@ -481,7 +491,7 @@ $(document).ready(function() { console.log("complete"); }); $.ajax({ - url: '/invoice?action=getproduct', + url: '/invoice?action=getproduct', type: 'POST', dataType: 'json', async: false, @@ -562,7 +572,7 @@ $(document).ready(function() { event.preventDefault(); $('#invoice_product_table_vat tbody tr:eq(' + curindex + ') td:eq(1) input').focus().select(); } - else if (event.which == 27) { + else if (event.which == 27) { $("#accountno").focus().select(); } }); @@ -900,7 +910,7 @@ else if (event.which == 38) { if ($(this).is("select")) { if ($(this).val() == "Road") { f[previndex].focus(); - f[previndex].select(); + f[previndex].select(); } } else { @@ -983,6 +993,7 @@ $(document).off("keyup").on("keyup", function(event) { } var tax = {}; + var cess = {}; var contents = {}; var stock = {}; var freeqty = {}; @@ -1069,7 +1080,9 @@ $(document).off("keyup").on("keyup", function(event) { contents[productcode] = obj; items[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(2) input").val(); freeqty[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(3) input").val(); - discount[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(5) input").val(); + discount[productcode] = $("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(5) input").val(); + tax[productcode] = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(7) input").val()) + parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(9) input").val()); + cess[productcode] = parseFloat($("#invoice_product_table_gst tbody tr:eq(" + i + ") td:eq(11) input").val()); } invoicetotal = $('#total_product_gst').text(); stock["items"] = items; @@ -1082,6 +1095,7 @@ $(document).off("keyup").on("keyup", function(event) { form_data.append("invoicedate", $("#invoice_year").val() + '-' + $("#invoice_month").val() + '-' + $("#invoice_date").val()); form_data.append("contents", JSON.stringify(contents)); form_data.append("tax", JSON.stringify(tax)); + form_data.append("cess", JSON.stringify(cess)); form_data.append("stock", JSON.stringify(stock)); form_data.append("invoicetotal", invoicetotal); form_data.append("taxstate", $("#invoice_state option:selected").val()); @@ -1481,14 +1495,14 @@ $(document).off("keyup").on("keyup", function(event) { event.preventDefault(); /* Act on the event */ - var curindex = $(this).closest('#invoice_product_table_gst tbody tr').index(); + var curindex = $(this).closest('#invoice_product_table_gst tbody tr').index(); if ($(this).val() == "") { $(this).val(0); } calculategstaxamt(curindex); }); - $(document).off("keydown", ".invoice_product_quantity_gst").on("keydown", ".invoice_product_quantity_gst", function(event) { - var curindex = $(this).closest('tr').index(); + $(document).off("keydown", ".invoice_product_quantity_gst").on("keydown", ".invoice_product_quantity_gst", function(event) { + var curindex = $(this).closest('tr').index(); var nextindex = curindex + 1; var previndex = curindex - 1; diff --git a/gkwebapp/static/js/addinvoice.js b/gkwebapp/static/js/addinvoice.js index f4a7987e..aa3026f8 100644 --- a/gkwebapp/static/js/addinvoice.js +++ b/gkwebapp/static/js/addinvoice.js @@ -1281,12 +1281,17 @@ $(document).ready(function() { //GST events start here //Change event for Product Name field. $(document).off('change', '.product_name_gst').on('change', '.product_name_gst', function(event) { - event.preventDefault(); - /* Act on the event */ - var productcode = $(this).find('option:selected').val(); - var curindex = $(this).closest('tbody tr').index(); - var destinationstate = ""; - var sourcestate = ""; + event.preventDefault(); + var productcode = $(this).find('option:selected').val(); + var curindex = $(this).closest('tbody tr').index(); + var destinationstate = ""; + var sourcestate = ""; + + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(0).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(9) input').val(parseFloat(0).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(11) input').val(parseFloat(0).toFixed(2)); + $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(13) input').val(parseFloat(0).toFixed(2)); + if ($("#status").val() == 9) { destinationstate = $("#invoicestate option:selected").val(); sourcestate = $("#invoice_customerstate").val(); @@ -1316,7 +1321,6 @@ $(document).ready(function() { }) .done(function(resp) { if (resp["gkstatus"] == 0) { - $(".trate", ".tname").val(parseFloat(0).toFixed(2)); //Sets all tax fields to zero on change of product //Loads SGST rate. if('SGST' in resp['tax']){ $('#invoice_product_table_gst tbody tr:eq(' + curindex + ') td:eq(7) input').val(parseFloat(resp['tax']['SGST']).toFixed(2)); diff --git a/gkwebapp/templates/addcashmemo.jinja2 b/gkwebapp/templates/addcashmemo.jinja2 index 03db4e65..ab2cb4d1 100644 --- a/gkwebapp/templates/addcashmemo.jinja2 +++ b/gkwebapp/templates/addcashmemo.jinja2 @@ -312,14 +312,14 @@ - - + + - - + + - - + + diff --git a/gkwebapp/views/cashmemo.py b/gkwebapp/views/cashmemo.py index 1657a2e5..51689bb6 100644 --- a/gkwebapp/views/cashmemo.py +++ b/gkwebapp/views/cashmemo.py @@ -70,9 +70,7 @@ def getproducts(request): def savecashmemo(request): header={"gktoken":request.headers["gktoken"]} - cashmemodata = {"invoiceno":request.params["invoiceno"],"invoicetotal":request.params["invoicetotal"],"icflag":3,"taxstate":request.params["taxstate"],"sourcestate":request.params["sourcestate"],"invoicedate":request.params["invoicedate"], - "tax":json.loads(request.params["tax"]), - "contents":json.loads(request.params["contents"]),"freeqty":json.loads(request.params["freeqty"]),"taxflag":request.params["taxflag"]} + cashmemodata = {"invoiceno":request.params["invoiceno"],"invoicetotal":request.params["invoicetotal"],"icflag":3,"taxstate":request.params["taxstate"],"sourcestate":request.params["sourcestate"],"invoicedate":request.params["invoicedate"],"tax":json.loads(request.params["tax"]), "cess":json.loads(request.params["cess"]), "contents":json.loads(request.params["contents"]),"freeqty":json.loads(request.params["freeqty"]),"taxflag":request.params["taxflag"]} if request.params.has_key("discount"): cashmemodata["discount"]=json.loads(request.params["discount"]) -- GitLab From 39ac0ea02e5af4a923b20417c655c88bf7e69788 Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 15:34:28 +0530 Subject: [PATCH 13/14] CESS appears in View Cash Memo --- gkwebapp/templates/viewsinglecashmemo.jinja2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gkwebapp/templates/viewsinglecashmemo.jinja2 b/gkwebapp/templates/viewsinglecashmemo.jinja2 index 14da37ec..e3e8fe0b 100644 --- a/gkwebapp/templates/viewsinglecashmemo.jinja2 +++ b/gkwebapp/templates/viewsinglecashmemo.jinja2 @@ -118,7 +118,8 @@ {% trans %}Discount Amount{% endtrans %} {% trans %}Taxable Value {% endtrans %} {% if gkresult["taxname"]=='SGST' %}{% trans %}CGST{% endtrans %}{% endif %} - {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST{% endtrans %}{% endif %} + {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST/UTGST{% endtrans %}{% endif %} + {% trans %}CESS{% endtrans %} @@ -126,6 +127,8 @@ {% if gkresult["taxname"]=='SGST' %}{% trans %}Amount{% endtrans %}{% endif %} {% if gkresult["taxname"]=='SGST' %}{% trans %}Rate{% endtrans %} %{% endif %} {% if gkresult["taxname"]=='SGST' %}{% trans %}Amount{% endtrans %}{% endif %} + {% trans %}Rate{% endtrans %} % + {% trans %}Amount{% endtrans %} @@ -163,6 +166,8 @@ {% if gkresult["invcontents"][product]["taxname"]=='SGST' %}{{ gkresult["invcontents"][product]["taxrate"] }}{% endif %} {% if gkresult["invcontents"][product]["taxname"]=='SGST' %}{{ gkresult["invcontents"][product]["taxamount"] }}{% endif %} + {{ gkresult["invcontents"][product]["cessrate"] }} + {{ gkresult["invcontents"][product]["cess"] }} {% endfor %} @@ -177,6 +182,7 @@ {{ gkresult["totaltaxablevalue"] }} {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} + {{ gkresult["totalcessamt"] }} -- GitLab From f1dba3bfaa3e4678485bcbed918700f6706aaacc Mon Sep 17 00:00:00 2001 From: abhijith Date: Sat, 28 Oct 2017 15:38:45 +0530 Subject: [PATCH 14/14] CESS appears in Print of Cash Memo too --- gkwebapp/templates/printcashmemo.jinja2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gkwebapp/templates/printcashmemo.jinja2 b/gkwebapp/templates/printcashmemo.jinja2 index f100118d..f10ce9be 100644 --- a/gkwebapp/templates/printcashmemo.jinja2 +++ b/gkwebapp/templates/printcashmemo.jinja2 @@ -202,7 +202,7 @@ {% trans %}Discount Amount{% endtrans %} {% trans %}Taxable Value {% endtrans %} {% if gkresult["taxname"]=='SGST' %}{% trans %}CGST{% endtrans %}{% endif %} - {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST{% endtrans %}{% endif %} + {% if gkresult["taxname"]=='SGST' %}{% trans %}SGST/UTGST{% endtrans %}{% endif %} Total @@ -211,6 +211,8 @@ {% if gkresult["taxname"]=='SGST' %}{% trans %}Amount{% endtrans %}{% endif %} {% if gkresult["taxname"]=='SGST' %}{% trans %}Rate{% endtrans %} %{% endif %} {% if gkresult["taxname"]=='SGST' %}{% trans %}Amount{% endtrans %}{% endif %} + {% trans %}Rate{% endtrans %} % + {% trans %}Amount{% endtrans %} @@ -244,7 +246,8 @@ {% if gkresult["invcontents"][product]["taxname"]=='SGST' %}{{ gkresult["invcontents"][product]["taxrate"] }}{% endif %} {% if gkresult["invcontents"][product]["taxname"]=='SGST' %}{{ gkresult["invcontents"][product]["taxamount"] }}{% endif %} - + {{ gkresult["invcontents"][product]["cessrate"] }} + {{ gkresult["invcontents"][product]["cess"] }} {{ gkresult["invcontents"][product]["totalAmount"] }} {% endfor %} @@ -256,6 +259,7 @@ {{ gkresult["totaltaxablevalue"] }} {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} {% if gkresult["taxname"]=='SGST' %}{{ gkresult["totaltaxamt"] }}{% endif %} + {{ gkresult["totalcessamt"] }} {{ gkresult["invoicetotal"] }} -- GitLab