Today’s in India GST calculation needed for every software So. I am thinking about the developer who wants to implement GST calculation on there software or website. They can be used my scripts for GST calculation.
function Calculation(){ var rate = 0, disc = 0, cgst=0, sgst=0, igst=0, total=0; this.setRate = function(mainPrice){ rate = mainPrice; } this.setDiscount = function(discount, type='%'){ if(type === '%'){ disc = rate * discount / 100 }else{ disc = discount; } } this.setCGST = function(val, type='%'){ if(type === '%'){ cgst = (rate - disc) * val/100; }else{ cgst = val; } } this.setSGST = function(val, type='%'){ if (type === '%') { sgst = (rate - disc) * val / 100; }else{ sgst = val; } } this.setIGST = function(val, type='%'){ if (type === '%') { igst = (rate - disc) * val / 100; } else { igst = val; } } this.getCost = function(igstApply=false){ if (igstApply === false) { total = (rate - disc) + (cgst + sgst); }else{ total = (rate - disc) + igst; } return total; } } // How To Use var c = new Calculation(); c.setRate(100); c.setDiscount(20); c.setCGST(5); c.setSGST(5); c.setIGST(18); var cost = c.getCost(); var costWithIgst = c.getCost(true); console.log('Actual Cost of the product: '+cost); console.log('Actual Cost of the Service: ' + costWithIgst);
function Calculation(){
var rate = 0, disc = 0, cgst=0, sgst=0, igst=0, total=0;
this.setRate = function(mainPrice){
rate = mainPrice;
}
this.setDiscount = function(discount, type='%'){
if(type === '%'){
disc = rate * discount / 100
}else{
disc = discount;
}
}
this.setCGST = function(val, type='%'){
if(type === '%'){
cgst = (rate - disc) * val/100;
}else{
cgst = val;
}
}
this.setSGST = function(val, type='%'){
if (type === '%') {
sgst = (rate - disc) * val / 100;
}else{
sgst = val;
}
}
this.setIGST = function(val, type='%'){
if (type === '%') {
igst = (rate - disc) * val / 100;
} else {
igst = val;
}
}
this.getCost = function(igstApply=false){
if (igstApply === false) {
total = (rate - disc) + (cgst + sgst);
}else{
total = (rate - disc) + igst;
}
return total;
}
}
// How To Use
var c = new Calculation();
c.setRate(100);
c.setDiscount(20);
c.setCGST(5);
c.setSGST(5);
c.setIGST(18);
var cost = c.getCost();
var costWithIgst = c.getCost(true);
console.log('Actual Cost of the product: '+cost);
console.log('Actual Cost of the Service: ' + costWithIgst);
You can use this code everywhere.
A full-stack developer course is good or not. This time, so many people want to…
As a software developer, having a comfortable and productive coding environment is essential to your…
Discovering the Software Development Career: This article will teach you everything you need to know…
Software Programming is done with various software programming languages. We are using these languages used…
There are several ways to AI application development using JavaScript, depending on your goals and…
This is the angular live project on audio player for website and mobile. This app…
This website uses cookies.