Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions payslip/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>employee</groupId>
<artifactId>payslip</artifactId>
<packaging>war</packaging>
<version>0.0.1</version>
<name>payslip Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/IT*.java</include>
<include>**/*IT.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>${surefire.skip}</skip>
</configuration>
</plugin>
</plugins>
</build>
<!-- <finalName>payslip</finalName> -->
</project>
42 changes: 42 additions & 0 deletions payslip/src/main/java/payslip/FixedComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package payslip;

public class FixedComponent {

public double basicPay(){
double basic = 14438;
return basic;
}

public double hraComponent(){
double hra = 5775;
return hra;
}

public double conveyanceAllowance(){
double conveyance = 800;
return conveyance;
}

public double medicalAllowance(){
double medical = 1250;
return medical;
}

public double ltaComponent(){
double lta = 1805;
return lta;
}

public double specialAllowance(){
double special = 15450;
return special;
}

public double totalFixedComponent(){
FixedComponent tot = new FixedComponent();
double totalfixedcomponent = tot.basicPay() + tot.conveyanceAllowance() + tot.hraComponent() + tot.ltaComponent() + tot.medicalAllowance() + tot.specialAllowance();
return totalfixedcomponent;
}

}

20 changes: 20 additions & 0 deletions payslip/src/main/java/payslip/GratuityComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package payslip;

public class GratuityComponent {

private double gratuity;

// constructor
public GratuityComponent(){

FixedComponent var = new FixedComponent();
this.gratuity = (var.basicPay()*15)/(26*12);
}

// prints the variable pay
public double printGratuity(){
System.out.println(gratuity);
return gratuity;
}
}

22 changes: 22 additions & 0 deletions payslip/src/main/java/payslip/NetComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package payslip;

public class NetComponent {

private double netsalary;

// constructor
public NetComponent(){

FixedComponent var1 = new FixedComponent();
VariableComponent var2 = new VariableComponent();
GratuityComponent var3 = new GratuityComponent();
TaxComponent var4 = new TaxComponent();
this.netsalary = var1.totalFixedComponent() + var2.printVariable() - var3.printGratuity() - var4.printTax();
}

// prints the variable pay
public double printNetSalary(){
System.out.println(netsalary);
return netsalary;
}
}
20 changes: 20 additions & 0 deletions payslip/src/main/java/payslip/TaxComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package payslip;

public class TaxComponent {

private double tax;

// constructor
public TaxComponent(){

FixedComponent var = new FixedComponent();
this.tax = (var.totalFixedComponent() * 9)/100;
}

// prints the variable pay
public double printTax(){
System.out.println(tax);
return tax;
}
}

22 changes: 22 additions & 0 deletions payslip/src/main/java/payslip/VariableComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package payslip;

/*
* This class prints the given message on console.
*/
public class VariableComponent {

private double variable;

// constructor
public VariableComponent(){

FixedComponent var = new FixedComponent();
this.variable = ((var.totalFixedComponent()) * 10)/100;
}

// prints the variable pay
public double printVariable(){
System.out.println(variable);
return variable;
}
}
7 changes: 7 additions & 0 deletions payslip/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
127 changes: 127 additions & 0 deletions payslip/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style>
table h5 {margin: 10px; font-size: 14px}
table td {text-align: left;}
</style>
</head>
<body>
<h2 align="center">PAY SLIP OCTOBER 2015</h2>

<table border="1" style="width:400" align="center">
<tr>
<td><h5>Salary Components</h5></td>
<td><h5>Monthly</h5></td>
<td><h5>Yearly</h5></td>
</tr>
<tr>
<td>Basic Pay</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C1 = new FixedComponent();
double basicpay = C1.basicPay();
out.println(basicpay);%>
</td>
<td>-</td>
</tr>
<tr>
<td>HRA</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C2 = new FixedComponent();
double hracomponent = C2.hraComponent();
out.println(hracomponent);%>
</td>
<td>-</td>
</tr>
<tr>
<td>Conveyance Allowance</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C3 = new FixedComponent();
double conveyanceallowance = C3.conveyanceAllowance();
out.println(conveyanceallowance);%>
</td>
<td>-</td>
</tr>
<tr>
<td>Medical Allowance</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C4 = new FixedComponent();
double medicalallowance = C4.medicalAllowance();
out.println(medicalallowance);%>
</td>
<td>-</td>
</tr>
<tr>
<td>LTA (Leave Travel Allowance)</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C5 = new FixedComponent();
double ltacomponent = C5.ltaComponent();
out.println(ltacomponent);%>
</td>
<td>-</td>
</tr>
<tr>
<td>Special Allowance</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C6 = new FixedComponent();
double specialallowance = C6.specialAllowance();
out.println(specialallowance);%>
</td>
<td>-</td>
</tr>
<tr>
<td>Total Fixed Pay</td>
<td><%@ page import="payslip.FixedComponent" %>
<% FixedComponent C7 = new FixedComponent();
double totalfixedpay = C7.totalFixedComponent();
out.println(totalfixedpay);%>
</td>
<td>-</td>
</tr>
<tr>
<td>Variable Pay</td>
<td><%@ page import="payslip.VariableComponent" %>
<% VariableComponent C8 = new VariableComponent();
double variablepay = C8.printVariable();
out.println(variablepay);
%>
</td>
<td>-</td>
</tr>
<tr>
<td>Gratuity</td>
<td><%@ page import="payslip.GratuityComponent" %>
<% GratuityComponent C9 = new GratuityComponent();
double gratuity = C9.printGratuity();
out.println(gratuity);
%>
</td>
<td>-</td>
</tr>
<tr>
<td>Income Tax</td>
<td><%@ page import="payslip.TaxComponent" %>
<% TaxComponent C10 = new TaxComponent();
double incometax = C10.printTax();
out.println(incometax);
%>
</td>
<td>-</td>
</tr>
<tr>
<td>Net Salary</td>
<td><%@ page import="payslip.NetComponent" %>
<% NetComponent C11 = new NetComponent();
double netsalary = C11.printNetSalary();
out.println(netsalary);
%>
</td>
<td>-</td>
</tr>
</table>
</body>
</html>
15 changes: 15 additions & 0 deletions payslip/src/test/java/payslip/FixedComponentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package payslip;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class FixedComponentTest {

FixedComponent messageUtil = new FixedComponent();

@Test
public void testPrintMessage() {
double message = 39518.0;
assertEquals(message,messageUtil.totalFixedComponent(),0.01);
}
}
15 changes: 15 additions & 0 deletions payslip/src/test/java/payslip/GratuityComponentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package payslip;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class GratuityComponentTest {

GratuityComponent messageUtil = new GratuityComponent();

@Test
public void testPrintMessage() {
double message = 694.1346153846154;
assertEquals(message,messageUtil.printGratuity(),0.01);
}
}
16 changes: 16 additions & 0 deletions payslip/src/test/java/payslip/HelloIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package payslip;

import static org.junit.Assert.*;

import org.junit.Test;

public class HelloIT {

TaxComponent messageUtil = new TaxComponent();

@Test
public void testPrintMessage() {
double message = 3556.62;
assertEquals(message,messageUtil.printTax(),0.01);
}
}
Loading